/* WesanDev Admin - graphite neutrals, one blue accent (from the logo), status colours only for status. 4px grid. */
:root {
  --bg: #f5f6f7; --surface: #ffffff; --raised: #eef0f2;
  --line: rgba(21, 24, 29, .10); --line-strong: rgba(21, 24, 29, .18);
  --text: #15181d; --text-2: #4a525c; --text-3: #656d78;
  --accent: #1f5fd6; --on-accent: #ffffff;
  --primary: #1f5fd6; --on-primary: #ffffff;
  --ok: #17803d; --bad: #c4302b;
  --ease: cubic-bezier(.2, 0, 0, 1);
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
/* Dark theme: used when theme.js sets data-theme="dark", or (without JS) when the device prefers dark. */
:root[data-theme="dark"] {
  --bg: #0f1114; --surface: #16191d; --raised: #1d2126;
  --line: rgba(233, 236, 240, .09); --line-strong: rgba(233, 236, 240, .18);
  --text: #e9ecf0; --text-2: #a4acb6; --text-3: #7c858f;
  --accent: #5b9bff; --on-accent: #0f1114;
  --primary: #e9ecf0; --on-primary: #0f1114;
  --ok: #4cc27a; --bad: #ff7a72;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0f1114; --surface: #16191d; --raised: #1d2126;
    --line: rgba(233, 236, 240, .09); --line-strong: rgba(233, 236, 240, .18);
    --text: #e9ecf0; --text-2: #a4acb6; --text-3: #7c858f;
    --accent: #5b9bff; --on-accent: #0f1114;
    --primary: #e9ecf0; --on-primary: #0f1114;
    --ok: #4cc27a; --bad: #ff7a72;
  }
}
* { box-sizing: border-box; }
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) { color-scheme: dark; } }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 14px/20px var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, p { margin: 0; }
a { color: var(--accent); }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- controls ---------- */
input { display: block; width: 100%; height: 44px; margin: 8px 0 0; padding: 0 12px; font: 400 16px/24px var(--sans); color: var(--text);
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px; transition: border-color .15s var(--ease), background-color .15s var(--ease); }
input::placeholder { color: var(--text-3); }
input:hover { border-color: var(--text-3); }
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.btn, button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; font: 500 14px/20px var(--sans);
  color: var(--on-primary); background: var(--primary); border: 1px solid transparent; border-radius: 8px; cursor: pointer; text-decoration: none;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .1s var(--ease); }
.btn:active, button:active { transform: scale(.98); }
.btn:hover, button:hover { filter: brightness(1.08); }
.btn.block, form.stack button { width: 100%; height: 44px; margin-top: 24px; }
.quiet { color: var(--text-2); background: transparent; border-color: var(--line-strong); }
.quiet:hover { filter: none; color: var(--text); background: var(--raised); }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- auth pages ---------- */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.panel { width: 100%; max-width: 400px; padding: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.brand img { height: 28px; width: auto; display: block; }
.brand span { font-weight: 500; color: var(--text-2); }
.panel h1 { font-size: 20px; line-height: 28px; font-weight: 500; }
.panel .lede { margin-top: 4px; color: var(--text-2); }
.panel form { margin-top: 24px; }
.panel label { display: block; margin-top: 16px; font-weight: 500; font-size: 13px; line-height: 20px; color: var(--text); }
.panel label:first-of-type { margin-top: 0; }
.panel label small { font-weight: 400; color: var(--text-3); }
.step { margin-bottom: 8px; font: 400 12px/16px var(--mono); color: var(--text-3); }
.alert { margin-top: 16px; padding: 8px 12px; font-size: 13px; color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); border-radius: 8px; }
.done { margin-top: 16px; color: var(--ok); font-weight: 500; }
.code-input { font-family: var(--mono); letter-spacing: .14em; }
ol.steps { margin: 16px 0 0; padding-left: 20px; color: var(--text-2); }
ol.steps li { margin-top: 4px; }
.keybox { display: flex; align-items: center; gap: 8px; margin-top: 16px; padding: 12px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px; }
.keybox code { flex: 1; font: 500 15px/24px var(--mono); letter-spacing: .06em; word-break: break-all; }
.keybox button { height: 32px; padding: 0 12px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 16px 0 0; padding: 16px; list-style: none; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px; font: 500 14px/20px var(--mono); }
.panel .row { display: flex; gap: 8px; margin-top: 16px; }
.panel .row .btn, .panel .row button { flex: 1; }
.panel .small { margin-top: 16px; font-size: 12px; line-height: 16px; color: var(--text-3); }

/* ---------- dashboard ---------- */
.bar { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; justify-content: space-between;
  min-height: 56px; padding: 8px 24px; background: var(--bg); border-bottom: 1px solid var(--line); }
.bar .brand { margin: 0; }
.bar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bar-right form { margin: 0; }
.search { position: relative; display: block; margin: 0; }
.search input { width: 220px; height: 36px; margin: 0; padding: 0 40px 0 36px; font-size: 14px; }
.search .icon { position: absolute; left: 12px; top: 10px; color: var(--text-3); pointer-events: none; }
.keycap { position: absolute; right: 8px; top: 8px; min-width: 20px; height: 20px; padding: 0 6px; font: 500 12px/18px var(--mono); text-align: center;
  color: var(--text-3); background: var(--raised); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; pointer-events: none; }
.bar-right .btn, .bar-right button { height: 36px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 32px 24px 64px; }
.head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; }
.head h1 { font-size: 28px; line-height: 36px; font-weight: 500; letter-spacing: -.01em; }
.summary { font: 400 13px/20px var(--mono); color: var(--text-2); }
.strip { display: flex; gap: 4px; margin: 16px 0 0; padding: 0; list-style: none; }
.strip li { flex: 1; height: 8px; border-radius: 4px; background: var(--line-strong); transition: background-color .3s var(--ease); }
.strip li[data-state="up"] { background: var(--ok); }
.strip li[data-state="down"] { background: var(--bad); }
section { margin-top: 40px; }
section h2 { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; font-size: 13px; line-height: 20px; font-weight: 500; color: var(--text-2); }
section h2 .mono { font-size: 12px; color: var(--text-3); font-weight: 400; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 16px; padding: 16px; color: var(--text); text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; transition: border-color .15s var(--ease), background-color .15s var(--ease); }
.tile:hover { border-color: var(--line-strong); background: color-mix(in srgb, var(--surface) 92%, var(--text) 8%); }
.tile[hidden] { display: none; }
.tile-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ttext { min-width: 0; }
.mono-mark { flex: none; display: grid; place-items: center; width: 40px; height: 40px; font: 500 13px/16px var(--mono); letter-spacing: .02em;
  color: var(--text-2); background: var(--raised); border-radius: 8px; }
.tname { display: block; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tdesc { display: block; font-size: 13px; line-height: 20px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.state { display: inline-flex; align-items: center; gap: 8px; font: 400 12px/16px var(--mono); color: var(--text-3); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); opacity: .6; }
.tile[data-state="up"] .dot { background: var(--ok); opacity: 1; }
.tile[data-state="down"] .dot { background: var(--bad); opacity: 1; }
.tile[data-state="down"] .state { color: var(--bad); }
.open { color: var(--text-3); transition: color .15s var(--ease); }
.tile:hover .open { color: var(--text); }
.empty { margin-top: 40px; color: var(--text-3); }

/* theme toggle + idle warning */
.icon-btn { width: 36px; height: 36px; padding: 0; }
.theme-corner { position: fixed; top: 16px; right: 16px; }
.icon-btn .i-sun, .icon-btn .i-moon { display: none; }
:root[data-theme="dark"] .icon-btn .i-sun { display: block; }       /* dark now -> offer the sun */
:root:not([data-theme="dark"]) .icon-btn .i-moon { display: block; } /* light now -> offer the moon */
.idle-warn { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 12px 16px; font-size: 13px; line-height: 20px;
  color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, .12); }
.idle-warn[hidden] { display: none; }
.info { margin-top: 16px; padding: 8px 12px; font-size: 13px; color: var(--text-2); border: 1px solid var(--line-strong); border-radius: 8px; }

@media (max-width: 560px) {
  .bar { padding: 8px 16px; }
  .search, .search input { width: 100%; }
  .search { flex: 1 1 100%; order: 3; }
  .wrap { padding: 24px 16px 48px; }
  .head h1 { font-size: 24px; line-height: 32px; }
  .panel { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
