/* Eggplant Control Room. Phone first; the computer layout adds a sidebar at 960px.
   Colours come from the 37 Mulberry brand tokens (brand-tokens.css, loaded first). */

@font-face { font-family: Lato; src: url(../fonts/lato-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Lato; src: url(../fonts/lato-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: Lato; src: url(../fonts/lato-latin-900-normal.woff2) format("woff2"); font-weight: 900; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(../fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(../fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --bg: #F7F5FA;
  --surface: #FFFFFF;
  --surface-2: var(--ea-mist);
  --border: #E6E0EE;
  --border-strong: #D3C9E0;
  --text: #1C1628;
  --text-2: #4A4158;
  --muted: var(--ea-slate);
  --accent: var(--ea-violet);
  --accent-soft: #EFE8FB;
  --accent-text: #FFFFFF;
  --link: var(--ea-neptune);
  --good: var(--ea-green);
  --good-soft: #E5F3EC;
  --bad: #B42318;
  --bad-soft: #FDECEA;
  --warn: #9A5B00;
  --warn-soft: #FFF3DC;
  --info-soft: #E8F0FD;
  --chart-1: var(--ea-violet);
  --chart-2: var(--ea-lavender);
  --chart-neg: #C4524A;
  --shadow: 0 1px 2px rgba(28, 22, 40, .06), 0 1px 1px rgba(28, 22, 40, .04);
  --radius: 12px;
  --radius-sm: 8px;
  --font: Lato, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --tabbar-h: 64px;
  --topbar-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--ea-night); --surface: #1C1929; --surface-2: #242036; --border: #2F2A44; --border-strong: #3C3656;
    --text: var(--ea-moon); --text-2: #CFC6DA; --muted: #A69CB5; --accent: var(--ea-lavender); --accent-soft: #2B2445;
    --accent-text: var(--ea-night); --link: var(--ea-ice); --good: var(--ea-green-dark); --good-soft: #17302A;
    --bad: #F59E94; --bad-soft: #3A1E22; --warn: #F5C46B; --warn-soft: #36290F; --info-soft: #1B2640;
    --chart-1: var(--ea-lavender); --chart-2: #6B5A9A; --chart-neg: #F08A80;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: var(--ea-night); --surface: #1C1929; --surface-2: #242036; --border: #2F2A44; --border-strong: #3C3656;
  --text: var(--ea-moon); --text-2: #CFC6DA; --muted: #A69CB5; --accent: var(--ea-lavender); --accent-soft: #2B2445;
  --accent-text: var(--ea-night); --link: var(--ea-ice); --good: var(--ea-green-dark); --good-soft: #17302A;
  --bad: #F59E94; --bad-soft: #3A1E22; --warn: #F5C46B; --warn-soft: #36290F; --info-soft: #1B2640;
  --chart-1: var(--ea-lavender); --chart-2: #6B5A9A; --chart-neg: #F08A80;
  --shadow: none; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 900; letter-spacing: -.2px; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0 0 .6em; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------ shell */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: 10px;
  padding: 0 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .mark { width: 30px; height: 30px; }
.topbar .title { font-weight: 900; font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main { padding: 16px 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.tabbar a, .tabbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font: 600 11px var(--font);
  color: var(--muted); background: none; border: 0; text-decoration: none; position: relative;
}
.tabbar svg { width: 24px; height: 24px; }
.tabbar .on { color: var(--accent); }
.tabbar .badge { position: absolute; top: 8px; left: calc(50% + 6px); }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 8, 18, .45); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--surface); border-radius: 18px 18px 0 0;
  padding: 8px 12px calc(16px + env(safe-area-inset-bottom)); max-height: 85vh; overflow: auto;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .2);
}
.sheet .grip { width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 4px auto 12px; }

.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-sec { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text-2); font-weight: 700;
  text-decoration: none; min-height: 44px;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.on { background: var(--accent-soft); color: var(--accent); }
.nav-item svg { width: 20px; height: 20px; flex: none; }
.nav-item .soon { margin-left: auto; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.nav-item .count { margin-left: auto; }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 240px 1fr; }
  .sidebar {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow: auto; padding: 18px 12px;
    background: var(--surface); border-right: 1px solid var(--border);
  }
  .sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 14px; }
  .sidebar .brand img { width: 34px; height: 34px; }
  .sidebar .brand b { display: block; font-weight: 900; font-size: 15px; letter-spacing: -.1px; }
  .sidebar .brand span { display: block; font-size: 11px; color: var(--muted); letter-spacing: 1.6px; text-transform: uppercase; }
  .sidebar .foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
  .topbar, .tabbar { display: none; }
  .main { padding: 28px 32px 48px; }
}

/* ------------------------------------------------------------ building blocks */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px 0; }
.card-head a { font-size: 13px; font-weight: 700; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; min-width: 20px; height: 20px; padding: 0 7px; border-radius: 10px;
  font: 700 11px/20px var(--font); background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.badge.accent { background: var(--accent); color: var(--accent-text); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.info { background: var(--info-soft); color: var(--link); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.dot.ok { background: var(--good); } .dot.stale, .dot.bad { background: var(--bad); } .dot.unknown { background: var(--warn); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 700 14px var(--font); cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn svg { width: 18px; height: 18px; }

input, select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 16px var(--font);  /* 16px stops iOS zooming */
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 4px; }
.field + .field { margin-top: 12px; }
.alert { padding: 10px 14px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-weight: 700; font-size: 14px; }
.alert.info { background: var(--info-soft); color: var(--link); }

/* ------------------------------------------------------------ KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 14px; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; min-height: 112px; }
.kpi:hover { text-decoration: none; border-color: var(--border-strong); }
.kpi .label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.kpi .value { font: 500 24px/1.15 var(--mono); letter-spacing: -.5px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .foot { font-size: 12.5px; color: var(--muted); margin-top: auto; padding-top: 6px; }
.kpi .value.neg { color: var(--bad); }
.kpi.alert-tile .value { color: var(--bad); }
.delta-up { color: var(--good); font-weight: 700; } .delta-down { color: var(--bad); font-weight: 700; }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } .kpi .value { font-size: 28px; } }

.home-grid { display: grid; gap: 12px; margin-top: 12px; }
@media (min-width: 1100px) { .home-grid { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); } }
.chart { width: 100%; height: 240px; }
@media (min-width: 720px) { .chart { height: 280px; } }

/* ------------------------------------------------------------ lists and cases */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--border); }
.list-row { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; color: inherit; text-decoration: none; }
.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-row .main-col { flex: 1; min-width: 0; }
.list-row .t { font-weight: 700; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.list-row .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12.5px; color: var(--muted); margin-top: 4px; align-items: center; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 14px; }

.prio { width: 4px; align-self: stretch; border-radius: 4px; background: var(--border); flex: none; }
.prio.p1 { background: var(--bad); } .prio.p2 { background: var(--warn); } .prio.p3 { background: var(--ea-lavender); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 -16px 12px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 18px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-weight: 700; font-size: 13.5px;
  text-decoration: none; white-space: nowrap;
}
.chip:hover { text-decoration: none; background: var(--surface-2); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip.on .badge { background: rgba(255,255,255,.22); color: inherit; }
@media (min-width: 960px) { .chips { margin: 0 0 14px; padding-left: 0; padding-right: 0; flex-wrap: wrap; } }

.filters { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 12px; }
.filters select { width: auto; }

/* table on a computer, cards on a phone */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .r { text-align: right; }
.case-cards { display: block; }
.case-table { display: none; }
@media (min-width: 960px) { .case-cards { display: none; } .case-table { display: block; } }

.ref { font: 500 12.5px var(--mono); color: var(--muted); }

/* case detail */
.detail { display: grid; gap: 12px; }
@media (min-width: 1100px) { .detail { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; } }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.facts dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; }
.facts dd { margin: 2px 0 0; font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0 16px 8px; }
.timeline li { position: relative; padding: 10px 0 10px 22px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 15px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline li.closed::before { background: var(--good); border-color: var(--good); }
.timeline li.escalated::before { background: var(--bad); border-color: var(--bad); }
.timeline .who { font-weight: 700; }
.timeline .when { color: var(--muted); font-size: 12.5px; }
.timeline .what { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ev { display: inline-flex; gap: 4px; align-items: center; font-size: 12.5px; margin: 4px 6px 0 0; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); }

.actions-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); z-index: 25;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; padding: 10px 12px; background: var(--surface);
  border-top: 1px solid var(--border);
}
.with-actions { padding-bottom: calc(var(--tabbar-h) + 84px + env(safe-area-inset-bottom)); }
@media (min-width: 1100px) { .actions-bar { display: none; } }
.side-actions { display: none; }
@media (min-width: 1100px) { .side-actions { display: block; } }
details.act { border-top: 1px solid var(--border); }
details.act > summary { list-style: none; cursor: pointer; padding: 12px 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; min-height: 44px; }
details.act > summary::-webkit-details-marker { display: none; }
details.act > summary::after { content: "›"; margin-left: auto; color: var(--muted); transition: transform .15s; }
details.act[open] > summary::after { transform: rotate(90deg); }
details.act form { padding: 0 16px 16px; }

dialog.panel { border: 0; padding: 0; border-radius: 18px 18px 0 0; width: 100%; max-width: 560px; margin: auto auto 0; background: var(--surface); color: var(--text); }
dialog.panel::backdrop { background: rgba(10, 8, 18, .45); }
dialog.panel .panel-head { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 900; }
dialog.panel .panel-body { padding: 16px; }
@media (min-width: 720px) { dialog.panel { border-radius: 16px; margin: auto; } }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px 24px; text-align: center; }
.login img.lockup { width: 230px; max-width: 100%; margin: 0 auto 8px; display: block; }

/* freshness strip */
.fresh { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); align-items: center; }
.fresh span { display: inline-flex; gap: 6px; align-items: center; }

.lockup-dark { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lockup-light { display: none; } :root:not([data-theme="light"]) .lockup-dark { display: block; } }
:root[data-theme="dark"] .lockup-light { display: none; }
:root[data-theme="dark"] .lockup-dark { display: block; }
.desk-only { display: none !important; }
@media (min-width: 960px) { .desk-only { display: inline-flex !important; } }
@media (min-width: 960px) { .shell { background: linear-gradient(to right, var(--surface) 240px, var(--bg) 240px); } }
