/* LiveDash console — dark-only design system, derived from the 2K Web Developments
   brand tokens (2kwebdev.com). Mobile-first (~380px); status dots are the signature.
   Elevation on dark = a lighter surface + border, not shadow. All text/bg pairs verified
   AA (see DECISIONS #29). */

:root {
  /* surfaces — near-black purple-tinted (--void/--surf-d ramp), elevation by lightness */
  --bg: #120a1f;        /* 2kwebdev --void */
  --surface: #1b1130;   /* 2kwebdev --surf-d  (cards) */
  --surface-2: #241738; /* 2kwebdev --surf-d2 (insets) */
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);

  /* ink — light 3-step ramp on dark (--mist / --off-2 / --off-soft) */
  --ink: #faf8fe;       /* primary   (18:1 on bg) */
  --ink-2: #cdc1e6;     /* secondary (10.6:1 on surface) */
  --ink-3: #a99fc4;     /* muted     (7.2:1 on surface) */

  /* brand purple — solid fill vs lightened accent (--purple / --purple-on-dark) */
  --brand: #a435ef;     /* 2kwebdev --purple (button fills; white text = 4.85:1) */
  --brand-ink: #c77dff; /* 2kwebdev --purple-on-dark (links/active; 6.7:1 on surface) */
  --brand-wash: rgba(196, 125, 255, 0.14);

  /* status re-derived for dark (brightened; washes = translucent tints) */
  --up: #6ee7b7; --up-dot: #34d399; --up-wash: rgba(52, 211, 153, 0.13);
  --down: #fca5a5; --down-dot: #f87171; --down-wash: rgba(248, 113, 113, 0.13);
  --warn: #fcd34d; --warn-dot: #fbbf24; --warn-wash: rgba(251, 191, 36, 0.13);

  /* chart series — brand purple + brand-derived cyan (validated CVD-safe on dark) */
  --c-visits: #a435ef;
  --c-pv: #0891b2;

  --radius: 16px;
  --radius-sm: 10px;
  /* dark elevation: a faint depth shadow only; borders carry most of the lift */
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --tap: 44px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--brand-ink); outline-offset: 2px; border-radius: 6px; }

/* ---------- layout ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 56px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(18, 10, 31, 0.82); /* --void, translucent for the blur */
  backdrop-filter: saturate(1.3) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 760px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand svg { display: block; }
.brand b { font-weight: 700; }
.brand .live { color: var(--brand-ink); }
.spacer { flex: 1; }
.who { color: var(--ink-2); font-size: 0.8rem; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-ghost { white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  min-height: var(--tap); padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { border-color: var(--brand); color: var(--brand-ink); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); color: #fff; }
.btn-primary[disabled] { opacity: 0.55; cursor: default; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); min-height: 44px; padding: 0 12px; white-space: nowrap; }
.btn-ghost:hover { color: var(--brand-ink); background: var(--brand-wash); }
.linkback { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); text-decoration: none; font-weight: 600; min-height: 44px; }
.linkback:hover { color: var(--brand-ink); }

/* ---------- page heading ---------- */
.page-h { display: flex; align-items: baseline; gap: 10px; margin: 20px 2px 4px; }
.page-h h1 { font-size: clamp(1.35rem, 5vw, 1.7rem); letter-spacing: -0.02em; margin: 0; }
.page-sub { color: var(--ink-2); font-size: 0.9rem; margin: 0 2px 16px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }

/* portfolio — exception-first row list (one card, divided rows) */
.sitelist { padding: 0; overflow: hidden; }
.srow { display: flex; align-items: flex-start; gap: 11px; padding: 10px 14px 11px; text-decoration: none; color: inherit; border-top: 1px solid var(--line); }
.srow:first-child { border-top: 0; }
.srow:hover { background: var(--surface-2); }
.srow:active { background: var(--brand-wash); }
.srow > .dot { margin-top: 5px; }
.srow-main { flex: 1; min-width: 0; }
.srow-line { display: flex; align-items: baseline; gap: 9px; line-height: 1.32; }
.srow-line.l2 { margin-top: 2px; }
.srow-name { font-weight: 650; font-size: 1rem; letter-spacing: -0.01em; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv { margin-left: auto; white-space: nowrap; flex: none; font-size: 0.88rem; color: var(--ink); }
.mv b { font-weight: 750; }
.mlab { color: var(--ink-2); }
.base { color: var(--ink-3); font-size: 0.94em; }
.srow-status { color: var(--ink-2); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acts { margin-left: auto; white-space: nowrap; flex: none; font-size: 0.83rem; font-weight: 650; color: var(--brand-ink); }
.chev { align-self: center; color: var(--ink-3); font-size: 1.5rem; line-height: 1; flex: none; margin-left: 2px; }
.srow:hover .chev { color: var(--brand-ink); }
/* the DOWN exception spends space: red edge + wash + ribbon + reason */
.srow.r-down { background: var(--down-wash); box-shadow: inset 3px 0 0 var(--down-dot); }
.srow.r-down:hover { background: rgba(248, 113, 113, 0.2); }
.down-since { color: var(--down); font-size: 0.94rem; }
.row-down-extra { margin-top: 2px; }
.row-down-extra .ribbon { margin: 10px 0 0; }
.down-reason { color: var(--down); font-size: 0.85rem; margin-top: 7px; font-weight: 600; }

/* status dot (the signature) — color set on the dot so the ring uses currentColor */
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; position: relative; }
.dot::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid currentColor; opacity: .28; }
.dot.up { background: var(--up-dot); color: var(--up-dot); }
.dot.down { background: var(--down-dot); color: var(--down-dot); }
.dot.warn { background: var(--warn-dot); color: var(--warn-dot); }  /* up, but a blip in 24h */
.dot.unknown { background: var(--ink-3); color: var(--ink-3); }
.dot.up.pulse { animation: pulse 2.4s ease-out infinite; }
.dot-lg { width: 14px; height: 14px; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(52,211,153,.5); } 70% { box-shadow: 0 0 0 9px rgba(52,211,153,0); } 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); } }
@media (prefers-reduced-motion: reduce) { .dot.pulse { animation: none; } }

/* 24h ribbon (detail + DOWN rows) */
.ribbon { margin: 14px 0 4px; }
.ribbon svg { display: block; width: 100%; height: 30px; }
.ribbon-cap { color: var(--ink-3); font-size: 0.76rem; margin-top: 5px; }
/* thin live strip on every portfolio row */
.ribbon-strip { display: block; width: 100%; height: 12px; margin-top: 8px; border-radius: 2px; }

/* ---------- site detail ---------- */
.detail-head { display: flex; align-items: center; gap: 10px; margin: 12px 0 2px; flex-wrap: wrap; }
.detail-head h1 { font-size: clamp(1.4rem, 5.5vw, 1.85rem); letter-spacing: -0.02em; margin: 6px 0 0; flex-basis: 100%; }
.toggle { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.toggle button { font: inherit; font-weight: 650; border: 0; background: transparent; color: var(--ink-2); border-radius: 999px; min-height: 44px; padding: 0 18px; cursor: pointer; }
.toggle button[aria-pressed="true"] { background: var(--surface-2); color: var(--brand-ink); box-shadow: inset 0 0 0 1px var(--line-2); }

.banner-down { display: flex; align-items: center; gap: 12px; background: var(--down-wash); border: 1px solid var(--down-dot); color: var(--down); border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; font-weight: 650; }
.banner-down .t { font-size: 1.05rem; }

.section { padding: 12px 16px; margin-top: 9px; }
.section h2 { font-size: 0.98rem; letter-spacing: -0.01em; margin: 0 0 6px; color: var(--ink); }
.section h2 .q { color: var(--ink-3); font-weight: 500; }

/* totals */
.totals { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; padding: 12px 16px; margin-top: 9px; }
.tstat .big { font-weight: 780; font-size: clamp(1.5rem, 7vw, 1.9rem); letter-spacing: -0.02em; display: block; }
.tstat .lab { color: var(--ink-2); font-size: 0.84rem; }
.tstat .cmp { font-size: 0.8rem; font-weight: 650; margin-top: 3px; }
.cmp.up { color: var(--up); } .cmp.down { color: var(--down); } .cmp.flat { color: var(--ink-3); }
.sublabel { color: var(--ink-3); font-size: 0.78rem; grid-column: 1 / -1; margin-top: -2px; }

/* chart */
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 2px 0 10px; font-size: 0.82rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 11px; height: 11px; border-radius: 3px; }
.swatch.visits { background: var(--c-visits); }
.swatch.pv { background: var(--c-pv); }
.mt-10 { margin-top: 10px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.axis { position: relative; height: 15px; margin-top: 5px; font-size: 0.72rem; color: var(--ink-3); }
.axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.brand-m { display: inline-flex; }
.chart-cap { color: var(--ink-3); font-size: 0.8rem; margin-top: 8px; }
details.data { margin-top: 8px; }
details.data summary { color: var(--brand-ink); font-weight: 600; font-size: 0.82rem; cursor: pointer; min-height: 32px; display: inline-flex; align-items: center; }
table.mini { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.82rem; }
table.mini th, table.mini td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.mini th:first-child, table.mini td:first-child { text-align: left; color: var(--ink-2); }

/* rows / lists */
.rows { display: grid; gap: 1px; }
.row { display: flex; align-items: baseline; gap: 10px; padding: 5px 2px; min-height: 36px; box-sizing: border-box; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .k { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .path { color: var(--ink-2); font-weight: 500; font-variant-numeric: tabular-nums; }
.row .v { margin-left: auto; font-weight: 700; }
.row .was { color: var(--ink-3); font-size: 0.82rem; font-weight: 600; }
.bar-track { flex: none; width: 84px; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; background: var(--c-visits); border-radius: 999px; }

.sentence { padding: 11px 16px; margin-top: 9px; font-size: 0.95rem; }
.sentence .em { font-weight: 750; }
.incident { display: flex; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.incident:last-child { border-bottom: 0; }
.incident .dur { font-weight: 700; color: var(--down); white-space: nowrap; }
.uptime-big { font-weight: 780; font-size: 1.5rem; letter-spacing: -0.01em; }

/* ---------- login ---------- */
.login { max-width: 400px; margin: 8vh auto 0; padding: 0 20px; }
.login .mark { display: flex; align-items: center; gap: 10px; justify-content: center; font-weight: 700; font-size: 1.3rem; letter-spacing: -0.02em; margin-bottom: 6px; }
.login .mark .live { color: var(--brand-ink); }
.login .tag { text-align: center; color: var(--ink-2); margin: 0 0 26px; }
.login .card { padding: 22px 20px 24px; }
.login label { display: block; font-weight: 650; font-size: 0.9rem; margin: 0 0 7px; }
.login input {
  width: 100%; font: inherit; min-height: var(--tap); padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface-2); color: var(--ink);
}
.login input:focus { background: #fff; border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-wash); }
.login .otp { letter-spacing: 0.35em; text-align: center; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.login .btn-primary { width: 100%; margin-top: 16px; }
.login .msg { margin-top: 14px; font-size: 0.9rem; text-align: center; }
.login .msg.err { color: var(--down); font-weight: 600; }
.login .msg.ok { color: var(--ink-2); }
.login .alt { text-align: center; margin-top: 16px; }
.login .alt button { font: inherit; background: none; border: 0; color: var(--brand-ink); font-weight: 600; cursor: pointer; text-decoration: underline; min-height: 40px; }

/* ---------- global states ---------- */
.state { text-align: center; color: var(--ink-2); padding: 60px 20px; }
.state.err button { margin-top: 12px; }
.spin { width: 26px; height: 26px; border: 3px solid var(--line-2); border-top-color: var(--brand); border-radius: 50%; margin: 0 auto 14px; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2s; } }
.empty { color: var(--ink-3); font-size: 0.9rem; padding: 10px 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

@media (min-width: 760px) {
  .srow { padding: 15px 20px 16px; gap: 14px; }
}
/* Narrow phones: drop the "(usually ~N)" baseline + the "· time" suffix so names and
   action numbers never truncate. */
@media (max-width: 380px) {
  .mv .base { display: none; }
  .st-time { display: none; }
  .acts, .srow-status { font-size: 0.76rem; }
  .srow-line { gap: 6px; }
}
