/* Portal shell and shared components (v3). Module styles live in css/mod-*.css. */
.sidebar { overflow: hidden; }
.nav-scroll { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -8px; padding: 0 8px; scrollbar-width: thin; scrollbar-color: rgba(184, 196, 214, 0.5) transparent; }
.nav-scroll .nav { margin-top: 0; }
.nav-group { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--steel); opacity: 0.75; padding: 16px 12px 6px; }
.nav a { font-size: 13.5px; padding: 8px 12px; }
.brand-name { font-size: 15px; }

.topbar { gap: 12px; }
/* min-width 0 lets the search box shrink on a narrow phone, so the top bar (menu, search, bell, theme switch) always fits.
   The search takes the free room before the spacer does (it used to share it equally, which left the box about 290px wide on a laptop and
   cut its hint mid-letter), up to its 440px limit. A hint that still does not fit ends in an ellipsis. */
.topbar .global-search { position: relative; flex: 100 1 0; max-width: 440px; min-width: 0; }
.topbar .spacer { flex: 1 1 0; }
.global-search > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.global-search .input { padding-left: 36px; min-height: 36px; text-overflow: ellipsis; }
.global-search .input::placeholder { text-overflow: ellipsis; }
/* The date is a convenience. Down to about 1100px wide the search box keeps its full 440px beside it; below 1080px the date would squeeze the box
   until its hint is cut, so it goes. */
@media (max-width: 1080px) { .topbar-date { display: none; } }
.search-pop { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22); max-height: 60vh; overflow: auto; z-index: 30; padding: 4px 0; }
.search-pop[hidden] { display: none; }
.search-group { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 8px 14px 4px; }
.search-item { display: flex; flex-direction: column; padding: 7px 14px; text-decoration: none; }
.search-item:hover, .search-item:focus-visible { background: var(--hover); }
/* The option the arrow keys are on (focus stays in the box, so the highlight has to show it) */
.search-item[aria-selected="true"] { background: var(--hover); box-shadow: inset 3px 0 0 var(--focus); }
.search-item small { color: var(--muted); }
/* the last row of a group that has more matches than it lists */
.search-item.search-more > span { font-weight: 600; }
.search-empty { padding: 12px 14px; color: var(--muted); }
.bell { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); color: var(--text); text-decoration: none; flex: none; }
.bell:hover { background: var(--hover); }
.bell-n { position: absolute; top: -7px; right: -7px; background: var(--gold); color: var(--navy); font-size: 11px; font-weight: 800; border-radius: 999px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 4px; }

.plink { font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--line); }
.plink:hover { border-color: var(--gold); }
.modal.wide { width: min(780px, 100%); }
.sc-0 { background: var(--surface-2); color: var(--muted); }

/* rating input */
.rating-input { display: flex; gap: 8px; flex-wrap: wrap; }
.rate { width: 46px; height: 42px; border-radius: 10px; border: 1px solid var(--field-line); background: var(--field-bg); font-weight: 700; cursor: pointer; font-size: 15px; }
.rate:hover { border-color: var(--text); }
.rate[aria-checked="true"] { background: var(--btn-dark); color: var(--btn-dark-fg); border-color: var(--btn-dark); }
.rate-1[aria-checked="true"] { background: var(--bad); color: #fff; border-color: var(--bad); }
.rate-2[aria-checked="true"] { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.rate-4[aria-checked="true"] { background: var(--good-bg); color: var(--good-fg); border-color: var(--good-fg); }
.rate-5[aria-checked="true"] { background: var(--gold); color: var(--navy); border-color: var(--gold); }
.rating-label { font-size: 13px; color: var(--muted); }

.progress { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; min-width: 80px; }
.progress-fill { height: 100%; background: var(--gold); border-radius: 5px; }

/* Shown when another tab saved while this page holds unsaved input (see FTD.app.onExternalChange) */
.stale-notice { margin-bottom: 20px; align-items: center; }
.stale-notice > div { flex: 1; min-width: 0; }
.stale-notice .btn { margin: 0 4px; }

/* Remote mode (js/remote.js): the sign-in states and the connection banners. Everything here hangs on .login-remote or .remote-banner,
   which only remote mode draws, so the local sign-in page is untouched. */
.login-remote h2 { font-size: 22px; }
.login-remote h2:focus, .login-remote h2:focus-visible { outline: none; } /* focused by script when the screen changes, so a screen reader reads it; it is not a control */
.login-remote p { color: var(--steel); }
.login-remote strong { color: var(--cream); }
.login-remote .login-note { background: var(--navy-2); color: var(--steel); }
.login-remote .btn-ghost { color: var(--cream); border-color: var(--navy-3); }
.login-remote .btn-ghost:hover { background: var(--navy-2); }
.login-remote .login-copy { margin-left: 8px; vertical-align: middle; }
.login-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.login-who { display: flex; align-items: center; gap: 12px; }
.login-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; background: var(--navy-3); }
/* The Discord ID is read out to someone else, so one tap or click selects all of it. */
.login-id { display: inline-block; max-width: 100%; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--navy-3); background: var(--navy-2); color: var(--cream); font-family: ui-monospace, Consolas, 'Courier New', monospace; font-size: 15px; user-select: all; overflow-wrap: anywhere; }
/* The banner stays in view under the top bar while the page scrolls. js/remote.js measures the real top bar and banner (they change with the
   width of the screen and with how many lines the sentence takes) and puts the heights on the root element: --remote-topbar-h and
   --remote-banner-h, and the class remote-banner-on while a banner shows. The 58px is only what the top bar measured when this was written. */
.remote-banner { position: sticky; top: var(--remote-topbar-h, 58px); z-index: 4; margin-bottom: 20px; align-items: center; flex-wrap: wrap; box-shadow: var(--shadow); }
.remote-banner > div { flex: 1 1 240px; min-width: 0; }
.remote-banner .btn { flex: none; }
@media (max-width: 900px) { .remote-banner { margin-bottom: 16px; } }
/* A field that keyboard focus (or the page) scrolls into view lands below the top bar and the banner, not under them. The page's usual padding
   (76px, styles.css) counts the top bar only. */
html.remote-banner-on { scroll-padding-top: calc(var(--remote-topbar-h, 61px) + var(--remote-banner-h, 0px) + 15px); }
/* What the top bar says about saving (js/remote.js): Saving..., Saved, Not saved yet. It is a polite live region that stays in the page, so it
   is announced when its words change; with no words it takes no room. */
.sync-status { flex: 0 1 auto; min-width: 0; max-width: 24em; font-size: 12.5px; line-height: 1.25; font-weight: 600; color: var(--muted); text-align: right; overflow-wrap: anywhere; }
.sync-status:empty { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.topbar .sync-status[data-state="saved"] { color: var(--good-fg); }
.topbar .sync-status[data-state="unsaved"] { color: var(--bad-fg); }
/* On a phone the search box is a sliver, and a sentence beside it would take all of it: the status goes on a row of its own under the bar. */
@media (max-width: 640px) {
  .topbar.has-sync-status { flex-wrap: wrap; } /* only while there is something to say, so the local portal's top bar is never touched */
  .sync-status { order: 9; flex: 1 1 100%; max-width: none; text-align: left; }
}

@media (max-width: 900px) {
  .topbar .global-search { max-width: none; }
  .topbar .demo-tag { display: none; }
  .topbar .spacer { display: none; } /* the search box takes the space, so nothing competes with it on a phone */
}
/* A phone. The search box is a sliver between the menu button and the bell (about 190px at 375), and a results list only that wide wrapped
   rows to two or three lines. The list hangs from the top bar instead, edge to edge with a 16px margin (never wider than the screen, so no
   sideways scroll). The top bar is sticky, which makes it the positioning parent the list is placed against, and that means the box
   is no longer the parent: its icon is placed in the flow and lies over the field's left padding with a negative margin. */
@media (max-width: 640px) {
  .topbar .global-search { position: static; display: flex; align-items: center; }
  .global-search > svg { position: relative; z-index: 1; flex: none; top: auto; left: auto; transform: none; margin: 0 -28px 0 12px; }
  .global-search .input { flex: 1 1 0; width: auto; min-width: 0; }
  .search-pop { top: 100%; left: 16px; right: 16px; }
}

/* Windows high contrast and other forced-colors modes replace every background with the page color, which would erase anything drawn with
   a fill: bars, the current step, pills, chosen buttons. Give those shapes borders, and draw fills in system colors. */
@media (forced-colors: active) {
  .progress, .hbar .track, .stackbar, .phasebar span { border: 1px solid CanvasText; }
  .progress-fill, .hbar .fill, .stackbar span, .phasebar span.done { forced-color-adjust: none; background: Highlight; }
  .phasebar span.cur { forced-color-adjust: none; background: Canvas; border: 3px solid Highlight; }
  .stepper li::before { forced-color-adjust: none; background: GrayText; }
  .stepper li.done::before, .stepper li.current::before { background: Highlight; }
  .stepper .dot { border-color: CanvasText; }
  .stepper li.done .dot, .stepper li.good .dot { forced-color-adjust: none; background: Highlight; color: HighlightText; border-color: Highlight; }
  .stepper li.current .dot { forced-color-adjust: none; background: Canvas; color: CanvasText; border: 4px solid Highlight; }
  .stepper li.bad .dot { forced-color-adjust: none; background: CanvasText; color: Canvas; border-color: CanvasText; }
  .pill, .tag, .sc, .badge, .bell-n { border: 1px solid CanvasText; }
  .pill::before { forced-color-adjust: none; background: CanvasText; }
  .seg button[aria-pressed="true"], .chip[aria-pressed="true"], .rate[aria-checked="true"] { forced-color-adjust: none; background: Highlight; color: HighlightText; border-color: Highlight; }
  .tabs a[aria-current="page"] { border-bottom: 3px solid Highlight; }
  .nav a[aria-current="page"] { outline: 2px solid Highlight; outline-offset: -2px; }
  .theme-switch .knob { border: 1px solid CanvasText; }
}

/* Print: paper is white, so every page prints dark ink on white whatever the screen theme is (styles.css keeps the dark colors off paper).
   Cards may break across pages, tables print as tables, and the controls that only make sense on screen stay off. */
@media print {
  .sidebar, .topbar, .toasts, .overlay, .no-print, .btn, .scrim, .skip-link, .stale-notice, .remote-banner, .tabs, .toolbar, .seg, .chips, .table-hint, .crumb { display: none !important; }
  .app { display: block; }
  html, body { background: #fff; color: #000; }
  body { font-size: 12px; }
  .content { padding: 0; max-width: none; }
  .card { background: #fff; box-shadow: none; break-inside: auto; }
  .kpi, .timeline li, .checklist li, .score-view, .hbar, .stepper li, .table tr { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
  .table-wrap { overflow: visible; background: none; }
  .table { font-size: 10.5px; }
  .table th, .table td { padding: 4px 6px; white-space: normal; overflow-wrap: break-word; }
  .table th:first-child, .table td:first-child, .table.compact th:first-child, .table.compact td:first-child { padding-left: 6px; }
  .table th:last-child, .table td:last-child, .table.compact th:last-child, .table.compact td:last-child { padding-right: 6px; }
  /* A browser drops background colors when it prints unless the page asks to keep them (the "Background graphics" box in the print dialog,
     off by default). That turned any chip with light text on a dark fill into pale text on white paper. Every element asks, so every chip,
     badge, tag, and bar prints with its fill, the module ones too. The paper itself stays white (see above). */
  *, *::before, *::after { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Belt and braces for a browser that ignores that request: a chip keeps a visible edge, so it reads as a chip without its fill. */
  .pill, .tag, .sc { border: 1px solid #555; }
}
