/* Black Spider: the CEO / Reports gold on ink. Phone first, then tablet and computer. */
:root {
  --ink: #14110A; --ink2: #1D180E; --ink3: #2A2110; --line: #3A2F18;
  --gold: #CFA53C; --gold-lt: #EBD597; --gold-dk: #9A7A22;
  --ivory: #F6F2EA; --mute: #B7AB90; --dim: #8F836A;
  --alert: #E8806F; --silent: #E3A94F; --calm: #7FBF9E; --unk: #9A8F76;
  --r: 14px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; background: var(--ink); color: var(--ivory); font-family: 'DM Sans', system-ui, sans-serif; font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.ti { line-height: 1; }

/* ── gate ── */
.gate { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(120% 90% at 50% 0%, #2A2110 0%, #14110A 60%); }
.gate-card { width: 100%; max-width: 340px; text-align: center; padding: 34px 26px 22px; border: 1px solid var(--line); border-radius: 22px; background: rgba(29, 24, 14, .86); }
.gate-mark { border-radius: 16px; margin-bottom: 14px; }
.gate-name { font-family: 'Playfair Display', serif; font-size: 28px; color: var(--gold-lt); }
.gate-sub { font-size: 12.5px; color: var(--mute); margin: 2px 0 24px; letter-spacing: .04em; }
.gate-btn { display: block; width: 100%; min-height: 48px; margin-top: 12px; border-radius: 12px; background: var(--gold); color: #1A1408; font-weight: 700; font-size: 15px; }
.gate-btn:active { background: var(--gold-lt); }
.gate-err { min-height: 20px; margin-top: 10px; font-size: 13px; color: var(--alert); }
.gate-device { display: none; }
.gate-device.show { display: block; }
.gate-device > .ti { font-size: 38px; color: var(--gold); }
.gate-h { font-family: 'Playfair Display', serif; font-size: 21px; margin: 8px 0 6px; }
.gate-device p { font-size: 13.5px; color: var(--mute); }
.gate-ver { margin-top: 22px; font-size: 11px; color: var(--dim); letter-spacing: .08em; }

/* ── bar and navigation ── */
.bar { position: sticky; top: 0; z-index: 20; background: rgba(20, 17, 10, .96); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); backdrop-filter: blur(8px); }
.bar-in { display: flex; align-items: center; gap: 12px; max-width: 1040px; margin: 0 auto; padding: 10px 16px; }
.bar-mark { border-radius: 9px; flex: none; }
.bar-title { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.bar-title span { font-family: 'Playfair Display', serif; font-size: 19px; color: var(--gold-lt); line-height: 1.1; }
.bar-title small { font-size: 11.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-btn { flex: none; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); display: grid; place-items: center; font-size: 19px; color: var(--gold); }
.bar-btn.spin .ti { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tabs { display: none; gap: 4px; }
.tab { display: flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 16px; border-radius: 12px; color: var(--mute); font-weight: 500; }
.tab.on { background: var(--gold); color: #1A1408; font-weight: 700; }
.tab .n { min-width: 20px; padding: 1px 6px; border-radius: 10px; background: var(--alert); color: #1A0A07; font-size: 11.5px; font-weight: 700; text-align: center; }
.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: rgba(20, 17, 10, .97); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); backdrop-filter: blur(8px); }
.bt { flex: 1; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 500; color: var(--dim); position: relative; }
.bt .ti { font-size: 21px; }
.bt.on { color: var(--gold); }
.bt .n { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--alert); color: #1A0A07; font-size: 11px; font-weight: 700; text-align: center; }

.banner { max-width: 1040px; margin: 12px auto 0; padding: 12px 16px; border-radius: var(--r); background: var(--ink3); border: 1px solid var(--gold-dk); color: var(--gold-lt); font-size: 13.5px; display: flex; gap: 10px; align-items: center; }
.banner a, .banner button { margin-left: auto; flex: none; min-height: 40px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 10px; background: var(--gold); color: #1A1408; font-weight: 700; font-size: 13px; }

.main { max-width: 1040px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
h2.sec { font-family: 'Playfair Display', serif; font-weight: 500; font-size: 20px; color: var(--gold-lt); margin: 22px 0 4px; }
h2.sec:first-child { margin-top: 4px; }
.sec-sub { font-size: 12.5px; color: var(--mute); margin-bottom: 12px; }
.empty { padding: 22px 16px; text-align: center; color: var(--mute); border: 1px dashed var(--line); border-radius: var(--r); font-size: 14px; }
.err { padding: 14px 16px; border-radius: var(--r); background: #3A1A14; border: 1px solid #7A3A2C; color: #F2B6A8; font-size: 13.5px; }
.note { padding: 12px 14px; border-radius: var(--r); background: var(--ink2); border: 1px solid var(--line); color: var(--mute); font-size: 13px; }

/* ── surfaces ── */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.tile { padding: 11px 8px; text-align: center; border-radius: var(--r); background: var(--ink2); border: 1px solid var(--line); min-width: 0; }
.tile b { display: block; font-family: 'Playfair Display', serif; font-size: 26px; line-height: 1.1; }
.tile span { font-size: 11px; color: var(--mute); }
.tile.alert b { color: var(--alert); } .tile.silent b { color: var(--silent); } .tile.calm b { color: var(--calm); } .tile.unknown b { color: var(--unk); }
.grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
.card { min-width: 0; padding: 13px 14px; border-radius: var(--r); background: var(--ink2); border: 1px solid var(--line); text-align: left; width: 100%; display: block; }
button.card:active { background: var(--ink3); }
.card.alert { border-color: #8A4A3C; } .card.silent { border-color: #8A6A2C; }
.card-h { display: flex; align-items: flex-start; gap: 10px; }
.card-n { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.card-m { font-size: 12.5px; color: var(--mute); margin-top: 3px; overflow-wrap: anywhere; }
.chip { flex: none; display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 11.5px; font-weight: 700; border: 1px solid currentColor; white-space: nowrap; }
.chip.alert, .chip.critical, .chip.high { color: var(--alert); } .chip.silent, .chip.medium { color: var(--silent); } .chip.calm { color: var(--calm); }
.chip.unknown, .chip.info, .chip.low { color: var(--unk); }
.chip.kind { color: var(--mute); font-weight: 500; }

/* ── ledger ── */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters .wide { grid-column: 1 / -1; }
.filters select, .filters input { width: 100%; min-height: 46px; padding: 0 12px; border-radius: 12px; background: var(--ink2); border: 1px solid var(--line); min-width: 0; }
.filters select:focus, .filters input:focus { border-color: var(--gold); outline: none; }
.ev { border-top: 1px solid var(--line); }
.ev:first-child { border-top: 0; }
.ev-row { display: flex; gap: 10px; align-items: flex-start; width: 100%; min-height: 56px; padding: 11px 2px; text-align: left; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--unk); }
.dot.critical, .dot.high { background: var(--alert); } .dot.medium { background: var(--silent); } .dot.low { background: #6E8E7E; }
.ev-b { flex: 1; min-width: 0; }
.ev-s { overflow-wrap: anywhere; }
.ev-m { font-size: 12px; color: var(--mute); margin-top: 2px; overflow-wrap: anywhere; }
.ev-d { padding: 0 2px 14px 20px; font-size: 12.5px; color: var(--mute); }
.ev-d dl { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; margin-bottom: 8px; }
.ev-d dt { color: var(--dim); } .ev-d dd { overflow-wrap: anywhere; color: var(--ivory); }
pre { max-width: 100%; overflow: auto; padding: 10px 12px; border-radius: 10px; background: var(--ink); border: 1px solid var(--line); font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; color: var(--gold-lt); white-space: pre-wrap; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--ink2); font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn.gold { background: var(--gold); color: #1A1408; border-color: var(--gold); }
.btn.on { border-color: var(--gold); color: var(--gold); }
.btn:disabled { opacity: .5; }
.more-row { text-align: center; margin-top: 14px; }

/* ── alerts ── */
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--ink2); border: 1px solid var(--line); margin-bottom: 12px; }
.seg button { min-height: 40px; padding: 0 18px; border-radius: 9px; color: var(--mute); font-weight: 600; }
.seg button.on { background: var(--gold); color: #1A1408; }
.al { margin-bottom: 10px; }
.al textarea { width: 100%; min-height: 70px; margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--ink); border: 1px solid var(--line); resize: vertical; }
.al textarea:focus { border-color: var(--gold); outline: none; }

/* ── more ── */
.list { padding-left: 18px; color: var(--mute); font-size: 13.5px; }
.list li { margin: 5px 0; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13.5px; }
.kv span:nth-child(odd) { color: var(--mute); }

.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 12px; background: var(--gold); color: #1A1408; font-weight: 600; font-size: 13.5px; z-index: 60; display: none; }
.toast.show { display: block; }

/* ── tablet and computer ── */
@media (min-width: 821px) {
  .tabs { display: flex; margin-right: auto; margin-left: 18px; }
  .bottom { display: none; }
  .bar-title { flex: none; }
  .main { padding-bottom: 40px; }
  .grid { grid-template-columns: 1fr 1fr; }
  .tiles { gap: 12px; } .tile b { font-size: 30px; }
  .toast { bottom: 28px; }
  .filters { grid-template-columns: 180px 220px 1fr; }
  .filters .wide { grid-column: auto; }
}
@media (min-width: 1100px) { .grid { grid-template-columns: 1fr 1fr 1fr; } }
@media (max-width: 420px) { .ev-d dl { grid-template-columns: 90px 1fr; } .tile b { font-size: 22px; } }
@media (prefers-reduced-motion: reduce) { .bar-btn.spin .ti { animation: none; } }
