/* Apex Alignment Systems — Command Center. Brushed steel on deep navy. */
:root {
  --navy-950: #0a1120; --navy-900: #0c1526; --navy-850: #0f1b30; --navy-800: #12213a;
  --navy-750: #16273f; --navy-700: #1a2e49; --line: #26405f; --line-soft: #1d3149;
  --steel-50: #f4f7fb; --steel-100: #e4e9f0; --steel-200: #cbd4df; --steel-300: #a6b1c1;
  --steel-400: #8791a2; --ink: #e9eef5; --ink-dim: #9fabbd; --ink-faint: #6c7a8e;
  --good: #52c98a; --good-dim: rgba(82,201,138,.14); --warn: #e8b155; --warn-dim: rgba(232,177,85,.14);
  --bad: #e8776a; --info: #7fa8ff; --focus: #9ec1ff;
  --steel-grad: linear-gradient(135deg, #f4f7fb 0%, #bcc5d1 46%, #8b95a2 56%, #d6dde5 100%);
  --r: 14px; --r-sm: 9px; --shadow: 0 10px 34px rgba(0,0,0,.4);
  --space: 20px; --sidebar: 244px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--navy-950); line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; }
a { color: inherit; }
code { font-family: var(--mono); font-size: .9em; color: var(--steel-200); background: rgba(255,255,255,.05); padding: 1px 5px; border-radius: 5px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -48px; z-index: 40; background: var(--steel-50); color: var(--navy-900); padding: 10px 16px; border-radius: 8px; font-weight: 700; text-decoration: none; transition: top .15s; }
.skip-link:focus { top: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* Shell */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

/* Sidebar */
.sidebar {
  background: linear-gradient(180deg, var(--navy-850), var(--navy-950));
  border-right: 1px solid var(--line-soft); padding: 22px 16px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar__brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.sidebar__logo { filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); flex: none; }
.sidebar__name { font-size: 12.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; line-height: 1.35; background: var(--steel-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sidebar__name em { font-style: normal; color: var(--ink-dim); -webkit-text-fill-color: var(--ink-dim); font-weight: 600; letter-spacing: .16em; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav__item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-dim);
  background: transparent; border: 0; border-radius: var(--r-sm); padding: 10px 12px; cursor: pointer; transition: background .12s, color .12s;
}
.nav__item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav__item:hover { background: rgba(255,255,255,.04); color: var(--ink); }
.nav__item[aria-current="page"] { background: linear-gradient(135deg, rgba(127,168,255,.16), rgba(127,168,255,.06)); color: var(--steel-50); box-shadow: inset 0 0 0 1px var(--line); }
.nav__badge { margin-left: auto; background: var(--warn); color: #3a2b06; font-size: 11px; font-weight: 800; min-width: 20px; height: 20px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }
.sidebar__foot { margin-top: auto; display: grid; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-dim); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; }
.pill--muted { color: var(--ink-faint); justify-content: center; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 9px var(--good); flex: none; }
.pill .dot--warn { background: var(--warn); box-shadow: 0 0 9px var(--warn); }
.pill .dot--bad { background: var(--bad); box-shadow: 0 0 9px var(--bad); }
.sysbar { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.sysbar .pill { padding: 5px 11px; font-size: 12px; }

/* Main */
.main { min-width: 0; display: flex; flex-direction: column; background: radial-gradient(1100px 600px at 78% -12%, #16294a 0%, transparent 62%); }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 22px clamp(18px, 3vw, 34px) 16px; border-bottom: 1px solid var(--line-soft); }
.topbar__title h1 { font-size: clamp(20px, 2.6vw, 26px); font-weight: 800; letter-spacing: -.01em; }
.topbar__sub { margin: 3px 0 0; color: var(--ink-dim); font-size: 13.5px; }
.topbar__actions { display: flex; align-items: center; gap: 12px; }
.topbar__updated { font-size: 12px; color: var(--ink-faint); font-family: var(--mono); }

.view { padding: clamp(18px, 3vw, 30px); outline: none; }
.panelview { display: grid; gap: var(--space); animation: fade .25s ease; }
.panelview[hidden] { display: none; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.lede { margin: 0; color: var(--ink-dim); font-size: 14px; max-width: 70ch; }

.grid2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: var(--space); align-items: start; }
.stack { display: grid; gap: var(--space); }
@media (max-width: 980px) { .grid2 { grid-template-columns: 1fr; } }

.card { background: linear-gradient(180deg, var(--navy-750), var(--navy-850)); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card h2 { font-size: 13px; letter-spacing: .07em; text-transform: uppercase; color: var(--steel-200); margin-bottom: 12px; }
.card__head h2 { margin: 0; }
.link { color: var(--info); font-size: 13px; font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }
.note { color: var(--ink-dim); font-size: 13px; margin: 0 0 12px; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat { background: linear-gradient(180deg, var(--navy-750), var(--navy-800)); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 16px 18px; position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--steel-grad); opacity: .8; }
.stat__num { font-size: clamp(24px, 3vw, 32px); font-weight: 800; color: var(--steel-50); line-height: 1.05; letter-spacing: -.02em; }
.stat__label { font-size: 12px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .08em; margin-top: 5px; }
.stat--alert::before { background: linear-gradient(180deg, var(--warn), #b98726); }
.stat--alert .stat__num { color: var(--warn); }

/* Approval cards */
.acards { display: grid; gap: 12px; }
.acard { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px 16px; background: rgba(255,255,255,.015); display: grid; gap: 10px; }
.acard__top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.acard__action { font-size: 14.5px; color: var(--ink); }
.acard__btns { display: flex; gap: 9px; }
.tag { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; font-weight: 700; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); color: var(--ink-dim); }
.tag--marketing { color: #9fc0ff; border-color: #35507a; }
.tag--social { color: #c8a9ff; border-color: #4a3f78; }
.tag--ops { color: #ffcf8a; border-color: #6a5330; }
.tag--sdr { color: #86e3c0; border-color: #2f6a55; }
.tag--csr, .tag--cs { color: #a9d0ff; border-color: #35507a; }
.tag--money { color: #ffd27a; border-color: #7a5a1e; background: var(--warn-dim); }
.empty { color: var(--ink-dim); text-align: center; padding: 22px; border: 1px dashed var(--line); border-radius: var(--r-sm); }
.grouphead { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); margin: 4px 0 10px; font-weight: 700; }

/* Buttons */
.btn { font: inherit; font-weight: 700; border-radius: var(--r-sm); padding: 9px 16px; cursor: pointer; border: 1px solid transparent; transition: transform .1s, background .12s, border-color .12s; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn--approve, .btn--primary { background: var(--good); color: #06231a; }
.btn--approve:hover, .btn--primary:hover { background: #6ad79a; }
.btn--reject { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--reject:hover { border-color: var(--bad); color: #ffb3aa; }
.btn--ghost { background: rgba(255,255,255,.03); color: var(--steel-200); border-color: var(--line); }
.btn--ghost:hover { border-color: #35507a; color: var(--steel-50); }

/* Engine mini (overview) + engine grid */
.enginemini { display: grid; gap: 8px; }
.emini { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.emini:last-child { border-bottom: 0; }
.engrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space); }
.engine { background: linear-gradient(180deg, var(--navy-750), var(--navy-850)); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 18px; display: grid; gap: 12px; }
.engine__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.engine__name { font-size: 15px; font-weight: 800; color: var(--steel-50); }
.engine__tag { color: var(--ink-dim); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 11.5px; font-weight: 600; padding: 4px 9px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); color: var(--ink-dim); }
.chip__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); }
.chip--ready { color: #bfe9d1; border-color: #2f6a55; background: var(--good-dim); }
.chip--ready .chip__dot { background: var(--good); box-shadow: 0 0 7px var(--good); }
.badge-auto { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge-auto--on { color: #bfe9d1; background: var(--good-dim); }
.badge-auto--off { color: var(--ink-dim); background: rgba(255,255,255,.05); }

/* Pipeline board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(180px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.col { background: rgba(255,255,255,.02); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 12px; min-height: 120px; }
.col__head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-dim); margin-bottom: 10px; }
.col__count { background: rgba(255,255,255,.08); border-radius: 999px; padding: 1px 8px; font-weight: 700; }
.leadchip { background: linear-gradient(180deg, var(--navy-700), var(--navy-800)); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 9px 11px; margin-bottom: 8px; }
.leadchip__co { font-size: 13px; color: var(--ink); font-weight: 600; }
.leadchip__meta { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; display: flex; justify-content: space-between; }
.chipacts { display: flex; gap: 6px; margin-top: 8px; }
.mini { font: inherit; font-size: 11px; font-weight: 700; color: var(--ink-dim); background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; cursor: pointer; transition: .15s; }
.mini:hover { color: var(--good); border-color: var(--good); }
.mini--warn:hover { color: var(--warn); border-color: var(--warn); }
.mini--bad:hover { color: var(--bad); border-color: var(--bad); }
.mini:disabled { opacity: .5; cursor: default; }

/* Feed */
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.feed--full { max-height: 62vh; overflow-y: auto; }
.feed__row { display: grid; gap: 2px; padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,.05); }
.feed__row:last-child { border-bottom: 0; }
.feed__meta { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .05em; }
.feed__reason { font-size: 13px; color: var(--ink); }

/* Autonomy */
.switch { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; color: var(--ink); cursor: pointer; margin-bottom: 14px; }
.switch input, .toggles input { width: 18px; height: 18px; accent-color: var(--good); }
.policy { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
@media (max-width: 560px) { .policy { grid-template-columns: 1fr; } }
.field { display: grid; gap: 5px; }
.field label { font-size: 13px; color: var(--steel-200); }
.field input[type=number] { width: 100px; font: inherit; padding: 9px 11px; border-radius: var(--r-sm); background: rgba(0,0,0,.28); border: 1px solid var(--line); color: var(--ink); }
.toggles { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; display: grid; gap: 9px; margin: 0; }
.toggles label { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink); }
.runs { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 14px; }
.digest { margin: 0; white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; color: var(--ink-dim); background: rgba(0,0,0,.28); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px; overflow-x: auto; min-height: 40px; }

/* Inbox */
.threads { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.thread { text-align: left; width: 100%; font: inherit; background: rgba(255,255,255,.015); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 12px 14px; cursor: pointer; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.thread:hover { border-color: #35507a; }
.thread__ch { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); color: var(--ink-dim); white-space: nowrap; }
.thread__body { min-width: 0; }
.thread__name { font-size: 13.5px; font-weight: 600; color: var(--steel-50); }
.thread__last { font-size: 12.5px; color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread__meta { font-size: 11px; color: var(--ink-faint); font-family: var(--mono); white-space: nowrap; }

/* Contacts + drawer */
.search { width: 100%; max-width: 420px; font: inherit; padding: 11px 14px; border-radius: var(--r-sm); background: rgba(0,0,0,.28); border: 1px solid var(--line); color: var(--ink); }
.contactgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.contact { text-align: left; font: inherit; background: linear-gradient(180deg, var(--navy-750), var(--navy-850)); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 15px; cursor: pointer; display: grid; gap: 6px; }
.contact:hover { border-color: #35507a; }
.contact__name { font-size: 14.5px; font-weight: 700; color: var(--steel-50); }
.contact__co { font-size: 12.5px; color: var(--ink-dim); }
.contact__row { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.contact__type { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; }
.contact__type--client { color: #bfe9d1; background: var(--good-dim); }
.contact__type--lead { color: #a9d0ff; background: rgba(127,168,255,.12); }

.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer__scrim { position: absolute; inset: 0; background: rgba(4,8,16,.6); backdrop-filter: blur(2px); }
.drawer__panel { position: absolute; top: 0; right: 0; height: 100%; width: min(520px, 94vw); background: linear-gradient(180deg, var(--navy-800), var(--navy-900)); border-left: 1px solid var(--line); box-shadow: -20px 0 50px rgba(0,0,0,.5); padding: 22px; overflow-y: auto; animation: slidein .2s ease; }
@keyframes slidein { from { transform: translateX(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.drawer__head h2 { font-size: 18px; font-weight: 800; color: var(--steel-50); }
.drawer__close { background: transparent; border: 1px solid var(--line); color: var(--ink-dim); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; font-size: 14px; }
.drawer__close:hover { color: var(--ink); border-color: var(--bad); }
.drawer__meta { color: var(--ink-dim); font-size: 13px; margin-bottom: 16px; }
.tl { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 16px; display: grid; gap: 14px; }
.tl__sec { display: grid; gap: 6px; }
.tl__h { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); font-weight: 700; }
.tl__item { font-size: 13px; color: var(--ink); background: rgba(255,255,255,.02); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 9px 11px; }
.tl__item small { display: block; color: var(--ink-faint); font-size: 11px; margin-top: 2px; }

/* Report charts */
.hbars { display: grid; gap: 9px; }
.hbar { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar__label { color: var(--ink-dim); text-transform: capitalize; }
.hbar__track { height: 12px; background: rgba(255,255,255,.05); border-radius: 6px; overflow: hidden; }
.hbar__fill { height: 100%; background: var(--steel-grad); border-radius: 6px; min-width: 3px; }
.hbar__val { color: var(--steel-200); font-variant-numeric: tabular-nums; }
.revrow { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.revrow:last-child { border-bottom: 0; }
.revrow__label { color: var(--ink-dim); font-size: 13.5px; }
.revrow__val { font-size: 18px; font-weight: 800; color: var(--steel-50); }
.revrow__val--good { color: var(--good); }
.revrow__val--warn { color: var(--warn); }

/* Business views: forms, appointments, training, deal cards */
.addform { background: rgba(255,255,255,.02); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 4px 14px; }
.addform summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--info); padding: 8px 0; }
.miniform { display: flex; gap: 10px; flex-wrap: wrap; padding: 4px 0 12px; }
.miniform input { font: inherit; padding: 9px 11px; border-radius: var(--r-sm); background: rgba(0,0,0,.28); border: 1px solid var(--line); color: var(--ink); min-width: 140px; }
.dealcard { background: linear-gradient(180deg, var(--navy-700), var(--navy-800)); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 8px; }
.dealcard__co { font-size: 13px; font-weight: 600; color: var(--ink); }
.dealcard__val { font-size: 13px; color: var(--good); font-weight: 700; margin-top: 2px; }
.dealcard__adv { display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.dealcard__adv button { font: inherit; font-size: 11px; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); background: rgba(255,255,255,.03); color: var(--ink-dim); cursor: pointer; }
.dealcard__adv button:hover { color: var(--steel-50); border-color: var(--info); }
.apptlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.appt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line-soft); border-radius: var(--r-sm); background: rgba(255,255,255,.015); }
.appt__when { font-family: var(--mono); font-size: 12.5px; color: var(--info); min-width: 130px; }
.appt__title { font-size: 14px; color: var(--ink); }
.appt__meta { font-size: 12px; color: var(--ink-faint); }
.trainrow { margin-bottom: 18px; }
.trainrow h3 { font-size: 14px; color: var(--steel-50); margin: 0 0 4px; }
.trainbar { height: 10px; background: rgba(255,255,255,.06); border-radius: 6px; overflow: hidden; margin: 8px 0; }
.trainbar i { display: block; height: 100%; background: var(--steel-grad); }
.trainmods { display: grid; gap: 6px; }
.trainmod { display: flex; align-items: center; justify-content: space-between; font-size: 13px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.04); }

/* Architect */
.warnbar { background: var(--warn-dim); border: 1px solid #6a5330; color: #ffdca0; border-radius: var(--r-sm); padding: 12px 16px; font-size: 13px; }
.subtabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line-soft); }
.subtab { font: inherit; font-size: 13.5px; font-weight: 700; color: var(--ink-dim); background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; cursor: pointer; }
.subtab[aria-selected="true"] { color: var(--steel-50); border-bottom-color: var(--info); }
.subtab:hover { color: var(--ink); }
.archsave { margin-top: 16px; }

.keygroup { margin-bottom: 18px; }
.keygroup h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); margin: 0 0 10px; font-weight: 700; }
.keyrow { display: grid; grid-template-columns: 200px 1fr auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.04); }
@media (max-width: 640px) { .keyrow { grid-template-columns: 1fr; gap: 6px; } }
.keyrow label { font-size: 13px; color: var(--steel-200); }
.keyrow input { font: inherit; padding: 8px 11px; border-radius: var(--r-sm); background: rgba(0,0,0,.28); border: 1px solid var(--line); color: var(--ink); width: 100%; }
.keyrow input::placeholder { color: var(--ink-faint); }
.keystate { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.keystate--set { color: #bfe9d1; background: var(--good-dim); }
.keystate--unset { color: var(--ink-faint); background: rgba(255,255,255,.05); }

.promptlist, .kblist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 60vh; overflow-y: auto; }
.promptlist button, .kblist button { width: 100%; text-align: left; font: inherit; background: rgba(255,255,255,.02); border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 10px 12px; color: var(--ink); cursor: pointer; }
.promptlist button:hover, .kblist button:hover { border-color: #35507a; }
.promptlist small, .kblist small { display: block; color: var(--ink-faint); font-size: 11.5px; margin-top: 2px; }
.editor { display: grid; gap: 12px; }
.editor label { font-size: 12px; color: var(--ink-dim); display: grid; gap: 5px; }
.editor input, .editor textarea, .kbform input, .kbform textarea, .kbform select { font: inherit; padding: 9px 11px; border-radius: var(--r-sm); background: rgba(0,0,0,.28); border: 1px solid var(--line); color: var(--ink); width: 100%; }
.editor textarea, .kbform textarea { min-height: 120px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
.editor .row2 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.kbform { display: grid; gap: 12px; }
.kbform label { font-size: 12px; color: var(--ink-dim); display: grid; gap: 5px; }

.tablepick { display: flex; gap: 8px; flex-wrap: wrap; }
.tablepick button { font: inherit; font-size: 13px; font-weight: 600; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,.03); color: var(--ink-dim); cursor: pointer; }
.tablepick button[aria-pressed="true"] { color: var(--steel-50); border-color: var(--info); background: rgba(127,168,255,.12); }
.datawrap { overflow-x: auto; }
.datatable { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.datatable th { text-align: left; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--navy-800); }
.datatable td { padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,.04); color: var(--ink); vertical-align: top; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Login */
.login { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: linear-gradient(160deg, var(--navy-850), var(--navy-950)); }
/* The `hidden` attribute must win over `display: grid` above (author display rules otherwise
   override the attribute), or the overlay stays on screen with the app rendering behind it. */
.login[hidden] { display: none; }
.login__box { background: linear-gradient(180deg, var(--navy-750), var(--navy-850)); border: 1px solid var(--line); border-radius: var(--r); padding: 32px; width: min(360px, 92vw); display: grid; gap: 12px; justify-items: center; box-shadow: var(--shadow); text-align: center; }
.login__box img { filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.login__box h1 { font-size: 18px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; background: var(--steel-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login__box p { color: var(--ink-dim); font-size: 13px; margin: 0 0 8px; }
.login__box input { width: 100%; font: inherit; padding: 11px 14px; border-radius: var(--r-sm); background: rgba(0,0,0,.3); border: 1px solid var(--line); color: var(--ink); }
.login__box .btn { width: 100%; }
.login__err { color: var(--bad); font-size: 12.5px; min-height: 16px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--steel-50); color: var(--navy-900); font-weight: 700; padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow); z-index: 50; max-width: 90vw; }
.toast--bad { background: #ffdad4; }

/* Responsive: collapse sidebar to a top strip */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav__item { padding: 8px 10px; }
  .sidebar__foot { margin: 0; flex-direction: row; }
}

/* Insights (daily / weekly / monthly / quarterly) */
.insights-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space); align-items: start; }
@media (max-width: 1100px) { .insights-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .insights-grid { grid-template-columns: 1fr; } }
.insights-col h2 { font-size: 14px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-dim); margin: 0 0 14px; }
.insights-rows { display: flex; flex-direction: column; gap: 2px; }
.insights-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.insights-row:last-child { border-bottom: 0; }
.insights-row__label { color: var(--ink-dim); font-size: 13px; }
.insights-row__val { color: var(--ink); font-family: var(--mono); font-size: 16px; font-weight: 600; }
.insights-row--zero .insights-row__val { color: var(--ink-faint); font-weight: 400; }
