:root {
  --bg: #070d18;
  --bg2: #0a1222;
  --card: #0d1729;
  --card2: #101c31;
  --line: #1b2a42;
  --line2: #24375a;
  --fg: #e6edf7;
  --muted: #8796ad;
  --green: #3ddc97;
  --green-dim: rgba(61, 220, 151, 0.14);
  --red: #ff5d6c;
  --red-dim: rgba(255, 93, 108, 0.14);
  --cyan: #22c7ee;
  --amber: #f5b544;
  --blue: #4a8cff;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; background: radial-gradient(1200px 600px at 80% -10%, rgba(34, 199, 238, 0.07), transparent 60%), radial-gradient(900px 500px at -10% 110%, rgba(61, 220, 151, 0.05), transparent 60%), var(--bg); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* brand */
.brand { font-weight: 800; letter-spacing: 0.04em; font-size: 26px; }
.brand .b1 { color: var(--cyan); text-shadow: 0 0 18px rgba(34, 199, 238, 0.45); }
.brand .b2 { color: var(--fg); margin-left: 4px; }
.brand.big { font-size: 40px; text-align: center; }
.brand.small { font-size: 20px; }
.dashes { display: flex; gap: 5px; margin: 8px 0 22px; }
.login .dashes { justify-content: center; }
.dashes i { width: 16px; height: 3px; border-radius: 2px; background: var(--red); }
.dashes i:nth-child(2) { background: var(--blue); }
.dashes i:nth-child(3) { background: #fff; }
.dashes i:nth-child(4) { background: #64748b; }
.dashes i:nth-child(5) { background: var(--amber); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left)); }
.login-card { width: min(380px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 34px 28px; display: grid; gap: 12px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); }
.login-card p { margin: 0 0 6px; text-align: center; }
input, select { width: 100%; background: var(--bg2); color: var(--fg); border: 1px solid var(--line2); border-radius: 10px; padding: 11px 12px; font: inherit; }
input:focus, select:focus { outline: 2px solid rgba(34, 199, 238, 0.5); border-color: transparent; }
.btn { border: 1px solid var(--line2); background: var(--card2); border-radius: 10px; padding: 10px 14px; cursor: pointer; font-weight: 600; }
.btn.primary { background: linear-gradient(135deg, #1fb8a6, #2bd48f); border: 0; color: #04120c; }
.btn.more { width: 100%; margin-top: 10px; }
.err { color: var(--red); text-align: center; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; }

/* layout */
.app { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; overflow-x: hidden; }
/* phone: the sidebar slides out from the left behind the ☰ button */
.side { display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; width: min(280px, 82vw); z-index: 30; padding: calc(24px + env(safe-area-inset-top)) 18px calc(20px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); background: #08101f; border-right: 1px solid var(--line); transform: translateX(-105%); transition: transform 0.22s ease; box-shadow: 20px 0 60px rgba(0, 0, 0, 0.5); }
.side.open { transform: none; }
.side .nav { display: grid; gap: 6px; }
.side .nav button { display: flex; align-items: center; gap: 12px; background: none; border: 0; border-radius: 10px; padding: 12px 14px; font-weight: 600; color: var(--muted); cursor: pointer; text-align: left; }
.side .nav button.on { background: var(--card2); color: var(--fg); box-shadow: inset 3px 0 0 var(--cyan); }
.side .nav button.on svg { stroke: var(--cyan); }
.side .nav .pill { margin-left: auto; }
.side .side-foot { margin-top: auto; display: grid; gap: 12px; }
.backdrop { position: fixed; inset: 0; background: rgba(2, 6, 14, 0.6); backdrop-filter: blur(2px); z-index: 25; }
.menu-btn { background: var(--card2); border: 1px solid var(--line2); border-radius: 10px; padding: 7px; display: grid; place-items: center; cursor: pointer; margin-right: 10px; }
.top .brand { margin-right: auto; }
.main { padding: calc(12px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; }
select, .seg, .dates, .dates label, .dates input { min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 2px; }
.bottom { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(9, 15, 28, 0.94); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
.bottom button { background: none; border: 0; display: grid; justify-items: center; gap: 2px; font-size: 11.5px; color: var(--muted); padding: 6px 0; position: relative; cursor: pointer; }
.bottom button.on { color: var(--fg); }
.bottom button.on svg { stroke: var(--cyan); filter: drop-shadow(0 0 6px rgba(34, 199, 238, 0.6)); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bottom .pill { position: absolute; top: 0; right: calc(50% - 26px); }

@media (max-width: 520px) {
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 9px 6px; font-size: 13px; }
  .dates { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .dates label { display: grid; gap: 2px; }
  .dates input { width: 100%; }
  .card-head .muted.small { width: 100%; }
}
@media (min-width: 960px) {
  .app { grid-template-columns: 250px minmax(0, 1fr); }
  .side { position: sticky; top: 0; height: 100vh; width: auto; transform: none; transition: none; box-shadow: none; padding: 28px 18px; background: rgba(7, 12, 22, 0.6); }
  .backdrop { display: none !important; }
  .nav { display: grid; gap: 6px; }
  .nav button { display: flex; align-items: center; gap: 12px; background: none; border: 0; border-radius: 10px; padding: 11px 14px; font-weight: 600; color: var(--muted); cursor: pointer; text-align: left; }
  .nav button:hover { background: var(--card); color: var(--fg); }
  .nav button.on { background: var(--card2); color: var(--fg); box-shadow: inset 3px 0 0 var(--cyan); }
  .nav button.on svg { stroke: var(--cyan); }
  .nav .pill { margin-left: auto; }
  .side-foot { margin-top: auto; display: grid; gap: 12px; }
  .top, .bottom { display: none; }
  .main { padding: 24px 28px 40px; }
}

.status { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.live .dot { background: var(--green); box-shadow: 0 0 10px var(--green); animation: pulse 2s infinite; }
.status.stale .dot { background: var(--amber); }
@keyframes pulse { 50% { opacity: 0.45; } }
.pill { background: var(--cyan); color: #032029; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.pill.warn { background: var(--amber); color: #2a1a00; }

/* cards */
.card { background: linear-gradient(180deg, var(--card2), var(--card)); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card h2 { margin: 0; font-size: 16px; font-weight: 700; }

.filters { display: grid; gap: 10px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
@media (max-width: 719px) { .tiles > .tile:last-child:nth-child(odd) { grid-column: span 2; } }
.item .meta.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.row.wrap { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg { display: flex; border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; flex-wrap: nowrap; max-width: 100%; overflow-x: auto; }
.seg button { background: none; border: 0; padding: 9px 12px; color: var(--muted); font-weight: 600; white-space: nowrap; cursor: pointer; border-right: 1px solid var(--line2); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: rgba(34, 199, 238, 0.12); color: var(--cyan); box-shadow: inset 0 -2px 0 var(--cyan); }
.dates { display: flex; gap: 10px; flex-wrap: wrap; }
.dates label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.dates input { width: auto; padding: 8px 10px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tiles.three, .tiles.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.item .status-badges { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.item .status-badges .badge { margin: 0; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); } .tiles.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tile { background: linear-gradient(180deg, var(--card2), var(--card)); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.tile.glow.up { border-color: rgba(61, 220, 151, 0.45); box-shadow: 0 0 0 1px rgba(61, 220, 151, 0.08), 0 10px 40px -18px rgba(61, 220, 151, 0.5); }
.tile.glow.down { border-color: rgba(255, 93, 108, 0.45); box-shadow: 0 10px 40px -18px rgba(255, 93, 108, 0.5); }
.t-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.t-value { font-size: clamp(22px, 5.4vw, 32px); font-weight: 800; letter-spacing: -0.02em; margin: 4px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.up .t-value { color: var(--green); text-shadow: 0 0 22px rgba(61, 220, 151, 0.35); }
.tile.down .t-value { color: var(--red); }
.t-sub { color: var(--muted); font-size: 12px; }
.tiles .tile:first-child { grid-column: span 1; }

/* chart */
.chart-card { padding: 16px 10px 10px; }
.chart-card .card-head { padding: 0 6px; }
.chart-wrap { position: relative; height: clamp(240px, 46vw, 420px); }
canvas { width: 100%; height: 100%; display: block; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 8px; border-bottom: 1px solid rgba(27, 42, 66, 0.6); white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; border-top: 1px solid var(--line2); }

/* lists */
.list { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(8, 14, 26, 0.6); }
.item .title { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { color: var(--muted); font-size: 12.5px; grid-column: 1 / -1; }
.item .right { text-align: right; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 2px 7px; margin-right: 6px; vertical-align: 1px; }
.badge.won, .badge.placed-ok { background: var(--green-dim); color: var(--green); }
.badge.lost { background: var(--red-dim); color: var(--red); }
.badge.void, .badge.wait { background: rgba(135, 150, 173, 0.15); color: var(--muted); }
.badge.on { background: rgba(34, 199, 238, 0.14); color: var(--cyan); }
.badge.warn { background: rgba(245, 181, 68, 0.15); color: var(--amber); }
.badge.strat { background: rgba(74, 140, 255, 0.14); color: #8fb4ff; }
.empty { color: var(--muted); padding: 10px 2px; }

.days { display: grid; gap: 6px; }
.day { display: grid; grid-template-columns: 92px 1fr 84px; align-items: center; gap: 10px; font-size: 13px; }
.bar { height: 10px; border-radius: 6px; background: var(--line); position: relative; overflow: hidden; }
.bar i { position: absolute; top: 0; bottom: 0; border-radius: 6px; }
.bar i.p { background: linear-gradient(90deg, rgba(61, 220, 151, 0.4), var(--green)); box-shadow: 0 0 10px rgba(61, 220, 151, 0.5); left: 50%; }
.bar i.n { background: linear-gradient(270deg, rgba(255, 93, 108, 0.4), var(--red)); right: 50%; }
.bar::after { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--line2); }
