/* Caraloggi Mission Control — command-console aesthetic.
   Dark-first, cyan primary + amber warning (matches the WMS imp banner).
   Forked-in-spirit from the WMS design tokens; self-contained (no CDN). */

:root {
  --bg: #070b12;
  --bg-2: #0b111c;
  --surface: #0f1826;
  --surface-2: #14203200;
  --panel: #111a2b;
  --border: #1e2c42;
  --border-strong: #2b3d5a;
  --text: #e6edf7;
  --text-muted: #8598b3;
  --text-dim: #5b6c85;
  --accent: #22d3ee;
  --accent-2: #0891b2;
  --accent-glow: rgba(34, 211, 238, 0.15);
  --good: #34d399;
  --warn: #f59e0b;
  --bad: #f87171;
  --plan: #a78bfa;
  --r: 10px;
  --r-lg: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(34, 211, 238, 0.06), transparent),
    radial-gradient(900px 500px at 0% 100%, rgba(167, 139, 250, 0.05), transparent),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 32px 28px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow);
}
.login-brand { font-weight: 800; letter-spacing: 0.14em; font-size: 20px; color: var(--accent); }
.login-sub { color: var(--text-muted); font-size: 13px; margin-top: -8px; letter-spacing: 0.18em; text-transform: uppercase; }
.login-err { color: var(--bad); font-size: 13px; }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px; background: rgba(11, 17, 28, 0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; letter-spacing: 0.1em; color: var(--accent); }
.brand-sub { color: var(--text-dim); font-weight: 600; letter-spacing: 0.14em; font-size: 11px; text-transform: uppercase; padding-left: 6px; }
.topnav { display: flex; gap: 4px; margin-left: 12px; }
.topnav a {
  padding: 7px 14px; border-radius: 8px; color: var(--text-muted); font-size: 14px; font-weight: 600;
  transition: background .15s, color .15s;
}
.topnav a:hover { background: var(--surface); color: var(--text); }
.topnav a.active { background: var(--accent-glow); color: var(--accent); }
.topbar #logout { margin-left: auto; }
.view { max-width: 1180px; margin: 0 auto; padding: 28px 24px 80px; }

/* ── Buttons / inputs ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 600; padding: 9px 16px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: transform .08s, background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--accent-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-color: transparent; color: #04121a; box-shadow: 0 4px 18px var(--accent-glow); }
.btn-primary:hover { box-shadow: 0 6px 26px var(--accent-glow); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--border-strong)); color: var(--warn); background: transparent; }
.btn-warn:hover { background: color-mix(in srgb, var(--warn) 12%, transparent); }
.btn-bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--border-strong)); color: var(--bad); background: transparent; }
.btn-bad:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.input, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: var(--bg-2); color: var(--text); font-family: inherit; font-size: 14px;
}
.input:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-glow); }
label.fld { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); font-weight: 600; }

/* ── Page head ─────────────────────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; margin: 0; letter-spacing: -0.02em; }
.page-head .sub { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.crumb { color: var(--text-dim); font-size: 13px; margin-bottom: 6px; }
.crumb a:hover { color: var(--accent); }

/* ── Hero score band ───────────────────────────────────────────────────── */
.hero {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px;
}
.score {
  position: relative; overflow: hidden; background: linear-gradient(180deg, var(--panel), var(--surface));
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 18px 16px;
}
.score::after { content: ""; position: absolute; inset: 0; background: radial-gradient(400px 120px at 100% 0, var(--accent-glow), transparent); opacity: .6; pointer-events: none; }
.score .k { color: var(--text-muted); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.score .v { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.score .u { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.score.accent .v { color: var(--accent); }
.score.good .v { color: var(--good); }

/* ── Franchise tiles (org grid) ────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.tile {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px; transition: transform .1s, border-color .15s, box-shadow .15s; cursor: pointer;
}
.tile:hover { transform: translateY(-3px); border-color: var(--accent-2); box-shadow: var(--shadow); }
.tile-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.tile-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.tile-slug { font-family: var(--mono); font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.tile-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile-stat .n { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-stat .l { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }
.tile-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-dim); }

/* new-tenant tile */
.tile-new { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; border-style: dashed; color: var(--text-muted); min-height: 180px; }
.tile-new:hover { color: var(--accent); }
.tile-new .plus { font-size: 30px; }

/* ── Chips ─────────────────────────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.active { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.chip.suspended { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.chip.plan { color: var(--plan); background: color-mix(in srgb, var(--plan) 14%, transparent); }
.chip.plan::before { display: none; }

/* ── Panels / detail ───────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 14px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 14px; }
.kv .k { color: var(--text-muted); }
.kv .v { color: var(--text); }
.usage { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.usage .cell { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; }
.usage .cell .n { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.usage .cell .l { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 3px; }
.actions-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ── Health ────────────────────────────────────────────────────────────── */
.health-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.health-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; }
.health-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.health-dot.up { background: var(--good); box-shadow: 0 0 10px var(--good); }
.health-dot.down { background: var(--bad); box-shadow: 0 0 10px var(--bad); }
.health-name { font-weight: 700; font-size: 16px; }
.health-meta { color: var(--text-muted); font-size: 13px; margin-top: 6px; font-family: var(--mono); }

/* ── Audit timeline ────────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-row { position: relative; padding: 10px 0 14px; }
.tl-row::before { content: ""; position: absolute; left: -21px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--bg); }
.tl-row.warn::before { background: var(--warn); }
.tl-row.bad::before { background: var(--bad); }
.tl-act { font-weight: 700; font-size: 14px; }
.tl-meta { color: var(--text-muted); font-size: 12px; margin-top: 3px; font-family: var(--mono); }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-back { position: fixed; inset: 0; background: rgba(3, 6, 12, 0.7); backdrop-filter: blur(3px); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 60px 20px; overflow-y: auto; }
.modal { width: 100%; max-width: 520px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.modal-head { padding: 20px 22px 0; }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-head p { color: var(--text-muted); font-size: 14px; margin: 6px 0 0; }
.modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 0 22px 20px; display: flex; justify-content: flex-end; gap: 10px; }
.modal-err { color: var(--bad); font-size: 13px; }

/* provision checklist */
.checklist { display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-muted); }
.check .box { width: 18px; height: 18px; border-radius: 5px; border: 1px solid var(--border-strong); display: flex; align-items: center; justify-content: center; font-size: 12px; }
.check.done { color: var(--text); }
.check.done .box { background: var(--good); border-color: var(--good); color: #04121a; }
.activation { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r); padding: 12px; font-family: var(--mono); font-size: 12px; word-break: break-all; color: var(--accent); }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; background: var(--panel); border: 1px solid var(--border-strong); border-radius: 10px; padding: 12px 18px; font-size: 14px; box-shadow: var(--shadow); max-width: 90vw; }
.toast.bad { border-color: var(--bad); color: var(--bad); }
.toast.good { border-color: var(--good); color: var(--good); }

.empty { text-align: center; color: var(--text-muted); padding: 60px 20px; }
.spinner { width: 22px; height: 22px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .hero { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .health-grid { grid-template-columns: 1fr; }
  .topnav { display: none; }
}
