/* WooHub — control room for a network of storefronts.
   Dark navy ground, one amber signal color, data set in Plex Mono. */

:root {
  --ink:    #0E1420;
  --slab:   #16202F;
  --raise:  #1C2838;
  --line:   #263349;
  --text:   #DDE4EE;
  --muted:  #7F8EA6;
  --signal: #FFB020;
  --live:   #30C08A;
  --fault:  #F2545B;
  --rail: 232px;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --r: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ink);
  color: var(--text);
  font: 400 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--text); text-decoration: none; }
a:hover { color: var(--signal); }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail {
  background: var(--slab);
  border-right: 1px solid var(--line);
  padding: 20px 0 32px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 20px 22px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand:hover b { color: var(--signal); }
.brand b { font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.brand .lamp { width: 9px; height: 9px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 10px var(--signal); }
.rail nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 20px; color: var(--muted); font-size: 14.5px;
  border-left: 2px solid transparent;
}
.rail nav a:hover { color: var(--text); background: rgba(255,255,255,.03); }
.rail nav a.is-active { color: var(--text); border-left-color: var(--signal); background: rgba(255,176,32,.06); }
.rail nav a svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.7; flex: 0 0 auto; }
.rail .group { padding: 18px 20px 6px; font-size: 11.5px; color: #5C6B85; letter-spacing: .04em; }
.rail .group:not(:first-of-type) { margin-top: 10px; padding-top: 16px; border-top: 1px solid var(--line); }

.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px);
}
.topbar h1 { font-size: 18px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.topbar .spacer { flex: 1; }
.page { padding: 26px 32px 56px; max-width: 1560px; margin: 0 auto; }

/* Wide screens are for showing more rows, not for stretching a text field to a
   metre wide. Tables and boards use the full width; reading and typing do not. */
.card > p.sub,
.card > p.muted            { max-width: 76ch; }
.card > label.field,
.card > .log,
.card > .preview-wrap      { max-width: 820px; }
.card > .row2,
.card > .row3              { max-width: 1080px; }
.tiles                     { max-width: 1120px; }

/* ---------- status board (dashboard hero) ---------- */
.board { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.board-row {
  display: grid; grid-template-columns: 14px 1.6fr 1fr 1fr 1fr auto;
  gap: 16px; align-items: center;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.board-row:last-child { border-bottom: 0; }
.board-row:hover { background: rgba(255,255,255,.02); }
.board-head { color: var(--muted); font-size: 12px; background: var(--slab); }
.board .name { font-weight: 500; }
.board .host { font: 400 12.5px/1.4 var(--mono); color: var(--muted); }
.lamp { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.lamp.ok { background: var(--live); box-shadow: 0 0 8px rgba(48,192,138,.7); }
.lamp.warn { background: var(--signal); box-shadow: 0 0 8px rgba(255,176,32,.6); }
.lamp.down { background: var(--fault); box-shadow: 0 0 8px rgba(242,84,91,.6); }

/* ---------- pieces ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 22px; }
.tile { background: var(--slab); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.tile .k { color: var(--muted); font-size: 12.5px; }
.tile .v { font: 500 26px/1.2 var(--sans); margin-top: 4px; letter-spacing: -0.02em; }
.tile .v.fault { color: var(--fault); }
.tile .v.signal { color: var(--signal); }

.card { background: var(--slab); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; margin-bottom: 18px; }
.card > h2 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.card > p.sub { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }

table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
table.grid td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tr:hover td { background: rgba(255,255,255,.02); }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 12px; border: 1px solid var(--line); color: var(--muted); }
.badge.ok { color: var(--live); border-color: rgba(48,192,138,.35); background: rgba(48,192,138,.08); }
.badge.warn { color: var(--signal); border-color: rgba(255,176,32,.35); background: rgba(255,176,32,.08); }
.badge.fault { color: var(--fault); border-color: rgba(242,84,91,.35); background: rgba(242,84,91,.08); }

.btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  background: var(--raise); border: 1px solid var(--line); color: var(--text);
  padding: 8px 14px; border-radius: var(--r); font: 500 14px var(--sans);
}
.btn:hover { border-color: #38476220; background: #22304400; background-color: #223044; }
.btn.primary { background: var(--signal); border-color: var(--signal); color: #171208; }
.btn.primary:hover { background: #FFC24D; border-color: #FFC24D; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--fault); border-color: rgba(242,84,91,.4); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

label.field { display: block; margin-bottom: 15px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
label.field > em { display: block; font-size: 12.5px; color: #64748B; font-style: normal; margin-top: 5px; }
input[type=text], input[type=url], input[type=number], input[type=password], select, textarea {
  width: 100%; background: var(--ink); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--r); padding: 9px 11px; font: 400 14px var(--sans);
}
input.mono, textarea.mono { font-family: var(--mono); font-size: 13px; }
textarea { min-height: 90px; resize: vertical; }
input[type=range] { width: 100%; accent-color: var(--signal); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.preview-wrap { background: #0A0F18; border: 1px solid var(--line); border-radius: var(--r); padding: 12px; text-align: center; }
.preview-wrap img { max-width: 100%; border-radius: 4px; }

.log { font: 400 12.5px/1.65 var(--mono); background: #0A0F18; border: 1px solid var(--line); border-radius: var(--r); padding: 14px; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
.log .lv-error { color: var(--fault); }
.log .lv-warn { color: var(--signal); }
.log .lv-info { color: var(--text); }
.log .lv-debug { color: var(--muted); }

.notice { border-left: 2px solid var(--signal); background: rgba(255,176,32,.07); padding: 12px 14px; border-radius: 0 var(--r) var(--r) 0; font-size: 14px; margin-bottom: 16px; }
.notice.bad { border-color: var(--fault); background: rgba(242,84,91,.08); }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h3 { color: var(--text); font-size: 16px; margin: 0 0 6px; }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; }
#toast div { background: var(--raise); border: 1px solid var(--line); border-left: 2px solid var(--live); padding: 10px 16px; border-radius: var(--r); font-size: 14px; }
#toast div.bad { border-left-color: var(--fault); }

.tabbar { display: none; }

/* ---------- the "more" sheet, phone only ---------- */
#sheet { display: none; }
#sheet[data-open="1"] { display: block; }
#sheetBackdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(8, 12, 20, .6); backdrop-filter: blur(2px);
}
#sheetPanel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  max-height: 72vh; overflow-y: auto;
  background: var(--slab); border-top: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  padding: 8px 0 calc(12px + env(safe-area-inset-bottom));
}
#sheetPanel .grab {
  width: 38px; height: 4px; border-radius: 2px; background: var(--line);
  margin: 8px auto 10px;
}
#sheetPanel a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 22px; color: var(--text); font-size: 15px;
}
#sheetPanel a.is-active { color: var(--signal); }
#sheetPanel a svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.7; }
#sheetPanel hr { border: 0; border-top: 1px solid var(--line); margin: 8px 22px; }
#sheetPanel .sheetgroup {
  padding: 14px 22px 4px; font-size: 11.5px; color: #5C6B85; letter-spacing: .04em;
}
#sheetPanel .sheetgroup:not(:first-of-type) { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 14px; }

/* ---------- phone: app-shaped ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .page { padding: 16px 14px 96px; }
  .topbar { padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); }
  .row2, .row3 { grid-template-columns: 1fr; }
  .board-row { grid-template-columns: 12px 1fr auto; row-gap: 6px; }
  .board-row .col-hide { display: none; }
  .board-head { display: none; }
  table.grid thead { display: none; }
  table.grid tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.grid td { display: flex; justify-content: space-between; gap: 14px; border: 0; padding: 5px 4px; }
  table.grid td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; }
  .page { padding: 16px 14px 96px; max-width: none; }
  .card > p.sub, .card > p.muted,
  .card > label.field, .card > .log,
  .card > .preview-wrap, .card > .row2,
  .card > .row3, .tiles { max-width: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: var(--slab); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 7px; font-size: 11px; color: var(--muted); }
  .tabbar a.is-active { color: var(--signal); }
  .tabbar a svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.7; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
