:root {
  --bg: #f5f6f8; --card: #ffffff; --text: #14161a; --muted: #6b7280; --line: #e5e7eb;
  --accent: #2563eb; --accent-text: #fff; --up: #16a34a; --down: #dc2626; --warn: #d97706;
  --dry: #6b7280; --paper: #2563eb; --live: #dc2626; --radius: 14px; --tab-h: 60px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --card: #171a21; --text: #e6e7ea; --muted: #9aa0aa; --line: #262a33;
    --accent: #3b82f6; --up: #4ade80; --down: #f87171; --warn: #fbbf24; }
}
* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text);
  min-height: 100dvh; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .warn { color: var(--warn); }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand img { border-radius: 8px; }
.mode { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; color: #fff; }
.mode-dry { background: var(--dry); } .mode-paper { background: var(--paper); } .mode-live { background: var(--live); }
.desk-nav { display: none; gap: 4px; margin-left: 12px; }
.desk-nav a { padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--text); }
.desk-nav a.active { background: var(--bg); font-weight: 600; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.main { max-width: 980px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.main > * { min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 760px) { .grid2 { grid-template-columns: minmax(0,1fr) minmax(0,1fr); } .desk-nav { display: flex; } .tabbar { display: none; }
  body { padding-bottom: 24px; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(4, minmax(0,1fr)); } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .lbl { font-size: .78rem; color: var(--muted); }
.tile .val { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--up); box-shadow: 0 0 0 4px color-mix(in srgb, var(--up) 25%, transparent); }
.dot.halt { background: var(--down); }
.dot.closed { background: var(--warn); }

.btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 12px;
  padding: 10px 14px; font: inherit; font-weight: 600; min-height: 44px; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.btn.danger { background: var(--down); color: #fff; border-color: transparent; }
.btn.small { min-height: 36px; padding: 6px 10px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.switch { position: relative; width: 52px; height: 30px; border-radius: 999px; background: var(--line); border: 0; cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch[aria-checked="true"] { background: var(--up); } .switch[aria-checked="true"]::after { left: 25px; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
td.time { white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.chip { display: inline-block; white-space: nowrap; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--bg); border: 1px solid var(--line); }
.chip.buy { color: var(--up); border-color: var(--up); } .chip.sell { color: var(--down); border-color: var(--down); }
.chip.skip { color: var(--warn); border-color: var(--warn); }
.chip.flatten { color: var(--down); }

.empty { color: var(--muted); padding: 18px 0; text-align: center; }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--card), var(--line), var(--card)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

.chart { width: 100%; height: 160px; display: block; }
.chart path { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .area { fill: color-mix(in srgb, var(--accent) 15%, transparent); stroke: none; }

label.f { display: grid; gap: 4px; font-size: .9rem; margin-bottom: 10px; }
label.f small { color: var(--muted); }
input, select, textarea { font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%; }
input[type=checkbox] { appearance: auto; width: 20px; height: 20px; accent-color: var(--accent); }
.fields { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 560px) { .fields { grid-template-columns: 1fr 1fr; } }
.note { font-size: .85rem; color: var(--muted); }
.error { color: var(--down); }
.banner { border-radius: var(--radius); padding: 10px 14px; font-weight: 600; }
.banner.live { background: color-mix(in srgb, var(--down) 15%, transparent); color: var(--down); }
.banner.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--card); border-top: 1px solid var(--line); z-index: 5; }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .72rem; min-height: 44px; }
.tabbar a.active { color: var(--accent); font-weight: 600; }
.tabbar svg { width: 22px; height: 22px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; z-index: 20; max-width: 90vw; font-weight: 600; }
.toast.err { background: var(--down); color: #fff; }

.sheet-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 760px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 18px; } }
.sheet .row { justify-content: flex-end; margin-top: 12px; }

.login-body { display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 380px; }
.login-card label { display: grid; gap: 4px; margin: 12px 0; font-size: .9rem; }
.login-card .btn { width: 100%; margin-top: 8px; }
.decision-reason { font-size: .85rem; color: var(--muted); }

/* poradie záleží: tieto pravidlá musia byť za definíciou .tabbar / .agent-lbl */
@media (min-width: 760px) { .tabbar { display: none; } }
@media (max-width: 559px) { .agent-lbl { display: none; } }
