/*
 * EMP Next build tracker styles.
 * Desanders brand tokens (same as apps/web/src/plugins/vuetify.js), Sneat-like soft cards.
 * Light/dark follows the operating system.
 */
:root {
  --brand: #114a8e;
  --brand-mid: #2269b5;
  --brand-light: #54a3f7;
  --accent: #e58e26;
  --bg: #f5f6f9;
  --surface: #ffffff;
  --text: #3a3b3c;
  --muted: #6b7280;
  --border: #e3e6ec;
  --done: #2e9e57;
  --wip: #f5b000;
  --todo: #c9ced6;
  --danger: #ca1111;
  --shadow: 0 2px 6px rgba(34, 48, 62, 0.12);
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #54a3f7;
    --bg: #171c26;
    --surface: #202734;
    --text: #dce1e8;
    --muted: #98a2b3;
    --border: #2e3747;
    --todo: #3a4456;
    --danger: #e5484d;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 Roboto, system-ui, -apple-system, 'Segoe UI', sans-serif; }
h1, h2, h3 { font-family: Raleway, Roboto, system-ui, sans-serif; margin: 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
a { color: var(--brand-mid); }
main { max-width: 1280px; margin: 0 auto; padding: 16px; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--surface); box-shadow: var(--shadow); position: sticky; top: 0; z-index: 5; }
.logo { height: 34px; width: auto; display: block; }
.title h1 { font-size: 18px; font-weight: 700; color: var(--brand); }
.subtitle { color: var(--muted); font-size: 12px; }
.conn { margin-left: auto; font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--todo); color: var(--text); }
.conn.live { background: color-mix(in srgb, var(--done) 18%, transparent); color: var(--done); }
.conn.live::before { content: '● '; }
.conn.down { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }

/* Summary cards */
.summary { display: grid; grid-template-columns: 260px 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 860px) { .summary { grid-template-columns: 1fr; } }
.card { background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); padding: 16px; }
.overall { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.ring { width: 140px; height: 140px; border-radius: 50%; display: grid; place-items: center; }
.ring > div { width: 112px; height: 112px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; }
.ring b { font-size: 28px; font-family: Raleway, Roboto, sans-serif; color: var(--brand); display: block; }
.ring span { font-size: 11px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; cursor: default; }
.stat b { display: block; font-size: 20px; font-family: Raleway, Roboto, sans-serif; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.click { cursor: pointer; }
.stat.click:hover { border-color: var(--brand-light); }
.stagebars { display: grid; gap: 6px; }
.stagebar { display: grid; grid-template-columns: 70px 1fr 110px; align-items: center; gap: 10px; font-size: 12px; }
.bar { height: 10px; border-radius: 999px; background: var(--todo); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar .d { background: var(--done); }
.bar .w { background: var(--wip); }

/* Tabs */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 8px 14px; border-radius: 6px; font: inherit; cursor: pointer; }
.tabs button.active { background: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { .tabs button.active { color: #0d1726; } }
.tabs button .n { opacity: 0.75; font-size: 12px; margin-left: 4px; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters input[type=search], .filters select { font: inherit; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.filters input[type=search] { min-width: 280px; flex: 1; }
.chip-toggle { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 5px 10px; border-radius: 999px; font: inherit; font-size: 12px; cursor: pointer; }
.chip-toggle.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand-light) 18%, transparent); color: var(--brand); }
.linkbtn { border: 0; background: none; color: var(--brand-mid); cursor: pointer; font: inherit; font-size: 12px; padding: 4px; }

/* Modules + items */
.module { background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); margin-bottom: 10px; overflow: hidden; }
.module-head { width: 100%; display: grid; grid-template-columns: 70px 1fr 220px 64px; align-items: center; gap: 12px; padding: 12px 16px; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-align: left; }
@media (max-width: 760px) { .module-head { grid-template-columns: 56px 1fr 64px; } .module-head .bar { display: none; } }
.module-head h3 { font-size: 15px; font-weight: 600; }
.module-head .meta { color: var(--muted); font-size: 12px; }
.mid { font-weight: 700; color: var(--brand); font-family: Raleway, Roboto, sans-serif; }
abbr.code { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.pct { text-align: right; font-weight: 600; }
.items { border-top: 1px solid var(--border); }
.item { border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: 0; }
.item-head { width: 100%; display: grid; grid-template-columns: 48px minmax(200px, 1fr) auto 18px 132px; gap: 10px; align-items: center; padding: 7px 16px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.item-head:hover { background: color-mix(in srgb, var(--brand-light) 7%, transparent); }
@media (max-width: 760px) { .item-head { grid-template-columns: 40px 1fr 110px; } .item-head .badges, .item-head .usage { display: none; } }
.seq { color: var(--muted); font-size: 12px; text-align: right; }
.url { font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.url .app { color: var(--accent); }
.badges { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.badge { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: color-mix(in srgb, var(--brand-light) 16%, transparent); color: var(--brand); white-space: nowrap; }
.badge.writes { background: color-mix(in srgb, var(--danger) 13%, transparent); color: var(--danger); }
.badge.email { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.badge.cron { background: color-mix(in srgb, var(--wip) 22%, transparent); color: #9a6b00; }
@media (prefers-color-scheme: dark) { .badge.cron { color: var(--wip); } }
.usage { width: 10px; height: 10px; border-radius: 50%; justify-self: center; }
.usage.used { background: var(--done); }
.usage.external { background: var(--brand-mid); }
.usage.internal { background: var(--wip); }
.usage.unreferenced { background: transparent; border: 2px solid var(--muted); }
.stages { display: flex; gap: 3px; justify-content: flex-end; }
.st { width: 22px; height: 18px; border-radius: 4px; font-size: 10px; font-style: normal; display: grid; place-items: center; background: var(--todo); color: var(--muted); font-weight: 600; }
.st.done { background: var(--done); color: #fff; }
.st.wip { background: var(--wip); color: #3a2a00; }
.st.na { background: repeating-linear-gradient(45deg, transparent 0 3px, var(--border) 3px 5px); color: transparent; }
.item.flash { animation: flash 3s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--accent) 35%, transparent); } to { background: transparent; } }

/* Sprints */
.sprint.wip { box-shadow: inset 4px 0 var(--wip), var(--shadow); }
.sprint-head { display: grid; grid-template-columns: 70px 1fr auto; align-items: center; gap: 12px; padding: 12px 16px; }
.sprint-head h3 { font-size: 15px; font-weight: 600; }
.sprint-head .meta { color: var(--muted); font-size: 12px; }
.sprint-status { display: inline-block; min-width: 76px; text-align: center; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--todo); color: var(--muted); }
.sprint-status.done { background: color-mix(in srgb, var(--done) 18%, transparent); color: var(--done); }
.sprint-status.wip { background: color-mix(in srgb, var(--wip) 22%, transparent); color: #9a6b00; }
@media (prefers-color-scheme: dark) { .sprint-status.wip { color: var(--wip); } }
.sprint-needs { padding: 0 16px 10px 98px; font-size: 12.5px; color: var(--accent); }
.sprint-items { list-style: none; margin: 0; padding: 8px 16px 12px 98px; border-top: 1px solid var(--border); display: grid; gap: 5px; font-size: 13px; }
.sprint-items li { display: flex; gap: 10px; align-items: baseline; }
@media (max-width: 760px) { .sprint-head { grid-template-columns: 48px 1fr; } .sprint-head .sprint-status { grid-column: 2; justify-self: start; } .sprint-needs, .sprint-items { padding-left: 16px; } }

/* Item details */
.details { padding: 4px 16px 14px 74px; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px 20px; font-size: 13px; }
@media (max-width: 760px) { .details { padding-left: 16px; } }
.details h4 { margin: 6px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.details ul { margin: 0; padding-left: 16px; }
.details li { margin: 1px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-family: var(--mono); font-size: 11.5px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); background: var(--bg); cursor: default; }
.chip.w { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.chip.link { cursor: pointer; }
.chip.link:hover { border-color: var(--brand-light); }
.note { color: var(--muted); font-size: 12px; }
.group-title { font-size: 14px; margin: 22px 0 8px; }
.group-title .n { color: var(--muted); font-weight: 400; margin-left: 6px; }

/* Tables (data) view */
table.grid { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); }
table.grid th, table.grid td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; font-size: 13px; }
table.grid th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--surface); position: sticky; top: 58px; }
table.grid tr.row { cursor: pointer; }
table.grid tr.row:hover td { background: color-mix(in srgb, var(--brand-light) 7%, transparent); }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 2px 14px; font-family: var(--mono); font-size: 12px; }
.cols .k { color: var(--accent); }

/* Loading skeleton (owner expectation: skeletons wherever possible) */
.skeleton { border-radius: 8px; margin-bottom: 10px; background: linear-gradient(90deg, var(--surface) 25%, var(--border) 37%, var(--surface) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.toast { position: fixed; bottom: 18px; right: 18px; background: var(--brand); color: #fff; padding: 10px 14px; border-radius: 6px; box-shadow: var(--shadow); font-size: 13px; z-index: 10; }
.error-box { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); padding: 12px; border-radius: 6px; white-space: pre-wrap; font-family: var(--mono); font-size: 12px; margin-bottom: 12px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }
