/* ════════════════════════════════════════════════════════════════════════
   Launchly360 admin V2 — tokens, base, layout and kit components.
   Brand matches V1 (src/public/admin/admin.css): navy #16243F, orange #F26B21.
   Rules: no inline styles in V2; every colour/space/z-index comes from a token.
   ════════════════════════════════════════════════════════════════════════ */

:root {
  /* Brand */
  --navy-900:#0a1322; --navy-800:#101b30; --navy-700:#16243f; --navy-600:#27374f;
  --navy-500:#3b4a63; --navy-400:#64748b; --navy-300:#94a3b8; --navy-200:#c3ccda;
  --navy-100:#e2e8f0; --navy-50:#f4f6f9;
  --orange-700:#bc3a11; --orange-600:#e35012; --orange-500:#f26b21; --orange-400:#fb7c3c;
  --orange-300:#ff9f70; --orange-100:#ffe6d5; --orange-50:#fff4ed;

  /* Semantic */
  --text:var(--navy-700); --text-muted:var(--navy-400); --text-faint:var(--navy-300);
  --surface:#fff; --surface-alt:#fafbfd; --canvas:#d6dde9; --line:#e4e8f0; --line-soft:#eef1f6;
  --accent:var(--orange-500); --accent-hover:var(--orange-600); --link:var(--orange-600);
  --focus-ring:0 0 0 3px rgba(242,107,33,.35);

  /* Status tones (one map for badges, alerts, toasts) */
  --green-bg:#e7f7ef; --green-fg:#0f7b4f; --green-line:#c4ecd7;
  --red-bg:#fdeaea;   --red-fg:#b62525;   --red-line:#f3c4c4;
  --amber-bg:#fff6e0; --amber-fg:#8a5a00; --amber-line:#f6dfa6;
  --blue-bg:#eaf1fd;  --blue-fg:#1f4fa8;  --blue-line:#cddcf7;
  --purple-bg:#f3ebfb;--purple-fg:#6d28d9;--purple-line:#e4d3f7;
  --gray-bg:var(--navy-50); --gray-fg:var(--navy-500); --gray-line:var(--navy-100);

  /* Type */
  --font-body:"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display:"Plus Jakarta Sans", "Inter", sans-serif;
  --font-mono:"SF Mono", "Fira Code", Consolas, monospace;
  --fs-xs:11px; --fs-sm:12px; --fs-md:14px; --fs-lg:16px; --fs-xl:20px; --fs-2xl:24px;

  /* Spacing scale (4px base) */
  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:20px; --sp-6:24px; --sp-8:32px; --sp-10:40px;
  --gutter:var(--sp-6);

  /* Radius & shadow */
  --r-sm:8px; --r-md:10px; --r-lg:14px; --r-xl:18px; --r-pill:9999px;
  --shadow-sm:0 1px 2px rgba(16,27,48,.06), 0 1px 3px rgba(16,27,48,.05);
  --shadow-md:0 8px 24px rgba(16,27,48,.08);
  --shadow-lg:0 24px 64px rgba(10,19,34,.22);

  /* Layers */
  --z-nav:100; --z-drawer:200; --z-modal:300; --z-toast:400;

  /* Sizes */
  --nav-h:60px; --content-max:1180px; --sidebar-w:210px;
}

/* ── Reset & base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body); font-size: var(--fs-md); line-height: 1.5; color: var(--text);
  background:
    radial-gradient(1200px 480px at 100% -10%, rgba(242,107,33,.09), transparent 60%),
    radial-gradient(900px 420px at -10% 0%, rgba(22,36,63,.10), transparent 55%),
    var(--canvas);
  background-attachment: fixed;
  min-height: 100vh; overflow-x: hidden; -webkit-font-smoothing: antialiased;
}
body.has-overlay { overflow: hidden; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; font-weight: 500; }
a:hover { color: var(--orange-700); text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.015em; color: var(--text); line-height: 1.25; }
h1 { font-size: var(--fs-2xl); font-weight: 800; }
h2 { font-size: var(--fs-lg); font-weight: 700; }
h3 { font-size: var(--fs-md); font-weight: 700; }
p { overflow-wrap: anywhere; }
code, .mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
code { background: var(--navy-50); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
/* Inside a <pre> block the inline-code chrome must not apply (dark snippet blocks). */
pre > code { background: transparent; border: 0; padding: 0; border-radius: 0; color: inherit; font-size: inherit; }
.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; }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }
.icon { flex: none; }

/* ── App shell ───────────────────────────────────────────────────────────── */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.page { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--sp-6) var(--gutter) var(--sp-10); flex: 1; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.page-header-text { min-width: 0; }
.page-title { font-size: var(--fs-2xl); font-weight: 800; }
.page-subtitle { color: var(--text-muted); margin-top: var(--sp-1); }
.page-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--sp-4); }
.stack > * + * { margin-top: var(--sp-4); }
.row { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }

/* ── Top nav ─────────────────────────────────────────────────────────────── */
.topnav {
  position: sticky; top: 0; z-index: var(--z-nav); color: #fff;
  background: linear-gradient(100deg, var(--navy-800), var(--navy-700) 60%, var(--navy-600));
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 6px 20px rgba(10,19,34,.18);
}
.topnav-inner { max-width: var(--content-max); margin: 0 auto; height: var(--nav-h); padding: 0 var(--gutter); display: flex; align-items: center; gap: var(--sp-5); }
.topnav-brand { display: inline-flex; align-items: center; gap: var(--sp-2); color: #fff; flex: none; }
.topnav-brand:hover { color: #fff; text-decoration: none; }
.topnav-logo { height: 30px; width: 30px; background: #fff; border-radius: 8px; padding: 2px; box-shadow: 0 2px 8px rgba(10,19,34,.25); }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 18px; letter-spacing: -.02em; line-height: 1; color: #fff; }
.brand-name .b-360 { color: var(--orange-500); }
.topnav-divider { width: 1px; height: 18px; background: rgba(255,255,255,.3); }
.topnav-area { font-size: 13px; font-weight: 600; color: rgba(255,255,255,.75); }
.topnav-panel { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); min-width: 0; }
.topnav-items { list-style: none; display: flex; gap: var(--sp-1); }
.topnav-link { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: var(--r-sm); color: rgba(255,255,255,.78); font-size: 13px; font-weight: 600; white-space: nowrap; }
.topnav-link:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.topnav-link.is-active { color: #fff; background: rgba(255,255,255,.14); box-shadow: inset 0 -2px 0 var(--orange-500); }
.nav-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); background: var(--orange-500); color: #fff; font-size: var(--fs-xs); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.topnav-user { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.topnav-email { font-size: 13px; color: rgba(255,255,255,.7); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.topnav .topnav-menu { display: none; margin-left: auto; color: #fff; } /* beats .icon-btn (declared later) */
.topnav .topnav-menu:hover { background: rgba(255,255,255,.12); color: #fff; }

@media (max-width: 900px) {
  .topnav-email { display: none; }
}
@media (max-width: 640px) {
  .topnav-inner { gap: var(--sp-3); }
  .topnav .topnav-menu { display: inline-flex; }
  .topnav-panel {
    display: none; position: absolute; top: var(--nav-h); left: 0; right: 0; flex-direction: column; align-items: stretch;
    background: var(--navy-800); padding: var(--sp-2) var(--sp-4) var(--sp-4); box-shadow: 0 12px 24px rgba(10,19,34,.3);
  }
  .topnav-panel.is-open { display: flex; }
  .topnav-items { flex-direction: column; }
  .topnav-link { display: flex; padding: 11px 12px; }
  .topnav-user { justify-content: space-between; border-top: 1px solid rgba(255,255,255,.12); padding-top: var(--sp-3); }
  .topnav-email { display: block; max-width: 60vw; }
}
@media (max-width: 380px) { .brand-name { display: none; } }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-5) var(--sp-6); box-shadow: var(--shadow-sm); min-width: 0; }
.card + .card { margin-top: var(--sp-5); }
.card-title { font-size: var(--fs-lg); font-weight: 700; margin-bottom: var(--sp-2); }

/* SectionCard: per-section save */
.section-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.section-card-title { font-size: var(--fs-lg); }
.section-card-desc { color: var(--text-muted); font-size: 13px; margin-top: 2px; max-width: 60ch; }
.section-card-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.section-card-foot { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3); border-top: 1px solid var(--line); margin-top: var(--sp-5); padding-top: var(--sp-4); }
.save-status { font-size: var(--fs-sm); color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }
.save-status.is-dirty { color: var(--amber-fg); font-weight: 600; }
.save-status.is-dirty .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange-500); }
.save-status.is-saved { color: var(--green-fg); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 15px; min-height: 36px;
  border-radius: var(--r-md); font-size: 13px; font-weight: 600; line-height: 1.2; white-space: nowrap; cursor: pointer;
  border: 1px solid transparent; background: none; text-decoration: none;
  transition: background .15s ease, box-shadow .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--r-md); }
/* .btn-primary: at most ONE per view — the action the view exists for. */
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(16,27,48,.12); }
.btn-primary:not(:disabled):hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: #fff; color: var(--navy-600); border-color: var(--navy-200); }
.btn-secondary:not(:disabled):hover { background: var(--navy-50); border-color: var(--navy-300); color: var(--navy-700); }
.btn-ghost { color: var(--navy-600); }
.btn-ghost:not(:disabled):hover { background: var(--navy-50); color: var(--navy-700); }
.btn-danger { background: #fff; color: var(--red-fg); border-color: var(--red-line); }
.btn-danger:not(:disabled):hover { background: var(--red-bg); }
.btn-danger-solid { background: #c23030; color: #fff; }
.btn-danger-solid:not(:disabled):hover { background: #a82525; color: #fff; }
.btn-nav { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.22); }
.btn-nav:not(:disabled):hover { background: rgba(255,255,255,.22); color: #fff; }
.btn-sm { padding: 5px 10px; min-height: 30px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 0; border-radius: var(--r-sm); background: none; color: var(--navy-500); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--navy-50); color: var(--navy-700); }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.field { margin-bottom: var(--sp-4); min-width: 0; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--navy-600); margin-bottom: 6px; }
.field-required { color: var(--red-fg); }
.field-hint { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 5px; }
.field-error { font-size: var(--fs-sm); color: var(--red-fg); margin-top: 5px; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--sp-4); }
.input {
  width: 100%; border: 1px solid var(--navy-200); border-radius: var(--r-md); padding: 9px 12px; font-size: 13px; min-height: 38px;
  color: var(--text); background: #fff; outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: #aab4c4; }
.input:focus { border-color: var(--orange-400); box-shadow: 0 0 0 3.5px rgba(242,107,33,.13); }
.input:disabled { background: var(--navy-50); color: var(--text-muted); }
.input[aria-invalid="true"] { border-color: #e7a3a3; }
.textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.select { appearance: auto; }
.checkbox { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: var(--sp-2); margin-bottom: var(--sp-3); }
.checkbox input { width: 16px; height: 16px; accent-color: var(--orange-500); }
.checkbox-label { font-weight: 500; color: var(--navy-600); cursor: pointer; }
.checkbox-hint { grid-column: 2; margin-top: 0; }
.secret-input { position: relative; }
.secret-input .input { padding-right: 42px; font-family: var(--font-mono); }
.secret-toggle { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); }

/* Alerts (blocked form). Toasts are for action outcomes. */
.alert { padding: 11px 14px; border-radius: var(--r-md); font-size: 13px; font-weight: 500; margin-bottom: var(--sp-4); border: 1px solid transparent; }
.alert-error { background: var(--red-bg); color: var(--red-fg); border-color: var(--red-line); }
.alert-success { background: var(--green-bg); color: var(--green-fg); border-color: var(--green-line); }
.alert-info { background: var(--blue-bg); color: var(--blue-fg); border-color: var(--blue-line); }
.alert-warning { background: var(--amber-bg); color: var(--amber-fg); border-color: var(--amber-line); }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; line-height: 1.6; border: 1px solid transparent; white-space: nowrap; vertical-align: middle; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green  { background: var(--green-bg);  color: var(--green-fg);  border-color: var(--green-line); }
.badge-red    { background: var(--red-bg);    color: var(--red-fg);    border-color: var(--red-line); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber-fg);  border-color: var(--amber-line); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue-fg);   border-color: var(--blue-line); }
.badge-purple { background: var(--purple-bg); color: var(--purple-fg); border-color: var(--purple-line); }
.badge-gray   { background: var(--gray-bg);   color: var(--gray-fg);   border-color: var(--gray-line); }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--line); margin-bottom: var(--sp-4); overflow-x: auto; scrollbar-width: thin; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -2px; padding: 9px 16px; font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--orange-600); border-bottom-color: var(--orange-500); }
.tab-badge { font-size: var(--fs-xs); background: var(--navy-50); color: var(--navy-500); border-radius: var(--r-pill); padding: 0 6px; }
.tab-panel:focus-visible { border-radius: var(--r-sm); }
/* Sideways strips (Tabs, workspace nav on phones): kit/scrollStrip.js sets
   data-overflow while content is hidden on that side; fade that edge. */
[data-overflow="end"] { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); }
[data-overflow="start"] { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent); }
[data-overflow="both"] { -webkit-mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent); }

/* ── Table (cards under 640px via data-label) ───────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; }
.table th { background: var(--navy-50); text-align: left; padding: 10px 14px; font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; color: var(--navy-600); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-alt); }
.table-clickable tbody tr { cursor: pointer; }
.table-clickable tbody tr:focus-visible { box-shadow: inset 3px 0 0 var(--orange-500); outline: none; }
.table .align-right { text-align: right; }
.cell-primary { font-weight: 600; color: var(--text); }
.cell-sub { display: block; font-size: var(--fs-sm); color: var(--text-muted); font-family: var(--font-mono); }
.row-skeleton td { padding: 16px 14px; }

@media (max-width: 640px) {
  .table-wrap { border: 0; background: none; overflow: visible; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-2) var(--sp-4); margin-bottom: var(--sp-3); box-shadow: var(--shadow-sm); }
  .table td { display: flex; justify-content: space-between; gap: var(--sp-4); padding: 8px 0; text-align: right; border-bottom: 1px solid var(--line-soft); }
  .table td::before { content: attr(data-label); font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); text-align: left; flex: none; }
  .table td:last-child { border-bottom: 0; }
  .table tbody tr:hover td { background: none; }
}

/* ── Skeleton / empty state ─────────────────────────────────────────────── */
.skeleton { display: grid; gap: 10px; }
.skeleton-line { display: block; height: 12px; border-radius: 6px; width: 100%; background: linear-gradient(90deg, var(--navy-50), var(--navy-100), var(--navy-50)); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
.skeleton-line.is-short { width: 60%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton-line, .spinner { animation: none; } }
.empty-state { text-align: center; padding: var(--sp-8) var(--sp-4); background: var(--surface); border: 1px dashed var(--navy-200); border-radius: var(--r-lg); }
.empty-icon { display: inline-flex; width: 44px; height: 44px; border-radius: 50%; align-items: center; justify-content: center; background: var(--navy-50); color: var(--navy-500); margin-bottom: var(--sp-3); }
.empty-icon .icon { margin: auto; }
.empty-title { font-weight: 700; color: var(--text); }
.empty-text { color: var(--text-muted); font-size: 13px; margin: var(--sp-1) auto 0; max-width: 52ch; }
.empty-action { margin-top: var(--sp-4); display: flex; justify-content: center; gap: var(--sp-2); flex-wrap: wrap; }
.empty-error { border-color: var(--red-line); }
.empty-error .empty-icon { background: var(--red-bg); color: var(--red-fg); }

/* ── Overlays: modal + drawer ───────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(10,19,34,.5); backdrop-filter: blur(3px); display: flex; }
.overlay-center { z-index: var(--z-modal); align-items: center; justify-content: center; padding: var(--sp-4); }
.overlay-right { z-index: var(--z-drawer); justify-content: flex-end; }
.modal { background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); border: 1px solid var(--line); width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column; outline: none; }
.modal-sm { max-width: 420px; } .modal-md { max-width: 560px; } .modal-lg { max-width: 820px; }
.modal-head, .drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) var(--sp-3) var(--sp-6); }
.modal-title, .drawer-title { font-size: 17px; font-weight: 700; padding-top: 4px; }
.drawer-subtitle { color: var(--text-muted); font-size: 13px; }
.modal-body, .drawer-body { padding: var(--sp-2) var(--sp-6) var(--sp-5); overflow-y: auto; flex: 1; }
.modal-foot, .drawer-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); flex-wrap: wrap; padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--line); }
.confirm-text { color: var(--navy-500); margin-bottom: var(--sp-4); }
.drawer { background: var(--surface); height: 100%; width: 100%; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); outline: none; animation: slide-in .18s ease-out; }
.drawer-md { max-width: 560px; } .drawer-lg { max-width: 920px; }
@keyframes slide-in { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (max-width: 640px) {
  .overlay-center { padding: var(--sp-2); align-items: flex-end; }
  .modal { max-height: calc(100vh - 16px); border-radius: var(--r-lg); }
  .drawer-md, .drawer-lg { max-width: none; }
  /* Full height on phones: cover the sticky nav completely (no strip at the top). */
  .overlay-right { align-items: stretch; }
  .overlay-right .drawer { position: fixed; inset: 0; height: 100%; height: 100dvh; max-height: none; border-radius: 0; animation: none; }
  .modal-head, .drawer-head { padding: var(--sp-4) var(--sp-3) var(--sp-2) var(--sp-4); }
  .modal-body, .drawer-body { padding: var(--sp-2) var(--sp-4) var(--sp-4); }
  .modal-foot, .drawer-foot { padding: var(--sp-3) var(--sp-4); }
}

/* ── Toasts ──────────────────────────────────────────────────────────────── */
.toast-region { position: fixed; right: var(--sp-4); bottom: var(--sp-4); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--sp-2); width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: var(--sp-2); padding: 11px 8px 11px 14px; border-radius: var(--r-md); background: var(--navy-800); color: #fff; box-shadow: var(--shadow-lg); font-size: 13px; border-left: 4px solid var(--blue-line); }
.toast-success { border-left-color: #3ccf8e; }
.toast-error { border-left-color: #f26b6b; }
.toast-warn { border-left-color: #f5b544; }
.toast-icon { margin-top: 2px; }
.toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-close { width: 26px; height: 26px; color: rgba(255,255,255,.7); }
.toast-close:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--sp-4); }
.login-box { width: 100%; max-width: 400px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-6); }
.login-logo { height: 56px; width: 56px; }
.login-brand .brand-name { font-size: 30px; color: var(--navy-700); }
.login-card { padding: 30px; }
.login-head { text-align: center; margin-bottom: var(--sp-6); }
.login-title { font-size: var(--fs-xl); font-weight: 800; }
.login-sub { font-size: 13px; color: var(--text-muted); margin-top: var(--sp-1); }
.login-foot { text-align: center; font-size: var(--fs-xs); color: var(--text-faint); margin-top: var(--sp-5); }
.login-foot strong { color: var(--text-muted); }
.login-card .btn-primary { width: 100%; padding: 11px; }

/* ── Workspace (sidebar + content; collapses under 900px) ───────────────── */
.ws-header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.ws-crumb { font-size: 13px; margin-bottom: var(--sp-1); }
.ws-title { display: flex; align-items: center; gap: var(--sp-2) var(--sp-3); flex-wrap: wrap; min-width: 0; }
.ws-title h1 { overflow-wrap: anywhere; }
.ws-meta { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; color: var(--text-muted); font-size: 13px; margin-top: var(--sp-1); }
.ws-meta .sep { color: var(--text-faint); }
.ws-layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); gap: var(--sp-6); align-items: start; }
.ws-sidebar { position: sticky; top: calc(var(--nav-h) + var(--sp-4)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-2); box-shadow: var(--shadow-sm); }
.ws-nav { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.ws-link { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: var(--r-sm); color: var(--navy-600); font-weight: 600; font-size: 13px; }
.ws-link:hover { background: var(--navy-50); color: var(--text); text-decoration: none; }
.ws-link.is-active { background: var(--orange-50); color: var(--orange-700); box-shadow: inset 3px 0 0 var(--orange-500); }
.ws-content { min-width: 0; }
@media (max-width: 900px) {
  .ws-layout { grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); }
  .ws-sidebar { position: static; padding: var(--sp-1); overflow-x: auto; scrollbar-width: thin; }
  .ws-nav { flex-direction: row; }
  .ws-link { white-space: nowrap; }
  .ws-link.is-active { box-shadow: inset 0 -3px 0 var(--orange-500); }
}

/* ── Shared blocks (kit-level classes sections reuse) ─────────────────────── */
/* .kv: key-value list <dl class="kv"><dt>Key</dt><dd>Value</dd>…</dl>; stacks under 640px. */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px var(--sp-4); margin: 0 0 var(--sp-4); }
.kv dt { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
/* .danger-zone: red-edged card of .danger-zone-row (label + text left, action right). */
.danger-zone { border-color: var(--red-line); }
.danger-zone .section-card-title { margin-bottom: var(--sp-2); color: var(--red-fg); }
.danger-zone-row { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); padding: var(--sp-3) 0; border-top: 1px solid var(--line-soft); }
.danger-zone-row:first-of-type { border-top: 0; }
.danger-zone-label { font-weight: 600; }
/* .pager: <nav class="pager">Prev · <span class="pager-label">Page x of y</span> · Next</nav> */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3); margin-top: var(--sp-3); flex-wrap: wrap; }
.pager-label { font-size: var(--fs-sm); color: var(--text-muted); }
/* .summary-tiles: row of stat tiles (.summary-tile > .summary-label + .summary-value); 2 per row on phones. */
.summary-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-5); }
.summary-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-4); box-shadow: var(--shadow-sm); min-width: 0; }
.summary-label { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.summary-value { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
/* SectionCard footer slot + inline overlay-footer error + SecretInput clear row + Table expanded row. */
.section-card-foot-start { margin-right: auto; display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.overlay-foot-error { flex: 1 1 100%; }
.overlay-foot-error .alert { margin-bottom: 0; }
.secret-clear { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-1); }
.secret-input.is-cleared .input { background: var(--surface-alt); }
.btn .icon { flex: none; }
.row-expanded > td { background: var(--surface-alt); padding: var(--sp-4); }
.table-expandable tbody tr.is-expanded { background: var(--navy-50); }
.expand-slot { display: inline-block; width: 18px; }
.expand-caret { transition: transform .15s ease; vertical-align: middle; color: var(--text-muted); }
tr.is-expanded .expand-caret { transform: rotate(90deg); }

/* ── Chip, Collapsible, Combobox, Menu, tab dot (Phase B kit) ───────────── */
.chip { display: inline-flex; align-items: center; padding: 0 7px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; line-height: 1.7; border: 1px solid transparent; white-space: nowrap; vertical-align: middle; }
.chip-green  { background: var(--green-bg);  color: var(--green-fg);  border-color: var(--green-line); }
.chip-red    { background: var(--red-bg);    color: var(--red-fg);    border-color: var(--red-line); }
.chip-amber  { background: var(--amber-bg);  color: var(--amber-fg);  border-color: var(--amber-line); }
.chip-blue   { background: var(--blue-bg);   color: var(--blue-fg);   border-color: var(--blue-line); }
.chip-purple { background: var(--purple-bg); color: var(--purple-fg); border-color: var(--purple-line); }
.chip-gray   { background: var(--gray-bg);   color: var(--gray-fg);   border-color: var(--gray-line); }
.tab-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--orange-500); flex: none; }

.collapsible { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.collapsible + .collapsible { margin-top: var(--sp-3); }
.collapsible-heading { margin: 0; font-size: var(--fs-md); }
.collapsible-toggle { display: flex; align-items: center; gap: var(--sp-2); width: 100%; padding: var(--sp-3) var(--sp-4); background: none; border: 0; border-radius: var(--r-md); font: inherit; font-weight: 700; color: var(--text); text-align: left; cursor: pointer; }
.collapsible-toggle:hover { background: var(--surface-alt); }
.collapsible-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.collapsible-chevron { color: var(--text-muted); flex: none; }
.collapsible-title { flex: 1; min-width: 0; }
.collapsible-meta { display: inline-flex; gap: var(--sp-1); flex-wrap: wrap; justify-content: flex-end; font-weight: 500; }
.collapsible.is-open > .collapsible-heading .collapsible-toggle { border-bottom: 1px solid var(--line-soft); border-radius: var(--r-md) var(--r-md) 0 0; }
.collapsible-panel { padding: var(--sp-4); }

.combobox { position: relative; min-width: 0; }
.combobox-input { padding-right: 34px; }
.combobox-toggle { position: absolute; top: 50%; right: 2px; transform: translateY(-50%); width: 28px; height: 28px; }
.combobox-list { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); max-height: 240px; overflow-y: auto; margin: 0; padding: var(--sp-1) 0; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-md); }
.combobox-option { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; padding: 6px var(--sp-3); cursor: pointer; font-size: 13px; }
.combobox-option.is-active, .combobox-option:hover { background: var(--navy-50); }
.combobox-option.is-current .combobox-option-value { font-weight: 700; }
.combobox-option-value { font-family: var(--font-mono); font-size: var(--fs-sm); word-break: break-all; }
.combobox-option-hint { color: var(--text-muted); font-size: var(--fs-xs); }
.combobox-empty { padding: 6px var(--sp-3); color: var(--text-muted); font-size: var(--fs-sm); }

.menu { position: relative; display: inline-block; }
.menu-popup { position: absolute; z-index: 6; right: 0; top: calc(100% + 4px); min-width: 180px; padding: var(--sp-1) 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-md); }
.menu-item { display: flex; align-items: center; gap: var(--sp-2); width: 100%; padding: 8px var(--sp-3); background: none; border: 0; font: inherit; font-size: 13px; color: var(--text); text-align: left; cursor: pointer; white-space: nowrap; }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--navy-50); outline: none; }
.menu-item:disabled { color: var(--text-faint); cursor: default; }
.menu-item.is-danger { color: var(--red-fg); }

/* ── Phone width ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  :root { --gutter: var(--sp-4); }
  .page { padding-top: var(--sp-4); }
  .page-title { font-size: var(--fs-xl); }
  .card { padding: var(--sp-4); border-radius: var(--r-lg); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .section-card-foot { justify-content: space-between; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: var(--sp-2); }
  .danger-zone-row { flex-direction: column; align-items: flex-start; }
  .summary-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.page-actions-spaced { margin-top: var(--sp-4); }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: var(--z-toast); background: #fff; color: var(--text); padding: 8px 12px; border-radius: var(--r-sm); box-shadow: var(--shadow-md); }
.skip-link:focus { left: 8px; }
main:focus { outline: none; }
