:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #16181d;
  --muted: #5d6572;
  --line: #dde1e7;
  --accent: #0b6cff;
  --accent-ink: #ffffff;
  --ok: #138a4b;
  --warn: #b26a00;
  --bad: #c62b3b;
  --field: #fbfcfd;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216;
    --surface: #171b21;
    --ink: #eceff4;
    --muted: #98a2b3;
    --line: #2a313b;
    --accent: #4b97ff;
    --accent-ink: #07101f;
    --ok: #3fcf84;
    --warn: #f0a63a;
    --bad: #ff6b78;
    --field: #12161b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
code { font: 13px ui-monospace, Consolas, monospace; background: var(--field); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); margin: 8px 0 0; }

.app, .auth { max-width: 820px; margin: 0 auto; padding: 24px 16px 64px; }
.auth { min-height: 100vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 360px; }
.auth-card h1 { margin-bottom: 6px; }

.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.status { margin: 6px 0 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.status.live .dot { background: var(--ok); }
.status.stale .dot { background: var(--warn); }
.status.off .dot { background: var(--bad); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 16px; }
.card > p { margin: 6px 0 12px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 4px; }
input[type="text"], input[type="password"] {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--ink);
  background: var(--field); border: 1px solid var(--line); border-radius: 7px;
}
input:focus-visible, button:focus-visible, .drop:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 7px; cursor: pointer;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line);
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:disabled { opacity: .6; cursor: default; }
.auth-card .btn { margin-top: 16px; width: 100%; }

.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.row-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.usage { display: flex; align-items: center; gap: 10px; }
.usage-bar { width: 140px; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.usage-fill { height: 100%; width: 0; background: var(--accent); }
.usage.over .usage-fill { background: var(--bad); }
.usage.over #usageText { color: var(--bad); font-weight: 600; }

.drop {
  display: grid; gap: 4px; text-align: center; padding: 22px 16px; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: 9px; background: var(--field);
}
.drop:hover, .drop.over { border-color: var(--accent); }

.uploads { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.upload { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.upload .meta { display: flex; justify-content: space-between; gap: 10px; }
.upload .bar { height: 5px; background: var(--line); border-radius: 3px; margin-top: 7px; overflow: hidden; }
.upload .bar div { height: 100%; width: 0; background: var(--accent); }
.upload.fail { border-color: var(--bad); }
.upload.fail .msg { color: var(--bad); }
.upload .msg { margin-top: 6px; font-size: 13px; }
.upload .msg.warn { color: var(--warn); }

.list { list-style: none; margin: 16px 0 0; padding: 0; }
.item { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item.disabled .title { color: var(--muted); text-decoration: line-through; }
.num { color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; }
.title { font-weight: 600; word-break: break-word; }
.title-input { font-weight: 600; }
.sub { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.icon { padding: 6px 10px; font-weight: 500; }
.icon.danger { color: var(--bad); }
.icon:disabled { opacity: .35; cursor: default; }

.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 11px; transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.empty { text-align: center; padding: 24px 0 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 10;
}

@media (max-width: 560px) {
  .item { grid-template-columns: 24px 1fr; }
  .item .actions { grid-column: 1 / -1; justify-content: flex-start; }
  .usage-bar { width: 100px; }
}

@media (prefers-reduced-motion: reduce) {
  .switch span, .switch span::after { transition: none; }
}
