:root {
  --bg: #08080d;
  --surface: #13131c;
  --surface-2: #1c1c28;
  --line: #2a2a3a;
  --text: #f4f4f8;
  --muted: #9a9ab0;
  --accent: #ff2d87;
  --accent-2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 16px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Space Grotesk", var(--font);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.01em; margin: 0 0 8px; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 10px; }
a { color: var(--accent-2); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  font: 600 15px var(--font);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform 0.08s, opacity 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.ok { background: var(--ok); color: #04210f; }
.btn.bad { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid #fff; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font: 15px var(--font);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type="range"] { padding: 0; accent-color: var(--accent); background: none; border: 0; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.pill.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: 12px; padding: 10px 14px; font: 600 14px var(--font); cursor: pointer;
}
.chip.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--surface-2)); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px);
  background: #fff; color: #111; padding: 12px 18px; border-radius: 12px; font-weight: 600;
  max-width: calc(100% - 32px); opacity: 0; pointer-events: none; transition: 0.2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #04210f; }

.sheet-wrap {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity 0.2s;
}
.sheet-wrap.open { opacity: 1; }
.sheet {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 22px 22px 0 0; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  transform: translateY(30px); transition: transform 0.2s;
}
.sheet-wrap.open .sheet { transform: none; }
@media (min-width: 700px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 22px; border-bottom: 1px solid var(--line); }
}
.sheet-x {
  position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); cursor: pointer;
}

.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%; margin: 24px auto;
  border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite;
}
