/* =====================================================================
   JNN Portal, design system.

   Light, dense and calm, in the spirit of an enterprise CRM. The brand
   navy carries structure and text, the brand gold is an accent used
   sparingly (active navigation, the current stage, focus), and only
   green, amber and red carry status meaning.

   The neutral scale is not a stock grey. Every step is tinted toward the
   brand navy, so white surfaces, borders and secondary text all read as
   part of the same family as the logo instead of a generic admin theme.

   No web fonts, no framework, no runtime CSS. The system font stack paints
   on the first frame, which matters on a field officer's phone.
   ===================================================================== */

:root {
  /* ---- Brand ---- */
  --navy-950: #0a1128;
  --navy-900: #0f1b3d;
  --navy-800: #16264d;
  --navy-700: #1f3466;
  --navy-600: #2b4580;
  --navy-200: #c9d3e8;
  --navy-100: #e3e8f3;
  --navy-50:  #f0f3f9;

  --gold-700: #85662a;
  --gold-600: #a3813f;
  --gold-500: #c6a15b;
  --gold-400: #d9b768;
  --gold-100: #f5ecd8;
  --gold-50:  #fbf7ee;

  /* ---- Neutrals, navy tinted ---- */
  --n-0:   #ffffff;
  --n-25:  #fafbfd;
  --n-50:  #f4f6fa;
  --n-100: #edf0f5;
  --n-150: #e4e8ef;
  --n-200: #d9dee8;
  --n-300: #c0c8d6;
  --n-400: #939db2;
  --n-500: #66718a;
  --n-600: #4c5770;
  --n-700: #353f57;
  --n-800: #222a41;
  --n-900: #141b30;

  /* ---- Semantic ---- */
  --bg: var(--n-50);
  --surface: var(--n-0);
  --surface-2: var(--n-25);
  --surface-hover: var(--navy-50);
  --border: var(--n-150);
  --border-strong: var(--n-200);
  --text: var(--n-900);
  --text-2: var(--n-600);
  --text-3: var(--n-500);
  --primary: var(--navy-800);
  --primary-hover: var(--navy-700);
  --link: var(--navy-600);
  --accent: var(--gold-500);

  --success: #17704a;  --success-bg: #e9f6ef;  --success-line: #bfe3cf;
  --warning: #8f5300;  --warning-bg: #fff5e2;  --warning-line: #f1d7a1;
  --danger:  #b3243a;  --danger-bg:  #fdeef0;  --danger-line:  #f3c4cc;
  --info:    #1e4f99;  --info-bg:    #ebf2fc;  --info-line:    #c5d7f2;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 27, 61, .06);
  --shadow: 0 1px 3px rgba(15, 27, 61, .08), 0 1px 2px rgba(15, 27, 61, .04);
  --shadow-lg: 0 12px 32px rgba(15, 27, 61, .14), 0 2px 6px rgba(15, 27, 61, .06);
  --ring: 0 0 0 3px rgba(198, 161, 91, .45);

  /* Names from the previous theme, still used in a few inline styles on the
     content screens. Mapped onto the new palette rather than left dangling. */
  --text-primary: var(--text);
  --text-secondary: var(--text-2);
  --text-muted: var(--text-3);
  --accent-strong: var(--link);
  --bg-surface: var(--surface);
  --bg-surface-raised: var(--surface-2);
  --bg-app: var(--bg);
  --border-subtle: var(--border);
  --radius-md: var(--radius);
  --status-success: var(--success);
  --status-warning: var(--warning);
  --status-danger: var(--danger);

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 56px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  color-scheme: light;
}

/* ---------------------------------------------------------------------
   Base
   --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
/* Author display rules (grid, flex) would otherwise beat the attribute. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
html { overflow-x: clip; -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* No overflow-x here: it makes <body> a scroll container, and the sticky
     sidebar and top bar then scroll away with the page. html clips instead. */
}

h1, h2, h3, h4 { color: var(--text); line-height: 1.3; margin: 0 0 .5em; font-weight: 650; }
h1 { font-size: 22px; letter-spacing: -.01em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; }
p { margin: 0 0 1em; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
code { font-family: var(--font-mono); font-size: .92em; background: var(--n-100); border-radius: 4px; padding: 1px 5px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

.i {
  width: 18px; height: 18px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: middle;
}
.i-sm { width: 15px; height: 15px; }
.i-lg { width: 22px; height: 22px; }
.i-up { transform: rotate(180deg); }

.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 200;
  background: var(--primary); color: #fff; padding: 10px 16px;
  border-radius: var(--radius); font-weight: 600;
}
.skip-link:focus { left: 8px; text-decoration: none; }

/* ---------------------------------------------------------------------
   App shell
   --------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  transition: width .18s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h); padding: 0 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text); text-decoration: none; flex-shrink: 0;
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand img { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }
.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.sidebar-brand strong { font-size: 14px; letter-spacing: .01em; white-space: nowrap; }
.sidebar-brand small { font-size: 11px; color: var(--text-3); white-space: nowrap; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-group + .nav-group { margin-top: 14px; }
.nav-group-label {
  font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-3); padding: 0 10px 6px; white-space: nowrap;
}
.sidebar-nav a {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; margin-bottom: 1px; border-radius: var(--radius);
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  white-space: nowrap;
}
.sidebar-nav a .i { color: var(--text-3); }
.sidebar-nav a:hover { background: var(--n-50); color: var(--text); text-decoration: none; }
.sidebar-nav a.active { background: var(--navy-50); color: var(--navy-800); font-weight: 600; }
.sidebar-nav a.active .i { color: var(--navy-700); }
.sidebar-nav a.active::before {
  content: ''; position: absolute; left: -10px; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}

.sidebar-foot { border-top: 1px solid var(--border); padding: 10px; flex-shrink: 0; }
.collapse-btn {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: var(--radius); background: none;
  color: var(--text-3); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.collapse-btn:hover { background: var(--n-50); color: var(--text); }

/* Collapsed to icons. Set server side from a cookie, so the page never
   paints wide and then snaps narrow. */
.nav-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.nav-collapsed .sidebar .brand-text,
.nav-collapsed .sidebar .nav-label,
.nav-collapsed .sidebar .nav-group-label { display: none; }
.nav-collapsed .sidebar-nav a,
.nav-collapsed .collapse-btn { justify-content: center; padding-left: 0; padding-right: 0; }
.nav-collapsed .sidebar-brand { justify-content: center; padding: 0; }
.nav-collapsed .nav-group + .nav-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.nav-collapsed .collapse-btn .i { transform: scaleX(-1); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar-spacer { flex: 1; }

.global-search { position: relative; width: min(380px, 40vw); }
.global-search .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.global-search input {
  width: 100%; height: 36px; padding: 0 12px 0 36px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--n-50); font: inherit; font-size: 13.5px; color: var(--text);
}
.global-search input::placeholder { color: var(--text-3); }
.global-search input:focus { outline: none; background: #fff; border-color: var(--gold-500); box-shadow: var(--ring); }

.icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius);
  border: 0; background: none; color: var(--text-2); cursor: pointer;
  list-style: none;
}
.icon-btn::-webkit-details-marker { display: none; }
.icon-btn:hover { background: var(--n-100); color: var(--text); text-decoration: none; }
.icon-btn .dot {
  position: absolute; top: 7px; right: 8px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px #fff;
}

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--navy-800); color: #fff;
  font-size: 12px; font-weight: 600; letter-spacing: .02em; flex-shrink: 0;
}
.avatar-btn { display: flex; align-items: center; gap: 8px; padding: 2px 6px 2px 2px; border-radius: 999px; cursor: pointer; list-style: none; }
.avatar-btn::-webkit-details-marker { display: none; }
.avatar-btn:hover { background: var(--n-100); }
.avatar-btn .i { color: var(--text-3); width: 15px; height: 15px; }

.nav-toggle, .search-link { display: none; }

.content { padding: 24px; width: 100%; max-width: 1440px; }

/* ---------------------------------------------------------------------
   Menus (notification panel, profile). Built on <details>, so they open
   without any script; app.js only adds closing on an outside click.
   --------------------------------------------------------------------- */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 80;
  width: 280px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.menu-panel.wide { width: 360px; }
.menu-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.menu-head strong { font-size: 14px; }
.menu-panel a.menu-item, .menu-panel button.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 16px; color: var(--text-2); font: inherit; font-size: 13.5px;
  background: none; border: 0; text-align: left; cursor: pointer;
}
.menu-panel .menu-item:hover { background: var(--n-50); color: var(--text); text-decoration: none; }
.menu-panel .menu-item .i { color: var(--text-3); }
.menu-sep { border-top: 1px solid var(--border); }
.profile-card { padding: 16px; display: flex; gap: 12px; align-items: center; }
.profile-card .avatar { width: 40px; height: 40px; font-size: 14px; }
.profile-card .who { min-width: 0; line-height: 1.35; }
.profile-card .who strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-card .who span { display: block; font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-empty { padding: 32px 22px; text-align: center; color: var(--text-3); font-size: 13px; }
.notif-empty .i { width: 30px; height: 30px; color: var(--n-300); margin-bottom: 8px; }
.notif-empty strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 4px; }

/* ---------------------------------------------------------------------
   Page header
   --------------------------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--text-2); margin: 4px 0 0; font-size: 13.5px; max-width: 760px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--text-3); }
.crumbs a:hover { color: var(--text); }
.crumbs .i { width: 13px; height: 13px; }

/* ---------------------------------------------------------------------
   Cards
   --------------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { margin: 0; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.card-head h2 .i, .card-head h3 .i { color: var(--text-3); }
.card-head .count { font-size: 12px; color: var(--text-3); font-weight: 500; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.stack > * + * { margin-top: 16px; }
.narrow { max-width: 720px; }

/* ---------------------------------------------------------------------
   Stat tiles
   --------------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  display: block; position: relative;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 18px; box-shadow: var(--shadow-sm); color: var(--text);
}
a.stat:hover { border-color: var(--navy-200); text-decoration: none; box-shadow: var(--shadow); }
.stat-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 7px; }
.stat-label .i { width: 16px; height: 16px; color: var(--text-3); }
.stat-value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-note { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.stat.tone-danger .stat-value { color: var(--danger); }
.stat.tone-warning .stat-value { color: var(--warning); }
.stat.tone-success .stat-value { color: var(--success); }
.stat.tone-danger::before, .stat.tone-warning::before, .stat.tone-success::before, .stat.tone-brand::before {
  content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0;
}
.stat.tone-danger::before { background: var(--danger); }
.stat.tone-warning::before { background: #d38b12; }
.stat.tone-success::before { background: var(--success); }
.stat.tone-brand::before { background: var(--accent); }

/* ---------------------------------------------------------------------
   Pipeline: the seven stages as one segmented row
   --------------------------------------------------------------------- */
.pipeline { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.pipeline a {
  display: block; padding: 14px 16px; color: var(--text);
  border-right: 1px solid var(--border);
}
.pipeline a:last-child { border-right: 0; }
.pipeline a:hover { background: var(--n-25); text-decoration: none; }
.pipeline .p-count { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.pipeline .p-label { font-size: 12px; color: var(--text-2); line-height: 1.35; margin-top: 2px; }
.pipeline .p-bar { height: 4px; border-radius: 2px; background: var(--n-100); margin-top: 10px; overflow: hidden; }
.pipeline .p-bar span { display: block; height: 100%; background: var(--navy-600); border-radius: 2px; }
.pipeline a.is-closed .p-bar span { background: var(--success); }

/* ---------------------------------------------------------------------
   Horizontal bar list (analytics)
   --------------------------------------------------------------------- */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 56px; gap: 12px; align-items: center; font-size: 13px; }
.bar-row .bar-label { color: var(--text-2); }
.bar-row .bar-track, .bar-row .bar-fill { display: block; }
.bar-row .bar-track { height: 8px; background: var(--n-100); border-radius: 4px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--navy-600); border-radius: 4px; }
.bar-row .bar-fill.good { background: var(--success); }
.bar-row .bar-fill.bad { background: var(--danger); }
.bar-row .bar-fill.mid { background: #d38b12; }
.bar-row .bar-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border-radius: var(--radius); border: 1px solid transparent;
  font: inherit; font-size: 13.5px; font-weight: 600; line-height: 1;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { text-decoration: none; }
.btn .i { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary, .btn-outline { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover, .btn-outline:hover { background: var(--n-50); border-color: var(--n-300); }
.btn-ghost { background: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--n-100); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #9a1d30; }
.btn-danger-outline { background: var(--surface); color: var(--danger); border-color: var(--danger-line); }
.btn-danger-outline:hover { background: var(--danger-bg); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { height: 42px; padding: 0 20px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: default; pointer-events: none; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: rgba(255,255,255,.9) rgba(255,255,255,.9) rgba(255,255,255,.25) rgba(255,255,255,.25);
  animation: spin .7s linear infinite;
}
.btn-secondary.is-busy::after, .btn-outline.is-busy::after { border-color: var(--n-500) var(--n-500) var(--n-200) var(--n-200); }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------- */
.form-group { margin-bottom: 16px; }
.form-group > label, .label {
  display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px;
}
.form-group > label .opt { font-weight: 400; color: var(--text-3); }
.req { color: var(--danger); margin-left: 2px; }
.form-control {
  display: block; width: 100%; max-width: 100%;
  height: 38px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
textarea.form-control { height: auto; min-height: 84px; padding: 9px 12px; line-height: 1.55; resize: vertical; }
select.form-control {
  appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366718a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
input[type="file"].form-control { height: auto; padding: 8px; font-size: 13px; }
input[type="file"].form-control::file-selector-button {
  font: inherit; font-weight: 600; font-size: 12.5px; margin-right: 10px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--n-50); color: var(--text); cursor: pointer;
}
.form-control::placeholder { color: var(--n-400); }
.form-control:hover { border-color: var(--n-300); }
.form-control:focus { outline: none; border-color: var(--gold-500); box-shadow: var(--ring); }
.form-control:disabled { background: var(--n-50); color: var(--text-3); }
.form-control.is-invalid, .form-control[aria-invalid="true"] { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(179, 36, 58, .18); }
.field-error { display: flex; align-items: center; gap: 5px; color: var(--danger); font-size: 12.5px; margin-top: 5px; }
.field-error .i { width: 14px; height: 14px; }
.help { font-size: 12.5px; color: var(--text-3); margin: 5px 0 0; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-section + .form-section { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 18px; }
.form-section-title { font-size: 13px; font-weight: 650; color: var(--text); margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.form-section-title .i { color: var(--text-3); width: 16px; height: 16px; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 4px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--navy-700); }
.file-note { margin: 6px 0 0; font-size: 12.5px; color: var(--text-2); }

/* ---------------------------------------------------------------------
   Toolbar / filters
   --------------------------------------------------------------------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.toolbar .form-control { height: 34px; font-size: 13.5px; width: auto; }
.toolbar .search-field { position: relative; flex: 1 1 240px; max-width: 320px; }
.toolbar .search-field .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; }
.toolbar .search-field .form-control { width: 100%; padding-left: 34px; }
.toolbar .btn { height: 34px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 12.5px; font-weight: 500; color: var(--text-2); white-space: nowrap;
}
.chip:hover { border-color: var(--n-300); color: var(--text); text-decoration: none; }
.chip.active { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
.chip .chip-count { font-size: 11px; font-weight: 600; opacity: .75; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------
   Data tables
   --------------------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; padding: 10px 14px; white-space: nowrap;
  font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-3); background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.data-table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.data-table th a:hover { color: var(--text); text-decoration: none; }
.data-table th a .i { width: 13px; height: 13px; opacity: .6; }
.data-table th.sorted a { color: var(--text); }
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--n-25); }
.data-table tr.is-muted td { color: var(--text-3); }
.data-table .cell-actions { text-align: right; white-space: nowrap; }
.data-table .cell-actions form { display: inline; }
.data-table .cell-actions .btn + .btn, .data-table .cell-actions form + .btn,
.data-table .cell-actions .btn + form, .data-table .cell-actions form + form { margin-left: 6px; }
.data-table .primary-link { font-weight: 600; color: var(--text); }
.data-table .primary-link:hover { color: var(--link); }
.data-table .sub-line { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.data-table.compact td { padding: 8px 14px; }
tr[data-href] { cursor: pointer; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-2); flex-wrap: wrap; }
.pagination .btn-row { gap: 6px; }

/* ---------------------------------------------------------------------
   Badges and pills
   --------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 1;
  background: var(--n-100); color: var(--text-2); border: 1px solid transparent;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-brand   { background: var(--navy-50);    color: var(--navy-700); }
.badge-gold    { background: var(--gold-50);    color: var(--gold-700); border-color: var(--gold-100); }
.badge-outline { background: var(--surface); border-color: var(--border-strong); }

/* TAT states, named as tat_status() returns them. */
.tat-healthy        { background: var(--success-bg); color: var(--success); }
.tat-nearing_breach { background: var(--warning-bg); color: var(--warning); }
.tat-breached       { background: var(--danger-bg);  color: var(--danger); }
.tat-done           { background: var(--n-100);      color: var(--text-2); }

/* Older content screens still emit these. */
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--n-100); color: var(--text-2); }
.pill-on { background: var(--success-bg); color: var(--success); }
.pill-off { background: var(--n-100); color: var(--text-3); }

/* ---------------------------------------------------------------------
   Banners (persistent, in page)
   --------------------------------------------------------------------- */
.banner, .alert {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 16px; border-radius: var(--radius); border: 1px solid;
  font-size: 13.5px; line-height: 1.55; margin-bottom: 16px;
}
.banner > .i { margin-top: 1px; }
.banner .banner-body { flex: 1; min-width: 0; }
.banner .banner-body strong { display: block; margin-bottom: 2px; }
.banner .banner-body ul { margin: 6px 0 0; padding-left: 18px; }
.banner a, .alert a { color: inherit; text-decoration: underline; }
.banner-info, .alert-info       { background: var(--info-bg);    border-color: var(--info-line);    color: var(--info); }
.banner-success, .alert-success { background: var(--success-bg); border-color: var(--success-line); color: var(--success); }
.banner-warning, .alert-warn    { background: var(--warning-bg); border-color: var(--warning-line); color: var(--warning); }
.banner-danger, .alert-danger   { background: var(--danger-bg);  border-color: var(--danger-line);  color: var(--danger); }
.banner .banner-body, .alert { color: var(--text); }
.banner-info > .i { color: var(--info); }
.banner-success > .i { color: var(--success); }
.banner-warning > .i { color: var(--warning); }
.banner-danger > .i { color: var(--danger); }

/* ---------------------------------------------------------------------
   Toasts
   Server rendered into .toast-region so they show even with scripting
   off. app.js adds the close timers and the slide in.
   --------------------------------------------------------------------- */
.toast-region {
  position: fixed; z-index: 300; right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
  width: min(400px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto; width: 100%;
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--navy-600);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 12px 12px 12px 14px; font-size: 13.5px; line-height: 1.5;
  animation: toast-in .22s ease both;
}
.toast > .i { margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 650; display: block; }
.toast-msg { color: var(--text-2); word-wrap: break-word; }
.toast-close { border: 0; background: none; color: var(--text-3); cursor: pointer; padding: 2px; border-radius: 4px; display: flex; }
.toast-close:hover { color: var(--text); background: var(--n-100); }
.toast-success { border-left-color: var(--success); } .toast-success > .i { color: var(--success); }
.toast-error   { border-left-color: var(--danger); }  .toast-error > .i   { color: var(--danger); }
.toast-warning { border-left-color: #d38b12; }        .toast-warning > .i { color: var(--warning); }
.toast-info    { border-left-color: var(--info); }    .toast-info > .i    { color: var(--info); }
.toast.is-leaving { animation: toast-out .18s ease both; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ---------------------------------------------------------------------
   Modals and the confirm dialog

   A modal is an element with an id, opened by a link to #id. With no
   script it still works through :target; app.js upgrades it to a proper
   dialog with focus trapping, Escape to close and no change to the URL.
   --------------------------------------------------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 250;
  display: none; align-items: center; justify-content: center;
  padding: 20px; background: rgba(10, 17, 40, .45);
}
.modal:target, .modal.is-open, .modal:has(> [data-open]) { display: flex; }
.modal.is-open { animation: fade-in .15s ease both; }
.modal-dialog {
  width: 100%; max-width: 480px; max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px);
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  animation: pop-in .18s ease both;
}
.modal-dialog.wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-body > p:first-child { margin-top: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal-close { color: var(--text-3); }
/* Locked on <html>, not <body>: overflow on body makes it a scroll container
   and the sticky sidebar and top bar jump while a dialog is open. */
html.modal-locked { overflow: hidden; }

.confirm-dialog .modal-dialog { max-width: 420px; }
.confirm-dialog .modal-body { display: flex; gap: 14px; align-items: flex-start; padding: 22px 22px 18px; }
.confirm-icon {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--info-bg); color: var(--info);
}
.confirm-dialog.tone-danger .confirm-icon { background: var(--danger-bg); color: var(--danger); }
.confirm-dialog.tone-warning .confirm-icon { background: var(--warning-bg); color: var(--warning); }
.confirm-dialog h2 { font-size: 16px; margin: 2px 0 6px; }
.confirm-dialog p { margin: 0; color: var(--text-2); font-size: 13.5px; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------------
   Empty states
   --------------------------------------------------------------------- */
.empty { text-align: center; padding: 40px 24px; color: var(--text-3); }
.empty .empty-icon {
  width: 48px; height: 48px; border-radius: 50%; margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--n-100); color: var(--n-500);
}
.empty strong { display: block; color: var(--text); font-size: 14.5px; margin-bottom: 4px; }
.empty p { margin: 0 auto; max-width: 380px; font-size: 13px; }
.empty .btn { margin-top: 14px; }
.empty.compact { padding: 24px 16px; }

/* ---------------------------------------------------------------------
   Case record
   --------------------------------------------------------------------- */
.record-head { padding: 18px 20px 0; }
.record-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.record-title .eyebrow { font-size: 12px; color: var(--text-3); font-weight: 500; display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.record-title h1 { margin: 0; font-size: 20px; }
.record-title .badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.highlights {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0; margin: 18px -20px 0; border-top: 1px solid var(--border);
}
.highlights > div { padding: 12px 20px; border-right: 1px solid var(--border); min-width: 0; }
.highlights > div:last-child { border-right: 0; }
.hl-label { font-size: 11.5px; color: var(--text-3); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.hl-value { font-size: 13.5px; font-weight: 600; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The stage path: where the case sits in its seven stages. */
.path { display: flex; list-style: none; margin: 0; padding: 14px 20px; gap: 4px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; border-top: 1px solid var(--border); background: var(--surface-2); }
.path li {
  flex: 1 0 auto; min-width: 104px; position: relative;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px 0 20px;
  font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap;
  background: var(--n-100);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%);
}
.path li:first-child { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); border-radius: 17px 0 0 17px; padding-left: 14px; }
.path li:last-child { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 10px 50%); border-radius: 0 17px 17px 0; }
.path li .i { width: 14px; height: 14px; }
.path li.done { background: var(--navy-100); color: var(--navy-700); }
.path li.current { background: var(--navy-800); color: #fff; }
.path li.current.is-closed, .path li.done.is-closed { background: var(--success); color: #fff; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 12px 10px; margin-bottom: -1px; border-bottom: 2px solid transparent;
  color: var(--text-2); font-weight: 600; font-size: 13.5px; white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--navy-800); border-bottom-color: var(--accent); }
.tabs a .badge { height: 19px; font-size: 11px; }
/* Without script every panel shows, one under the other. */
.tabs-ready .tab-panel:not(.active) { display: none; }
.tab-panel + .tab-panel { border-top: 1px solid var(--border); }
.tabs-ready .tab-panel + .tab-panel { border-top: 0; }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; margin: 0; }
.fields > div { padding: 10px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.fields dt { font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.fields dd { margin: 0; font-size: 13.5px; font-weight: 500; overflow-wrap: anywhere; }
.fields .full { grid-column: 1 / -1; }

.doc-group + .doc-group { margin-top: 20px; }
.doc-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.doc-group-head h3 { margin: 0; font-size: 13.5px; }
.doc-list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.doc {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.doc:last-child { border-bottom: 0; }
.doc-icon { width: 34px; height: 34px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; background: var(--navy-50); color: var(--navy-600); flex-shrink: 0; }
.doc-icon.t-image { background: var(--info-bg); color: var(--info); }
.doc-icon.t-video { background: var(--gold-50); color: var(--gold-700); }
.doc-icon.t-pdf { background: var(--danger-bg); color: var(--danger); }
.doc-main { flex: 1; min-width: 0; }
.doc-name { font-weight: 600; color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { font-size: 12px; color: var(--text-3); }
.doc-remarks { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 18px 44px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline .t-dot {
  position: absolute; left: 4px; top: 0; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 2px solid var(--navy-200); color: var(--navy-600);
}
.timeline .t-dot .i { width: 12px; height: 12px; stroke-width: 2.4; }
.timeline li:first-child .t-dot { border-color: var(--accent); color: var(--gold-700); }
.timeline .t-desc { font-size: 13.5px; }
.timeline .t-desc strong { font-weight: 600; }
.timeline .t-when { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.timeline .t-remarks { margin-top: 6px; padding: 8px 12px; background: var(--n-50); border-radius: var(--radius); font-size: 13px; color: var(--text-2); border: 1px solid var(--border); }

.action-list { display: flex; flex-direction: column; gap: 10px; }
.action-block + .action-block { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; }
.action-hint { font-size: 12.5px; color: var(--text-3); margin: 0 0 10px; }
.people { display: flex; flex-direction: column; gap: 12px; }
.person { display: flex; align-items: center; gap: 10px; }
.person .avatar { width: 30px; height: 30px; font-size: 11px; background: var(--navy-100); color: var(--navy-700); }
.person .avatar.empty-avatar { background: var(--n-100); color: var(--n-400); }
.person-role { font-size: 11.5px; color: var(--text-3); }
.person-name { font-size: 13.5px; font-weight: 600; }

/* ---------------------------------------------------------------------
   Sign in and the other standalone pages
   --------------------------------------------------------------------- */
.auth {
  min-height: 100vh; min-height: 100dvh;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  background: var(--surface);
}
.auth-brand {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px; color: #fff;
  background: linear-gradient(155deg, var(--navy-800) 0%, var(--navy-900) 55%, var(--navy-950) 100%);
}
.auth-brand::after {
  content: ''; position: absolute; right: -160px; bottom: -160px;
  width: 480px; height: 480px; border-radius: 50%;
  border: 1px solid rgba(217, 183, 104, .18);
  box-shadow: 0 0 0 60px rgba(217, 183, 104, .035), 0 0 0 120px rgba(217, 183, 104, .025);
  pointer-events: none;
}
.auth-brand .brand-top { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.auth-brand .brand-top img { width: 44px; height: 44px; border-radius: 50%; }
.auth-brand .brand-top strong { font-size: 15px; letter-spacing: .02em; }
.auth-brand .brand-top small { display: block; color: #aeb9d4; font-size: 12px; }
.auth-pitch { position: relative; z-index: 1; max-width: 440px; }
.auth-pitch h2 { color: #fff; font-size: 28px; line-height: 1.25; letter-spacing: -.01em; margin: 0 0 14px; font-weight: 650; }
.auth-pitch p { color: #c3cce0; font-size: 15px; margin: 0 0 26px; }
.auth-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.auth-points li { display: flex; gap: 10px; align-items: center; color: #dfe5f2; font-size: 14px; }
.auth-points .i { color: var(--gold-400); }
.auth-brand .legal { position: relative; z-index: 1; color: #8692b2; font-size: 12px; }

.auth-form-side { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .mobile-logo { display: none; }
.auth-card h1 { font-size: 24px; margin: 0 0 6px; }
.auth-card .lead { color: var(--text-2); margin: 0 0 26px; font-size: 14px; }
.auth-card .form-control { height: 42px; font-size: 15px; }
.auth-card .btn-primary { height: 44px; font-size: 15px; }
.auth-card .form-group > label { display: flex; justify-content: space-between; align-items: baseline; }
.auth-card .form-group > label a { font-weight: 500; font-size: 12.5px; }
.auth-foot { margin-top: 26px; text-align: center; font-size: 13px; color: var(--text-3); }
.pw-field { position: relative; }
.pw-field .form-control { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: 0; background: none; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; color: var(--text-3); cursor: pointer;
}
.pw-toggle:hover { color: var(--text); background: var(--n-100); }
.pw-toggle .i-hide { display: none; }
.pw-toggle[aria-pressed="true"] .i-show { display: none; }
.pw-toggle[aria-pressed="true"] .i-hide { display: block; }

.otp-input { letter-spacing: .5em; font-variant-numeric: tabular-nums; font-size: 20px !important; text-align: center; font-family: var(--font-mono); }

.standalone { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.standalone .card { max-width: 420px; width: 100%; text-align: center; padding: 36px 28px; }
.standalone .empty-icon { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 16px; display: flex; align-items: center; justify-content: center; background: var(--danger-bg); color: var(--danger); }

/* ---------------------------------------------------------------------
   Content (website CMS) screens
   --------------------------------------------------------------------- */
.hub { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.hub a {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 18px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); color: var(--text);
}
.hub a:hover { border-color: var(--navy-200); box-shadow: var(--shadow); text-decoration: none; }
.hub .hub-icon { width: 38px; height: 38px; border-radius: var(--radius); background: var(--navy-50); color: var(--navy-700); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.hub h3 { margin: 0 0 4px; font-size: 14.5px; }
.hub p { margin: 0; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }

.cms-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.cms-section > summary {
  cursor: pointer; padding: 14px 18px; font-weight: 600; font-size: 14px;
  list-style: none; display: flex; align-items: center; gap: 10px;
}
.cms-section > summary::-webkit-details-marker { display: none; }
.cms-section > summary::after {
  content: ''; width: 16px; height: 16px; margin-left: 8px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366718a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat center / 16px;
  transition: transform .15s ease;
}
.cms-section[open] > summary::after { transform: rotate(180deg); }
.cms-section[open] > summary { border-bottom: 1px solid var(--border); }
.cms-count { margin-left: auto; font-size: 11.5px; color: var(--text-3); background: var(--n-100); border-radius: 999px; padding: 2px 8px; font-weight: 600; }
.cms-section-body { padding: 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 20px; }
.cms-field label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.cms-help { margin: 5px 0 0; font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.cms-meter { font-size: 12px; margin-top: 5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.cms-meter.good { color: var(--success); }
.cms-meter.over { color: var(--danger); }
.cms-savebar {
  position: sticky; bottom: 12px; z-index: 30; margin-top: 18px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 12px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.cms-savebar .note { font-size: 12.5px; color: var(--text-3); margin: 0; }
.cms-syntax { font-size: 12.5px; color: var(--text-3); line-height: 1.9; margin: 0 0 10px; }
.cms-preview { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; line-height: 1.75; font-size: 14.5px; }
.cms-preview h2 { font-size: 17px; margin: 22px 0 8px; color: var(--navy-800); }
.cms-preview h2:first-child { margin-top: 0; }
.cms-preview h3 { font-size: 15px; margin: 18px 0 6px; }
.cms-preview p, .cms-preview li { color: var(--text-2); }
.mono { font-family: var(--font-mono); font-size: 13px; line-height: 1.7; }

/* Logos are made for the dark public site, so they are previewed on its
   background, not on the portal's white. */
.logo-preview {
  width: 160px; height: 72px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; padding: 10px;
  background: var(--navy-950); border-radius: var(--radius);
}
.logo-preview img { max-width: 100%; max-height: 52px; }
.logo-preview span { font-size: 11.5px; color: #8692b2; }

/* ---------------------------------------------------------------------
   ID card (printable, keeps the brand's physical card look)
   --------------------------------------------------------------------- */
.id-card {
  width: 340px; max-width: 100%; border-radius: 16px; overflow: hidden;
  background: linear-gradient(160deg, var(--navy-800), var(--navy-950));
  color: #fff; box-shadow: var(--shadow-lg);
}
.id-card .band { background: var(--gold-500); height: 8px; }
.id-card .body { padding: 22px; text-align: center; }
.id-card img.photo { width: 92px; height: 92px; border-radius: 50%; object-fit: cover; border: 3px solid var(--gold-500); background: var(--navy-700); }
.id-card .name { font-weight: 700; font-size: 17px; margin-top: 12px; }
.id-card .role { color: var(--gold-400); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }
.id-card .fo-id { margin-top: 14px; font-size: 13px; color: #c3cce0; }
.id-card .brand { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.12); }
.id-card .brand img { width: 24px; height: 24px; border-radius: 50%; }
.id-card .brand span { font-size: 11px; color: #aeb9d4; letter-spacing: .04em; }
@media print {
  body * { visibility: hidden; }
  .id-card, .id-card * { visibility: visible; }
  .id-card { position: fixed; top: 40px; left: 50%; transform: translateX(-50%); box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* =====================================================================
   RESPONSIVE

   The breakpoint is 900px. Below it the sidebar becomes a drawer: between
   900 and 720 a fixed sidebar leaves less room than the phone layout.
   ===================================================================== */
@media (max-width: 1180px) {
  .grid-main-side { grid-template-columns: minmax(0, 1fr) 300px; }
  .pipeline { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pipeline a { border-bottom: 1px solid var(--border); }
  .pipeline a:nth-child(4n) { border-right: 0; }
}

@media (max-width: 900px) {
  .app-shell { display: block; min-height: 100dvh; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 90; height: auto;
    width: min(84vw, 300px) !important;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .nav-open .sidebar { transform: none; }
  /* The collapsed desktop state means nothing inside the drawer. */
  .nav-collapsed .sidebar .brand-text,
  .nav-collapsed .sidebar .nav-label,
  .nav-collapsed .sidebar .nav-group-label { display: revert; }
  .nav-collapsed .sidebar-nav a { justify-content: flex-start; padding: 8px 10px; }
  .nav-collapsed .sidebar-brand { justify-content: flex-start; padding: 0 16px; }
  .collapse-btn { display: none; }
  .sidebar-nav a { padding: 11px 10px; font-size: 15px; }

  .nav-scrim {
    position: fixed; inset: 0; z-index: 85; border: 0; padding: 0;
    background: rgba(10, 17, 40, .4); opacity: 0; pointer-events: none; transition: opacity .22s ease;
  }
  .nav-scrim[hidden] { display: none; }
  .nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  html.nav-locked { overflow: hidden; }

  .topbar { padding: 0 10px; padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); gap: 4px; }
  .nav-toggle { display: inline-flex; width: 44px; height: 44px; }
  .topbar-title { flex: 1; font-size: 15.5px; margin-left: 2px; }
  .global-search { display: none; }
  .search-link { display: inline-flex; }
  .icon-btn { width: 44px; height: 44px; }
  .avatar-btn .i { display: none; }
  .menu-panel, .menu-panel.wide { position: fixed; left: 10px; right: 10px; top: calc(var(--topbar-h) + env(safe-area-inset-top) + 6px); width: auto; }

  .content { padding: 16px 14px calc(28px + env(safe-area-inset-bottom)); }
  h1 { font-size: 20px; }
  .page-head { margin-bottom: 16px; align-items: stretch; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }

  .grid-2, .grid-3, .grid-main-side { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 24px; }
  .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipeline a:nth-child(4n) { border-right: 1px solid var(--border); }
  .pipeline a:nth-child(2n) { border-right: 0; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .bar-row { grid-template-columns: 110px minmax(0, 1fr) 44px; }

  /* Anything under 16px makes iOS zoom the page on focus and stay zoomed. */
  .form-control, .toolbar .form-control, .global-search input { font-size: 16px; }
  .form-control { height: 44px; }
  textarea.form-control { min-height: 96px; }
  .btn { height: 44px; font-size: 14.5px; }
  .btn-sm { height: 36px; }
  .toolbar { padding: 12px 14px; }
  .toolbar .search-field { max-width: none; flex-basis: 100%; }
  .toolbar .form-control { flex: 1 1 140px; height: 44px; }
  .toolbar .btn { height: 44px; flex: 1 1 auto; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  /* Secondary lines (the city under a name) only crowd a stacked card. */
  .table-stack td:not(.cell-primary) .sub-line { display: none; }

  .highlights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .highlights > div:nth-child(2n) { border-right: 0; }
  .highlights > div { border-bottom: 1px solid var(--border); }
  .record-head { padding: 16px 16px 0; }
  .highlights { margin: 16px -16px 0; }
  .highlights > div { padding: 10px 16px; }
  .path { padding: 12px 16px; }
  .path li { min-width: 92px; }

  /* Actions first on a phone. People open a case to do something. */
  .case-grid { display: flex; flex-direction: column; }
  .case-grid .case-side { order: -1; }

  /* Tables collapse into labelled cards. Every <td> needs a data-label. */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table-stack tbody tr:last-child { border-bottom: 0; }
  .table-stack td { border: 0 !important; padding: 4px 0; display: flex; gap: 12px; align-items: baseline; text-align: left !important; }
  .table-stack tbody tr:hover td { background: none; }
  .table-stack td::before {
    content: attr(data-label); flex: 0 0 38%;
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3);
  }
  .table-stack td.cell-primary { font-size: 15px; padding-bottom: 6px; }
  .table-stack td.cell-primary::before, .table-stack td.cell-actions::before { display: none; }
  .table-stack td.cell-actions { padding-top: 10px; flex-wrap: wrap; gap: 8px; white-space: normal; }
  .table-stack td.cell-actions .btn, .table-stack td.cell-actions form { flex: 1 1 auto; margin: 0 !important; }
  .table-stack td.cell-actions form .btn { width: 100%; }

  .modal { align-items: flex-end; padding: 0; }
  .modal-dialog { max-width: none !important; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
  .modal-foot { border-radius: 0; }
  .modal-foot .btn { flex: 1; }
  .toast-region { left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); width: auto; }

  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-brand { display: none; }
  .auth-form-side { align-items: flex-start; padding: 48px 20px 32px; }
  .auth-card .mobile-logo { display: block; width: 56px; height: 56px; border-radius: 50%; margin-bottom: 22px; }

  .cms-section-body { grid-template-columns: minmax(0, 1fr); }
  .cms-savebar { bottom: calc(8px + env(safe-area-inset-bottom)); }
  .id-card { width: 100%; max-width: 340px; }
}

@media (max-width: 380px) {
  .content { padding-left: 12px; padding-right: 12px; }
  .table-stack td { flex-direction: column; gap: 1px; }
  .table-stack td::before { flex: none; }
  .highlights { grid-template-columns: minmax(0, 1fr); }
  .highlights > div { border-right: 0; }
}

/* A hover style latches after a tap on touch screens. */
@media (hover: none) {
  .data-table tbody tr:hover td { background: none; }
  a.stat:hover, .hub a:hover { box-shadow: var(--shadow-sm); border-color: var(--border); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* The content screens still use the original card class. Styled as a
   padded card so they match without rewriting every form on them. */
.case-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 18px; min-width: 0;
}
.case-card + .case-card, .case-card + h3, form + .case-card { margin-top: 16px; }
.case-card > .data-table, .case-card > .table-wrap { margin: -18px; width: calc(100% + 36px); }
.case-card > .data-table th:first-child, .case-card > .data-table td:first-child { padding-left: 18px; }
