:root {
  --green: #0b6b3a; --green-ink: #ffffff; --green-soft: #e3f1e8;
  --bg: #f4f7f4; --card: #ffffff; --ink: #14221a; --muted: #5a6b61; --line: #d9e2dc;
  --warn: #8a5a00; --warn-soft: #fff3d6; --bad: #a3231b; --bad-soft: #fde7e5; --good: #0b6b3a;
  --radius: 12px; --gutter: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --green: #3fbf7a; --green-ink: #06210f; --green-soft: #15301f;
    --bg: #0e1511; --card: #16201a; --ink: #e8f0ea; --muted: #9ab0a2; --line: #26362c;
    --warn: #f0c36a; --warn-soft: #33290f; --bad: #ff8a80; --bad-soft: #3a1815; --good: #6fe0a0;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1.02rem; }
p { margin: .3rem 0 .7rem; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; margin: .2rem 0; font-size: .92rem; }
[hidden] { display: none !important; }

.login { min-height: 100vh; display: grid; place-items: center; padding: var(--gutter); }
.login-card { width: 100%; max-width: 380px; display: grid; gap: .6rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
label { display: grid; gap: .25rem; font-size: .9rem; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .65rem .75rem; width: 100%; min-height: 44px; }
textarea { min-height: 84px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }

.btn { font: inherit; min-height: 44px; padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--green-ink); font-weight: 600; }
.btn.danger { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn.link { border: 0; background: none; color: var(--green); text-decoration: underline; min-height: 40px; }
.btn.small { min-height: 38px; padding: .3rem .7rem; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.shell { min-height: 100vh; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .6rem; padding: .5rem var(--gutter); background: var(--green); color: var(--green-ink); }
.top h2 { flex: 1; margin: 0; font-size: 1.05rem; }
.icon-btn { font-size: 1.4rem; min-width: 44px; min-height: 44px; border: 0; background: transparent; color: inherit; cursor: pointer; border-radius: 10px; }
.chip { display: inline-block; padding: .15rem .6rem; border-radius: 999px; background: rgba(255,255,255,.2); font-size: .8rem; max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(280px, 82vw); background: var(--card); border-right: 1px solid var(--line); transform: translateX(-102%); transition: transform .18s ease; z-index: 40; padding: 1rem .6rem; display: flex; flex-direction: column; gap: .2rem; overflow-y: auto; }
.drawer.open { transform: none; }
@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; }
.nav { font: inherit; text-align: left; min-height: 46px; padding: .5rem .8rem; border-radius: 10px; border: 0; background: none; color: var(--ink); cursor: pointer; }
.nav.active { background: var(--green-soft); color: var(--green); font-weight: 600; }
.nav.out { margin-top: auto; color: var(--bad); }
.main { padding: var(--gutter); max-width: 980px; margin: 0 auto; }
@media (min-width: 900px) {
  .drawer { transform: none; }
  .top .icon-btn { display: none; }
  .scrim { display: none !important; }
  .shell { padding-left: 280px; }
  .top { margin-left: 0; }
}

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; }
.tile b { display: block; font-size: 1.7rem; line-height: 1.1; }
.tile span { color: var(--muted); font-size: .85rem; }
.tile.warn b { color: var(--warn); } .tile.bad b { color: var(--bad); }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row.spread { justify-content: space-between; }
.list { display: grid; gap: .6rem; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; }
.item h3 { margin-bottom: .2rem; word-break: break-word; }
.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; border: 1px solid var(--line); background: var(--bg); }
.pill.good { color: var(--good); border-color: var(--good); }
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn); }
.pill.bad { color: var(--bad); background: var(--bad-soft); border-color: var(--bad); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .15rem .8rem; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.tabs { display: flex; gap: .4rem; margin-bottom: .8rem; }
.tab { font: inherit; min-height: 42px; padding: .4rem .9rem; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.tab.active { background: var(--green); border-color: var(--green); color: var(--green-ink); }
details > summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .6rem; font-size: .8rem; max-height: 220px; overflow: auto; }
.empty { text-align: center; color: var(--muted); padding: 1.6rem .5rem; }
.secret { font: 600 1.4rem/1.3 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .04em; text-align: center; padding: .8rem; background: var(--green-soft); border-radius: 10px; word-break: break-all; user-select: all; }

.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.5); display: grid; place-items: end center; }
.modal-box { width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; background: var(--card); border-radius: 18px 18px 0 0; padding: 1.1rem var(--gutter) calc(1.1rem + env(safe-area-inset-bottom)); display: grid; gap: .6rem; }
@media (min-width: 600px) { .modal { place-items: center; } .modal-box { border-radius: 18px; } }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 80; background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 999px; max-width: 90vw; font-size: .92rem; }

.row + .row, form.row + .row { margin-top: .6rem; }
