/* ============================================================================
   Lilly Intelligence — shared design system ("Void & Aurora")
   Dark-first: near-black surfaces, hairline borders and ONE gradient used with
   restraint — logo, primary action, active state, key numbers. Nothing else is
   coloured unless it is a status. Type: Archivo, stretched wide (125%) for
   display, normal width for the interface; Red Hat Mono for code.

   Loaded by every /console, /admin and /workspace page — all three interfaces
   share this one look. Page-specific layout stays inline per page; this file
   owns tokens, the app shell, and all common components.

   Legacy token names (--bg,--card,--line,--fg,--mut,--acc,--ok,--bad,--warn)
   are kept intentionally: page scripts inject markup that references them, so
   re-pointing the values here re-themes that markup for free.
   ============================================================================ */

@import url("https://fonts.googleapis.com/css2?family=Archivo:wdth,wght@62..125,300..900&family=Red+Hat+Mono:wght@400;500&display=swap");

:root {
  color-scheme: dark;

  /* Surfaces */
  --bg:      #07080D;   /* void — app canvas            */
  --chrome:  #0B0C13;   /* sidebar + top bar            */
  --card:    #0E1018;   /* panels / surfaces            */
  --raise:   #121522;   /* hovers, table heads          */
  --sunken:  #151826;   /* wells, chips, raised fills   */
  --field:   #0A0B11;   /* form fields (sit in panels)  */
  --line:    #1A1D2B;   /* panel borders                */
  --line-2:  #161925;   /* hairline dividers            */
  --line-3:  #23273A;   /* control borders              */

  /* Text */
  --fg:      #E8EAF2;   /* ink                      */
  --fg-2:    #C5C9D8;   /* secondary ink            */
  --mut:     #8A90A6;   /* muted text               */
  --faint:   #6E7489;   /* eyebrows / placeholders  */
  --link:    #9DB4FF;

  /* Aurora — the one gradient */
  --a1: #7C5CFF;  --a2: #4F7BFF;  --a3: #22D3EE;
  --grad:   linear-gradient(110deg, var(--a1), var(--a2) 55%, var(--a3));
  --grad-v: linear-gradient(180deg, var(--a1), var(--a3));

  /* Accent = electric blue. Primary buttons use --grad; --acc is the solid fallback. */
  --acc:      #4F7BFF;
  --acc-2:    #6A8FFF;  /* hover  */
  --acc-soft: #141725;  /* active / selected tint */
  --focus:    #7C9BFF;  /* focus ring */

  /* Status (the only place saturated colour appears) */
  --ok:   #34D399;  --ok-bg:   rgba(52,211,153,.10);
  --bad:  #F87171;  --bad-bg:  rgba(248,113,113,.10);
  --warn: #FBBF24;  --warn-bg: rgba(251,191,36,.10);
  --info: #22D3EE;  --info-bg: rgba(34,211,238,.10);

  /* Shape & depth */
  --r-sm: 6px;  --r: 10px;  --r-lg: 16px;  --r-xl: 20px;
  --sh-1: none;
  --sh-2: 0 24px 60px -16px rgba(0,0,0,.65), 0 0 0 1px rgba(255,255,255,.03);
  --glow: 0 8px 24px -10px var(--a2);

  --side-w: 248px;
  --font:    "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --display: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono:    "Red Hat Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 400 14px/1.55 var(--font);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: rgba(79,123,255,.35); color: #fff; }

/* Display type: wide, heavy, uppercase — for page heroes and key numbers */
.display, .stat .v {
  font-family: var(--display); font-stretch: 125%; font-weight: 800;
  letter-spacing: -.01em; line-height: 1;
}
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

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

.side {
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  background: var(--chrome);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
body.signed-out .side { display: none; }

/* Lockup: geometric L + LILLY / INTELLIGENCE */
.side-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 22px 20px 20px;
}
.side-brand .mark { width: 30px; height: 30px; flex: 0 0 30px; display: block; }
.side-brand .mark svg { width: 100%; height: 100%; display: block; }
.side-brand .txt { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.side-brand .txt b {
  font-family: var(--display); font-stretch: 125%; font-size: 18px; font-weight: 900;
  letter-spacing: .02em; line-height: 1; color: #fff;
}
.side-brand .txt span {
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint);
  margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.side-nav { flex: 1; overflow-y: auto; padding: 4px 14px 12px; }
.side-nav a {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  min-height: 38px; padding: 0 12px; margin: 2px 0;
  border-radius: var(--r); border: 1px solid transparent;
  color: #A3A8BC; text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.side-nav a svg { width: 18px; height: 18px; flex: 0 0 18px; stroke-width: 1.75; opacity: .8; }
.side-nav a:hover { background: var(--raise); color: var(--fg); text-decoration: none; }
.side-nav a.active { background: var(--acc-soft); border-color: var(--line-3); color: #fff; font-weight: 600; }
.side-nav a.active svg { opacity: 1; color: var(--a3); }
.side-nav a.active::before {           /* aurora bar on the active item */
  content: ""; position: absolute; left: -15px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--grad-v);
}
.side-nav a .ext { margin-left: auto; opacity: .5; }
.side-nav a .count {
  margin-left: auto; font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--mut);
}
.side-nav a .count:empty { display: none; }
.side-nav a .count.hot { color: var(--a3); }

.side-sep {
  font-size: 10.5px; font-weight: 600; letter-spacing: .16em;
  text-transform: uppercase; color: var(--faint);
  padding: 18px 12px 6px;
}

.side-foot { padding: 14px; }
.side-user {
  display: flex; align-items: center; gap: 10px; min-width: 0; margin-bottom: 10px;
  padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
}
.side-user .avatar {
  position: relative;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--sunken); border: 1px solid var(--line-3); color: var(--fg);
  display: grid; place-items: center; font-weight: 600; font-size: 12.5px; flex: 0 0 32px;
}
.side-user .avatar::after {           /* online dot */
  content: ""; position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--a3); box-shadow: 0 0 0 2px var(--card), 0 0 8px var(--a3);
}
.side-user .u { min-width: 0; line-height: 1.3; }
.side-user .u b { font-size: 13px; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user .u span { font-size: 11.5px; color: var(--mut); text-transform: capitalize; }
.side-foot button {
  width: 100%; justify-content: center;
}
.side-foot button svg { width: 16px; height: 16px; flex: 0 0 16px; }

.side [data-admin] { display: none; }
body.is-admin .side [data-admin] { display: flex; }

.side [data-manager] { display: none; }
body.is-manager .side [data-manager] { display: flex; }   /* is-manager set for manager+admin */

/* Main column */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
body.signed-out .main { width: 100%; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 32px; height: 64px; flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(11,12,19,.78);
  backdrop-filter: saturate(1.3) blur(8px);
  position: sticky; top: 0; z-index: 20;
}
/* Breadcrumb: "<Interface> / <Page>" — console.js adds the .crumb before the h1 */
.topbar .crumb { font-size: 12.5px; color: var(--faint); white-space: nowrap; }
.topbar .crumb::after { content: " /"; }
.topbar h1 { font-size: 14px; font-weight: 600; letter-spacing: 0; margin: 0; color: var(--fg); }
.topbar .sub { color: var(--faint); font-size: 12.5px; }
.topbar .spacer { flex: 1; }
.topbar .who {
  font-size: 12px; color: var(--mut);
  display: inline-flex; align-items: center; gap: 8px;
}
.topbar .who::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--a3); box-shadow: 0 0 8px var(--a3);
}
.topbar .who:empty { display: none; }

.content { flex: 1; min-height: 0; overflow: auto; }
.content.pad { padding: 32px; }
.wrap { max-width: 1240px; margin: 0 auto; }
.wrap.narrow { max-width: 760px; }

/* Page hero: eyebrow + wide uppercase headline (dashboard, overviews) */
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin: 0 0 24px; }
.hero .hero-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.hero h1, .hero h2 {
  margin: 0; font-family: var(--display); font-stretch: 125%; font-weight: 800;
  font-size: 36px; line-height: 1; letter-spacing: -.01em; text-transform: uppercase; color: #fff;
}

/* ------- Typography helpers ---------------------------------------------- */
h2.eyebrow, .eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: .16em;
  text-transform: uppercase; color: var(--faint); margin: 0 0 12px;
}
.section-title { font-size: 15px; font-weight: 600; letter-spacing: 0; margin: 0 0 4px; }
.muted { color: var(--mut); font-size: 12.5px; }
.faint { color: var(--faint); }
a { color: var(--link); text-decoration: none; text-underline-offset: 2px; }
a:hover { color: #C9D6FF; text-decoration: underline; }

/* ------- Buttons ---------------------------------------------------------- */
button, .btn {
  appearance: none; font: inherit; font-weight: 600; font-size: 13.5px;
  border: 1px solid transparent; border-radius: var(--r);
  padding: 9px 16px; cursor: pointer;
  background: var(--grad); color: #fff;
  box-shadow: var(--glow);
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  transition: filter .12s ease, background-color .12s ease, border-color .12s ease, box-shadow .12s ease, opacity .12s ease;
  white-space: nowrap; text-decoration: none;
}
button:hover, .btn:hover { filter: brightness(1.12); text-decoration: none; color: #fff; }
button:focus-visible, .btn:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 1px;
}
button:disabled, .btn:disabled { opacity: .4; cursor: not-allowed; filter: none; }

button.ghost, .btn.ghost {
  background: var(--card); color: var(--fg); border-color: var(--line-3); box-shadow: none; font-weight: 500;
}
button.ghost:hover, .btn.ghost:hover { background: var(--sunken); border-color: #2E3350; filter: none; color: var(--fg); }

button.danger, .btn.danger, button.warn {
  background: transparent; color: var(--bad); border-color: rgba(248,113,113,.3); box-shadow: none;
}
button.danger:hover, .btn.danger:hover, button.warn:hover { background: var(--bad-bg); filter: none; color: var(--bad); }

button.mini, .btn.mini { padding: 5px 11px; font-size: 12.5px; }

/* ------- Forms ------------------------------------------------------------ */
input, select, textarea {
  font: inherit; width: 100%;
  background: var(--field); color: var(--fg);
  border: 1px solid var(--line-3); border-radius: var(--r);
  padding: 9px 12px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: #2E3350; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--a2); box-shadow: 0 0 0 3px rgba(79,123,255,.18);
}
input:disabled, select:disabled, textarea:disabled { opacity: .55; }
input[type=checkbox], input[type=radio], input[type=range] { accent-color: var(--a2); }
textarea { resize: vertical; min-height: 60px; }
label { display: block; font-size: 12.5px; color: var(--mut); margin: 12px 0 4px; font-weight: 500; }
.help { font-size: 11.5px; color: var(--faint); margin-top: 4px; }
select {
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A90A6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px;
}
select option { background: var(--card); color: var(--fg); }

.field-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field-row > div { display: grid; gap: 4px; flex: 1; min-width: 140px; }
.field-row label { margin: 0; }

/* ------- Cards ------------------------------------------------------------ */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 20px 22px; box-shadow: var(--sh-1);
}
.card + .card { margin-top: 14px; }
.card h2:not(.eyebrow) { font-size: 15px; font-weight: 600; margin: 0 0 14px; }

/* ------- Pills / badges --------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 500; line-height: 1;
  padding: 4px 9px; border-radius: 7px;
  background: var(--sunken); color: var(--mut); border: 1px solid transparent;
}
.pill.on   { background: var(--ok-bg);   color: var(--ok); }
.pill.off  { background: var(--warn-bg); color: var(--warn); }
.pill.bad  { background: var(--bad-bg);  color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.agent, .pill.await { background: var(--info-bg); color: var(--info); }

/* status (tickets, customers) */
.s-open     { background: var(--info-bg); color: var(--info); }
.s-pending  { background: var(--warn-bg); color: var(--warn); }
.s-resolved { background: var(--ok-bg);   color: var(--ok); }
.s-closed   { background: rgba(138,144,166,.12); color: var(--mut); }
.breach     { background: var(--bad-bg);  color: var(--bad); font-weight: 600; }

/* priority */
.p-urgent, .p-high { color: var(--bad); font-weight: 600; }
.p-medium { color: var(--warn); font-weight: 500; }
.p-low { color: var(--mut); }

/* roles */
.role-admin   { background: rgba(124,92,255,.14); color: #B7A6FF; }
.role-manager { background: var(--warn-bg); color: var(--warn); }
.role-agent   { background: var(--info-bg); color: var(--info); }

/* channel tag */
.ch {
  font-size: 11px; font-weight: 500; color: var(--fg-2);
  background: var(--sunken); border: 1px solid var(--line-3); border-radius: var(--r-sm);
  padding: 1px 7px;
}

/* ------- Tables ----------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
th {
  color: var(--faint); font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .12em;
  background: var(--card); position: sticky; top: 0;
}
td { font-variant-numeric: tabular-nums; }
tbody tr { transition: background .1s ease; }
tbody tr.t, tbody tr[onclick] { cursor: pointer; }
tbody tr.t:hover, tbody tr[onclick]:hover { background: var(--raise); }
tbody tr.sel { background: var(--acc-soft); box-shadow: inset 3px 0 0 var(--a2); }

/* ------- Chat bubbles (inbox / playground / dev console) ------------------ */
.bubble, .msg {
  max-width: 76%; padding: 10px 13px; border-radius: 14px;
  white-space: pre-wrap; word-wrap: break-word; font-size: 13.5px; line-height: 1.5;
  border: 1px solid transparent;
}
.bubble.in, .msg.bot {
  align-self: flex-start; background: var(--sunken);
  border-color: var(--line-3); border-bottom-left-radius: 4px;
}
.bubble.out, .msg.user {
  align-self: flex-end; background: rgba(79,123,255,.16); color: var(--fg);
  border-color: rgba(79,123,255,.35); border-bottom-right-radius: 4px;
}
.bubble .who { font-size: 11px; font-weight: 600; color: var(--mut); margin-bottom: 3px; }
.bubble.out .who { color: var(--link); }

/* ------- Gate (unauthenticated pages) ------------------------------------- */
.gate {
  max-width: 420px; margin: 12vh auto; text-align: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 32px 28px;
}
.gate h2 { font-size: 16px; margin: 0 0 8px; }
.gate p { color: var(--mut); margin: 0; }

/* ------- Sign-in screens (console, admin, workspace share one look) ------- */
.login-screen {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px;
  min-height: 100vh; background: var(--bg) !important;
}
.login-card {
  width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 32px 30px; box-shadow: var(--sh-2);
}
.login-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-card .brand .mark { width: 36px; height: 36px; flex: 0 0 36px; background: none !important; display: block; }
.login-card .brand .mark svg { width: 100%; height: 100%; display: block; }
.login-card .brand b {
  display: block; font-family: var(--display); font-stretch: 125%; font-weight: 900;
  font-size: 20px; letter-spacing: .02em; line-height: 1; color: #fff;
}
.login-card .brand span {
  display: block; margin-top: 5px; font-size: 10.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--faint);
}
.login-card h2 { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.login-card .lead { color: var(--mut); font-size: 13px; margin-bottom: 16px; }
.login-card button { width: 100%; margin-top: 18px; padding: 11px; }

/* ------- Utilities -------------------------------------------------------- */
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: grid; gap: 14px; }
.note { font-size: 12.5px; margin-top: 8px; min-height: 16px; }
code {
  font: 12px/1.4 var(--mono); background: var(--sunken); border: 1px solid var(--line-3);
  padding: 1px 6px; border-radius: var(--r-sm); color: var(--fg-2);
}
pre {
  font: 12px/1.55 var(--mono); background: var(--field);
  border: 1px solid var(--line-3); border-radius: var(--r);
  padding: 12px; overflow: auto; white-space: pre-wrap; color: var(--fg-2); margin: 0;
}
.divider { height: 1px; background: var(--line); margin: 14px 0; }

/* Quiet scrollbars */
* { scrollbar-width: thin; scrollbar-color: #262A3D transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #262A3D; border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #343A55; background-clip: content-box; }

/* Responsive: collapse the sidebar to icons on tablets (phones get a drawer — see "Mobile" below) */
@media (min-width: 761px) and (max-width: 900px) {
  :root { --side-w: 64px; }
  .side-brand .txt, .side-user .u, .side-sep, .side-nav a span, .side-foot button span { display: none; }
  .side-nav { padding: 4px 10px 12px; }
  .side-nav a { justify-content: center; padding: 10px; }
  .side-nav a.active::before { left: -11px; }
  .side-brand { justify-content: center; padding: 18px 0 14px; }
  .side-user { justify-content: center; padding: 8px; border: 0; background: none; }
  .topbar { padding: 0 20px; }
  .content.pad { padding: 24px 20px; }
}

/* ============================================================================
   Interface marker. Console, admin platform and agency workspace share ONE
   look; the breadcrumb ("Operations / …", "Admin / …", "Workspace / …") says
   which one you're in.
   ============================================================================ */

/* Admin building blocks (studio, playground, versions, review) */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; }
.stat .v { font-size: 28px; color: #fff; }
.stat .k { font-size: 12.5px; color: var(--mut); margin-top: 8px; }
.banner { border-radius: var(--r); padding: 11px 13px; font-size: 13px; border: 1px solid transparent; }
.banner.warn { background: var(--warn-bg); color: var(--warn); border-color: rgba(251,191,36,.25); }
.banner.info { background: var(--info-bg); color: var(--info); border-color: rgba(34,211,238,.25); }
.banner.ok   { background: var(--ok-bg); color: var(--ok); border-color: rgba(52,211,153,.25); }
.banner ul { margin: 4px 0 0 18px; padding: 0; }
.list-item { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; background: var(--field); }
.list-item + .list-item { margin-top: 10px; }
.list-item.off { opacity: .5; }
.list-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-head input[type=text], .list-head .grow { flex: 1; min-width: 160px; }
.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--mut); cursor: pointer; margin: 0; user-select: none; }
.switch input { width: auto; margin: 0; }
.idx { width: 26px; height: 26px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: 0 0 26px; }
.list-item.off .idx { background: var(--sunken); color: var(--faint); }
.mono-area { font: 12.5px/1.5 var(--mono); }
.kbd { font: 11.5px var(--mono); background: var(--sunken); border: 1px solid var(--line-3); border-radius: 5px; padding: 1px 6px; color: var(--mut); }
.trace { font: 12px/1.45 var(--mono); background: var(--field); border: 1px solid var(--line-3); border-radius: var(--r); padding: 8px 10px; margin-top: 6px; white-space: pre-wrap; word-break: break-word; color: var(--fg-2); }
.trace.fail { border-color: rgba(248,113,113,.3); background: var(--bad-bg); }
details > summary { cursor: pointer; font-size: 12.5px; color: var(--mut); }
.modal-back { position: fixed; inset: 0; background: rgba(3,4,8,.72); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--card); border: 1px solid var(--line-3); border-radius: var(--r-lg); box-shadow: var(--sh-2); width: min(860px, 100%); max-height: 88vh; display: flex; flex-direction: column; }
.modal-head, .modal-foot { display: flex; align-items: center; gap: 8px; padding: 14px 18px; }
.modal-head { border-bottom: 1px solid var(--line); }
.modal-foot { border-top: 1px solid var(--line); justify-content: flex-end; }
.modal-body { padding: 18px; overflow: auto; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 120; padding: 11px 15px; border-radius: var(--r); font-size: 13px; font-weight: 600; box-shadow: var(--sh-2); border: 1px solid var(--line-3); background: var(--sunken); color: var(--fg); transition: opacity .4s ease, transform .4s ease; }
.toast.ok { color: var(--ok); border-color: rgba(52,211,153,.35); } .toast.bad { color: var(--bad); border-color: rgba(248,113,113,.35); } .toast.info { color: var(--info); border-color: rgba(34,211,238,.35); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ============================================================================
   Agency workspace (/workspace/*) + "working inside a client" banner
   ============================================================================ */
.side [data-platform] { display: none; }
body.is-platform .side [data-platform] { display: flex; }

.acting-bar { display: flex; align-items: center; gap: 10px; padding: 8px 32px; font-size: 13px;
  background: #15120A; color: var(--warn); border-bottom: 1px solid rgba(251,191,36,.25); position: sticky; top: 0; z-index: 25; }
.acting-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.acting-bar b { color: #fff; }
.acting-bar a { color: var(--warn); font-weight: 600; }
.acting-bar button.mini { background: transparent; color: var(--warn); border-color: rgba(251,191,36,.4); box-shadow: none; }
body.has-shell .acting-bar ~ .topbar { top: 37px; }

.progress { height: 8px; background: var(--sunken); border-radius: 999px; overflow: hidden; min-width: 90px; }
.progress > i { display: block; height: 100%; background: var(--grad); border-radius: 999px; }
.progress.warn > i { background: var(--warn); }
.trk-step { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.trk-step:first-child { border-top: 0; }
.trk-step .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700;
  border: 2px solid var(--line-3); color: var(--faint); margin-top: 1px; }
.trk-step.done .ic { background: var(--ok); border-color: var(--ok); color: #05130D; }
.trk-step.skipped .ic { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.trk-step .t { font-weight: 600; font-size: 14px; }
.trk-step .d { font-size: 12.5px; color: var(--mut); margin-top: 2px; }
.trk-step.todo.next { background: var(--acc-soft); border: 1px solid var(--line-3); margin: 0 -22px; padding: 12px 22px; border-radius: var(--r); }
.trk-step .how { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--fg-2); }
.trk-step .how li { margin: 3px 0; }
.trk-step .meta { font-size: 11.5px; color: var(--faint); margin-top: 4px; }
.trk-step .acts { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; justify-content: flex-end; }
.tag { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; padding: 2px 6px;
  border-radius: 4px; background: var(--sunken); color: var(--mut); margin-left: 6px; vertical-align: 1px; }
.tag.auto { background: var(--info-bg); color: var(--info); }
.st-onboarding { background: var(--info-bg); color: var(--info); }
.st-live { background: var(--ok-bg); color: var(--ok); }
.st-suspended { background: var(--bad-bg); color: var(--bad); }
.st-offboarding { background: var(--warn-bg); color: var(--warn); }
.st-offboarded, .st-purged { background: var(--sunken); color: var(--mut); }
[data-owner] { display: none !important; }
body.is-owner [data-owner] { display: inline-flex !important; }

/* ============================================================================
   Mobile (≤760px) — staff run the inbox and tickets from their phones.
     • the sidebar becomes a slide-in drawer opened from the ☰ in the top bar
       (console.js injects the button + backdrop; nothing to add per page)
     • list/detail pages (inbox, tickets) show ONE pane at a time: mark the panes
       with data-pane="list|detail" and call Lilly.openDetail()/closeDetail()
     • 16px form text so iOS Safari doesn't zoom the page on focus; finger-sized
       buttons; wide tables scroll sideways; dialogs become bottom sheets
   ============================================================================ */
.nav-toggle, .side-backdrop, .pane-back { display: none; }


@media (max-width: 760px) {
  body.has-shell { display: block; }
  .main { min-height: 100vh; min-height: 100dvh; }

  /* Drawer */
  .side {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 200;
    width: min(84vw, 288px); height: 100%;
    transform: translateX(-100%); transition: transform .22s ease, box-shadow .22s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.nav-open .side { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.7); }
  .side-backdrop {
    display: block; position: fixed; inset: 0; z-index: 190;
    background: rgba(3,4,8,.7); opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  body.nav-open .side-backdrop { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .side-nav a { min-height: 44px; font-size: 15px; }
  .side-sep { padding-top: 16px; }

  .nav-toggle {
    display: inline-flex; flex: 0 0 auto; width: 40px; height: 40px; min-height: 40px; padding: 0; margin-left: -6px;
    background: transparent; color: var(--fg); border: 0; box-shadow: none;
  }
  .nav-toggle:hover { background: var(--sunken); filter: none; }
  .nav-toggle svg { width: 22px; height: 22px; }
  body.signed-out .nav-toggle { display: none; }

  /* Top bar: compact, wraps extra actions onto a second line instead of overflowing */
  .topbar {
    height: auto; min-height: 56px; flex-wrap: wrap; gap: 6px 8px;
    padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top));
  }
  .topbar .crumb { display: none; }
  .topbar h1 { font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .sub, .topbar .who { display: none; }
  .topbar select { max-width: 100%; }

  .acting-bar { position: static; flex-wrap: wrap; padding: 8px 12px; }
  body.has-shell .acting-bar ~ .topbar { top: 0; }

  .content.pad { padding: 18px 12px calc(28px + env(safe-area-inset-bottom)); }
  .card { padding: 16px; }
  .gate { margin: 8vh 12px; padding: 26px 20px; }
  .hero h1, .hero h2 { font-size: 26px; }

  /* Forms & touch targets */
  input, select, textarea { font-size: 16px; padding: 10px 12px; }
  select { padding-right: 32px; }
  input[type=checkbox], input[type=radio] { width: 18px; height: 18px; padding: 0; }
  button, .btn { min-height: 42px; }
  button.mini, .btn.mini { min-height: 36px; padding: 6px 12px; font-size: 13px; }
  .field-row > div { min-width: 120px; }

  /* Tables & content blocks (console.js wraps bare tables in .tscroll) */
  .tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  th, td { padding: 9px 10px; }
  .bubble, .msg { max-width: 88%; font-size: 15px; }
  .trk-step { grid-template-columns: 26px 1fr; }
  .trk-step .acts { grid-column: 2; justify-content: flex-start; }
  .trk-step.todo.next { margin: 0 -16px; padding: 12px 16px; }

  /* Dialogs become bottom sheets; toasts sit above the home indicator */
  .modal-back { padding: 0; place-items: end stretch; }
  .modal { width: 100%; max-height: 92dvh; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .modal-foot { flex-wrap: wrap; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .toast { left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); text-align: center; }

  /* List/detail: one pane at a time */
  body.pane-split .main { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
  body.pane-split [data-pane] { width: 100% !important; flex: 1 1 auto !important; border-right: 0 !important; }
  body.pane-split:not(.pane-detail) [data-pane="detail"],
  body.pane-split.pane-detail [data-pane="list"] { display: none !important; }
  .pane-back {
    display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 6px 10px 6px 6px;
    background: transparent; color: var(--fg); border: 0; font-weight: 600; margin-left: -6px; box-shadow: none;
  }
  .pane-back:hover { background: var(--sunken); filter: none; }
}
