:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #16172b;
  --muted: #6b6f86;
  --line: #e4e6f0;
  --accent: #4f46e5;
  --accent-soft: #eceafd;
  --good: #16a34a;
  --good-soft: #e3f6ea;
  --bad: #dc2626;
  --bad-soft: #fdeaea;
  --warn: #d97706;
  --warn-soft: #fdf1df;
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1020;
    --card: #1a1b30;
    --text: #eceef8;
    --muted: #9aa0bd;
    --line: #2b2d47;
    --accent: #8b85ff;
    --accent-soft: #29285a;
    --good: #34d27a;
    --good-soft: #163626;
    --bad: #f87171;
    --bad-soft: #3d1c22;
    --warn: #fbbf24;
    --warn-soft: #3a2d12;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 calc(env(safe-area-inset-bottom) + 24px);
}
#app { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
h1 { font-size: 26px; margin: 18px 0 14px; display: flex; align-items: center; justify-content: space-between; }
h2 { font-size: 20px; margin: 0 0 14px; }
h3 { font-size: 15px; margin: 22px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
button {
  font: inherit; border: 0; border-radius: 12px; padding: 12px 14px; cursor: pointer;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
button.primary { background: var(--accent); color: #fff; }
button.danger { background: var(--bad-soft); color: var(--bad); }
button.good { background: var(--good-soft); color: var(--good); }
button.ghost { background: transparent; color: var(--muted); padding: 8px; }
button:disabled { opacity: .5; }
button:active { transform: scale(.97); }
input, select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; width: 100%;
}
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
label.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.icon-btn { background: var(--card); color: var(--text); width: 44px; height: 44px; padding: 0; font-size: 20px; border-radius: 50%; }

.card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.dev-name { font-size: 19px; font-weight: 700; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); margin-top: 2px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.running { background: var(--good); box-shadow: 0 0 0 4px var(--good-soft); }
.dot.locked { background: var(--bad); }
.dot.paused, .dot.nouser, .dot.free { background: var(--warn); }
.balance { font-size: 44px; font-weight: 800; letter-spacing: -.02em; margin: 14px 0 0; font-variant-numeric: tabular-nums; }
.balance.zero { color: var(--bad); }
.sub { color: var(--muted); font-size: 14px; }
.grid { display: grid; gap: 8px; margin-top: 14px; }
.grid.g4 { grid-template-columns: repeat(4, 1fr); }
.grid.g2 { grid-template-columns: 1fr 1fr; }
.badge { display: inline-block; font-size: 13px; padding: 4px 10px; border-radius: 99px; background: var(--bad-soft); color: var(--bad); font-weight: 600; margin-top: 10px; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.request { background: var(--warn-soft); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.request b { display: block; margin-bottom: 4px; }
.request .msg { font-style: italic; margin: 6px 0; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .big { font-size: 56px; }

#sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 10; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; max-height: 92vh; overflow-y: auto;
  background: var(--card); border-radius: 22px 22px 0 0; padding: 20px 16px calc(env(safe-area-inset-bottom) + 24px);
  max-width: 600px; margin: 0 auto; animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; }
.field { margin: 10px 0; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.days input { padding: 10px 2px; text-align: center; }
.days small { display: block; text-align: center; color: var(--muted); font-size: 12px; }
.steps { padding-left: 20px; margin: 8px 0; }
.steps li { margin: 8px 0; }
.code-input { font-size: 30px; text-align: center; letter-spacing: .3em; font-weight: 700; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 110px; margin-top: 8px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar i { display: block; width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar small { font-size: 10px; color: var(--muted); margin-top: 4px; }
.events { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.events li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; }
.events time { color: var(--muted); white-space: nowrap; }
.link-box { display: flex; gap: 8px; align-items: center; }
.link-box code { flex: 1; font-size: 13px; background: var(--bg); padding: 10px; border-radius: 10px; overflow-wrap: anywhere; }
#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%); z-index: 20;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; max-width: 90vw;
}
.login { margin-top: 18vh; }
.login .card { padding: 24px; }
.login p { color: var(--muted); }
