/* Platform dashboard: the portal's look (warm paper, one hero, cards, bottom sheets) with its own colour.
   Colour is information: platform = calm blue; green = up, red = down, amber = deploying or needs attention. */
:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1d1b18; --muted: #7a746a; --line: #e8e3d9; --soft: #efece5;
  --plat: #2f6fb0; --on-plat: #ffffff;
  --up: #3d8f5f; --down: #b4443a; --busy: #c08a2b;
  --shadow: 0 10px 40px rgb(0 0 0 / 0.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513; --card: #201e1b; --ink: #ece8e1; --muted: #958e83; --line: #2e2b27; --soft: #262420;
    --plat: #7fa9db; --on-plat: #10161d;
    --up: #6fc093; --down: #e07a70; --busy: #e3b25e;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 17px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button, input { font: inherit; }
[hidden] { display: none !important; }
.loading { padding: 80px 16px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- shared bits */
.mark { width: 34px; height: 34px; border-radius: 10px; background: url("/icon.svg") center / cover; flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 22px; border-radius: 14px; border: 0; background: var(--ink); color: var(--bg); font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--soft); color: var(--ink); }
.btn.danger { background: var(--down); color: #fff; }
.btn.plat { background: var(--plat); color: var(--on-plat); }
.err { color: var(--down); min-height: 1.5em; font-size: 15px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 13px; font-weight: 700; color: var(--muted); }
h3.section { font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 32px 0 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; display: inline-block; }
.dot.up { background: var(--up); box-shadow: 0 0 0 4px color-mix(in srgb, var(--up) 18%, transparent); }
.dot.down { background: var(--down); box-shadow: 0 0 0 4px color-mix(in srgb, var(--down) 18%, transparent); }
.dot.busy { background: var(--busy); box-shadow: 0 0 0 4px color-mix(in srgb, var(--busy) 18%, transparent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }
.tag { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.tag.plat { background: color-mix(in srgb, var(--plat) 14%, transparent); color: var(--plat); }
.tag.warn { background: color-mix(in srgb, var(--busy) 18%, transparent); color: var(--busy); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 14px; }

/* top bar: title and status up top, nothing to press but sign-out */
.top { position: sticky; top: 0; z-index: 10; height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; }
.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--muted); font-size: 15px; padding: 8px 10px 8px 0; }
.top .out { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; padding: 8px; }
.page { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }

/* ---------------------------------------------------------------- home: one hero, then cards */
.hero { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; align-items: center; padding: 22px; border-radius: 24px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--tone, var(--up)) 14%, transparent), transparent 60%); pointer-events: none; }
.hero > * { position: relative; }
.hero.bad { --tone: var(--down); }
.ring { width: 112px; height: 112px; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring .track { stroke: color-mix(in srgb, var(--tone, var(--up)) 16%, var(--soft)); }
.ring .fill { stroke: var(--tone, var(--up)); stroke-linecap: round; transition: stroke-dashoffset 0.8s ease; }
.ring b { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 28px; line-height: 1.05; }
.ring b small { font-size: 13px; font-weight: 500; color: var(--muted); }
.hero .eyebrow { color: var(--tone, var(--up)); }
.hero h1 { margin: 4px 0 6px; font-size: 26px; line-height: 1.2; }
.meters { display: flex; flex-wrap: wrap; gap: 8px; }
.meter { font-size: 14px; color: var(--muted); background: var(--soft); border-radius: 10px; padding: 6px 10px; }
.meter b { color: var(--ink); }
.meter.warn { background: color-mix(in srgb, var(--busy) 18%, transparent); color: var(--busy); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 16px 18px; text-decoration: none; transition: transform 0.15s, border-color 0.15s; }
a.card:hover { transform: translateY(-2px); border-color: var(--plat); }
.card .head { display: flex; align-items: center; gap: 10px; }
.card .head b { font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .sub { color: var(--muted); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .foot { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 14px; }
.small-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.lines { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.line { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; }
.line span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line span:last-child { color: var(--muted); white-space: nowrap; }

/* ---------------------------------------------------------------- app page: content scrolls, action row is pinned */
.shell { height: 100dvh; display: flex; flex-direction: column; }
.shell > main { flex: 1; overflow-y: auto; }
.actionbar { flex: none; display: flex; gap: 10px; justify-content: center; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--card); }
.actionbar .btn { flex: 1; max-width: 200px; padding: 13px 10px; }
.apphead { display: flex; align-items: center; gap: 14px; margin: 4px 0 6px; }
.apphead h1 { margin: 0; font-size: 30px; line-height: 1.2; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.apphead .dot { width: 14px; height: 14px; }
.facts { color: var(--muted); margin: 0 0 4px; }
.facts a { color: var(--plat); }
.history { display: flex; flex-direction: column; gap: 8px; }
.event { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); }
.event .what { font-weight: 600; }
.event small { color: var(--muted); font-size: 14px; }
.event.live { border-color: var(--plat); }
.logbox { margin: 0; padding: 14px; border-radius: 16px; background: #14130f; color: #e9e4da; font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-word; max-height: 55vh; overflow: auto; }
.logbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.logbar .btn { padding: 8px 14px; font-size: 15px; }
details.build summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
.empty { color: var(--muted); padding: 14px 2px; }

/* ---------------------------------------------------------------- bottom sheet (actions live in the thumb zone) */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / 0.4); opacity: 0; transition: opacity 0.2s; }
.scrim.on { opacity: 1; }
.sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 640px; max-height: 88dvh; display: flex; flex-direction: column; background: var(--card); border-radius: 24px 24px 0 0; box-shadow: 0 -10px 40px rgb(0 0 0 / 0.2); transform: translateY(105%); transition: transform 0.25s ease; }
.sheet.on { transform: none; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 10px auto 0; flex: none; }
.sheet .inner { overflow-y: auto; padding: 14px 20px calc(20px + env(safe-area-inset-bottom)); }
.sheet h2 { margin: 4px 0 4px; font-size: 22px; }
.sheet p { margin: 0 0 16px; color: var(--muted); }
.sheet .stack { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.sheet .logbox { max-height: 45vh; margin-bottom: 12px; }
.result { display: flex; align-items: center; gap: 10px; font-weight: 700; margin: 0 0 12px; }
.result.ok { color: var(--up); }
.result.bad { color: var(--down); }
.result.busy { color: var(--busy); }
.field { width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 16px; }
.field:focus { outline: 2px solid var(--plat); outline-offset: 1px; }

/* ---------------------------------------------------------------- sign-in and setup */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.authcard { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 32px 24px; text-align: center; box-shadow: var(--shadow); }
.authcard .mark { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 18px; }
.authcard h1 { margin: 0 0 6px; font-size: 26px; }
.authcard p { margin: 0 0 22px; color: var(--muted); }
.authcard .field { margin-bottom: 10px; }
.authcard .btn { width: 100%; margin-top: 6px; background: var(--plat); color: var(--on-plat); }
.authcard .err { margin-top: 12px; }
.authcard .hint { margin: 14px 0 0; font-size: 14px; }
.match { min-height: 1.4em; margin: -2px 4px 8px; text-align: left; font-size: 14px; color: var(--muted); }
.match.ok { color: var(--up); }
.match.no { color: var(--down); }

@media (min-width: 720px) {
  .page { padding: 32px 24px 80px; }
  .hero { padding: 28px; gap: 28px; }
  .ring { width: 136px; height: 136px; }
  .hero h1 { font-size: 30px; }
}
@media (max-width: 420px) {
  .hero { grid-template-columns: 1fr; justify-items: start; }
  .ring { width: 96px; height: 96px; }
  .apphead h1 { font-size: 26px; }
}
