:root {
  --bg: #f4f6f5; --surface: #ffffff; --surface-2: #eef2f0; --line: #dde3e0;
  --ink: #14201c; --ink-2: #4a5a55; --ink-3: #7b8a85;
  --accent: #1f6f5c; --accent-ink: #ffffff; --accent-soft: #dcefe8;
  --hot: #c2410c; --hot-soft: #ffedd5;
  --good: #15803d; --warn: #b45309; --bad: #b91c1c;
  --bar: #2a8a72;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1312; --surface: #181d1c; --surface-2: #202725; --line: #2b3432;
    --ink: #e6ecea; --ink-2: #a9b6b2; --ink-3: #74827e;
    --accent: #3fb394; --accent-ink: #06231c; --accent-soft: #173a31;
    --hot: #fb923c; --hot-soft: #3a2314;
    --good: #4ade80; --warn: #fbbf24; --bad: #f87171;
    --bar: #3fb394;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.45 Roboto, "Noto Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

#top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
#top h1 { font-size: 19px; margin: 0; flex: 1; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#top-actions { display: flex; gap: 6px; }
#view { padding: 12px 16px 24px; max-width: 760px; margin: 0 auto; }

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 7px; color: var(--ink-3); text-decoration: none; font-size: 11.5px;
}
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabs a.on { color: var(--accent); }
#tabs a.on svg { stroke-width: 2.3; }

#banner {
  position: sticky; top: 0; z-index: 7; padding: 10px 16px; background: var(--hot-soft); color: var(--ink);
  font-size: 14px; border-bottom: 1px solid var(--line);
}
#banner a { font-weight: 600; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.card.hot { border-color: color-mix(in srgb, var(--hot) 55%, var(--line)); }
.card h3 { margin: 0 0 4px; font-size: 15.5px; font-weight: 620; line-height: 1.3; }
.meta { color: var(--ink-3); font-size: 12.5px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { height: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 550; white-space: nowrap;
}
.chip.hot { background: var(--hot-soft); color: var(--hot); }
.chip.acc { background: var(--accent-soft); color: var(--accent); }
.chip.good { color: var(--good); }
.chip.bad { color: var(--bad); }
.chip.warn { color: var(--warn); }

.items { list-style: none; margin: 8px 0 0; padding: 0; }
.items li { padding: 6px 0; border-top: 1px dashed var(--line); }
.items li:first-child { border-top: 0; }
.items .t { font-weight: 560; }
.items .p { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 650; }
.items .n { color: var(--ink-2); font-size: 13px; font-style: italic; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; }
.thumbs img { height: 84px; border-radius: 10px; flex: none; background: var(--surface-2); }
.photo-one { float: right; width: 72px; height: 72px; object-fit: cover; border-radius: 10px; margin: 0 0 6px 10px; background: var(--surface-2); }

.actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 10px;
  font-weight: 560; font-size: 14px; cursor: pointer; text-decoration: none; color: var(--ink);
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px;
}
.btn.pri { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn:disabled { opacity: .55; }
.icon-btn { border: 0; background: transparent; padding: 6px; border-radius: 8px; color: var(--ink-2); cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }

.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; margin-bottom: 10px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 7px 4px; border-radius: 8px; font-size: 13.5px; font-weight: 560; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
input[type=text], input[type=search], input[type=number], input[type=password], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 12px; min-height: 40px;
}
textarea { min-height: 120px; font-family: ui-monospace, monospace; font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label.field { display: block; margin: 10px 0; }
label.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }

.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .15s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 18px 2px 8px; font-weight: 650; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat span { color: var(--ink-3); font-size: 12.5px; }
.svc { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.svc:first-child { border-top: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--ink-3); }
.dot.ok { background: var(--good); } .dot.bad { background: var(--bad); } .dot.busy { background: var(--warn); }

.chart { position: relative; }
.chart svg { width: 100%; height: 130px; display: block; overflow: visible; }
.chart .tip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 12px;
  padding: 4px 8px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, -100%); top: 0;
}
pre.logs {
  background: var(--surface-2); border-radius: 10px; padding: 10px; font-size: 11px; line-height: 1.4;
  overflow-x: auto; white-space: pre-wrap; word-break: break-word; max-height: 60vh; overflow-y: auto; margin: 8px 0 0;
}
.desc { font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.desc b { font-weight: 650; }

.chat { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.bubble { padding: 8px 12px; border-radius: 14px; max-width: 88%; white-space: pre-wrap; font-size: 14px; }
.bubble.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.chat-input { display: flex; gap: 8px; }
.chat-input input { flex: 1; }

#sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--surface);
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: 85vh; overflow-y: auto; max-width: 760px; margin: 0 auto;
}
#sheet h2 { margin: 0 0 8px; font-size: 17px; }
#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 30;
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 14px; max-width: 90vw;
}
.empty { text-align: center; color: var(--ink-3); padding: 40px 10px; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -3px; }
@keyframes sp { to { transform: rotate(360deg); } }
details > summary { cursor: pointer; color: var(--ink-2); font-size: 13.5px; padding: 4px 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; }
.login { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.login img { width: 84px; height: 84px; border-radius: 22px; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; flex: none; background: var(--surface-2); }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
article.card { cursor: pointer; }
.items .p { margin-left: 8px; }
