/* ==========================================================================
   ui-v2.css — navigation rework: compact density + one pill style.
   Loaded by base.html after ui-refresh.css. Every rule is scoped to
   body.ui-v2 (always set on <body> by base.html) for specificity.

   ui-refresh.css and base.html's inline block set nearly every tab rule with
   !important; the rules here carry !important too and win on specificity
   (body.ui-v2 prefix), never by load order alone.
   ========================================================================== */

/* ---- Top bar: Admin menu ------------------------------------------------ */
body.ui-v2 .ui2-admin-menu { min-width: 15rem; max-height: 80vh; overflow-y: auto; }
body.ui-v2 .ui2-admin-menu .dropdown-header {
    font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; padding-top: 0.35rem;
}
body.ui-v2 .ui2-admin-menu .dropdown-item { font-size: 0.82rem; padding: 0.28rem 0.9rem; }

/* ---- Workspace bar: one tight row, same text size as before -------------- */
body.ui-v2 .ui2-shell { padding: 0.3rem 0.45rem !important; margin-bottom: 0.5rem !important; }
body.ui-v2 .ui2-shell .tenant-tabs-list { gap: 0.2rem !important; flex-wrap: wrap; row-gap: 0.2rem; }
body.ui-v2 #tenantTabs .nav-link {
    padding: 0.28rem 0.62rem !important;
    font-size: 0.85rem !important;
    line-height: 1.35 !important;
}
body.ui-v2 #tenantTabs .nav-link .badge {
    font-size: 0.66rem !important;
    padding: 0.1rem 0.34rem !important;
}
body.ui-v2 #tenantTabs .ui2-divider {
    width: 1px; flex: 0 0 1px; align-self: stretch;
    margin: 0.3rem 0.2rem; background: var(--ui-border, #353c47);
}

/* ---- Second level: ONE pill style everywhere ----------------------------
   The console had six spellings of this strip (nav-tabs-sub, bare nav-tabs,
   ai-subtabs, settings-tabs, nav-sm, and the tenant bar's own). They all render
   as the ai-subtabs pill here, at one compact size. */
body.ui-v2 .ui2-pills { margin: 0.35rem 0 0 !important; }
body.ui-v2 .ai-subtabs,
body.ui-v2 .nav-tabs-sub,
body.ui-v2 #domainScoresTabs,
body.ui-v2 .settings-tabs,
body.ui-v2 .quarantine-detail-page .nav-tabs.nav-sm {
    gap: 0.3rem !important;
    border-bottom: 0 !important;
    margin-bottom: 0.45rem !important;
}
body.ui-v2 .ai-subtabs .nav-link,
body.ui-v2 .nav-tabs-sub .nav-link,
body.ui-v2 .tenant-detail-page .nav-tabs-sub .nav-link,
body.ui-v2 #domainScoresTabs .nav-link,
body.ui-v2 .settings-tabs .nav-link,
body.ui-v2 .quarantine-detail-page .nav-tabs.nav-sm .nav-link {
    padding: 0.14rem 0.62rem !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    color: #4da3ff !important;
    background: transparent !important;
    border: 1px solid rgba(77, 163, 255, 0.3) !important;
    border-radius: 2rem !important;
    margin: 0 !important;
}
body.ui-v2 .ai-subtabs .nav-link:hover,
body.ui-v2 .nav-tabs-sub .nav-link:hover,
body.ui-v2 #domainScoresTabs .nav-link:hover,
body.ui-v2 .settings-tabs .nav-link:hover,
body.ui-v2 .quarantine-detail-page .nav-tabs.nav-sm .nav-link:hover {
    color: #82c0ff !important;
    background: rgba(77, 163, 255, 0.08) !important;
    border-color: rgba(77, 163, 255, 0.5) !important;
}
body.ui-v2 .ai-subtabs .nav-link.active,
body.ui-v2 .nav-tabs-sub .nav-link.active,
body.ui-v2 #domainScoresTabs .nav-link.active,
body.ui-v2 .settings-tabs .nav-link.active,
body.ui-v2 .quarantine-detail-page .nav-tabs.nav-sm .nav-link.active {
    color: #9ccaff !important;
    background: rgba(77, 163, 255, 0.15) !important;
    border-color: rgba(77, 163, 255, 0.6) !important;
}
body.ui-v2 .ai-subtabs .nav-link .badge,
body.ui-v2 .nav-tabs-sub .nav-link .badge,
body.ui-v2 #domainScoresTabs .nav-link .badge {
    font-size: 0.64rem !important;
    padding: 0.08rem 0.32rem !important;
}

/* Three sizes, one per level (operator, 2026-09-23: "make the second subtab
   bigger and the third smaller"):
     level 1  the workspace tabs          (#tenantTabs, above)
     level 2  the group pills under it     (.ui2-pills) — and on admin pages the
              first strip under the top bar (.ai-subtabs, .settings-tabs)
     level 3  a tab row inside a page      (.nav-tabs-sub, #domainScoresTabs,
              the message page's strips) — smallest */
body.ui-v2 .ui2-pills .nav-link,
body.ui-v2 .ai-subtabs .nav-link,
body.ui-v2 .settings-tabs .nav-link {
    padding: 0.2rem 0.72rem !important;
    font-size: 0.8rem !important;
}
body.ui-v2 .ui2-pills .nav-link .badge,
body.ui-v2 .ai-subtabs .nav-link .badge { font-size: 0.68rem !important; padding: 0.1rem 0.36rem !important; }
body.ui-v2 .nav-tabs-sub .nav-link,
body.ui-v2 .tenant-detail-page .nav-tabs-sub .nav-link,
body.ui-v2 #domainScoresTabs .nav-link,
body.ui-v2 .quarantine-detail-page .nav-tabs.nav-sm .nav-link {
    padding: 0.05rem 0.5rem !important;
    font-size: 0.71rem !important;
    line-height: 1.35 !important;
}
body.ui-v2 .nav-tabs-sub .nav-link .badge,
body.ui-v2 #domainScoresTabs .nav-link .badge,
body.ui-v2 .quarantine-detail-page .nav-tabs.nav-sm .nav-link .badge {
    font-size: 0.6rem !important;
    padding: 0.05rem 0.28rem !important;
    line-height: 1.2 !important;
}
body.ui-v2 .nav-tabs-sub,
body.ui-v2 #domainScoresTabs,
body.ui-v2 .quarantine-detail-page .nav-tabs.nav-sm { gap: 0.25rem !important; }

/* Admin pages (Settings, System Health, Audit Logs, Detectors; 2026-10-08):
   a strip that shares its line with the page's own controls (Audit Logs'
   Columns + count beside the Settings strip, System Health's refresh buttons
   beside its sub-tabs) — the row carries the bottom margin, not the pills. */
body.ui-v2 .settings-tabs-row,
body.ui-v2 .admin-subtabs-row { margin-bottom: 0.45rem !important; row-gap: 0.3rem; }
body.ui-v2 .settings-tabs-row > .settings-tabs,
body.ui-v2 .admin-subtabs-row > .admin-subtabs { margin-bottom: 0 !important; }

/* The message page's strips (URLs / Attachments / Body Preview / Raw Headers,
   Threat Intelligence / Threats) use the workspace tabs' text size, not the
   level-3 size (operator, 2026-09-25: "make it same text as the main tabs").
   Keep these values in step with #tenantTabs above. */
body.ui-v2 .quarantine-detail-page .nav-tabs.nav-sm .nav-link {
    padding: 0.28rem 0.62rem !important;
    font-size: 0.85rem !important;
    line-height: 1.35 !important;
}
body.ui-v2 .quarantine-detail-page .nav-tabs.nav-sm .nav-link .badge {
    font-size: 0.66rem !important;
    padding: 0.1rem 0.34rem !important;
}

/* The Filtering Rules and Recipients panes each had their own sub-tab strip.
   The Policy / People / Tools pills under the workspace bar now carry those
   links, so the in-pane strips would be a second, duplicate row. The panes
   themselves are unchanged. */
body.ui-v2 #rulesSubTabs,
body.ui-v2 #recipientsSubTabs { display: none !important; }

/* ---- Page headings: title with a short description BESIDE it -------------
   Operator, 2026-09-23: every page has a heading and next to it a short
   description of what the page is — on one line, not stacked. Covers the
   shared .page-header markup (every admin page + the workspace heading that
   _tenant_nav_tabs.html renders), the older "h4 + small" header (Review Queue,
   URL Review) and card headers such as Platform Policies. */
body.ui-v2 .page-header { margin-bottom: 0.5rem !important; padding-top: 0 !important; padding-bottom: 0 !important; min-height: 0 !important; }
body.ui-v2 .page-header > div:first-child {
    display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 0.75rem; row-gap: 0.1rem;
}
body.ui-v2 .page-header .page-title {
    margin: 0 !important; font-size: 1.15rem !important; line-height: 1.3 !important;
}
body.ui-v2 .page-header .page-subtitle,
body.ui-v2 .page-header > div:first-child > small.text-muted {
    margin: 0 !important; font-size: 0.8rem !important; color: #b1bac4 !important;
}
/* A page's short description, rendered INSIDE its own heading by
   _ui2_desc.html. Many headings use .gradient-text (transparent text fill over a
   gradient), which a child would inherit and vanish — so the fill is reset. */
body.ui-v2 .ui2-desc {
    margin-left: 0.6rem;
    font-size: 0.76rem; font-weight: 400; letter-spacing: 0; text-transform: none;
    color: #b1bac4 !important; -webkit-text-fill-color: #b1bac4 !important;
    background: none !important;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: baseline;
}
body.ui-v2 .page-shell > .d-flex > div:first-child:has(> h4.mb-0 + small.text-muted) {
    display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 0.75rem;
}
body.ui-v2 .page-shell > .d-flex > div:first-child > h4.mb-0 { font-size: 1.15rem; }
body.ui-v2 .page-shell > .d-flex > div:first-child > h4.mb-0 + small.text-muted { font-size: 0.8rem; }
/* card headers: "Title   short description" instead of stacked lines */
body.ui-v2 .card-header > :is(h3, h4, h5, h6).mb-0 + small.text-muted {
    margin-left: 0.6rem; margin-right: auto; font-size: 0.76rem;
}
body.ui-v2 .card-header:not(.d-flex) > :is(h3, h4, h5, h6).mb-0 { display: inline-block; }
body.ui-v2 .card-header:not(.d-flex) > :is(h3, h4, h5, h6).mb-0 + small.text-muted { display: inline; }
/* Phones: the description cannot sit beside its title — inline + nowrap ran it
   off the right edge, and a header's buttons (Recipient directory's "3 VIPs")
   were pushed off-screen with it. The description takes its own line and
   wraps, and a flex header wraps its controls under the title. */
@media (max-width: 576px) {
    body.ui-v2 .ui2-desc { display: block; margin-left: 0; margin-top: 0.1rem; white-space: normal; }
    body.ui-v2 .card-header.d-flex { flex-wrap: wrap; row-gap: 0.35rem; }
    body.ui-v2 .card-header:not(.d-flex) > :is(h3, h4, h5, h6).mb-0 + small.text-muted { display: block; margin-left: 0; }
}

/* ---- Resizable tables: the last column fills to the right edge ---------
   column-resize.js marks the last visible header .seg-fill-col (re-derived on
   every drag, so column reorder/visibility cannot strand it). It has no handle
   and takes whatever width the other columns leave, so its end never moves off
   the table's right side. .seg-fill-min is the floor when the others already
   use the whole wrapper (the table then scrolls). */
/* The table is exactly as wide as its wrapper — never max-content — so the
   fill column's end is the wrapper's right edge. column-resize.js (segFitTable)
   keeps the other columns' sum inside that width, shrinking the text columns
   when the screen is narrow, so nothing is pushed off the page. */
body.ui-v2 table.table-autofit,
body.ui-v2 table.table-layout-fixed { width: 100% !important; min-width: 0 !important; }
body.ui-v2 th.seg-fill-col { width: auto !important; }
body.ui-v2 th.seg-fill-col.seg-fill-min { width: 90px !important; }
body.ui-v2 th.seg-fill-col > .column-resizer { display: none !important; }

/* ---- Addresses never wrap (same as the subject column) ------------------
   Email Log, Quarantine, Recipients and the anomaly tables already truncate;
   the console-users table was the one that still wrapped. Full value on hover
   via the cell's title / the code element's text. */
body.ui-v2 td[data-column-id="email"] {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px;
}
body.ui-v2 td[data-column-id="email"] code { white-space: nowrap; }

/* ---- Recipients: compact rows ------------------------------------------- */
body.ui-v2 #recipients-table > :not(caption) > * > * {
    padding: 0.16rem 0.45rem !important;
    white-space: nowrap;
    vertical-align: middle;
}
body.ui-v2 #recipients-table .badge,
body.ui-v2 #recipients-table .count-pill { font-size: 0.68rem !important; padding: 0.12rem 0.38rem !important; }
body.ui-v2 #recipients-table .recipient-actions .btn {
    padding: 0.05rem 0.35rem !important; font-size: 0.7rem !important; line-height: 1.3 !important;
}
body.ui-v2 #recipients-table .recipient-bounce-reason { max-width: 260px; }

/* ---- Insights: compact, one table of checks ----------------------------
   Replaces the 12-tile grid (template: .ui2-checks). Tone colours
   are the ones the tiles already used, so a check reads the same colour as
   before; the word (count / "Not measured") still carries the state. */
body.ui-v2 #anomalies .card-header { padding: 0.35rem 0.6rem !important; }
body.ui-v2 #anomalies .card-body { padding: 0.5rem 0.6rem !important; }
body.ui-v2 #anomalies .anomaly-toolbar { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; }
body.ui-v2 #anomalies .anomaly-toolbar .btn { padding: 0.12rem 0.5rem !important; font-size: 0.76rem !important; }
body.ui-v2 #anomalies > .alert,
body.ui-v2 #anomaly-card-grid > .alert { padding: 0.4rem 0.6rem !important; font-size: 0.8rem !important; text-align: left !important; }

body.ui-v2 .ui2-checks { font-size: 0.82rem; table-layout: fixed; width: 100%; }
body.ui-v2 .ui2-checks td { vertical-align: middle; border-color: rgba(255, 255, 255, 0.06); }
body.ui-v2 .ui2-checks__group th {
    background: transparent !important;
    padding: 0.55rem 0.5rem 0.2rem !important;
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
    color: #b1bac4; border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}
body.ui-v2 .ui2-checks tbody:first-child .ui2-checks__group th { padding-top: 0.15rem !important; }
body.ui-v2 .ui2-checks__hint { font-weight: 500; letter-spacing: 0; text-transform: none; color: #8b96a5; margin-left: 0.4rem; }
body.ui-v2 .ui2-checks__row { cursor: pointer; }
body.ui-v2 .ui2-checks__row:focus-visible { outline: 2px solid #2a96fb; outline-offset: -2px; }
body.ui-v2 .ui2-checks__row.is-empty { opacity: 0.55; }
body.ui-v2 .ui2-checks__tag { width: 3.2rem; border-left: 3px solid transparent; }
body.ui-v2 .ui2-checks__tag .anomaly-tag {
    font-size: 0.66rem; font-weight: 600; padding: 1px 6px; border-radius: 4px;
    background: rgba(255, 255, 255, 0.08); color: #cbd5e1; letter-spacing: 0.4px;
}
body.ui-v2 .ui2-checks__name { width: 14rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.ui-v2 .ui2-checks__desc { color: #9aa4b2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.ui-v2 .ui2-checks__count { width: 7.5rem; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
body.ui-v2 .ui2-checks__n { font-weight: 700; font-size: 0.86rem; }
body.ui-v2 .ui2-checks__row.tone-danger  .ui2-checks__tag { border-left-color: #dc3545; } body.ui-v2 .ui2-checks__row.tone-danger  .ui2-checks__n { color: #ef5d6f; }
body.ui-v2 .ui2-checks__row.tone-warning .ui2-checks__tag { border-left-color: #fd7e14; } body.ui-v2 .ui2-checks__row.tone-warning .ui2-checks__n { color: #ffa657; }
body.ui-v2 .ui2-checks__row.tone-success .ui2-checks__tag { border-left-color: #20c997; } body.ui-v2 .ui2-checks__row.tone-success .ui2-checks__n { color: #3ddcab; }
body.ui-v2 .ui2-checks__row.tone-info    .ui2-checks__tag { border-left-color: #0dcaf0; } body.ui-v2 .ui2-checks__row.tone-info    .ui2-checks__n { color: #5ddef5; }
body.ui-v2 .ui2-checks__row.tone-primary .ui2-checks__tag { border-left-color: #2a96fb; } body.ui-v2 .ui2-checks__row.tone-primary .ui2-checks__n { color: #6cb6fc; }
body.ui-v2 .ui2-checks__row.tone-purple  .ui2-checks__tag { border-left-color: #8b5cf6; } body.ui-v2 .ui2-checks__row.tone-purple  .ui2-checks__n { color: #b694ff; }
body.ui-v2 .ui2-checks__row.is-empty .ui2-checks__tag { border-left-color: transparent; }
@media (max-width: 768px) {
    body.ui-v2 .ui2-checks__desc { display: none; }
    body.ui-v2 .ui2-checks__name { width: auto; }
}

/* Detail views: the long explanatory alert becomes one quiet line. */
body.ui-v2 #anomalies .anomaly-detail > .alert,
body.ui-v2 #anomalies #anomaly-review-panel > .alert {
    background: transparent !important;
    border: 0 !important; border-left: 2px solid rgba(77, 163, 255, 0.45) !important;
    border-radius: 0 !important;
    color: #b1bac4 !important;
    padding: 0.1rem 0 0.1rem 0.6rem !important;
    margin-bottom: 0.5rem !important;
    font-size: 0.78rem !important;
}
body.ui-v2 #anomalies .anomaly-detail > .btn,
body.ui-v2 #anomaly-review-panel .btn.mb-3 { margin-bottom: 0.4rem !important; padding: 0.12rem 0.5rem !important; font-size: 0.76rem !important; }

/* Delivery health + AI false-positive backlog: tighter cards. */
body.ui-v2 #anomalies > .section-card { margin-bottom: 0.5rem !important; }
body.ui-v2 #anomalies > .section-card .card-body { padding: 0.45rem 0.6rem !important; }
body.ui-v2 #anomalies > .section-card .card-body .small { font-size: 0.74rem !important; }
body.ui-v2 #anomalies .fp-backlog-card .card-body { padding: 0 !important; }

/* ---- Content: shorter rows, same fonts ---------------------------------- */
body.ui-v2 .table-sm > :not(caption) > * > * { padding: 0.24rem 0.5rem !important; }
body.ui-v2 .card-body { padding: 0.6rem 0.75rem; }
body.ui-v2 .card-header { padding-top: 0.38rem; padding-bottom: 0.38rem; }
body.ui-v2 .row.g-2 { --bs-gutter-y: 0.4rem; --bs-gutter-x: 0.4rem; }
