:root {
  --bg: #0D1015; --surface: #151A22; --surface-2: #171C24; --line: #222937; --line-2: #2A3240;
  --fg: #E8ECF2; --fg-2: #C9D2DE; --muted: #8B95A5; --muted-2: #A8B1BE;
  --accent: #4C8DFF; --accent-ink: #0D1015; --accent-soft: #132036; --accent-line: #1F3354;
  --ok: #3FCB86; --ok-soft: #12261D; --warn: #F0A23B; --danger: #FF8A8A; --danger-line: #3A2226;
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 15px/1.4 Onest, system-ui, -apple-system, "Segoe UI", sans-serif; min-height: 100vh;
       overscroll-behavior-y: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { opacity: .5; cursor: default; }
a { color: #7FB0FF; text-decoration: none; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
.muted { color: var(--muted); }
h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
h2 { margin: 0; font-size: 16px; font-weight: 600; }
.section-title { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--muted);
                 text-transform: uppercase; letter-spacing: .06em; }

.screen { padding: 0 16px calc(96px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 14px;
          animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* header */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 4px 4px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.logo-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent);
             display: flex; align-items: center; justify-content: center; }
.splash { height: 100vh; display: flex; align-items: center; justify-content: center; }
.splash .logo-mark { width: 48px; height: 48px; border-radius: 14px; animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .4; } to { opacity: 1; } }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px;
        background: var(--surface-2); font-weight: 600; }
.pagehead { display: flex; align-items: center; gap: 8px; padding: 16px 0 0; }
.pagehead .grow { flex: 1; min-width: 0; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2);
           display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.tap { display: block; text-align: left; width: 100%; transition: transform .08s; }
.card.tap:active { transform: scale(.985); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.row + .row { margin-top: 10px; }
.divider { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.cc { font-size: 12px; font-weight: 600; color: var(--muted); background: #1F2531; border-radius: 6px; padding: 2px 7px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.pill { padding: 6px 10px; border-radius: 999px; background: var(--surface-2); }
.st-running { color: var(--ok); } .st-stopped { color: #9AA5B4; } .st-busy { color: var(--warn); }
.st-suspended { color: var(--danger); }
.bars2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.meter-l { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.meter { height: 5px; border-radius: 3px; background: #232A36; margin-top: 6px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

.notice { padding: 14px 16px; border-radius: 16px; background: var(--accent-soft); border: 1px solid var(--accent-line);
          display: flex; gap: 12px; align-items: center; font-size: 13px; color: #C9D6EA; }
.empty { text-align: center; padding: 40px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty .big { width: 64px; height: 64px; border-radius: 18px; background: var(--surface-2);
              display: flex; align-items: center; justify-content: center; }

/* buttons */
.btn { height: 48px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 600;
       font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 18px; }
.btn.block { width: 100%; }
.btn.small { height: 44px; border-radius: 12px; padding: 0 16px; }
.btn.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line-2); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn:active { filter: brightness(.92); }

.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.action { height: 84px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface);
          display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-size: 13px; }
.action span { color: var(--fg-2); }
.action.accent { color: var(--accent); }
.action:active { background: var(--surface-2); }

.chart { display: flex; align-items: flex-end; gap: 4px; height: 90px; margin-top: 14px; }
.chart i { flex: 1; border-radius: 3px 3px 0 0; background: #2A3A57; }
.chart i:last-child { background: var(--accent); }
.stats3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.stats3 b { display: block; font-size: 17px; font-weight: 600; margin-top: 2px; }
.stats3 small { font-size: 12px; color: var(--muted); }

/* selectable options */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); text-align: left;
       padding: 10px 12px; min-height: 44px; transition: border-color .12s, background .12s; }
.opt.on { border-color: var(--accent); background: var(--accent-soft); }
.opt:disabled { opacity: .45; }
.opt.center { text-align: center; }
.badge { font-size: 11px; font-weight: 600; color: var(--accent-ink); background: var(--warn); border-radius: 6px; padding: 2px 6px; }

/* switch */
.switch { position: relative; width: 46px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: #2A3240; transition: background .15s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
                   background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }

input.field { width: 100%; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
              color: var(--fg); font: inherit; font-size: 16px; padding: 0 14px; }
input.field:focus { outline: none; border-color: var(--accent); }

.balance-hero { background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 20px; padding: 20px; }
.balance-hero .sum { font-size: 38px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.tx { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid #1C222C; }
.tx .plus { color: var(--ok); }

.danger-zone { border: 1px solid var(--danger-line); border-radius: var(--radius); padding: 16px;
               display: flex; flex-direction: column; gap: 10px; }
.danger-zone h2 { color: var(--danger); }

/* bottom: tab bar & sticky summary */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: #0F1319; border-top: 1px solid #1C222C;
          display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding-bottom: var(--safe-bottom); z-index: 5; }
.tabbar button { height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center;
                 gap: 4px; font-size: 11px; color: var(--muted); }
.tabbar button.on { color: var(--accent); }
.sticky { position: fixed; left: 0; right: 0; bottom: 0; background: #11151C; border-top: 1px solid #1C222C;
          padding: 14px 16px calc(18px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 10px; z-index: 5; }

/* sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; animation: fadebg .15s ease; }
@keyframes fadebg { from { opacity: 0; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; background: #12161D; border-radius: 22px 22px 0 0;
         border-top: 1px solid var(--line); padding: 10px 16px calc(20px + var(--safe-bottom)); z-index: 21;
         display: flex; flex-direction: column; gap: 14px; max-height: 85vh; overflow-y: auto; animation: up .2s ease; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: #2A3240; align-self: center; }
.secret-box { padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
              font-size: 17px; word-break: break-all; text-align: center; }

#toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px);
         background: #232A36; color: var(--fg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
         opacity: 0; pointer-events: none; transition: all .2s; z-index: 30; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: #3A2226; color: #FFD0D0; }

.skeleton { background: linear-gradient(90deg, #151A22, #1C222C, #151A22); background-size: 200% 100%;
            animation: sk 1.2s linear infinite; border-radius: var(--radius); height: 170px; }
@keyframes sk { to { background-position: -200% 0; } }

/* browser (website) mode: phone-width column centred on desktop */
#app { max-width: 560px; margin: 0 auto; }
.tabbar, .sticky { max-width: 560px; margin: 0 auto; }
