:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e2e5ea;
  --text: #16181d;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #e8f0fe;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --crit: #b91c1c;
  --crit-soft: #fdeaea;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131417;
    --surface: #1c1e23;
    --surface-2: #23262c;
    --border: #32363e;
    --text: #e8eaed;
    --muted: #9aa1ad;
    --accent: #5b93f7;
    --accent-soft: #1e2a42;
    --ok: #4ade80;
    --ok-soft: #16281c;
    --warn: #fbbf24;
    --warn-soft: #2e2517;
    --crit: #f87171;
    --crit-soft: #2e1a1a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- shell ---------- */
.topbar {
  display: flex; align-items: center; gap: 22px;
  padding: 0 26px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: -.2px; white-space: nowrap; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  padding: 6px 12px; border-radius: 8px; color: var(--muted);
  font-weight: 500; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.who { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 10px; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 26px; }
.wrap.narrow { max-width: 940px; }

h1 { font-size: 21px; margin: 0 0 4px; letter-spacing: -.3px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0 0 10px; }
.lead { color: var(--muted); margin: 0 0 22px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.grid { display: grid; gap: 16px; }
.grid.k4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.k3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.k2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -.6px; margin-top: 4px; }
.kpi .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.up { color: var(--ok); } .down { color: var(--crit); }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--surface-2); font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; position: sticky; top: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.name { max-width: 300px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.crit { background: var(--crit-soft); color: var(--crit); }
.badge.neutral { background: var(--surface-2); color: var(--muted); }
.badge.pending { background: var(--accent-soft); color: var(--accent); }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.muted { background: var(--surface-2); color: var(--muted); }

/* ---------- forms ---------- */
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text);
  font: inherit; font-size: 13.5px;
}
textarea { resize: vertical; min-height: 78px; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 150px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
  font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--crit); border-color: var(--crit); }
.btn.danger:hover { background: var(--crit-soft); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- flash ---------- */
.flash { padding: 11px 15px; border-radius: 9px; margin-bottom: 16px; font-size: 13.5px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--crit-soft); color: var(--crit); }

/* ---------- alerts ---------- */
.alert { display: flex; gap: 14px; padding: 15px 17px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); margin-bottom: 11px; box-shadow: var(--shadow); }
.alert .stripe { width: 3px; border-radius: 3px; flex: 0 0 3px; }
.alert.critical .stripe { background: var(--crit); }
.alert.warning .stripe { background: var(--warn); }
.alert.opportunity .stripe { background: var(--ok); }
.alert.info .stripe { background: var(--muted); }
.alert .body { flex: 1; min-width: 0; }
.alert .title { font-weight: 620; margin-bottom: 3px; }
.alert .detail { color: var(--muted); font-size: 13px; }
.alert .obj { font-size: 12px; color: var(--muted); margin-top: 6px; }
.alert .side { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

/* ---------- mockups ---------- */
.mockups { display: flex; gap: 20px; flex-wrap: wrap; }
.mock { width: 320px; flex: 0 0 auto; }
.mock > .caption { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.phone { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.phone .head { display: flex; align-items: center; gap: 9px; padding: 10px 12px; }
.phone .avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #9333ea); flex: 0 0 32px; }
.phone .pname { font-weight: 620; font-size: 13px; }
.phone .psub { color: var(--muted); font-size: 11px; }
.phone .copy { padding: 0 12px 10px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.phone img { display: block; width: 100%; height: auto; }
.phone .cta {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--surface-2); gap: 10px;
}
.phone .cta .t { font-size: 13px; font-weight: 620; }
.phone .cta .d { font-size: 11.5px; color: var(--muted); }
.phone .cta .b { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 5px 11px; font-size: 12px; font-weight: 600; white-space: nowrap; }

.story { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: #000; }
.story img { display: block; width: 100%; height: auto; }
.story .bar { position: absolute; top: 8px; left: 8px; right: 8px; height: 2.5px; background: rgba(255,255,255,.35); border-radius: 2px; }
.story .bar::after { content: ""; display: block; width: 42%; height: 100%; background: #fff; border-radius: 2px; }
.story .who { position: absolute; top: 18px; left: 10px; color: #fff; font-size: 12px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.story .swipe { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); background: rgba(255,255,255,.94); color: #111; border-radius: 20px; padding: 7px 18px; font-size: 12px; font-weight: 650; }
.story .missing, .phone .missing {
  aspect-ratio: 9/16; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--muted); font-size: 12.5px; text-align: center; padding: 20px;
}
.phone .missing { aspect-ratio: 4/5; }

/* ---------- assets ---------- */
.assets { display: flex; gap: 14px; flex-wrap: wrap; }
.asset { width: 168px; }
.asset img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); display: block; }
.asset .meta { font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.4; }
.asset .slot { font-weight: 650; color: var(--text); font-size: 12px; }
.asset.empty {
  border: 1.5px dashed var(--border); border-radius: 8px; padding: 14px;
  display: flex; flex-direction: column; justify-content: center; min-height: 128px;
}

/* ---------- misc ---------- */
.variants .v { display: flex; gap: 9px; margin-bottom: 9px; align-items: flex-start; }
.variants .v .idx { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: 0 0 22px; margin-top: 7px; }
.comment { padding: 11px 13px; border-radius: 9px; background: var(--surface-2); margin-bottom: 9px; }
.comment .who { font-size: 12px; font-weight: 620; margin-bottom: 3px; }
.comment .when { color: var(--muted); font-weight: 400; font-size: 11.5px; }
.comment .text { font-size: 13.5px; white-space: pre-wrap; }
.problems { background: var(--warn-soft); color: var(--warn); border-radius: 9px; padding: 12px 15px; font-size: 13px; }
.problems ul { margin: 6px 0 0; padding-left: 20px; }
.empty-state { text-align: center; padding: 46px 20px; color: var(--muted); }
.split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--surface-2); border-radius: 20px; padding: 3px 11px; font-size: 12px; color: var(--muted); }
.sticky { position: sticky; top: 74px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.hr { height: 1px; background: var(--border); margin: 16px 0; }
