:root {
  --bg: #0f172a; --card: #1e293b; --fg: #e5e7eb; --muted: #94a3b8;
  --accent: #38bdf8; --ok: #34d399; --warn: #fbbf24; --danger: #f87171;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.topbar {
  display: flex; align-items: center; gap: .75rem;
  padding: .9rem 1rem; position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid #ffffff1a;
}
.brand { height: 30px; width: auto; display: block; }
.whoami { color: var(--muted); margin-left: auto; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { max-width: 820px; margin: 0 auto; padding: 1rem; }
.card { background: var(--card); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; }
.login { max-width: 460px; margin: 2rem auto; }
h1, h2 { margin: .2rem 0 .8rem; }
.muted { color: var(--muted); font-size: .9rem; }
label { display: block; margin: .6rem 0; font-size: .9rem; color: var(--muted); }
input, select, textarea {
  width: 100%; margin-top: .3rem; padding: .65rem .7rem; border-radius: 10px;
  border: 1px solid #334155; background: #0b1220; color: var(--fg); font: inherit;
}
button { font: inherit; cursor: pointer; border-radius: 10px; padding: .6rem .9rem; border: 1px solid transparent; }
button.primary, button.tab.active { background: var(--accent); color: #05202e; font-weight: 700; }
button.ghost { background: transparent; color: var(--fg); border-color: #334155; }
button:disabled { opacity: .5; cursor: wait; }
.row { display: flex; gap: .5rem; align-items: center; margin: .3rem 0 .6rem; }
.row input { flex: 1; margin: 0; }
.msg { min-height: 1.2em; font-size: .85rem; color: var(--warn); }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--ok); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.tile {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 84px; border-radius: var(--radius); background: var(--card);
  color: var(--fg); text-decoration: none; font-weight: 600; border: 1px solid #ffffff12;
}
.tile:active { transform: scale(.98); }
.tabs { display: flex; gap: .4rem; margin-bottom: 1rem; }
.tabs .tab { background: var(--card); color: var(--muted); border: 1px solid #ffffff12; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.toolbar input, .toolbar select { width: auto; flex: 1 1 140px; margin: 0; }
.list { display: grid; gap: .6rem; }
.entry { background: var(--card); border-radius: var(--radius); padding: .85rem 1rem; border-left: 4px solid var(--accent); }
.entry.closed { border-left-color: var(--ok); opacity: .75; }
.entry .head { display: flex; gap: .5rem; align-items: baseline; }
.entry .type { font-weight: 700; }
.entry .date { color: var(--muted); font-size: .8rem; margin-left: auto; white-space: nowrap; }
.entry .detail { margin: .4rem 0 .5rem; white-space: pre-wrap; }
.entry .actions { display: flex; gap: .5rem; }
.entry .actions button { padding: .3rem .6rem; font-size: .8rem; }
.pill { font-size: .72rem; padding: .12rem .5rem; border-radius: 999px; background: #ffffff14; color: var(--muted); }
.chart { min-height: 160px; display: grid; place-items: center; color: var(--muted); border: 1px dashed #334155; border-radius: 10px; }
#boot { display: none; min-height: 60vh; place-items: center; }
.icon-btn { background: transparent; color: var(--fg); border: 1px solid #334155; border-radius: 10px; padding: .35rem .6rem; font-size: 1.1rem; line-height: 1; }
.scrim { position: fixed; inset: 0; background: #0009; z-index: 20; }
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: min(78vw, 300px); background: var(--card); z-index: 21; transform: translateX(-100%); transition: transform .2s ease; display: flex; flex-direction: column; padding: .8rem; border-right: 1px solid #ffffff1a; }
.drawer[data-open="1"] { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.drawer-brand { font-weight: 800; letter-spacing: .02em; }
.drawer-nav { display: flex; flex-direction: column; gap: .35rem; }
.drawer-nav .tab { text-align: left; background: transparent; color: var(--fg); border: 1px solid transparent; }
.drawer-nav .tab.active { background: var(--accent); color: #05202e; font-weight: 700; }
.drawer-link { display: block; padding: .6rem .9rem; border-radius: 10px; color: var(--fg); text-decoration: none; border: 1px solid transparent; }
.drawer-link:hover { background: #ffffff10; }
.drawer-foot { margin-top: auto; }
.drawer-foot .logout { width: 100%; border-color: #7f1d1d; color: var(--danger); }
html[data-boot="1"] #login { display: none; }
html[data-boot="1"] #boot { display: grid; }
@media (prefers-color-scheme: light) {
  :root { --bg: #f8fafc; --card: #ffffff; --fg: #0f172a; --muted: #64748b; }
  input, select, textarea { background: #f1f5f9; border-color: #cbd5e1; }
}
