:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #f0f2ee;
  --border: #dde1d9;
  --text: #1d2420;
  --muted: #5d6a62;
  --accent: #2f7a4f;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1e8;
  --warn: #9a6400;
  --warn-soft: #fdf3dc;
  --bad: #b3261e;
  --bad-soft: #fbe6e4;
  --info: #1f5f99;
  --info-soft: #e3eef8;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --surface: #1a201c;
    --surface-2: #222a25;
    --border: #2f3a33;
    --text: #e4ebe6;
    --muted: #9aa8a0;
    --accent: #5fbf86;
    --accent-ink: #0d1a12;
    --accent-soft: #1f3528;
    --warn: #e5b04a;
    --warn-soft: #3a2f17;
    --bad: #f08a80;
    --bad-soft: #3b1f1c;
    --info: #79b4ec;
    --info-soft: #1b2c3d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 13px;
}
.brand-name { font-weight: 650; }
.brand-sub { color: var(--muted); font-size: 12px; }
.conn { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.conn .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.conn.ok .dot { background: var(--accent); }
.conn.bad .dot { background: var(--bad); }
.count {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px;
  border-radius: 10px; background: var(--surface-2); font-size: 12px;
}

/* Layout */
.layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); min-height: calc(100vh - 55px); }
.layout.with-inspector { grid-template-columns: 200px minmax(0, 1fr) 380px; }

.sidenav {
  position: sticky; top: 55px; align-self: start;
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px 10px;
}
.sidenav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  color: var(--text); text-decoration: none;
}
.sidenav a:hover { background: var(--surface-2); }
.sidenav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidenav a.sep { margin-top: 10px; }
.step {
  display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600;
}
.sidenav a.active .step { background: var(--accent); color: var(--accent-ink); }

main { padding: 20px 24px 60px; outline: none; min-width: 0; }

h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 22px 0 8px; }
.lead { color: var(--muted); margin: 0 0 18px; max-width: 760px; }

/* Cards and forms */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.form { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.field.grow { flex: 1 1 320px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
/* A note on the label's own line, so fields with one still line up */
.label-hint { font-weight: 400; margin-left: 6px; }
.label-hint::before { content: '\00B7'; margin-right: 6px; }
input[type=text], input[type=password], input[type=search], input[type=datetime-local], input[type=number], select {
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 9px; min-height: 36px; width: 100%;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; min-height: 36px; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; min-height: 36px;
  border-radius: 6px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--accent); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.small { padding: 3px 9px; min-height: 28px; font-size: 12.5px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Notices */
.notice { border-radius: var(--radius); padding: 10px 12px; margin: 12px 0; border: 1px solid transparent; }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice.ok { background: var(--accent-soft); color: var(--accent); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice strong { display: block; margin-bottom: 2px; }
.notice .detail { color: var(--text); margin-top: 6px; font-size: 13px; }
.notice pre { margin: 6px 0 0; white-space: pre-wrap; word-break: break-word; color: var(--text); }

/* Stats */
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.stat { background: var(--surface-2); border-radius: var(--radius); padding: 8px 12px; min-width: 120px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; }

/* Region chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: 12.5px; cursor: pointer;
  padding: 3px 10px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .n { opacity: .7; margin-left: 4px; }
.scope { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin-top: 6px; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
tr.expandable { cursor: pointer; }
tr.expandable:hover td { background: var(--surface-2); }
tr.offers > td { background: var(--surface-2); padding: 8px 10px 12px 34px; }
tr.offers table { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.caret { display: inline-block; width: 12px; color: var(--muted); }
.sub { color: var(--muted); font-size: 12px; }
.linkish { color: var(--accent); cursor: pointer; text-decoration: underline; background: none; border: 0; padding: 0; font: inherit; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.available { background: var(--accent-soft); color: var(--accent); }
.badge.out_of_stock { background: var(--warn-soft); color: var(--warn); }
.badge.discontinued { background: var(--bad-soft); color: var(--bad); }
.badge.live { background: var(--info-soft); color: var(--info); }
.badge.snapshot { background: var(--surface-2); color: var(--muted); }
.badge.file { background: var(--accent-soft); color: var(--accent); }

.more { margin-top: 10px; }

/* Inspector */
.inspector {
  position: sticky; top: 55px; align-self: start;
  height: calc(100vh - 55px); display: flex; flex-direction: column;
  border-left: 1px solid var(--border); background: var(--surface);
}
/* display:flex above would otherwise beat the hidden attribute */
.inspector[hidden] { display: none; }
.inspector-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.req-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; max-height: 38%; border-bottom: 1px solid var(--border); }
.req-list li { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; padding: 6px 12px; cursor: pointer; font-size: 12.5px; border-bottom: 1px solid var(--border); }
.req-list li:hover, .req-list li.sel { background: var(--surface-2); }
.req-list .st { font-family: var(--mono); font-weight: 700; }
.req-list .st.s2 { color: var(--accent); }
.req-list .st.s3 { color: var(--info); }
.req-list .st.s4, .req-list .st.s0 { color: var(--warn); }
.req-list .st.s5 { color: var(--bad); }
.req-list .path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.req-list .ms { color: var(--muted); }
.req-detail { flex: 1; overflow-y: auto; padding: 12px; font-size: 13px; }
.req-detail pre {
  background: var(--surface-2); border-radius: 6px; padding: 10px;
  overflow: auto; max-height: 420px; white-space: pre; margin: 6px 0 12px;
}
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 10px; margin-bottom: 10px; }
.kv .k { color: var(--muted); }
.kv .v { word-break: break-all; }

/* Docs */
.docs h2 { margin-top: 26px; }
.docs table { margin: 8px 0 14px; }
.docs pre { background: var(--surface-2); border-radius: 6px; padding: 10px; overflow-x: auto; }

/* Phone and tablet */
@media (max-width: 900px) {
  .layout, .layout.with-inspector { grid-template-columns: 1fr; }
  .sidenav { position: static; flex-direction: row; overflow-x: auto; padding: 8px 16px; border-bottom: 1px solid var(--border); }
  .sidenav a { white-space: nowrap; }
  .sidenav a.sep { margin-top: 0; }
  main { padding: 16px; }
  .inspector { position: fixed; inset: auto 0 0 0; height: 60vh; border-left: 0; border-top: 1px solid var(--border); z-index: 20; }
  .brand-sub { display: none; }
}

/* Splash: the start screen and the password page */
body.splash .sidenav { display: none; }
body.splash .layout { grid-template-columns: minmax(0, 1fr); }
body.splash .layout.with-inspector { grid-template-columns: minmax(0, 1fr) 380px; }
.splash-page { display: grid; place-items: center; min-height: calc(100vh - 120px); padding: 24px 16px; }
.splash-card { width: 100%; max-width: 520px; text-align: center; padding: 32px 28px; }
.splash-card h1 { font-size: 22px; margin: 14px 0 6px; }
.splash-card .lead { margin: 0 auto 18px; }
.splash-card .field { text-align: left; margin-bottom: 12px; }
.brand-mark.big { width: 56px; height: 56px; font-size: 20px; border-radius: 12px; margin: 0 auto; }
.btn.big { padding: 10px 28px; font-size: 15px; min-height: 44px; }
a.conn { text-decoration: none; }

@media (max-width: 900px) {
  body.splash .layout.with-inspector { grid-template-columns: 1fr; }
}

.lock-form { margin: 0; }
