:root {
  --bg: #f6f7f9; --card: #fff; --text: #16181d; --muted: #646b78; --line: #e3e6eb;
  --accent: #2f6bff; --accent-text: #fff; --buy: #138a4f; --sell: #c43c3c; --warn-bg: #fff4dd; --warn: #8a5a00;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --card: #181b21; --text: #e8eaee; --muted: #9aa1ad; --line: #2a2f38;
          --accent: #5b8cff; --buy: #3ccf85; --sell: #ff6b6b; --warn-bg: #3a2e12; --warn: #ffd27a; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
nav { display: flex; gap: 4px 16px; flex-wrap: wrap; align-items: center; padding: 10px 16px;
      padding-top: max(10px, env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line);
      position: sticky; top: 0; z-index: 5; }
nav a { text-decoration: none; color: var(--text); font-weight: 500; }
nav .brand { font-weight: 800; margin-right: 8px; }
nav .right { margin-left: auto; }
main { max-width: 900px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.6rem; margin: 8px 0; }
h2 { font-size: 1.2rem; margin: 28px 0 8px; }
h3 { font-size: 1rem; margin: 16px 0 4px; }
.narrow { max-width: 400px; margin: 40px auto; }
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px;
        margin: 10px 0; color: inherit; }
.linkcard { text-decoration: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.grid .card { margin: 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.tiny { color: var(--muted); font-size: .82rem; }
.addr { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; word-break: break-all; color: var(--muted); margin: 4px 0; }
.pill { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.pill.off { opacity: .6; }
label { display: block; margin: 10px 0; font-size: .9rem; color: var(--muted); }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 10px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
input[type=checkbox] { width: auto; display: inline; margin: 0; }
button { font: inherit; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
         color: var(--text); cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.big { padding: 14px; width: 100%; font-size: 1.05rem; margin: 6px 0; }
button.link { background: none; border: none; padding: 0; color: var(--accent); }
.danger { color: var(--sell) !important; }
.flash { background: var(--card); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; }
.warn { background: var(--warn-bg); color: var(--warn); padding: 10px 14px; border-radius: 8px; margin: 10px 0; font-size: .9rem; }
table { width: 100%; border-collapse: collapse; }
.bal td { padding: 4px 0; border-bottom: 1px solid var(--line); }
.bal td:first-child { color: var(--muted); padding-right: 12px; }
.list td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list tr:last-child td, .bal tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.side { font-weight: 700; text-transform: uppercase; font-size: .8rem; }
.side.buy { color: var(--buy); } .side.sell { color: var(--sell); }
.status { font-size: .8rem; }
.status.copied { color: var(--buy); } .status.skipped, .status.expired { color: var(--muted); }
.status.pending { color: var(--accent); font-weight: 600; }
tr.click { cursor: pointer; }
@media (max-width: 600px) { .list td:first-child { display: none; } }

/* wallets table */
.card.flush { padding: 0; overflow: hidden; }
.card.total { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.card.total b { font-size: 1.5rem; }
.wtable th { text-align: left; font-size: .78rem; color: var(--muted); font-weight: 600; padding: 10px 12px;
             border-bottom: 1px solid var(--line); }
.wtable td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.wtable tbody tr:last-child td { border-bottom: none; }
.wtable tr.empty { opacity: .6; }
.wtable .hold { display: flex; justify-content: space-between; gap: 12px; white-space: nowrap; }
.wtable .addr { margin: 2px 0 0; }
.wtable .sep { display: none; }
.wtable .lp { margin-top: 4px; font-size: .85rem; }
.lppill { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
@media (max-width: 700px) {   /* phone: each wallet becomes a compact block */
  .wtable thead { display: none; }
  .wtable, .wtable tbody, .wtable tr, .wtable td { display: block; width: 100%; }
  .wtable tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .wtable tbody tr:last-child { border-bottom: none; }
  .wtable td { border: none; padding: 4px 14px; }
  .wtable td.num { text-align: left; }
  .wtable td[data-l="Value"]:empty, .wtable td[data-l="Checked"] br { display: none; }
  .wtable .sep { display: inline; }
}
