:root {
  --bg: #0f172a; --bg2: #1e293b; --bg3: #273449; --fg: #e2e8f0; --muted: #94a3b8; --line: #334155;
  --green: #22c55e; --red: #ef4444; --amber: #f59e0b; --blue: #38bdf8;
  --radius: 12px; --gap: 12px;
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: 10px 14px; background: var(--bg3); color: var(--fg); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--green); color: #052e16; font-weight: 600; }
button.danger { background: #7f1d1d; color: #fee2e2; }
button.ghost { background: transparent; border: 1px solid var(--line); }
button.small { padding: 6px 10px; font-size: .9rem; }
input, select, textarea { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: var(--gap); }
.row { display: flex; gap: var(--gap); align-items: center; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.right { text-align: right; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; }
.small { font-size: .85rem; }
h1, h2, h3 { margin: 0 0 8px; font-weight: 600; }
h1 { font-size: 1.25rem; } h2 { font-size: 1.1rem; margin-top: 8px; } h3 { font-size: 1rem; }

header.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(15,23,42,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
header.top .brand { display: flex; align-items: center; gap: 10px; }
header.top img { width: 28px; height: 28px; border-radius: 6px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; letter-spacing: .02em; }
.badge.dryrun { background: #1e3a8a; color: #bfdbfe; }
.badge.live { background: #7f1d1d; color: #fee2e2; }
.badge.ok { background: #14532d; color: #bbf7d0; } .badge.error { background: #7f1d1d; color: #fee2e2; } .badge.running { background: #78350f; color: #fde68a; }
.badge.open { background: #1e3a8a; color: #bfdbfe; } .badge.executed, .badge.adjusted { background: #14532d; color: #bbf7d0; } .badge.rejected { background: #3f3f46; color: #d4d4d8; } .badge.expired { background: #422006; color: #fde68a; }

main { padding: 16px; max-width: 760px; margin: 0 auto; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: var(--gap); }
.card.proposal { border-left: 4px solid var(--blue); }
.card.proposal.sell { border-left-color: var(--amber); }
.card.proposal.buy { border-left-color: var(--green); }
.card .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.preview { background: var(--bg); border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; margin: 10px 0; word-break: break-word; }
.actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.actions button { flex: 1 1 100px; }
.conf { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.conf > i { display: block; height: 100%; background: var(--blue); }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .8rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--gap); }
.kpi { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.kpi .v { font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: .8rem; }

nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--bg2); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
nav.tabs button { flex: 1; background: transparent; border-radius: 0; padding: 12px 4px; color: var(--muted); font-size: .8rem; display: flex; flex-direction: column; align-items: center; gap: 2px; }
nav.tabs button[aria-selected="true"] { color: var(--fg); box-shadow: inset 0 2px 0 var(--green); }
nav.tabs .count { background: var(--green); color: #052e16; border-radius: 999px; font-size: .7rem; padding: 0 6px; margin-left: 4px; }

.login { max-width: 380px; margin: 12vh auto; padding: 24px; }
.login img { width: 56px; height: 56px; border-radius: 12px; display: block; margin: 0 auto 12px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.checks label { display: flex; align-items: center; gap: 8px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 0; font-size: .9rem; }
.checks input { width: auto; }
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #0b1220; color: var(--fg); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; max-width: 92vw; z-index: 20; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.error { border-color: var(--red); }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.modal { background: var(--bg2); border-radius: 16px 16px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); width: 100%; max-width: 640px; max-height: 88dvh; overflow: auto; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--fg); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
details summary { cursor: pointer; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }

.card.proposal.focus { box-shadow: 0 0 0 2px var(--blue); }
