:root {
  --bg: #f4f5f7; --card: #fff; --text: #1d1d1f; --muted: #6e6e73; --line: #e2e2e7;
  --accent: #0a84ff; --accent-h: #0070e0; --danger: #d70015; --ok: #1f9d55; --warn-bg: #ffe066;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111214; --card: #1c1c1f; --text: #f2f2f7; --muted: #9a9aa0; --line: #2e2e33;
          --accent: #0a84ff; --accent-h: #3395ff; --danger: #ff453a; --ok: #32d74b; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
       background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); white-space: pre-wrap; margin: 8px 0; }
.ok { color: var(--ok); }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 12px 0; }
h3 { margin: 0 0 10px; font-size: 17px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; min-width: 0;
}
input[type=search] { flex: 1; }
textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .button {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 8px; padding: 7px 14px; text-decoration: none; display: inline-block; white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-h); }
button.danger { color: var(--danger); }
button.link { border: none; background: none; color: var(--accent); padding: 4px; }
button.small-btn { padding: 3px 9px; font-size: 13px; }
.warning { background: var(--warn-bg); color: #000; padding: 10px 16px; white-space: pre-wrap; font-size: 14px; }
.login-screen { min-height: 90vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 12px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.logo { font-weight: 700; font-size: 20px; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--card);
          border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.tabs button { border: none; background: none; padding: 7px 12px; }
.tabs button.active { background: var(--bg); color: var(--accent); font-weight: 600; }
.who { font-size: 13px; color: var(--muted); }
main { max-width: 1100px; margin: 0 auto; padding: 16px 20px 60px; }
.table-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0 8px; }
.table-tools input { width: 180px; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: 13px; position: sticky; top: 0; background: var(--card); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
td.num, th.num { width: 1%; white-space: nowrap; color: var(--muted); }
td.id { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
td.actions { white-space: nowrap; text-align: right; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--bg); color: var(--muted); margin-left: 6px; }
.scroll { max-height: 60vh; overflow-y: auto; }
.badge { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; }
.job { border-left: 4px solid var(--line); }
.job.running, .job.queued { border-left-color: var(--accent); }
.job.done { border-left-color: var(--ok); }
.job.error { border-left-color: var(--danger); }
.job pre { background: var(--bg); padding: 8px; border-radius: 8px; max-height: 240px; overflow: auto;
           font-size: 12px; white-space: pre-wrap; margin: 8px 0 0; }
.progress { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--accent); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center;
         justify-content: center; padding: 16px; z-index: 20; }
.modal-box { width: 100%; max-width: 720px; max-height: 90vh; overflow-y: auto; margin: 0; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #333; color: #fff;
         padding: 10px 18px; border-radius: 10px; z-index: 30; max-width: 90vw; white-space: pre-wrap; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line);
           border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 640px) {
  .topbar { padding: 8px 12px; } main { padding: 12px; }
  td.actions button { padding: 3px 6px; }
}
.spacer { flex: 1; }
.credits { font-size: 13px; padding: 4px 10px; border-radius: 14px; color: var(--accent); }
.token-input { flex: 1; min-width: 220px; font-family: ui-monospace, Consolas, monospace; text-transform: uppercase; }
.buy-box { margin-top: 10px; } .buy-box p { margin: 0 0 8px; white-space: pre-wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat { margin: 0; } .stat b { display: block; font-size: 24px; } .stat span { color: var(--muted); font-size: 13px; }
.pill { font-size: 12px; padding: 1px 8px; border-radius: 8px; background: var(--bg); }
.pill.ok { color: var(--ok); } .pill.bad { color: var(--danger); }
.codes { width: 100%; font-family: ui-monospace, Consolas, monospace; }
label.inline { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.login-card { gap: 14px; align-items: stretch; }
.login-card .brand { justify-content: center; margin-bottom: 4px; }
.login-card h2 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack input { padding: 12px 14px; font-size: 16px; }
.code-input { text-align: center; letter-spacing: 10px; font-size: 26px !important; font-family: ui-monospace, Consolas, monospace; }
button.big { padding: 12px; font-size: 16px; font-weight: 600; border-radius: 10px; }
.center { text-align: center; }
.empty { text-align: center; padding: 30px 10px; }
.accent { color: var(--accent); }
.topbar .tabs { justify-content: center; }
.tabs button { font-size: 15px; }
.balance { margin-left: auto; border-radius: 18px; padding: 6px 14px; font-size: 14px; }
.badge.bad { background: var(--danger); }
.search { display: flex; gap: 8px; max-width: 680px; margin: 10px auto 6px; }
.search input { flex: 1; padding: 13px 16px; font-size: 17px; border-radius: 12px; }
.search button { padding: 0 22px; border-radius: 12px; font-size: 16px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 22px 0 10px; }
.section-head h3 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.app-card { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line);
            border-radius: 14px; padding: 10px 12px; min-width: 0; }
.app-card.wide { margin-bottom: 10px; }
.app-card.flat { border: none; padding: 0 0 10px; }
.app-card.failed { border-color: var(--danger); }
.app-icon { width: 52px; height: 52px; border-radius: 12px; flex: none; object-fit: cover; background: var(--bg); }
.app-icon.letter { display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 22px; }
.av0 { background: #0a84ff; } .av1 { background: #30b0c7; } .av2 { background: #34c759; }
.av3 { background: #ff9f0a; } .av4 { background: #ff375f; } .av5 { background: #af52de; }
.app-info { flex: 1; min-width: 0; }
.app-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-action { flex: none; }
.app-action.row { gap: 4px; }
.pill-btn { border-radius: 16px; padding: 6px 16px; font-weight: 600; font-size: 14px; background: var(--bg);
            color: var(--accent); border: none; position: relative; overflow: hidden; text-decoration: none; display: inline-block; }
.pill-btn.primary { background: var(--accent); color: #fff; }
.pill-btn.ready { background: var(--ok); color: #fff; }
.pill-btn:disabled { opacity: 1; color: var(--muted); }
.progress-btn { min-width: 150px; }
.progress-btn > span:last-child { position: relative; }
.progress-btn .bar { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(10, 132, 255, .25); }
.progress-line { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin: 6px 0 4px; position: relative; }
.progress-line .bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 3px; transition: width .4s; }
.balance-big { font-size: 18px; margin: 0 0 12px; } .balance-big b { font-size: 30px; }
.help { margin-top: 20px; } .help summary { cursor: pointer; font-weight: 600; } .help ol { padding-left: 20px; }
button.link.danger { color: var(--danger); }
#app .card h3 { margin-bottom: 8px; }
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .topbar .tabs { order: 3; flex: 1 1 100%; justify-content: space-around; }
  .tabs button { padding: 6px 8px; }
  .search input { font-size: 16px; }
  .app-card.wide { flex-wrap: wrap; }
  .app-card.wide .app-action { flex: 1 1 100%; display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
}
.bar.w0 { width: 0%; } .bar.w5 { width: 5%; } .bar.w10 { width: 10%; } .bar.w15 { width: 15%; } .bar.w20 { width: 20%; } .bar.w25 { width: 25%; } .bar.w30 { width: 30%; } .bar.w35 { width: 35%; } .bar.w40 { width: 40%; } .bar.w45 { width: 45%; } .bar.w50 { width: 50%; } .bar.w55 { width: 55%; } .bar.w60 { width: 60%; } .bar.w65 { width: 65%; } .bar.w70 { width: 70%; } .bar.w75 { width: 75%; } .bar.w80 { width: 80%; } .bar.w85 { width: 85%; } .bar.w90 { width: 90%; } .bar.w95 { width: 95%; } .bar.w100 { width: 100%; } 
