/* LANGUAGYM Ops. Direction: a quiet instrument panel. Cool canvas, LANGUAGYM blue for actions,
   status carried by shape and colour together, numbers large and tabular. Light mode only. */

@font-face {
  font-family: "LANGUAGYM Rounded";
  src: url("/fonts/languagym-sans-rounded-var.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --blue: oklch(0.55 0.23 263);
  --blue-press: oklch(0.43 0.20 264);
  --blue-ink: oklch(0.42 0.19 264);
  --blue-wash: oklch(0.955 0.02 258);
  --ok: oklch(0.55 0.16 146);
  --ok-wash: oklch(0.95 0.05 145);
  --warn: oklch(0.58 0.13 68);
  --warn-ink: oklch(0.50 0.11 65);
  --warn-wash: oklch(0.96 0.055 92);
  --down: oklch(0.585 0.215 26);
  --down-ink: oklch(0.48 0.18 25);
  --down-wash: oklch(0.955 0.022 20);
  --ink: oklch(0.24 0.04 266);
  --ink-2: oklch(0.44 0.035 266);
  --ink-3: oklch(0.54 0.03 266);
  --line: oklch(0.905 0.014 262);
  --line-strong: oklch(0.845 0.02 262);
  --canvas: oklch(0.975 0.007 262);
  --surface: oklch(1 0 0);

  --font: "LANGUAGYM Rounded", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-sm: 10px; --r-md: 16px; --r-lg: 24px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.55, 0, 1, 0.45);
  --fast: 160ms;
  --base: 240ms;
  --tabbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-weight: 500;
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
code { font-size: 0.875em; background: var(--blue-wash); color: var(--blue-ink); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.sprite { display: none; }
.ico { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--ink-2); }
.small { font-size: 0.8125rem; }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 6px; }

/* ---------- buttons and fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 48px; padding: 0 var(--s5);
  border: 2px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); font-weight: 700; cursor: pointer;
  transition: transform var(--fast) var(--ease-out), background-color var(--fast) var(--ease-out), border-color var(--fast) var(--ease-out);
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 3px 0 var(--blue-press); }
.btn-primary:hover { background: var(--blue-press); border-color: var(--blue-press); }
.btn-primary:active { box-shadow: 0 1px 0 var(--blue-press); transform: translateY(2px); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--down-ink); padding: 0 var(--s3); }
.btn-quiet.link { color: var(--blue-ink); margin-top: var(--s3); width: 100%; }
.invite-out { padding: var(--s4); border-radius: var(--r-md); background: var(--blue-wash); color: var(--blue-ink); font-weight: 700; }
.invite-out strong { display: block; font-size: 1.5rem; font-weight: 900; letter-spacing: 0.04em; margin: var(--s1) 0; user-select: all; }

.field { display: grid; gap: var(--s1); font-weight: 700; font-size: 0.9375rem; min-width: 0; }
.field input {
  width: 100%; min-width: 0;
  min-height: 52px; padding: 0 var(--s4);
  border: 2px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface);
  font-weight: 600; transition: border-color var(--fast) var(--ease-out);
}
.field input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 4px var(--blue-wash); }
.code-input { letter-spacing: 0.5em; font-size: 1.375rem; text-align: center; }
.stack { display: grid; gap: var(--s4); }
.row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: end; }
.grow { flex: 1 1 160px; }
.form-error { color: var(--down-ink); font-weight: 700; min-height: 1.5em; margin-top: var(--s3); }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: var(--s5); }
.auth-card {
  width: min(400px, 100%); background: var(--surface); border-radius: var(--r-lg);
  padding: var(--s6) var(--s5); border: 1px solid var(--line);
  animation: rise var(--base) var(--ease-out) both;
}
.auth-card h1 { font-size: 1.75rem; font-weight: 900; letter-spacing: -0.02em; margin: var(--s4) 0 var(--s4); }
.auth-mark { width: 48px; height: 48px; }
.auth-mark rect { fill: var(--blue); }
.auth-mark path { fill: none; stroke: #fff; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- app shell ---------- */
.app { max-width: 1080px; margin: 0 auto; padding: 0 var(--s4) calc(var(--tabbar-h) + var(--s6) + env(safe-area-inset-bottom)); }
.top { padding: calc(var(--s4) + env(safe-area-inset-top)) 0 var(--s4); }
.top-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); }
.brand { font-weight: 800; letter-spacing: 0.01em; }
.brand b { color: var(--blue); font-weight: 900; }

.overall {
  display: flex; gap: var(--s4); align-items: center;
  margin-top: var(--s4); padding: var(--s5); border-radius: var(--r-lg);
  background: var(--ok-wash); color: var(--ok);
  transition: background-color var(--base) var(--ease-out), color var(--base) var(--ease-out);
}
.overall h1 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.25rem); font-weight: 900; letter-spacing: -0.03em; line-height: 1.1; color: var(--ink); }
.overall-ico { width: 44px; height: 44px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.overall[data-status="warn"] { background: var(--warn-wash); color: var(--warn); }
.overall[data-status="down"] { background: var(--down-wash); color: var(--down); }

.tab { animation: rise var(--base) var(--ease-out) both; }
.section-title { font-size: 1.1875rem; font-weight: 850; letter-spacing: -0.01em; margin: var(--s6) 0 var(--s3); }

/* ---------- install and alerts cards ---------- */
.setup-card {
  display: grid; grid-template-columns: auto 1fr; gap: var(--s3) var(--s4); align-items: center;
  margin-bottom: var(--s3); padding: var(--s4); border-radius: var(--r-md);
  background: var(--surface); border: 2px solid var(--blue);
  animation: rise var(--base) var(--ease-out) both;
}
.setup-card .btn { grid-column: 1 / -1; }
.setup-ico { width: 48px; height: 48px; }
.setup-ico rect { fill: var(--blue); }
.setup-ico path { fill: none; stroke: #fff; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.setup-ico-bell { width: 40px; height: 40px; fill: none; stroke: var(--blue); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.setup-body h2 { font-size: 1.125rem; font-weight: 850; letter-spacing: -0.01em; }
.setup-body p { font-size: 0.9375rem; }
.steps { margin: var(--s2) 0 0; padding-left: 1.25em; font-size: 0.9375rem; color: var(--ink-2); }
@media (min-width: 768px) { .setup-card { grid-template-columns: auto 1fr auto; } .setup-card .btn { grid-column: auto; } }

/* ---------- status ---------- */
.problems { display: grid; gap: var(--s3); }
.problem {
  display: grid; grid-template-columns: auto 1fr; gap: var(--s1) var(--s3); align-items: start;
  padding: var(--s4); border-radius: var(--r-md); background: var(--surface);
  border-left: 6px solid var(--down);
}
.problem[data-status="warn"] { border-left-color: var(--warn); }
.problem .st { grid-row: span 2; }
.problem strong { font-weight: 800; }
.problem p { color: var(--ink-2); font-size: 0.9375rem; overflow-wrap: anywhere; }

.group { margin-top: var(--s5); }
.group h2 { font-size: 0.8125rem; font-weight: 800; color: var(--ink-3); letter-spacing: 0.04em; margin-bottom: var(--s2); }
.checks { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--r-md); }
.checks li { display: grid; grid-template-columns: auto 1fr auto; gap: var(--s3); align-items: center; padding: var(--s3) var(--s4); }
.checks li + li { border-top: 1px solid var(--line); }
.checks .name { font-weight: 700; }
.checks .detail { display: block; color: var(--ink-2); font-size: 0.875rem; overflow-wrap: anywhere; }
.checks .since { color: var(--ink-3); font-size: 0.8125rem; white-space: nowrap; }

.st { width: 22px; height: 22px; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.st-ok { stroke: var(--ok); }
.st-warn { stroke: var(--warn); }
.st-down { stroke: var(--down); }
.st-unknown { stroke: var(--ink-3); }

.events { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.events li { display: grid; grid-template-columns: auto 1fr; gap: 2px var(--s3); align-items: start; font-size: 0.9375rem; }
.events li .st { grid-row: span 2; width: 18px; height: 18px; margin-top: 3px; }
.events time { color: var(--ink-3); font-size: 0.8125rem; }
.empty { color: var(--ink-3); padding: var(--s3) 0; }

/* ---------- traffic ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
.stat { display: grid; gap: 2px; padding: var(--s4); background: var(--surface); border-radius: var(--r-md); align-content: start; }
.stat-label { font-size: 0.8125rem; font-weight: 700; color: var(--ink-2); }
.stat strong { font-size: clamp(1.75rem, 1.4rem + 1.5vw, 2.5rem); font-weight: 900; letter-spacing: -0.03em; line-height: 1.1; }
.stat-note { font-size: 0.8125rem; color: var(--ink-3); }
.stat-hero { grid-column: 1 / -1; background: var(--blue); color: #fff; }
.stat-hero .stat-label, .stat-hero .stat-note { color: oklch(0.92 0.04 258); }
.stat-hero strong { font-size: clamp(2.75rem, 2rem + 3.4vw, 4.25rem); }
.up { color: var(--ok); }
.down-n { color: var(--down-ink); }

.chart-card { margin: var(--s4) 0 0; padding: var(--s4); background: var(--surface); border-radius: var(--r-md); }
.chart-card figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s2); font-weight: 800; font-size: 0.9375rem; margin-bottom: var(--s3); }
.chart { height: 160px; }
.chart svg { width: 100%; height: 100%; overflow: visible; display: block; }
.chart .area { fill: var(--blue-wash); }
.chart .line { fill: none; stroke: var(--blue); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart .bar { fill: var(--blue); }
.chart .bar-today { fill: var(--blue-press); }
.chart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-frame { height: 100%; display: grid; grid-template-rows: auto 1fr auto; gap: var(--s1); }
.chart-frame svg { min-height: 0; }
.chart-max, .chart-axis { font-size: 0.75rem; color: var(--ink-3); }
.chart-axis { display: flex; justify-content: space-between; }

.seg { display: inline-flex; background: var(--canvas); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; border-radius: 8px; padding: 6px 10px; min-height: 36px; font-weight: 700; font-size: 0.8125rem; color: var(--ink-2); cursor: pointer; transition: background-color var(--fast) var(--ease-out); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px oklch(0.24 0.04 266 / 0.12); }

.lists { display: grid; gap: var(--s3); margin-top: var(--s4); }
.list-card { padding: var(--s4); background: var(--surface); border-radius: var(--r-md); }
.list-card h2 { font-size: 0.9375rem; font-weight: 800; margin-bottom: var(--s3); }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.bars li { position: relative; display: flex; justify-content: space-between; gap: var(--s3); padding: 6px var(--s2); font-size: 0.9375rem; isolation: isolate; }
.bars li::before { content: ""; position: absolute; inset: 0; width: 100%; transform: scaleX(var(--w, 0)); transform-origin: left; background: var(--blue-wash); border-radius: 8px; z-index: -1; transition: transform var(--base) var(--ease-out); }
.bars .k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .v { font-weight: 800; }

/* ---------- server ---------- */
.meters { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
.meter { padding: var(--s4); background: var(--surface); border-radius: var(--r-md); display: grid; gap: var(--s2); }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; }
.meter-top span { font-size: 0.8125rem; font-weight: 700; color: var(--ink-2); }
.meter-top strong { font-size: 1.5rem; font-weight: 900; letter-spacing: -0.02em; }
.track { height: 8px; border-radius: 99px; background: var(--canvas); overflow: hidden; }
.fill { height: 100%; width: 100%; transform: scaleX(var(--w, 0)); transform-origin: left; background: var(--ok); border-radius: 99px; transition: transform var(--base) var(--ease-out); }
.fill[data-status="warn"] { background: var(--warn); }
.fill[data-status="down"] { background: var(--down); }
.meter small { color: var(--ink-3); font-size: 0.8125rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--r-md); }
.table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.table th, .table td { text-align: left; padding: var(--s3) var(--s4); white-space: nowrap; }
.table th { font-size: 0.8125rem; color: var(--ink-3); font-weight: 800; }
.table tbody tr { border-top: 1px solid var(--line); }
.table .num { text-align: right; }
.table td:first-child { font-weight: 700; }
.state { display: inline-flex; align-items: center; gap: 6px; white-space: normal; min-width: 9em; }
.state .st { width: 18px; height: 18px; }

.budget { padding: var(--s4); background: var(--surface); border-radius: var(--r-md); display: grid; gap: var(--s2); }
.budget + .budget { margin-top: var(--s3); }
.budget-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); }
.budget-top strong { font-size: 1.75rem; font-weight: 900; letter-spacing: -0.02em; }
.track-budget { position: relative; height: 12px; }
.track-budget .forecast { position: absolute; top: -3px; bottom: -3px; width: 3px; border-radius: 2px; background: var(--ink-2); }
.note { padding: var(--s4); background: var(--surface); border-radius: var(--r-md); color: var(--ink-2); }

/* ---------- settings ---------- */
.panel { padding: var(--s5) var(--s4); background: var(--surface); border-radius: var(--r-md); margin-top: var(--s3); display: grid; gap: var(--s4); }
.panel h2 { display: flex; align-items: center; gap: var(--s2); font-size: 1.1875rem; font-weight: 850; }
.devices { list-style: none; margin: 0; padding: 0; }
.devices li { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding: var(--s3) 0; }
.devices li + li { border-top: 1px solid var(--line); }
.devices small { display: block; color: var(--ink-3); }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 0 max(var(--s2), env(safe-area-inset-left)) env(safe-area-inset-bottom);
  background: oklch(1 0 0 / 0.94); border-top: 1px solid var(--line);
}
@supports (backdrop-filter: blur(12px)) { .tabbar { background: oklch(1 0 0 / 0.82); backdrop-filter: blur(12px); } }
.tabbar button {
  position: relative; display: grid; justify-items: center; gap: 2px; align-content: center;
  min-height: var(--tabbar-h); border: 0; background: none; cursor: pointer;
  color: var(--ink-3); font-size: 0.75rem; font-weight: 700;
  transition: color var(--fast) var(--ease-out);
}
.tabbar button[aria-current="page"] { color: var(--blue); }
.tabbar button:active .ico { transform: scale(0.9); }
.tabbar .ico { transition: transform var(--fast) var(--ease-out); }
.badge { position: absolute; top: 10px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--down); color: #fff; font-style: normal; font-size: 0.6875rem; font-weight: 800; line-height: 18px; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--s4) + env(safe-area-inset-bottom)); z-index: 20;
  max-width: min(420px, calc(100% - 32px)); padding: var(--s3) var(--s4); border-radius: var(--r-md);
  background: var(--ink); color: #fff; font-weight: 700; font-size: 0.9375rem;
  opacity: 0; transform: translate(-50%, 12px); pointer-events: none;
  transition: opacity var(--fast) var(--ease-in), transform var(--fast) var(--ease-in);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); transition-timing-function: var(--ease-out); transition-duration: var(--base); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- wider screens ---------- */
@media (min-width: 768px) {
  .app { padding-left: var(--s6); padding-right: var(--s6); }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat-hero { grid-column: span 1; grid-row: span 2; align-content: center; }
  .meters { grid-template-columns: repeat(4, 1fr); }
  .lists { grid-template-columns: repeat(3, 1fr); }
  .chart { height: 200px; }
}
@media (min-width: 1100px) {
  .tabbar { left: 50%; right: auto; bottom: var(--s4); transform: translateX(-50%); width: 520px; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0 var(--s2); box-shadow: 0 12px 32px -12px oklch(0.24 0.04 266 / 0.28); }
}

@media (prefers-reduced-motion: reduce) {
  .tab, .auth-card { animation-name: fade; }
  .bars li::before, .fill, .toast { transition-property: opacity; }
  .btn:active, .tabbar button:active .ico { transform: none; }
}
@keyframes fade { from { opacity: 0; } }
