/* ============================================================
   Greystone Capital — Operator Console Design System (gs.css)
   Ported from FCC HQ (Papayawebservices-com/fcc-hq, hq.css) and
   re-tokenized on the Trailing Paper azure palette. Inter only.
   No left-accent bars, no square buttons, no yellow/gold.
   Radii: 12px cards / 9px inputs / 999px pills.
   ============================================================ */

@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter-VariableFont.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #F6F8FB; --card: #FFFFFF; --text: #12233A; --body: #425466;
  --muted: #7A8798; --faint: #98A4B4; --line: #E7EDF3; --line-soft: #EEF2F7;
  --chip: #F1F5F9; --accent: #0C8CE9; --accent-ink: #0A6FBF; --accent-tint: #EAF6FE;
  --ok: #0E9F6E; --ok-bg: #E6F6EF; --warn: #B47818; --warn-bg: #FBF1DC;
  --due: #C0492E; --due-bg: #FBEAE5;
  --grad: linear-gradient(140deg,#0CAEE9,#0287E8);
  --r-card: 12px; --r-input: 9px;
  --field: #FFFFFF; --panel: #FFFFFF; --line-strong: #D8E1EA;
  /* structural (non-theme) layout constants */
  --sidebar-w: 214px; --topbar-h: 60px;
  /* Sidebar — near-black graphite, shared by BOTH themes (hard rule: no light-surface sidebar) */
  --sb-bg: #121214; --sb-line: #1E1E22; --sb-text: #F2F3F5; --sb-muted: #8B8D93;
  --sb-active-bg: rgba(12,140,233,.14); --sb-active-text: #2BA3F2;
  --sb-tip-bg: #1C1C1F; --sb-tip-text: #F2F3F5;
}
:root[data-theme=dark] {
  --bg: #0A0A0B; --card: #141416; --text: #F0F1F3; --body: #B9BDC4;
  --muted: #82868D; --faint: #58585E; --line: #26262A; --line-soft: #1E1E21;
  --chip: #1C1C1F; --accent: #2BA3F2; --accent-ink: #5FB9F5; --accent-tint: #132436;
  --ok: #34C08B; --ok-bg: #0F231B; --warn: #D9A03C; --warn-bg: #2A2013;
  --due: #E06A4E; --due-bg: #2C1712;
  --field: #101012; --panel: #141416; --line-strong: #333338;
  color-scheme: dark;
}

/* ---------- Reset + base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  letter-spacing: -.006em;
  line-height: 1.55;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button { font-family: inherit; }
h1, h2, h3 { letter-spacing: -.02em; }

/* ============================================================
   Shell frame
   ============================================================ */
.gs-shell { min-height: 100vh; }
.gs-main { min-height: 100vh; display: flex; flex-direction: column; }
.gs-content { flex: 1; padding: 18px 16px 56px; width: 100%; max-width: 1440px; margin: 0 auto; }
.gs-content.gs-wide { max-width: none; }
@media (max-width: 767px) { .gs-content { overflow-x: hidden; } }
@media (min-width: 980px) {
  .gs-main { margin-left: var(--sidebar-w); }
  .gs-content { padding: 26px 30px 64px; }
}

/* ---------- Page head ---------- */
.page-head { margin-bottom: 20px; }
.page-head h1 { font-weight: 700; font-size: 1.35rem; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* ---------- Layout helpers ---------- */
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 13.5px; }

/* ============================================================
   Sidebar (.gs-sb) — 3-mode: open / rail / expand-on-hover
   Near-black graphite in BOTH themes (hard rule — see --sb-* tokens).
   Active row = azure-on-black tint bg + azure text. No left-accent bar.
   ============================================================ */
.gs-sb {
  position: fixed; inset: 0 auto 0 0; z-index: 90;
  width: var(--sidebar-w);
  background: var(--sb-bg); color: var(--sb-muted);
  border-right: 1px solid var(--sb-line);
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform .25s ease, width .18s ease;
  overflow: hidden;
  overscroll-behavior: contain;
}
.gs-sb.is-open { transform: translateX(0); box-shadow: 8px 0 40px rgba(0,0,0,.5); }
@media (min-width: 980px) { .gs-sb { transform: none; } }

.sb-brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h); padding: 0 18px; flex-shrink: 0;
  border-bottom: 1px solid var(--sb-line);
}
.sb-logo { display: flex; align-items: center; }
.sb-logo-full { height: auto; width: 152px; max-width: 100%; display: block; }
.sb-logo-mark { display: none; height: auto; width: 30px; }

.sb-nav { flex: 1; padding: 14px 12px 20px; overflow-y: auto; scrollbar-width: none; }
.sb-nav::-webkit-scrollbar { display: none; }
.sb-sec {
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--sb-muted);
  padding: 14px 10px 6px;
}
.sb-item {
  display: flex; align-items: center; gap: 11px;
  min-height: 42px; padding: 0 10px;
  border-radius: 7px;
  font-size: 13.5px; font-weight: 500; color: var(--sb-muted);
  position: relative;
  transition: background .15s, color .15s;
}
.sb-item svg, .sb-item .gs-ico { width: 17px; height: 17px; flex: 0 0 17px; stroke: currentColor; }
.sb-item:hover { background: var(--sb-line); color: var(--sb-text); }
.sb-item.is-active { background: var(--sb-active-bg); color: var(--sb-active-text); font-weight: 600; }
.sb-item.is-soon { opacity: .45; cursor: default; }
.sb-item .soon {
  margin-left: auto; font-size: 9.5px; font-weight: 700; letter-spacing: .06em;
  color: var(--sb-muted); border: 1px solid color-mix(in srgb, var(--sb-text) 20%, transparent);
  border-radius: 999px; padding: 1px 7px; text-transform: uppercase;
}
.sb-badge {
  margin-left: auto; min-width: 18px; text-align: center; font-size: 10.5px; font-weight: 700;
  color: #fff; background: var(--sb-active-text); border-radius: 999px; padding: 2px 6px; line-height: 1;
}

.sb-user { border-top: 1px solid var(--sb-line); padding: 14px; display: flex; align-items: center; gap: 10px; }
.sb-user-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; border-radius: 9px; padding: 4px; margin: -4px; }
.sb-user-link:hover { background: var(--sb-line); }
.sb-user .avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
  background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
}
.sb-user .who { min-width: 0; }
.sb-user .who .n { font-size: 13px; font-weight: 600; color: var(--sb-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user .who .r { font-size: 11px; color: var(--sb-muted); text-transform: capitalize; }
.sb-user .out {
  margin-left: auto; display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 9px; color: var(--sb-muted);
}
.sb-user .out:hover { background: var(--sb-line); color: var(--sb-text); }
.sb-user .out svg { width: 16px; height: 16px; stroke: currentColor; }

.sb-collapse {
  display: none; align-items: center; gap: 10px; width: calc(100% - 24px); margin: 0 12px 8px;
  padding: 9px 12px; background: none; border: 0; border-radius: var(--r-input); cursor: pointer;
  color: var(--sb-muted); font-size: 12.5px; font-family: inherit;
}
.sb-collapse:hover { background: var(--sb-line); color: var(--sb-text); }
.sb-collapse svg { width: 15px; height: 15px; stroke: currentColor; fill: none; transition: transform .18s; }

.sb-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,.55);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.sb-overlay.is-open { opacity: 1; pointer-events: auto; }
@media (min-width: 980px) { .sb-overlay { display: none; } }

/* Rail tooltip bubble — same near-black surface as the sidebar, both themes */
.sb-tip {
  position: fixed; transform: translateY(-50%); z-index: 300;
  background: var(--sb-tip-bg); color: var(--sb-tip-text);
  font-size: 12.5px; font-weight: 600; padding: 7px 13px; border-radius: 8px; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .12s;
}
.sb-tip::before { content: ""; position: absolute; right: 100%; top: 50%; transform: translateY(-50%); border: 5px solid transparent; border-right-color: var(--sb-tip-bg); }
.sb-tip.on { opacity: 1; }

/* Sidebar modes: expanded / rail / expand-on-hover */
@media (min-width: 980px) {
  .sb-collapse { display: flex; flex-shrink: 0; }
  html.sb-mode-rail, html.sb-mode-auto { --sidebar-w: 72px; }
  html.sb-mode-auto .gs-sb { width: 72px; }
  html.sb-mode-auto .gs-sb:hover { width: 248px; box-shadow: 12px 0 34px rgba(0,0,0,.4); }
  html.sb-mode-rail .gs-sb .sb-sec, html.sb-mode-auto .gs-sb:not(:hover) .sb-sec { display: none; }
  html.sb-mode-rail .gs-sb .sb-item span, html.sb-mode-auto .gs-sb:not(:hover) .sb-item span { display: none; }
  html.sb-mode-rail .gs-sb .sb-item, html.sb-mode-auto .gs-sb:not(:hover) .sb-item { justify-content: center; padding: 11px 0; }
  html.sb-mode-rail .gs-sb .sb-brand, html.sb-mode-auto .gs-sb:not(:hover) .sb-brand { justify-content: center; padding: 0 8px; }
  html.sb-mode-rail .gs-sb .sb-logo-full, html.sb-mode-auto .gs-sb:not(:hover) .sb-logo-full { display: none; }
  html.sb-mode-rail .gs-sb .sb-logo-mark, html.sb-mode-auto .gs-sb:not(:hover) .sb-logo-mark { display: block; margin: 0 auto; }
  html.sb-mode-rail .gs-sb .sb-user .who, html.sb-mode-auto .gs-sb:not(:hover) .sb-user .who { display: none; }
  html.sb-mode-rail .gs-sb .sb-user, html.sb-mode-auto .gs-sb:not(:hover) .sb-user { flex-direction: column; gap: 10px; }
  html.sb-mode-rail .gs-sb .sb-collapse, html.sb-mode-auto .gs-sb:not(:hover) .sb-collapse { justify-content: center; }
  html.sb-mode-rail .gs-sb .sb-collapse span, html.sb-mode-auto .gs-sb:not(:hover) .sb-collapse span { display: none; }
  html.sb-mode-rail .gs-sb .sb-collapse svg, html.sb-mode-auto .gs-sb .sb-collapse svg { transform: rotate(180deg); }
  html.sb-mode-rail .gs-sb .sb-badge, html.sb-mode-auto .gs-sb:not(:hover) .sb-badge {
    position: absolute; top: 4px; right: 8px; margin: 0;
    font-size: 0; width: 9px; height: 9px; padding: 0;
  }
}

/* ============================================================
   Topbar (.gs-topbar)
   ============================================================ */
.gs-topbar {
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  position: sticky; top: 0; z-index: 60;
}
@media (min-width: 980px) { .gs-topbar { padding: 0 26px; } }

.tb-brand { display: none; }
@media (max-width: 759px) {
  .tb-brand { display: flex; align-items: center; }
  .tb-brand img { height: 30px; width: auto; border-radius: 6px; display: block; }
}

.tb-burger {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 1px solid var(--line); background: var(--card); cursor: pointer;
  border-radius: var(--r-input); color: var(--muted); transition: all .13s;
}
.tb-burger:hover { border-color: var(--line-strong); color: var(--text); background: var(--chip); }
.tb-burger svg { width: 21px; height: 21px; stroke: currentColor; }
@media (min-width: 980px) { .tb-burger { display: none; } }

.tb-search { display: none; flex: 1; max-width: 420px; margin-left: 8px; position: relative; }
@media (min-width: 760px) { .tb-search { display: block; } }
@media (min-width: 760px) {
  .gs-topbar { position: sticky; }
  .tb-search { position: absolute; left: 50%; transform: translateX(-50%); width: clamp(280px, 40vw, 560px); max-width: none; margin: 0; flex: none; }
}
.tb-search input {
  width: 100%; height: 40px; border: 1px solid var(--line); border-radius: var(--r-input);
  background: var(--field); padding: 0 12px 0 38px; font-size: 13.5px; font-family: inherit; color: var(--text);
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.tb-search input:focus { outline: none; background: var(--card); border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.tb-search svg { position: absolute; left: 12px; top: 11px; width: 17px; height: 17px; stroke: var(--muted); pointer-events: none; }
.tb-msearch { display: none; }
@media (max-width: 759px) {
  .tb-msearch { display: inline-flex; }
  html.tb-search-open .tb-search {
    display: block; position: absolute; left: 0; right: 0; top: 100%; margin: 0; max-width: none;
    padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--line);
    box-shadow: 0 14px 28px rgba(9,15,26,.12); z-index: 55;
  }
  html.tb-search-open .tb-search input { width: 100%; padding-left: 46px; }
  html.tb-search-open .tb-search svg { left: 26px; }
  html.tb-search-open .gs-dropdown { left: 14px; right: 14px; }
}

.tb-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.tb-ico {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--r-input); border: 1px solid var(--line);
  background: var(--card); cursor: pointer; color: var(--muted); transition: all .13s;
}
.tb-ico:hover { border-color: var(--line-strong); color: var(--text); background: var(--chip); }
.tb-ico svg { width: 18px; height: 18px; stroke: currentColor; }
.tb-icon-wrap { position: relative; }
.tb-iconbtn {
  position: relative; width: 40px; height: 40px; border-radius: var(--r-input);
  background: var(--card); border: 1px solid var(--line); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); transition: all .13s;
}
.tb-iconbtn:hover { border-color: var(--line-strong); color: var(--text); background: var(--chip); }
.tb-iconbtn:active { transform: scale(.93); }
.tb-iconbtn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }
.tb-badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px;
  background: var(--accent); color: #fff; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center; padding: 0 5px;
  border: 2px solid var(--card); box-sizing: content-box; box-shadow: 0 2px 6px rgba(9,15,26,.18);
}

/* Bell: dropdown on desktop, straight link to /console/notifications on touch
   widths — a hover popover under a thumb is worse than the full page. */
.tb-bell-lg { display: none; }
.tb-bell-sm { display: flex; }
@media (min-width: 768px) {
  .tb-bell-lg { display: block; }
  .tb-bell-sm { display: none; }
}

/* Theme toggle: show moon in light, sun in dark */
.tb-ico .ico-sun { display: none; }
:root[data-theme=dark] .tb-ico .ico-sun { display: block; }
:root[data-theme=dark] .tb-ico .ico-moon { display: none; }

/* ============================================================
   Dropdowns / popovers (generic .dd / .dd-menu)
   ============================================================ */
.dd { position: relative; }
.dd-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 100;
  min-width: 210px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: 0 10px 15px -3px rgba(9,15,26,.10), 0 4px 6px -4px rgba(9,15,26,.10);
  padding: 6px;
  display: none;
}
:root[data-theme=dark] .dd-menu { box-shadow: 0 10px 15px -3px rgba(0,0,0,.5), 0 4px 6px -4px rgba(0,0,0,.5); }
.dd.is-open .dd-menu { display: block; }
.dd-menu a, .dd-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 40px; padding: 8px 10px; border: none; background: none; cursor: pointer;
  border-radius: 8px; font-size: 13px; font-family: inherit; color: var(--text); text-align: left;
  transition: background .1s, color .1s;
}
.dd-menu a:hover, .dd-menu button:hover { background: var(--chip); }
.dd-menu .dis { opacity: .45; cursor: default; }
.dd-menu .dis:hover { background: none; }
.dd-menu .sep { height: 1px; background: var(--line); margin: 6px -2px; }

/* Icon-button popover (row action "..." menus) */
.btn-iconb {
  width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); border-radius: var(--r-input); background: var(--card);
  color: var(--muted); cursor: pointer; transition: color .12s, background .12s, border-color .12s;
}
.btn-iconb:hover { color: var(--text); background: var(--chip); }
.ktm-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  min-width: 200px; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(9,15,26,.10); padding: 8px 4px; flex-direction: column; gap: 2px;
}
.dd.is-open .ktm-menu { display: flex; }
.ktm-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 0 4px; border-radius: 8px;
  background: none; border: 0; cursor: pointer; font: inherit; font-size: 13px; font-weight: 500;
  color: var(--text); text-decoration: none; text-align: start; white-space: nowrap;
}
.ktm-link:hover { background: var(--chip); }

/* Avatar menu (dark toggle, account, sign out) */
.user-menu { min-width: 230px; right: 0; left: auto; }
.user-menu .um-head { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-menu .um-n { font-weight: 700; font-size: 13.5px; }
.user-menu .um-r { font-size: 11.5px; color: var(--muted); }
.user-menu a, .user-menu button#theme-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 9px 14px; font-size: 13.5px; color: var(--text); text-decoration: none;
  background: none; border: 0; cursor: pointer; font-family: inherit; text-align: left;
}
.user-menu a:hover, .user-menu button#theme-toggle:hover { background: var(--chip); }
.um-count { min-width: 20px; text-align: center; font-size: 10.5px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 999px; padding: 2px 6px; }
.um-count:empty { display: none; }
.um-label { font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); padding: 8px 14px 3px; font-weight: 600; }
.um-theme {
  display: flex; margin: 2px 14px 10px; padding: 3px;
  background: var(--chip); border: 1px solid var(--line); border-radius: var(--r-input);
}
.dd-menu .um-theme button {
  flex: 1; display: block; width: auto; min-height: 0; text-align: center;
  font: inherit; font-size: 12px; font-weight: 600; line-height: 1; cursor: pointer;
  padding: 7px 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); transition: background .12s, color .12s;
}
.dd-menu .um-theme button:hover { background: transparent; color: var(--text); }
.dd-menu .um-theme button.is-current, .dd-menu .um-theme button.is-current:hover { background: var(--accent-tint); color: var(--accent-ink); }

/* Global search dropdown (topbar) */
.gs-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; max-height: 520px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: 0 12px 32px rgba(9,15,26,.14); z-index: 300; padding: 4px 0;
}
.gs-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 10px 14px 5px; border-top: 1px solid var(--line); }
.gs-group:first-child { border-top: 0; }
.gs-item { display: flex; align-items: center; gap: 10px; padding: 8px 14px; text-decoration: none; color: var(--text); border-left: 2px solid transparent; }
.gs-item:hover { background: var(--chip); border-left-color: var(--accent); }
.gs-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--grad); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 11px; letter-spacing: .04em; flex-shrink: 0; }
.gs-body { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.gs-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-badge { font-size: 10px; font-weight: 700; color: var(--accent-ink); background: var(--accent-tint); border-radius: 6px; padding: 1px 6px; margin-left: 7px; vertical-align: 1px; text-transform: uppercase; letter-spacing: .03em; }
.gs-amount { font-size: 12.5px; font-weight: 700; color: var(--accent-ink); margin-left: 8px; flex-shrink: 0; }
.gs-empty, .gs-loading { padding: 16px 14px; font-size: 13px; color: var(--muted); }

/* Notifications menu (topbar bell) */
.tb-menu { width: 360px; max-width: calc(100vw - 24px); padding: 0; overflow: hidden; border-radius: 16px; }
.tb-menu-head { padding: 13px 16px 11px; font-weight: 700; font-size: 14px; border-bottom: 1px solid var(--line); color: var(--text); }
.tb-menu-day { padding: 9px 16px 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.tb-menu-list { max-height: 380px; overflow-y: auto; overscroll-behavior: contain; }
.tb-menu-item { display: flex; gap: 12px; align-items: center; padding: 10px 16px; text-decoration: none; transition: background .1s; position: relative; }
.tb-menu-item:hover { background: var(--chip); }
.tb-menu-item.is-unread { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.tb-menu-item.is-unread:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.tb-menu-item.is-unread .t { font-weight: 700; }
.tb-nicon { flex: none; width: 36px; height: 36px; border-radius: 11px; display: flex; align-items: center; justify-content: center; }
.tb-nicon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.nk-person { background: var(--accent-tint); color: var(--accent); }
.nk-money { background: var(--ok-bg); color: var(--ok); }
.nk-doc { background: var(--warn-bg); color: var(--warn); }
.nk-alert { background: var(--due-bg); color: var(--due); }
.nk-default { background: var(--chip); color: var(--muted); }
.tb-menu-av {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  background: var(--grad); color: #fff;
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
  display: flex; align-items: center; justify-content: center;
}
.tb-menu-main { flex: 1; min-width: 0; }
.tb-menu-item .trow { display: flex; align-items: baseline; gap: 8px; }
.tb-menu-item .t {
  font-size: 13px; font-weight: 570; color: var(--text); line-height: 1.4;
  flex: 1; min-width: 0; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.tb-menu-item .t b { font-weight: 700; }
.tb-menu-item .t .ent { color: var(--accent); font-weight: 650; }
.tb-menu-item .tm { flex: none; font-size: 11px; color: var(--muted); }
.tb-menu-item .s { font-size: 12.5px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-menu-item .meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.tb-fresh { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.tb-count { flex: none; min-width: 19px; height: 19px; background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 19px; text-align: center; padding: 0 5px; }
.tb-menu-empty { padding: 34px 16px; font-size: 13px; color: var(--muted); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tb-menu-empty svg { width: 26px; height: 26px; fill: none; stroke: var(--line-strong); stroke-width: 1.6; }
.tb-menu-foot { display: block; padding: 11px 16px; text-align: center; font-size: 12.5px; font-weight: 700; color: var(--accent); text-decoration: none; border-top: 1px solid var(--line); transition: background .1s; }
.tb-menu-foot:hover { background: var(--chip); }
.tb-tabs { display: flex; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); }
.tb-tab { background: none; border: none; cursor: pointer; padding: 7px 11px 9px; font-size: 12.5px; font-weight: 650; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .12s; }
.tb-tab:hover { color: var(--text); }
.tb-tab.is-on { color: var(--accent); border-bottom-color: var(--accent); }
.tb-pills { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.tb-pill { font-size: 11px; font-weight: 650; padding: 2px 9px; border-radius: 7px; background: var(--chip); border: 1px solid var(--line-strong); color: var(--muted); }
.tb-menu-actions { display: flex; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--line); }
.tb-menu-act { flex: 1; text-align: center; padding: 9px 0; border-radius: var(--r-input); cursor: pointer; font-size: 12.5px; font-weight: 700; text-decoration: none; transition: all .12s; background: var(--chip); border: 1px solid var(--line-strong); color: var(--text); }
.tb-menu-act:hover { border-color: var(--accent); color: var(--accent); }
.tb-menu-act.is-primary { background: var(--grad); border-color: transparent; color: #fff; }
.tb-menu-act.is-primary:hover { filter: brightness(.95); }
@media (max-width: 640px) { .tb-menu { width: calc(100vw - 24px); } }

/* ============================================================
   Cards / KPIs
   ============================================================ */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: 0 3px 11px rgba(18,35,58,.06);
  padding: 20px;
}
:root[data-theme=dark] .card { box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.card + .card { margin-top: 16px; }
.card h2 { font-weight: 650; font-size: 14.5px; letter-spacing: -.01em; margin-bottom: 14px; }
.card > h2:first-child {
  margin: -20px -20px 16px; padding: 0 20px; min-height: 52px;
  display: flex; align-items: center; border-bottom: 1px solid var(--line);
}

.kpis {
  display: grid; gap: 0; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 18px; border: 1px solid var(--line); border-radius: var(--r-card);
  overflow: hidden; background: var(--card); box-shadow: 0 3px 11px rgba(18,35,58,.06);
}
:root[data-theme=dark] .kpis { box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.kpi { padding: 16px 18px; border-left: 1px solid var(--line); }
.kpi:first-child { border-left: 0; }
.kpi .l { font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--muted); }
.kpi .v { font-weight: 700; font-size: 1.7rem; letter-spacing: -.025em; margin-top: 4px; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 9px;
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: color .12s, background .12s, border-color .12s, box-shadow .12s, transform .06s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--grad); color: #fff; border: 0; box-shadow: 0 1px 2px rgba(9,15,26,.1); }
.btn-primary:hover { filter: brightness(.95); }
.btn-ghost { background: var(--card); border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--muted); background: var(--chip); }
:root[data-theme=dark] .btn-ghost:hover { background: var(--chip); }
.btn-danger { background: var(--due); color: #fff; }
.btn-danger:hover { filter: brightness(.9); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }

/* ============================================================
   Forms
   ============================================================ */
select {
  appearance: none; -webkit-appearance: none;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background-color: var(--field);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 0 34px 0 12px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%237A8798' stroke-width='2'><path d='M2 4l4 4 4-4' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 11px;
}
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
:root[data-theme=dark] select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%237E8CA0' stroke-width='2'><path d='M2 4l4 4 4-4' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}

.fld { margin-bottom: 14px; }
.fld label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.fld input, .fld select, .fld textarea,
.tbl input:not([type="checkbox"]):not([type="file"]), .tbl select {
  width: 100%; min-height: 44px; padding: 0 13px;
  border: 1px solid var(--line-strong); border-radius: 9px;
  font-size: 14px; font-family: inherit; background-color: var(--field); color: var(--text);
  box-shadow: 0 1px 2px rgba(9,15,26,.03);
  transition: border-color .12s, box-shadow .12s;
}
.tbl select { padding-right: 34px; }
.fld select { padding-right: 34px; }
.fld textarea { padding: 11px 13px; min-height: 90px; resize: vertical; }
.fld input:focus, .fld select:focus, .fld textarea:focus,
.tbl input:focus, .tbl select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.fld input::placeholder, .fld textarea::placeholder { color: var(--faint); }
.form-row { display: grid; gap: 12px; }
@media (min-width: 720px) {
  .form-row { grid-template-columns: repeat(var(--cols, 2), 1fr); align-items: end; }
  .form-row .span2 { grid-column: span 2; }
}

/* File inputs (styled picker) */
input[type="file"] {
  width: 100%; font-size: 13px; color: var(--muted); font-family: inherit;
  border: 1px solid var(--line-strong); border-radius: 9px;
  padding: 6px 10px; background: var(--field); cursor: pointer; min-height: 44px;
}
input[type="file"]::file-selector-button,
input[type="file"]::-webkit-file-upload-button {
  font-family: inherit; font-size: 12.5px; font-weight: 700; color: #fff;
  background: var(--accent); border: 0; border-radius: 8px; padding: 6px 12px;
  margin-right: 12px; cursor: pointer;
}
input[type="file"]:hover { border-color: var(--accent); }
input[type="file"]:hover::file-selector-button { background: var(--accent-ink); }

/* iOS date/time inputs: strip native sizing so width:100% is honored */
input[type="time"], input[type="date"], input[type="datetime-local"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--field); color: var(--text); font-family: inherit; font-size: 14px;
  padding: 0 13px; min-height: 44px; text-align: left;
}

/* iOS: inputs under 16px trigger auto-zoom on focus. Force 16px on touch widths. */
@media (max-width: 759px) {
  input, select, textarea { font-size: 16px !important; }
}

/* ============================================================
   Pills / status
   TP-style dot-pill anatomy: leading currentColor dot, soft bg.
   ============================================================ */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .01em;
  padding: 3px 11px; border-radius: 999px; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-due { background: var(--due-bg); color: var(--due); }
.pill-gray { background: var(--chip); color: var(--muted); }

/* Status pill dropdown (clickable status change, e.g. loan/document status) */
.status-dd { position: relative; }
.status-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 700; border-radius: var(--r-input); padding: 0 12px; min-height: 34px;
}
.status-btn::after { content: ""; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); }
.status-btn.pill-ok { background: var(--ok); color: #fff; }
.status-btn.pill-warn { background: var(--warn); color: #fff; }
.status-btn.pill-due { background: var(--due); color: #fff; }
.status-btn.pill-gray { background: var(--muted); color: #fff; }
.status-menu { min-width: 190px; padding: 6px; left: 0; right: auto; max-width: calc(100vw - 28px); }
.status-opt { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; background: none; cursor: pointer; font-family: inherit; font-size: 13px; color: var(--text); border-radius: 8px; text-align: left; }
.status-opt:hover { background: var(--chip); }
.status-opt.is-current { font-weight: 700; background: var(--chip); }
.status-swatch { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; border: 2px solid transparent; }
.status-swatch.pill-ok { background: var(--ok); }
.status-swatch.pill-warn { background: var(--warn); }
.status-swatch.pill-due { background: var(--due); }
.status-swatch.pill-gray { background: var(--muted); }

/* ============================================================
   Tables (mobile = card rows)
   ============================================================ */
.tbl-wrap { overflow: visible; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  padding: 14px 16px; border-bottom: 1px solid var(--line); background: transparent;
}
.tbl td { padding: 15px 16px; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .muted { color: var(--muted); font-size: 12.5px; }
.tbl .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 767px) {
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr {
    border: 1px solid var(--line); border-radius: var(--r-card);
    margin-bottom: 12px; padding: 6px 0; background: var(--card);
  }
  .tbl td { border: none; padding: 8px 14px; }
  /* Flatten the wrapper card so row-cards don't sit on a card-behind-cards */
  .card:has(.tbl), .card:has(.tbl-wrap) {
    background: transparent; border: 0; box-shadow: none;
    border-radius: 0; padding: 0 !important;
  }
  .card:has(.tbl) > h2:first-child, .card:has(.tbl-wrap) > h2:first-child {
    margin: 0 0 10px; padding: 0;
  }
  .tbl td[data-label]::before {
    content: attr(data-label);
    display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: var(--muted); margin-bottom: 2px;
  }
}

/* ============================================================
   Flash messages
   ============================================================ */
.flash { display: flex; align-items: flex-start; gap: 10px; border-radius: var(--r-card); padding: 13px 16px; margin-bottom: 16px; font-size: 13.5px; font-weight: 500; }
.flash-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); }
.flash-err { background: var(--due-bg); color: var(--due); border: 1px solid color-mix(in srgb, var(--due) 35%, transparent); }
.flash .x { margin-left: auto; background: none; border: none; cursor: pointer; color: inherit; font-size: 16px; line-height: 1; padding: 2px; }

/* ============================================================
   Modals (mobile = full-screen sheet, header fixed, footer pinned)
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300; display: none;
  background: rgba(9,15,26,.45); backdrop-filter: blur(2px);
  align-items: center; justify-content: center; padding: 18px;
}
.modal-overlay.is-open { display: flex; }
.modal {
  width: 100%; max-width: 440px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: 0 20px 25px -5px rgba(9,15,26,.15), 0 8px 10px -6px rgba(9,15,26,.1);
  display: flex; flex-direction: column; max-height: 86vh; overflow: hidden;
}
:root[data-theme=dark] .modal { box-shadow: 0 20px 25px -5px rgba(0,0,0,.6); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); flex: none; }
.modal-title { font-weight: 650; font-size: 14.5px; letter-spacing: -.01em; }
.modal-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.modal-x {
  width: 30px; height: 30px; border-radius: 8px; border: none; background: none;
  color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.modal-x:hover { background: var(--chip); color: var(--text); }
.modal-body { overflow-y: auto; padding: 16px 20px; flex: 1 1 auto; min-height: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 13px 20px; border-top: 1px solid var(--line); flex: none; }
.modal-actions .btn[disabled] { opacity: .5; cursor: default; }
@media (max-width: 759px) {
  .modal-overlay { padding: 0; }
  .modal { max-width: 100%; width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
}

/* ============================================================
   Toast (transient confirmations)
   ============================================================ */
.toast-wrap {
  position: fixed; bottom: 20px; right: 20px; z-index: 1000;
  display: flex; flex-direction: column; gap: 10px; max-width: 360px;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: 0 10px 15px -3px rgba(9,15,26,.12), 0 4px 6px -4px rgba(9,15,26,.1);
  padding: 13px 16px; font-size: 13.5px; font-weight: 500; color: var(--text);
  animation: gs-toast-in .18s ease;
}
:root[data-theme=dark] .toast { box-shadow: 0 10px 15px -3px rgba(0,0,0,.5), 0 4px 6px -4px rgba(0,0,0,.5); }
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 5px; }
.toast-ok::before { background: var(--ok); }
.toast-warn::before { background: var(--warn); }
.toast-due::before { background: var(--due); }
.toast .x { margin-left: auto; background: none; border: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 2px; }
@keyframes gs-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   Avatar
   ============================================================ */
.gs-av { border-radius: 50%; object-fit: cover; display: inline-block; flex-shrink: 0; }
.gs-av--ini {
  background: var(--grad); color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; letter-spacing: .04em;
}
.tb-avatar { position: relative; background: none; border: 0; padding: 0; cursor: pointer; border-radius: 50%; display: flex; }
.tb-avatar:hover .gs-av { outline: none; }
.tb-avatar .dot {
  position: absolute; top: -1px; right: -1px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--card); display: none;
}
.tb-avatar .dot.on { display: block; }

/* ============================================================
   iOS-style toggle switch (reusable boolean control)
   Markup: <label class="gs-switch"><input type="checkbox"><span class="gs-switch__track"></span></label>
   ============================================================ */
.gs-switch { display: inline-flex; align-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.gs-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.gs-switch__track {
  position: relative; width: 42px; height: 25px; border-radius: 20px; flex-shrink: 0;
  background: var(--chip); box-shadow: inset 0 0 0 .5px var(--line-strong);
  transition: background .18s;
}
.gs-switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 21px; height: 21px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(9,15,26,.2); transition: left .18s;
}
.gs-switch input:checked + .gs-switch__track { background: var(--accent); box-shadow: none; }
.gs-switch input:checked + .gs-switch__track::after { left: 19px; }
.gs-switch input:focus-visible + .gs-switch__track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }

/* ============================================================
   Focus visibility (accent ring, not the brand orange)
   ============================================================ */
a:focus-visible, button:focus-visible, [data-dd]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 8px;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

/* ============================================================
   Scrollbars
   ============================================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   Public shell (Task 3 addition, restyled Task 6) — centered card,
   no sidebar/topbar. Login, e-signature, invite-accept, portal-accept
   pages. Logo sits on the light card, so gold-on-white is fine here
   (marketing site's normal usage) — unlike the black sidebar.
   ============================================================ */
.gs-pub { background: var(--bg); min-height: 100vh; }
.gs-pub-wrap {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 22px; padding: 40px 16px;
}
.gs-pub-logo { display: block; width: 190px; max-width: 70vw; height: auto; }
.gs-pub-card {
  width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-card); box-shadow: 0 20px 25px -5px rgba(9,15,26,.1), 0 8px 10px -6px rgba(9,15,26,.06);
  padding: 30px;
}
:root[data-theme=dark] .gs-pub-card { box-shadow: 0 20px 25px -5px rgba(0,0,0,.5); }

/* Print: hide app chrome (receipts print from inside the shell) */
@media print{
  .gs-sb,.gs-topbar,.sb-overlay{display:none !important}
  .gs-main{margin:0 !important}
}

/* ============================================================
   E-signature cell (.sig-cell) — shared component rendered by
   console/documents/_sigcell.php on both the loan-detail rail and
   the flat documents grid. Status itself uses the shared .pill set;
   only the inline links + row rhythm live here.
   ============================================================ */
.sig-cell { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 5px 10px; font-size: 12.5px; }
.sig-cell a { color: var(--accent-ink); font-weight: 650; text-decoration: none; }
.sig-cell a:hover { text-decoration: underline; }

/* ============================================================
   Google Places dropdown (.pac-*) — Google appends this panel to
   <body> with its own inline styles, so it is themed here rather
   than scoped to a page. z-index clears .modal-overlay (300) so the
   suggestions sit above the wizard's New-borrower modal.
   ============================================================ */
.pac-container {
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  box-shadow: 0 14px 34px rgba(9,15,26,.16); font-family: inherit;
  margin-top: 6px; padding: 6px 0; z-index: 1200;
}
:root[data-theme=dark] .pac-container { box-shadow: 0 14px 34px rgba(0,0,0,.6); }
.pac-item { padding: 9px 14px; font-size: 13px; line-height: 1.4; color: var(--muted); border-top: 0; cursor: pointer; }
.pac-item:hover, .pac-item-selected, .pac-item-selected:hover { background: var(--accent-tint); }
.pac-item-query { font-size: 13px; font-weight: 650; color: var(--text); }
.pac-matched { color: var(--accent-ink); }
.pac-icon { display: none; }
.pac-logo::after { filter: grayscale(1) opacity(.55); }
