:root {
  --bg: #0f1218;
  --panel: #171b24;
  --panel-2: #1e2430;
  --line: #2a3140;
  --text: #e6e9ef;
  --muted: #8b94a7;
  --accent: #f5a524;
  --accent-text: #1a1204;
  --good: #3ecf8e;
  --bad: #f2555a;
  --info: #5b9dff;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }

/* Layout */
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 12px; }
.brand { font-weight: 700; font-size: 18px; padding: 0 10px 18px; }
.brand span { color: var(--accent); }
.side nav a {
  display: block; padding: 9px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; margin-bottom: 2px;
}
.side nav a:hover { color: var(--text); background: var(--panel-2); }
.side nav a.active { color: var(--text); background: var(--panel-2); font-weight: 600; }
.main { padding: 20px 28px 60px; min-width: 0; }
.topbar { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.balance-pill { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 600; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px; }
  .side nav { display: flex; gap: 4px; overflow-x: auto; }
  .side nav a { white-space: nowrap; }
  .brand { padding-bottom: 8px; }
  .main { padding: 16px; }
}

/* Panels and cards */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.card .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.spread h1, .spread h2 { margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; word-break: break-all; }
.empty { color: var(--muted); padding: 14px 0; }

/* Forms */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; resize: vertical; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form > div { flex: 1; min-width: 150px; }
button, .btn {
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: 8px; padding: 9px 14px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.6; cursor: default; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button.sm { padding: 5px 10px; font-size: 12px; }
button.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }

/* Status badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); }
.badge.active, .badge.confirmed, .badge.paid { color: var(--good); }
.badge.pending { color: var(--accent); }
.badge.rejected, .badge.expired, .badge.suspended { color: var(--bad); }
.badge.paused { color: var(--info); }

.notice { border: 1px solid var(--accent); border-radius: 10px; padding: 14px; margin-bottom: 14px; background: rgba(245, 165, 36, 0.07); }
.notice .amount { font-size: 22px; font-weight: 700; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 10px; max-width: 90vw; display: none; z-index: 10;
}
#toast.error { border-color: var(--bad); }
#toast.ok { border-color: var(--good); }

/* Landing page */
.landing { max-width: 980px; margin: 0 auto; padding: 40px 20px; display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; min-height: 100vh; }
.landing h1 { font-size: 38px; line-height: 1.15; }
.landing ul { padding-left: 18px; color: var(--muted); }
.landing li { margin-bottom: 6px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button { flex: 1; }
.field { margin-bottom: 12px; }
.error-text { color: var(--bad); min-height: 20px; margin-bottom: 8px; }
@media (max-width: 760px) {
  .landing { grid-template-columns: 1fr; gap: 20px; }
  .landing h1 { font-size: 28px; }
}
