:root {
  --fg: #1d2420;
  --muted: #5f6b65;
  --bg: #f4f6f5;
  --card: #ffffff;
  --brand: #0f5132;
  --buy: #1971c2;
  --sell: #e8590c;
  --none: #adb5bd;
  --bad: #c92a2a;
  --warn-bg: #fff4e6;
  --err-bg: #fff5f5;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--fg); background: var(--bg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.top { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px;
  background: var(--card); border-bottom: 1px solid #e3e7e5; position: sticky; top: 0; z-index: 2; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--brand); font-weight: 700;
  text-decoration: none; font-size: 1.15rem; }
main { max-width: 720px; margin: 0 auto; padding: 12px; }
h1 { font-size: 1.4rem; margin: 8px 4px 12px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
.card { display: block; background: var(--card); border-radius: 12px; padding: 14px 16px; margin: 0 0 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06); color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
dl { margin: 0; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid #f0f2f1; }
.row:last-child { border-bottom: 0; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; }
.alert { background: var(--warn-bg); border-radius: 8px; padding: 10px 12px; margin: 10px 0 0; }
.alert.error { background: var(--err-bg); color: var(--bad); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; background: #e9ecef; font-size: .85rem; }
.badge.ok { background: #d3f9d8; color: #2b8a3e; }
.badge.bad { background: #ffe3e3; color: var(--bad); }
.units { list-style: none; padding: 0; margin: 0; }
.unit { display: flex; gap: 8px; align-items: center; }
.unit .badge { margin-left: auto; }
label { display: block; margin: 8px 0 4px; font-weight: 600; }
input[type=text], input[type=password] { width: 100%; font: inherit; font-family: ui-monospace, Menlo, Consolas, monospace;
  padding: 10px; border: 1px solid #ced4da; border-radius: 8px; }
.unit.svc { flex-wrap: wrap; }
#nav { display: flex; align-items: center; gap: 8px; }
button { font: inherit; border-radius: 8px; border: 1px solid #ced4da; background: #fff; padding: 10px 14px;
  cursor: pointer; color: inherit; }
button.primary { background: var(--brand); color: #fff; border-color: var(--brand); margin-top: 10px; }
button.danger { color: var(--bad); border-color: #ffc9c9; }
button.link { border: 0; background: none; color: var(--brand); padding: 6px; }
.switch { display: flex; flex-direction: column; gap: 8px; }
.switch button { text-align: left; }
.switch button.active { border-color: var(--brand); background: #ebfbee; font-weight: 600; }
.switch button.active.danger { border-color: var(--bad); background: var(--err-bg); color: var(--bad); }
.tabs { display: flex; gap: 8px; margin-bottom: 8px; }
.tabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.chart { display: flex; align-items: flex-end; gap: 1px; height: 140px; border-bottom: 1px solid #ced4da; }
.bar { flex: 1 1 0; min-width: 1px; background: var(--none); border-radius: 1px 1px 0 0; }
.bar.buy { background: var(--buy); }
.bar.sell { background: var(--sell); }
.bar.neg { opacity: .55; }
.bar.now { outline: 2px solid var(--fg); outline-offset: 0; }
.axis { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); }
.legend { font-size: .85rem; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--none); }
.dot.buy { background: var(--buy); }
.dot.sell { background: var(--sell); }
table.slots { width: 100%; border-collapse: collapse; font-size: .9rem; }
.slots th, .slots td { padding: 3px 6px; text-align: right; border-bottom: 1px solid #f0f2f1; }
.slots th:first-child, .slots td:first-child { text-align: left; }
.slots tr.buy td:last-child { color: var(--buy); font-weight: 600; }
.slots tr.sell td:last-child { color: var(--sell); font-weight: 600; }
.slots tr.now { background: #fff9db; }
summary { cursor: pointer; margin: 8px 0; }
code { font-size: .8rem; word-break: break-all; }
@media (prefers-color-scheme: dark) {
  :root { --fg: #e9ecef; --muted: #a5b0aa; --bg: #121614; --card: #1c211f; --warn-bg: #3b2f1a; --err-bg: #3b1d1d;
    color-scheme: dark; }
  .top { border-color: #2a302d; }
  .row, .slots th, .slots td { border-color: #2a302d; }
  button { background: #252b28; border-color: #3a423e; }
  input[type=text], input[type=password] { background: #252b28; color: inherit; border-color: #3a423e; }
  .switch button.active { background: #1f3a2a; }
}
