/* Desk console — shared layout for every desk. Colours are tokens; dark is the default, light follows the system. */
:root {
  --bg: #0b0f17; --bg-2: #0f1520; --panel: #131b28; --panel-2: #182233; --line: #223047; --line-2: #2c3d58;
  --text: #e7edf7; --muted: #8d9bb3; --faint: #5d6b84;
  --accent: #5b8cff; --accent-2: #7c5cff; --accent-soft: rgba(91, 140, 255, .14);
  --good: #22c55e; --good-soft: rgba(34, 197, 94, .14); --bad: #f43f5e; --bad-soft: rgba(244, 63, 94, .14);
  --warn: #f59e0b; --warn-soft: rgba(245, 158, 11, .15);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px rgba(0, 0, 0, .25);
  --radius: 14px; --radius-s: 9px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6fb; --bg-2: #eef1f8; --panel: #ffffff; --panel-2: #f7f9fd; --line: #e3e8f2; --line-2: #d3dbea;
    --text: #0f1729; --muted: #5b6780; --faint: #8b96ab;
    --accent: #3b6cf6; --accent-2: #6d4cf5; --accent-soft: rgba(59, 108, 246, .1);
    --good: #13a150; --good-soft: rgba(19, 161, 80, .1); --bad: #e11d48; --bad-soft: rgba(225, 29, 72, .09);
    --warn: #c27803; --warn-soft: rgba(194, 120, 3, .12);
    --shadow: 0 1px 2px rgba(15, 23, 41, .04), 0 8px 24px rgba(15, 23, 41, .06);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f4f6fb; --bg-2: #eef1f8; --panel: #ffffff; --panel-2: #f7f9fd; --line: #e3e8f2; --line-2: #d3dbea;
  --text: #0f1729; --muted: #5b6780; --faint: #8b96ab;
  --accent: #3b6cf6; --accent-2: #6d4cf5; --accent-soft: rgba(59, 108, 246, .1);
  --good: #13a150; --good-soft: rgba(19, 161, 80, .1); --bad: #e11d48; --bad-soft: rgba(225, 29, 72, .09);
  --warn: #c27803; --warn-soft: rgba(194, 120, 3, .12);
  --shadow: 0 1px 2px rgba(15, 23, 41, .04), 0 8px 24px rgba(15, 23, 41, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  background-image: radial-gradient(1200px 500px at 10% -10%, var(--accent-soft), transparent 60%),
                    radial-gradient(900px 400px at 100% 0%, rgba(124, 92, 255, .08), transparent 60%);
  background-attachment: fixed;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.pos { color: var(--good); } .neg { color: var(--bad); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; } h3 { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }

/* ---- top bar ---- */
.top {
  position: sticky; top: 0; z-index: 20; backdrop-filter: saturate(140%) blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent); border-bottom: 1px solid var(--line);
}
.top-in { max-width: 1320px; margin: 0 auto; padding: 0 24px; height: 62px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; white-space: nowrap; }
.logo { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
        background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 18px rgba(91, 140, 255, .35); }
.logo svg { width: 18px; height: 18px; }
.desk-pill { font-size: 12px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 99px; padding: 3px 10px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 3px; margin-left: 8px; }
.tabs button { all: unset; cursor: pointer; padding: 6px 16px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 13px; }
.tabs button.on { background: var(--panel-2); color: var(--text); box-shadow: 0 1px 0 var(--line-2) inset, 0 2px 8px rgba(0, 0, 0, .15); }
.spacer { flex: 1; }
.clock { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 0 4px var(--good-soft); }
.dot.off { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px;
          background: var(--panel-2); border: 1px solid var(--line-2); text-transform: uppercase; }
.role { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; }
.role.admin { color: var(--accent); background: var(--accent-soft); }
.role.guest { color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); }
.icon-btn { all: unset; cursor: pointer; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---- page ---- */
main { max-width: 1320px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.cols { grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); align-items: start; }
.bt-cols { grid-template-columns: 340px minmax(0, 1fr); align-items: start; }
.stack { display: grid; gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.card-b { padding: 16px 18px 18px; }
.card-h .sub { font-size: 12px; color: var(--muted); }

/* ---- hero + tiles ---- */
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.tile { padding: 16px 18px; }
.tile .k { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tile .v { font-size: 22px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.tile .s { font-size: 12px; color: var(--faint); margin-top: 2px; }
.tile.big { position: relative; overflow: hidden; }
.tile.big .v { font-size: 34px; }
.tile.big::after { content: ""; position: absolute; inset: auto -40px -60px auto; width: 180px; height: 180px; border-radius: 50%;
                   background: radial-gradient(circle, var(--accent-soft), transparent 70%); pointer-events: none; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 3px 9px; border-radius: 99px;
         display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-live { color: var(--bad); background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.b-live::before { animation: pulse 1.6s infinite; }
.b-dry { color: var(--warn); background: var(--warn-soft); }
.b-off, .b-paused { color: var(--muted); background: var(--panel-2); border-color: var(--line); }
.b-run { color: var(--good); background: var(--good-soft); }
.b-stop { color: var(--bad); background: var(--bad-soft); }
@keyframes pulse { 50% { opacity: .25; } }

/* ---- position ---- */
.position { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; }
.side { width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.side.CE { color: var(--good); background: var(--good-soft); } .side.PE { color: var(--bad); background: var(--bad-soft); }
.pos-name { font-weight: 650; font-size: 16px; }
.pos-meta { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 4px; }
.pos-meta b { color: var(--text); font-weight: 600; }
.pos-pnl { text-align: right; } .pos-pnl .v { font-size: 24px; font-weight: 700; }
.empty { padding: 26px 10px; text-align: center; color: var(--faint); }
.empty svg { width: 34px; height: 34px; display: block; margin: 0 auto 8px; opacity: .6; }

/* ---- tables ---- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .06em;
     padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--panel-2); }
td.r, th.r { text-align: right; }
.chip { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.chip.CE { color: var(--good); background: var(--good-soft); border-color: transparent; }
.chip.PE { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.chip.Open, .chip.Buying, .chip.Selling { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.chip.live { color: var(--bad); } .chip.dry_run { color: var(--warn); }
.pager { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; color: var(--muted); font-size: 12px; }

/* ---- forms / buttons ---- */
.btn { all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
       height: 38px; padding: 0 16px; border-radius: 10px; font-weight: 650; font-size: 13px; white-space: nowrap;
       background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text); transition: transform .06s, filter .15s; }
.btn:hover { filter: brightness(1.08); } .btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff;
               box-shadow: 0 6px 16px rgba(91, 140, 255, .3); }
.btn.danger { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 40%, transparent); color: var(--bad); }
.btn.block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; filter: none; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 3px; }
.seg button { all: unset; cursor: pointer; text-align: center; padding: 8px 6px; border-radius: 8px; font-weight: 650; font-size: 12.5px; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 0 var(--line-2) inset, 0 2px 8px rgba(0, 0, 0, .18); }
.seg button.on.m-live { color: var(--bad); } .seg button.on.m-dry_run { color: var(--warn); }
.seg button:disabled { cursor: not-allowed; opacity: .5; }
label.f { display: grid; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.f input, .f select {
  font: inherit; color: var(--text); background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; height: 38px; padding: 0 12px; width: 100%;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.f input:focus, .f select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.f input:disabled { opacity: .6; }
.f .hint { font-weight: 500; color: var(--faint); font-size: 11.5px; }
.prefix { position: relative; } .prefix span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.prefix input { padding-left: 26px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; padding: 4px 0; cursor: pointer; }
.toggle input { appearance: none; width: 36px; height: 20px; border-radius: 99px; background: var(--line-2); position: relative; cursor: pointer; flex: none; margin: 0; transition: background .15s; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle input:checked { background: var(--accent); } .toggle input:checked::after { left: 18px; }
.section { display: grid; gap: 12px; padding: 16px 0; border-top: 1px solid var(--line); }
.section:first-child { border-top: 0; padding-top: 0; }
.section > h3 { margin-bottom: 2px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { all: unset; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line); }
.quick button:hover, .quick button.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.weekdays { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.weekdays button { all: unset; cursor: pointer; text-align: center; padding: 7px 0; border-radius: 8px; font-size: 12px; font-weight: 650; color: var(--muted); border: 1px solid var(--line); }
.weekdays button.on { color: var(--text); background: var(--accent-soft); border-color: var(--accent); }
.note { font-size: 12px; color: var(--muted); background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.note.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.note.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.readonly { display: grid; gap: 10px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.kv span:first-child { color: var(--muted); }

/* ---- activity ---- */
.feed { display: grid; gap: 2px; max-height: 330px; overflow-y: auto; }
.ev { display: grid; grid-template-columns: 58px 1fr; gap: 10px; padding: 7px 0; font-size: 12.5px; border-bottom: 1px dashed var(--line); }
.ev:last-child { border-bottom: 0; }
.ev .t { color: var(--faint); font-family: var(--mono); font-size: 11.5px; padding-top: 1px; }
.ev.good .m { color: var(--good); } .ev.bad .m { color: var(--bad); } .ev.warn .m { color: var(--warn); }

/* ---- charts ---- */
.chart { width: 100%; height: 260px; display: block; }
.chart.sm { height: 170px; }
.chart text { fill: var(--faint); font-size: 10.5px; font-family: var(--font); }
.chart .grid-l { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .zero { stroke: var(--line-2); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--panel); border: 1px solid var(--line-2); border-radius: 9px;
       padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); white-space: nowrap; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpis .tile { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; }
.kpis .tile .v { font-size: 20px; }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 90px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-track { height: 8px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--accent); }
.bar-fill.neg { background: var(--bad); } .bar-fill.pos { background: var(--good); }
.progress { height: 6px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.progress div { height: 100%; width: 30%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
.runs { display: grid; gap: 6px; max-height: 360px; overflow-y: auto; }
.run { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; font-size: 12.5px; }
.run:hover, .run.on { border-color: var(--accent); background: var(--accent-soft); }
.run .sub { color: var(--faint); font-size: 11.5px; grid-column: 1 / -1; }

/* ---- modal / toast ---- */
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(5, 8, 14, .6); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; }
.modal { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, .45); padding: 22px; display: grid; gap: 14px; }
.modal h2 { font-size: 18px; }
.modal p { margin: 0; color: var(--muted); }
.modal .acts { display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 70; display: grid; gap: 8px; }
.toast { background: var(--panel); border: 1px solid var(--line-2); border-left: 3px solid var(--accent); border-radius: 10px; padding: 10px 14px; font-size: 13px; box-shadow: var(--shadow); max-width: 360px; }
.toast.bad { border-left-color: var(--bad); } .toast.good { border-left-color: var(--good); }
.banner { margin-bottom: 16px; }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(400px, 100%); padding: 30px 28px; display: grid; gap: 16px; }
.login .brand { justify-content: center; font-size: 18px; flex-direction: column; gap: 14px; }
.login .logo { width: 48px; height: 48px; border-radius: 14px; } .login .logo svg { width: 26px; height: 26px; }
.login p { margin: 0; text-align: center; color: var(--muted); }
.err { color: var(--bad); font-size: 13px; min-height: 18px; text-align: center; }

/* ---- responsive ---- */
@media (max-width: 1100px) {
  .hero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero .tile.big { grid-column: 1 / -1; }
  .cols, .bt-cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .top-in { padding: 0 16px; gap: 10px; height: auto; min-height: 58px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .desk-pill, .clock .txt, .user .name { display: none; }
  .tabs { margin-left: 0; order: 5; width: 100%; } .tabs button { flex: 1; text-align: center; }
  main { padding: 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { gap: 10px; } .tile.big .v { font-size: 28px; }
  .position { grid-template-columns: auto 1fr; } .pos-pnl { grid-column: 1 / -1; text-align: left; }
  .bar-row { grid-template-columns: 80px 1fr 80px; }
}
.legend .lg-eq { background: var(--accent); } .legend .lg-dd { background: var(--bad); opacity: .5; }
h3.spaced { margin: 18px 0 10px; }
label.f { align-content: start; min-width: 0; }
.f input { min-width: 0; }
.row3 .f input[type="time"] { padding: 0 8px; }
.grid > *, .stack > *, .hero > * { min-width: 0; }
@media (max-width: 640px) { .user .role { display: none; } .top-in > .brand span { font-size: 14px; } }
