/* ============================================================================
   Complitica Energy — design system
   Hand-authored. Replaces the Tailwind CDN (no runtime JIT, no FOUC).
   Keeps the utility class names the existing markup uses, so templates
   and API wiring are untouched.
   ========================================================================== */

/* ---------- tokens ---------------------------------------------------- */
:root {
  /* ground → raised. Each step lifts ~4% luminance with a slight cool cast. */
  --ink:        #080d14;
  --ink-2:      #0b1220;
  --panel:      #111a28;
  --panel-2:    #18222f;
  --panel-3:    #1e2a39;

  --line:       #212e40;
  --line-soft:  #1a2534;
  --line-hard:  #2c3c52;

  --brand:      #21c08b;
  --brand-lift: #35d6a0;
  --brand-deep: #0f8f66;
  --brand-ink:  #06231a;

  --amber:      #f5a524;
  --amber-lift: #ffbc4d;
  --danger:     #f04438;
  --danger-lift:#ff6152;
  --blue:       #6ba3de;

  --txt:        #e8eefa;
  --txt-2:      #b9c6da;
  --muted:      #7f92ac;
  --muted-2:    #5e7089;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, "Cascadia Mono", Consolas, monospace;

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;
  --r-xl: 18px;

  --ring: 0 0 0 3px rgba(33, 192, 139, 0.18);
  --lift-1: 0 1px 2px rgba(0,0,0,.4);
  --lift-2: 0 4px 16px -4px rgba(0,0,0,.5);
  --lift-3: 0 18px 48px -12px rgba(0,0,0,.65);
}

/* ---------- reset ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--ink-2);
  color: var(--txt);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02","cv03","cv04","ss01";
  min-height: 100vh;
}

/* ambient depth — a very soft brand wash from the top, keeps the ground
   from reading as flat black without being a "gradient hero" */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 70vh;
  background: radial-gradient(72% 46% at 50% -8%, rgba(33,192,139,.055), transparent 72%);
  pointer-events: none;
  z-index: 0;
}
body > * { position: relative; z-index: 1; }

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 9px; border: 2px solid var(--ink-2); }
::-webkit-scrollbar-thumb:hover { background: var(--line-hard); }

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

::selection { background: rgba(33,192,139,.28); color: #fff; }

/* ---------- typography ------------------------------------------------ */
h1, h2, h3 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.021em; }

.text-2xl { font-size: 26px; line-height: 1.15; letter-spacing: -0.024em; font-weight: 680; }
.text-3xl { font-size: 32px; line-height: 1.1;  letter-spacing: -0.028em; font-weight: 720; }
.text-4xl { font-size: 40px; line-height: 1.05; letter-spacing: -0.032em; font-weight: 760; }
.text-xl  { font-size: 19px; line-height: 1.25; letter-spacing: -0.018em; font-weight: 660; }
.text-lg  { font-size: 16.5px; line-height: 1.35; letter-spacing: -0.012em; }
.text-base{ font-size: 14px; }
.text-sm  { font-size: 13px; line-height: 1.5; }
.text-xs  { font-size: 12px; line-height: 1.45; }
.text-\[10px\] { font-size: 10px; line-height: 1.4; }
.text-\[11px\] { font-size: 11px; line-height: 1.45; }
.text-\[12px\] { font-size: 12px; line-height: 1.45; }

.font-normal   { font-weight: 400; }
.font-medium   { font-weight: 520; }
.font-semibold { font-weight: 620; }
.font-bold     { font-weight: 680; }
.font-black    { font-weight: 780; letter-spacing: -0.03em; }

.uppercase  { text-transform: uppercase; letter-spacing: 0.075em; font-weight: 560; }
.capitalize { text-transform: capitalize; }
.tracking-tight { letter-spacing: -0.02em; }
.leading-snug    { line-height: 1.35; }
.leading-relaxed { line-height: 1.7; }
.line-through { text-decoration: line-through; opacity: .55; }
.whitespace-pre-line { white-space: pre-line; }
.whitespace-nowrap   { white-space: nowrap; }
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-mono { font-family: var(--mono); font-size: .92em; letter-spacing: -0.01em; }

/* numerals line up in every data context */
table, .chip, input[type="date"], .tabular { font-variant-numeric: tabular-nums; }

/* ---------- color utilities ------------------------------------------- */
.text-txt    { color: var(--txt); }
.text-muted  { color: var(--muted); }
.text-brand  { color: var(--brand); }
.text-amber  { color: var(--amber); }
.text-danger { color: var(--danger); }
.text-ink    { color: var(--brand-ink); }
.text-blue-300 { color: var(--blue); }
.text-white  { color: #fff; }

.bg-ink    { background: var(--ink-2); }
.bg-panel  { background: var(--panel); }
.bg-panel2 { background: var(--panel-2); }
.bg-brand  { background: var(--brand); }
.bg-amber  { background: var(--amber); }
.bg-danger { background: var(--danger); }
.bg-line   { background: var(--line); }

.bg-ink\/95     { background: rgba(9,14,22,.88); }
.bg-brand\/10   { background: rgba(33,192,139,.10); }
.bg-brand\/15   { background: rgba(33,192,139,.14); }
.bg-brand\/20   { background: rgba(33,192,139,.19); }
.bg-amber\/5    { background: rgba(245,165,36,.06); }
.bg-amber\/10   { background: rgba(245,165,36,.10); }
.bg-amber\/15   { background: rgba(245,165,36,.14); }
.bg-amber\/20   { background: rgba(245,165,36,.18); }
.bg-amber\/80   { background: rgba(245,165,36,.88); }
.bg-danger\/20  { background: rgba(240,68,56,.18); }
.bg-danger\/30  { background: rgba(240,68,56,.26); }
.bg-blue-400\/15{ background: rgba(107,163,222,.15); }
.bg-panel2\/30  { background: rgba(24,34,47,.42); }
.bg-panel2\/40  { background: rgba(24,34,47,.55); }
.bg-panel2\/50  { background: rgba(24,34,47,.66); }
.bg-panel2\/60  { background: rgba(24,34,47,.78); }

.bg-gradient-to-br { background-image: linear-gradient(140deg, var(--brand) 0%, var(--brand-deep) 100%); }
.from-brand, .to-branddk { /* consumed by the gradient above */ }

/* ---------- borders --------------------------------------------------- */
.border    { border: 1px solid var(--line); }
.border-t  { border-top: 1px solid var(--line); }
.border-b  { border-bottom: 1px solid var(--line); }
.border-r  { border-right: 1px solid var(--line); }
.border-l-4{ border-left: 3px solid var(--line); }
.border-line { border-color: var(--line); }
.border-brand { border-color: var(--brand); }
.border-transparent { border-color: transparent; }
.border-line\/50   { border-color: rgba(33,46,64,.55); }
.border-brand\/30  { border-color: rgba(33,192,139,.32); }
.border-brand\/40  { border-color: rgba(33,192,139,.42); }
.border-amber\/20  { border-color: rgba(245,165,36,.26); }
.border-white\/10  { border-color: rgba(255,255,255,.10); }

.rounded      { border-radius: var(--r-sm); }
.rounded-lg   { border-radius: var(--r); }
.rounded-full { border-radius: 999px; }

/* ---------- layout ---------------------------------------------------- */
.flex { display: flex; }
.grid { display: grid; }
.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }

.flex-col { flex-direction: column; }
.flex-1 { flex: 1 1 0%; min-width: 0; }
.flex-wrap { flex-wrap: wrap; }
.shrink-0 { flex-shrink: 0; }

.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.items-end     { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.justify-center  { justify-content: center; }
.place-items-center { place-items: center; }

.grid-cols-2  { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-cols-3  { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-cols-4  { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-cols-12 { grid-template-columns: repeat(12, minmax(0,1fr)); }
.col-span-2 { grid-column: span 2 / span 2; }
.col-span-3 { grid-column: span 3 / span 3; }
.col-span-4 { grid-column: span 4 / span 4; }
.col-span-5 { grid-column: span 5 / span 5; }

.gap-1   { gap: 4px; }
.gap-1\.5{ gap: 6px; }
.gap-2   { gap: 8px; }
.gap-3   { gap: 12px; }
.gap-4   { gap: 16px; }
.gap-5   { gap: 20px; }

.space-y-1 > * + * { margin-top: 4px; }
.space-y-2 > * + * { margin-top: 8px; }
.space-y-3 > * + * { margin-top: 12px; }

.sticky { position: sticky; }
.fixed  { position: fixed; }
.relative { position: relative; }
.top-0   { top: 0; }
.bottom-5{ bottom: 20px; }
.right-5 { right: 20px; }
.z-20 { z-index: 20; }
.z-50 { z-index: 50; }

.overflow-hidden { overflow: hidden; }
.backdrop-blur { backdrop-filter: blur(14px) saturate(1.6); -webkit-backdrop-filter: blur(14px) saturate(1.6); }
.opacity-60 { opacity: .6; }
.cursor-pointer { cursor: pointer; }
.align-top { vertical-align: top; }
.mx-auto { margin-left: auto; margin-right: auto; }
.ml-auto { margin-left: auto; }

/* ---------- spacing --------------------------------------------------- */
.p-2   { padding: 8px; }  .p-2\.5{ padding: 10px; }
.p-3   { padding: 12px; } .p-4   { padding: 16px; }
.p-5   { padding: 20px; } .p-6   { padding: 24px; }
.p-7   { padding: 28px; } .p-8   { padding: 32px; }

.px-1\.5{ padding-left: 6px;  padding-right: 6px; }
.px-2   { padding-left: 8px;  padding-right: 8px; }
.px-2\.5{ padding-left: 10px; padding-right: 10px; }
.px-3   { padding-left: 12px; padding-right: 12px; }
.px-4   { padding-left: 16px; padding-right: 16px; }
.px-5   { padding-left: 20px; padding-right: 20px; }
.px-6   { padding-left: 24px; padding-right: 24px; }

.py-0\.5{ padding-top: 2px;  padding-bottom: 2px; }
.py-1   { padding-top: 4px;  padding-bottom: 4px; }
.py-1\.5{ padding-top: 6px;  padding-bottom: 6px; }
.py-2   { padding-top: 8px;  padding-bottom: 8px; }
.py-2\.5{ padding-top: 10px; padding-bottom: 10px; }
.py-3   { padding-top: 12px; padding-bottom: 12px; }

.pb-2 { padding-bottom: 8px; }
.pb-16{ padding-bottom: 64px; }
.pt-0\.5 { padding-top: 2px; }
.pt-1 { padding-top: 4px; }
.pt-2 { padding-top: 8px; }
.pl-1 { padding-left: 4px; }

.m-0 { margin: 0; }
.mb-1 { margin-bottom: 4px; }  .mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mt-0\.5{ margin-top: 2px; }
.mt-1 { margin-top: 4px; }  .mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 20px; } .mt-6 { margin-top: 24px; }
.mt-16{ margin-top: 64px; }
.ml-1 { margin-left: 4px; } .ml-2 { margin-left: 8px; }
.mr-1 { margin-right: 4px; }
.my-4 { margin-top: 16px; margin-bottom: 16px; }

/* ---------- sizing ---------------------------------------------------- */
.w-full { width: 100%; }
.w-1\.5 { width: 6px; }  .w-2   { width: 8px; }
.w-2\.5 { width: 10px; } .w-5   { width: 20px; }
.w-7    { width: 28px; } .w-14  { width: 56px; }
.w-24   { width: 96px; } .w-28  { width: 112px; }
.w-40   { width: 160px; }.w-48  { width: 192px; }
.w-56   { width: 224px; }
.h-px { height: 1px; }
.h-1\.5 { height: 6px; }  .h-2   { height: 8px; }
.h-2\.5 { height: 10px; } .h-5   { height: 20px; }
.h-7    { height: 28px; } .h-10  { height: 40px; }
.h-14   { height: 56px; } .h-full{ height: 100%; }
.min-h-screen { min-height: 100vh; }
.min-h-\[1rem\] { min-height: 1rem; }
.min-h-\[calc\(100vh-3\.5rem\)\] { min-height: calc(100vh - 56px); }
.max-w-sm { max-width: 384px; }
.max-w-\[70\%\]  { max-width: 70%; }
.max-w-\[75\%\]  { max-width: 75%; }
.max-w-\[260px\] { max-width: 260px; }
.max-w-\[1150px\]{ max-width: 1150px; }

/* ============================================================================
   components
   ========================================================================== */

/* ---------- card: the workhorse surface ------------------------------- */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,.028) 0%, rgba(255,255,255,0) 42%), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--lift-1);
  position: relative;
}
/* hairline top highlight — what separates crafted dark UI from flat dark UI */
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.09) 22%, rgba(255,255,255,.09) 78%, transparent);
  pointer-events: none;
}
button.card { transition: border-color .16s ease, background .16s ease, transform .16s ease; }
button.card:hover { border-color: var(--brand); transform: translateY(-1px); }
button.card:active { transform: translateY(0); }

/* ---------- chip ------------------------------------------------------ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 2.5px 8px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.5;
  background: var(--panel-2);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.045);
}

/* ---------- buttons --------------------------------------------------- */
button { transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease, box-shadow .15s ease; }
button:active { transform: translateY(.5px); }
button:disabled { opacity: .5; cursor: default; transform: none; }

/* primary = brand fill (matched by .bg-brand.text-ink in the markup) */
.bg-brand.text-ink {
  color: var(--brand-ink);
  box-shadow: 0 1px 0 rgba(255,255,255,.15) inset;
}
.bg-brand.text-ink:hover { background: var(--brand-lift); }
.bg-amber.text-ink, .bg-amber\/80.text-ink {
  color: #2a1a02;
  box-shadow: 0 1px 0 rgba(255,255,255,.24) inset;
}
.bg-amber.text-ink:hover, .bg-amber\/80.text-ink:hover { background: var(--amber-lift); }

/* quiet/secondary buttons */
button.border, button.bg-panel2 { color: var(--txt-2); }
button.border:hover { border-color: var(--line-hard); background: var(--panel-2); color: var(--txt); }
button.bg-panel2:hover { background: var(--panel-3); color: var(--txt); }

.hover\:bg-branddk:hover { background: var(--brand-lift); }
.hover\:border-brand:hover  { border-color: var(--brand); }
.hover\:border-amber:hover  { border-color: var(--amber); }
.hover\:border-danger:hover { border-color: var(--danger); }
.hover\:text-txt:hover { color: var(--txt); }
.hover\:bg-panel2\/50:hover { background: rgba(24,34,47,.6); color: var(--txt); }
.hover\:bg-panel2\/60:hover { background: rgba(24,34,47,.78); }
.hover\:bg-panel2\/40:hover { background: rgba(24,34,47,.5); }

/* ---------- form controls --------------------------------------------- */
input, select, textarea {
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--txt);
  padding: 8px 11px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  font-size: 13px;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:hover, select:hover, textarea:hover { border-color: var(--line-hard); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
  background: var(--ink-2);
}
textarea { line-height: 1.6; resize: vertical; }
select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 8l3-3.5' stroke='%237f92ac' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.62) sepia(.1) saturate(.8); cursor: pointer; }

/* ---------- navigation ------------------------------------------------ */
#nav button {
  width: 100%;
  text-align: left;
  padding: 7px 11px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  position: relative;
  letter-spacing: -.005em;
}
#nav button:hover { background: rgba(24,34,47,.6); color: var(--txt); }
#nav button > span:first-child { width: 20px; text-align: center; opacity: .75; font-size: 12px; }

.nav-active,
#nav button.nav-active {
  background: linear-gradient(90deg, rgba(33,192,139,.13), rgba(33,192,139,.03));
  color: #fff;
  font-weight: 580;
  border-left: none;
}
#nav button.nav-active > span:first-child { opacity: 1; color: var(--brand); }
#nav button.nav-active::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 2.5px; height: 17px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}

/* ---------- tables ---------------------------------------------------- */
table { width: 100%; }
thead th {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .085em;
  font-weight: 580;
  color: var(--muted-2);
  padding-bottom: 9px;
  text-align: left;
}
tbody tr { transition: background .13s ease; }
tbody tr:hover { background: rgba(24,34,47,.42); }
tbody td { padding-top: 11px; padding-bottom: 11px; }
tbody tr td:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
tbody tr td:last-child  { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

/* ---------- highlight (cited clause) ---------------------------------- */
.hl {
  background: rgba(33,192,139,.2);
  border-bottom: 2px solid var(--brand);
  border-radius: 2px;
  padding: 0 2px;
  color: #fff;
  font-weight: 600;
}

/* ---------- toasts ---------------------------------------------------- */
#toast .card {
  box-shadow: var(--lift-3);
  background: var(--panel-2);
  min-width: 260px;
  max-width: 380px;
  font-size: 13px;
  border-radius: var(--r);
}

/* ---------- motion ---------------------------------------------------- */
.fade { animation: fade-in .26s cubic-bezier(.22,.61,.36,1) both; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}
.glow { /* legacy hook — ambient wash now lives on body::before */ }

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

/* ---------- app chrome ------------------------------------------------ */
/* The header must survive a narrow logical viewport (browser zoom, small
   laptop). Nothing in it is allowed to wrap: the identity string truncates,
   secondary items drop out at breakpoints, everything else holds its size. */
header.h-14 {
  border-bottom: 1px solid var(--line-soft);
  background: rgba(9,14,22,.82);
  height: 56px;
  min-height: 56px;
  flex-wrap: nowrap;
  overflow: hidden;
}
header.h-14 > * { min-width: 0; }
header.h-14 > .flex.items-center.gap-2 { flex-shrink: 0; white-space: nowrap; }
header.h-14 > .ml-auto { flex-shrink: 1; min-width: 0; white-space: nowrap; }

/* Right side reads context -> identity -> actions. Sign out used to sit between
   the user's name and the tenant selector, which put a terminal action in the
   middle of a row of state. It belongs at the edge. */
.hdr-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  white-space: nowrap;
}

/* the working context — which tenant, and whether we are actually talking to it.
   Grouped into one control so the dot reads as the selector's status, not as a
   free-floating light. */
.hdr-context {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 11px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--ink);
  flex-shrink: 1;
  min-width: 0;
  transition: border-color .15s ease;
}
.hdr-context:hover { border-color: var(--line-hard); }
.hdr-context select {
  border: none;
  background-color: transparent;
  padding: 0 24px 0 0;
  height: auto;
  font-size: 13px;
  font-weight: 520;
  background-position: right 2px center;
  min-width: 0;
  text-overflow: ellipsis;
}
.hdr-context select:hover { border: none; }
.hdr-context select:focus { box-shadow: none; border: none; background-color: transparent; }
.hdr-context:focus-within { border-color: var(--brand); box-shadow: var(--ring); }

.hdr-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted-2);
}
.hdr-dot.is-ok      { background: var(--brand);  box-shadow: 0 0 0 3px rgba(33,192,139,.15); }
.hdr-dot.is-down    { background: var(--danger); box-shadow: 0 0 0 3px rgba(240,68,56,.16); }
.hdr-dot.is-unknown { background: var(--amber);  box-shadow: 0 0 0 3px rgba(245,165,36,.14); }

.hdr-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  flex-shrink: 0;
}

/* identity is state, not a control — no border, so it never reads as clickable */
.hdr-identity {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--txt-2);
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.hdr-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 11px;
  font-size: 12.5px;
  font-weight: 520;
  color: var(--txt-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: transparent;
  flex-shrink: 0;
}
.hdr-btn:hover { border-color: var(--line-hard); background: var(--panel-2); color: var(--txt); }
.hdr-btn.is-primary {
  background: var(--brand); color: var(--brand-ink); border-color: transparent;
  font-weight: 620;
}
.hdr-btn.is-primary:hover { background: var(--brand-lift); }
header.h-14 button,
header.h-14 a,
header.h-14 .status-badge,
header.h-14 .portal-tag,
header.h-14 .field-label-inline { flex-shrink: 0; white-space: nowrap; }
header.h-14 select { max-width: 210px; flex-shrink: 1; min-width: 0; }

#authstate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

/* Shed secondary chrome before anything is allowed to collide, worst-value first.
   The cross-surface link goes before the environment badge; the identity truncates
   rather than disappearing, because knowing who you are signed in as decides
   whether an approval is even yours to make. */
@media (max-width: 1180px) {
  header.h-14 a.hdr-btn[href="portal.html"],
  header.h-14 a.hdr-btn[href="live.html"] { display: none; }
}
@media (max-width: 1000px) {
  header.h-14 .status-badge,
  header.h-14 .portal-tag { display: none; }
}
@media (max-width: 880px) {
  .hdr-identity { max-width: 140px; }
  .hdr-right { gap: 8px; }
}

/* brand mark */
.bg-gradient-to-br.grid.place-items-center {
  box-shadow: 0 2px 10px -2px rgba(33,192,139,.55), inset 0 1px 0 rgba(255,255,255,.3);
  border-radius: 8px;
  font-weight: 800;
  font-size: 15px;
  color: var(--brand-ink);
}

aside { border-right: 1px solid var(--line-soft); }

/* progress bars pick up a subtle sheen */
.h-2 > .h-full, .h-2\.5 > .h-full, .h-1\.5 > .h-full {
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
  transition: width .4s cubic-bezier(.22,.61,.36,1);
}

/* responsive: the console's dense grids need room */
@media (max-width: 1100px) {
  .grid-cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-cols-12 { grid-template-columns: repeat(1, minmax(0,1fr)); }
  .col-span-3, .col-span-4, .col-span-5 { grid-column: span 1 / span 1; }
}
@media (max-width: 820px) {
  .grid-cols-3, .grid-cols-2 { grid-template-columns: repeat(1, minmax(0,1fr)); }
  .col-span-2 { grid-column: span 1 / span 1; }
  aside { display: none; }
}
@media (min-width: 1024px) {
  .lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* ---------- production application shell ----------------------------- */
.skip-link {
  position: fixed; left: 12px; top: 8px; z-index: 100;
  padding: 8px 12px; border-radius: var(--r); color: var(--brand-ink);
  background: var(--brand); transform: translateY(-150%);
}
.skip-link:focus-visible { transform: translateY(0); }
.app-shell { display: flex; min-height: calc(100vh - 56px); }
.app-sidebar {
  width: 232px; flex: 0 0 232px; padding: 14px 12px;
  border-right: 1px solid var(--line-soft);
  background: rgba(8,13,20,.72);
}
.app-main { flex: 1 1 auto; min-width: 0; max-width: 1440px; padding: 24px; }
.menu-toggle { display: none; }
.global-search {
  width: min(360px, 34vw); min-width: 180px; height: 34px;
  padding-left: 34px; background-position: 11px center;
}
.search-wrap { position: relative; min-width: 0; }
.search-wrap::before {
  content: "⌕"; position: absolute; left: 12px; top: 7px; z-index: 1;
  color: var(--muted); font-size: 16px; pointer-events: none;
}
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; margin-bottom: 20px;
}
.page-head h1 { text-wrap: balance; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kpi-grid {
  display: grid; grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 12px; margin-bottom: 18px;
}
.kpi { padding: 16px; min-width: 0; }
.kpi-label { color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
.kpi-value { margin-top: 5px; font-size: 25px; line-height: 1.1; font-weight: 760; font-variant-numeric: tabular-nums; }
.kpi-note { margin-top: 5px; color: var(--muted); font-size: 11.5px; overflow-wrap: anywhere; }
.work-grid { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(280px,.65fr); gap: 16px; }
.section-card { padding: 18px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; font-weight: 650; }
.action-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 0;
  border-top: 1px solid var(--line-soft); min-width: 0;
}
.action-row:first-child { border-top: 0; }
.action-main { min-width: 0; flex: 1 1 auto; }
.action-title { font-size: 13px; font-weight: 590; overflow-wrap: anywhere; }
.action-meta { color: var(--muted); font-size: 11px; margin-top: 3px; overflow-wrap: anywhere; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 7px 12px; border-radius: var(--r);
  border: 1px solid var(--line); color: var(--txt-2); font-size: 12.5px; font-weight: 620;
}
.btn:hover { color: var(--txt); background: var(--panel-2); border-color: var(--line-hard); }
.btn-primary { color: var(--brand-ink); background: var(--brand); border-color: transparent; }
.btn-primary:hover { color: var(--brand-ink); background: var(--brand-lift); }
.btn-danger { color: #fff; background: var(--danger); border-color: transparent; }
.btn-warning { color: #2a1a02; background: var(--amber); border-color: transparent; }
.btn-sm { min-height: 30px; padding: 5px 9px; font-size: 11.5px; }
.notice {
  min-width: 260px; max-width: 390px; padding: 12px 14px;
  border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--r);
  box-shadow: var(--lift-3); background: var(--panel-2); font-size: 13px;
}
.notice-success { border-left-color: var(--brand); }
.notice-warning { border-left-color: var(--amber); }
.notice-danger { border-left-color: var(--danger); }
.progress { height: 8px; overflow: hidden; border-radius: 999px; background: var(--panel-2); }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.lane-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.lane { padding: 16px; min-width: 0; }
.lane-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-weight: 650; }
.trust-panel {
  display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px;
  padding: 13px; border: 1px solid var(--line); border-radius: var(--r); background: var(--ink);
}
.trust-panel dt { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.trust-panel dd { margin: 3px 0 0; font-size: 11.5px; overflow-wrap: anywhere; }
.mode-switch { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: var(--r); background: var(--ink); }
.mode-switch button { padding: 6px 10px; border-radius: var(--r-sm); color: var(--muted); font-size: 11.5px; }
.mode-switch button[aria-pressed="true"] { color: var(--txt); background: var(--panel-2); }
.operational-view .kpi {
  width: 100%;
  color: inherit;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.operational-view .kpi:hover { border-color: var(--line-hard); background: var(--panel-2); }
.operational-view .kpi:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.operational-table { min-width: 0; }
.operational-row {
  display: grid;
  grid-template-columns: minmax(220px,2fr) minmax(105px,.8fr) minmax(120px,.9fr) minmax(90px,.65fr);
  gap: 14px;
  align-items: center;
  padding: 11px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
}
.operational-head {
  padding-top: 0;
  border-top: 0;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: .065em;
  text-transform: uppercase;
}
.domain-row {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-top: 1px solid var(--line-soft);
  color: var(--txt-2);
  font-size: 12px;
}
.domain-row:first-of-type { border-top: 0; }
.domain-row:hover { color: var(--brand); }
.domain-row span:last-child {
  min-width: 26px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.table-wrap { overflow-x: auto; }
.mobile-card-list { display: none; }
dialog {
  width: min(480px,calc(100vw - 32px)); padding: 0; border: 1px solid var(--line);
  border-radius: var(--r-lg); color: var(--txt); background: var(--panel); box-shadow: var(--lift-3);
}
dialog::backdrop { background: rgba(3,7,12,.72); backdrop-filter: blur(3px); }
.dialog-body { padding: 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.empty-state { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 4px; color: var(--txt); }
.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;
}
.numeric { font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-button { width: 100%; text-align: left; color: inherit; cursor: pointer; }
.kpi-button:hover { border-color: var(--line-hard); background: var(--panel-2); }
.kpi-button:focus-visible, .work-client:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
.portfolio-toolbar {
  display: grid; grid-template-columns: minmax(150px,1fr) minmax(150px,1fr)
    minmax(150px,1fr) minmax(220px,1.5fr) auto;
  align-items: end; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.portfolio-toolbar label {
  display: block; margin-bottom: 5px; color: var(--muted);
  font-size: 10px; font-weight: 650; letter-spacing: .055em; text-transform: uppercase;
}
.portfolio-toolbar select, .portfolio-toolbar input {
  width: 100%; min-height: 36px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: var(--r);
  color: var(--txt); background: var(--ink); font-size: 12.5px;
}
.portfolio-toolbar select:focus-visible, .portfolio-toolbar input:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent;
}
.clear-filters { margin-bottom: 1px; white-space: nowrap; }
.portfolio-result { padding: 12px 0 8px; color: var(--muted); font-size: 12px; }
.portfolio-result strong { color: var(--txt); }
.work-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.work-table th {
  padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left;
  color: var(--muted); font-size: 10px; font-weight: 650;
  letter-spacing: .055em; text-transform: uppercase;
}
.work-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.work-table tbody tr:hover { background: color-mix(in srgb,var(--panel-2) 65%,transparent); }
.work-client { color: var(--brand); font-weight: 650; text-align: left; }
.work-client:hover { text-decoration: underline; }
.work-title { color: var(--txt); font-weight: 650; line-height: 1.35; }
.work-detail { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.work-owner { color: var(--txt-2); }
.work-status {
  display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px;
  border: 1px solid var(--line); border-radius: 999px; white-space: nowrap;
  font-size: 10.5px; font-weight: 650;
}
.work-danger { color: var(--danger); background: color-mix(in srgb,var(--danger) 10%,transparent); }
.work-warning { color: var(--amber); background: color-mix(in srgb,var(--amber) 10%,transparent); }
.work-neutral { color: var(--txt-2); background: var(--panel-2); }
.pagination {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding-top: 14px; color: var(--muted); font-size: 11.5px;
}
.pagination button:disabled { opacity: .45; cursor: not-allowed; }
.work-card {
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.work-card h3 { margin: 10px 0 2px; font-size: 14px; }
.work-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.work-card dl div { padding: 8px; border-radius: var(--r); background: var(--ink); }
.work-card dt { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.work-card dd { margin: 3px 0 0; font-size: 12px; }
.client-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.client-work-card { padding: 17px; min-width: 0; }
.client-work-card h2 { font-size: 15px; }
.client-work-stats {
  display: grid; grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 8px; margin: 16px 0;
}
.client-work-stats div { padding: 10px; border-radius: var(--r); background: var(--ink); }
.client-work-stats strong { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.client-work-stats span { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }

@media (max-width: 1050px) {
  .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .work-grid { grid-template-columns: 1fr; }
  .trust-panel { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .global-search { width: min(280px,31vw); }
  .portfolio-toolbar { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .clear-filters { justify-self: start; }
}
@media (max-width: 820px) {
  .menu-toggle { display: inline-flex; }
  .app-sidebar {
    display: block; position: fixed; z-index: 35; inset: 56px auto 0 0;
    transform: translateX(-105%); transition: transform .18s ease;
    box-shadow: var(--lift-3); overflow-y: auto;
  }
  .app-shell.nav-open .app-sidebar { transform: translateX(0); }
  .app-main { padding: 18px 14px; }
  .global-search { width: min(260px,44vw); }
  .lane-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
  .client-grid { grid-template-columns: 1fr; }
  .operational-table { overflow-x: auto; }
  .operational-row { min-width: 700px; }
}
@media (max-width: 620px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 21px; }
  .global-search { display: none; }
  .hdr-context { max-width: 150px; }
  .desktop-table { display: none; }
  .mobile-card-list { display: block; }
  .trust-panel { grid-template-columns: 1fr; }
  .portfolio-toolbar { grid-template-columns: 1fr; }
  .client-work-stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

/* ---------- staff viewing a client portal ----------------------------- */
/* Deliberately loud. Confusing "what the client sees" with "what I see" is how
   internal notes end up quoted to a client, so the state is never subtle. */
.viewas-bar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px;
  font-size: 12.5px;
  color: #2a1a02;
  background: var(--amber);
  box-shadow: 0 1px 0 rgba(0,0,0,.25);
}
.viewas-bar b { font-weight: 700; }
.viewas-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #2a1a02; flex-shrink: 0;
}
.viewas-exit {
  margin-left: auto;
  font-size: 11.5px; font-weight: 620;
  padding: 4px 10px; border-radius: var(--r-sm);
  background: rgba(0,0,0,.16); color: #2a1a02;
}
.viewas-exit:hover { background: rgba(0,0,0,.26); }
/* the app header is sticky too — push it below the banner rather than under it */
body.has-viewas header.h-14 { top: 37px; }
