:root {
  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --bg: #100b1a; --ink: #f4edff; --muted: #b8aacd; --dim: #a391bb; --line: #332648;
  --surface: #1b1329; --accent: #cfa7ff; --violet: #a86bff; --green: #79efbb; --loss: #ff98ad;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; width: 100%; max-width: 100%; overflow-x: hidden; background: #0d0816; }
html { min-height: 100%; scroll-padding-top: calc(160px + env(safe-area-inset-top, 0px)); }
body { margin: 0; color: var(--ink); min-width: 0; }
button, input, select { color: inherit; font: inherit; min-width: 0; }
button, select, summary { cursor: pointer; }
button, input, select, summary { min-height: 48px; }
button { border-radius: 12px; border: 1px solid var(--line); background: var(--surface); min-width: 48px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:disabled { opacity: .48; cursor: default; }
button, summary { -webkit-tap-highlight-color: transparent; }
h1, h2, p, ul, dl, dd { margin: 0; }
.app { width: 100%; max-width: 480px; min-height: 100vh; min-height: 100dvh; margin: 0 auto; background: var(--bg); border-inline: 1px solid #221732; }
#workspace { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.header { position: sticky; top: 0; z-index: 4; padding: max(12px, env(safe-area-inset-top, 0px)) 15px 14px; background: radial-gradient(ellipse at top right,#332054 0%,#181026 64%,#130d20 100%); border-bottom: 1px solid #2d2041; }
.pills { display: flex; gap: 7px; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: thin; scrollbar-color: #563a7e transparent; padding: 4px 3px 6px; margin-inline: -3px; }
.pills button { flex: 0 0 auto; padding: 0 12px; border-radius: 100vw; background: #231734; font-size: .69rem; font-weight: 740; letter-spacing: .035em; color: #ded0f2; border-color: #43305d; }
.pills button[aria-pressed="true"] { background: #d1a9ff; color: #211032; border-color: #d1a9ff; }
.brand-line { display: flex; align-items: center; justify-content: space-between; margin: 13px 0 12px; gap: 10px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 1.55rem; font-weight: 740; letter-spacing: -.055em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: #231334; background: linear-gradient(140deg,#e6ceff,#ad76ff); font-size: 1.1rem; box-shadow: 0 0 20px #b77fff45; }
time, .numeric { font-variant-numeric: tabular-nums; }
.brand-line time, .section-heading time { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.status { display: grid; grid-template-columns: 1.35fr 1fr .8fr; background: #140d20; border: 1px solid #412c61; border-radius: 14px; overflow: hidden; }
.status > div { min-width: 0; padding: 9px 7px; }
.status > div + div { border-left: 1px solid #35234d; }
.status dt { font-size: .66rem; color: var(--muted); margin-bottom: 4px; }
.status dd { min-width: 0; overflow-wrap: anywhere; color: var(--accent); font-size: .72rem; line-height: 1.24; font-weight: 720; }
.status [data-state="healthy"] { color: var(--green); }
.status [data-state="stale"], .status [data-state="incident"] { color: var(--loss); }
.screen { width: 100%; padding: 17px 15px calc(110px + env(safe-area-inset-bottom, 0px)); scroll-padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)); flex: 1; min-width: 0; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 13px; }
h1 { font-size: 1.54rem; letter-spacing: -.045em; line-height: 1.16; }
h2 { font-size: 1.22rem; letter-spacing: -.02em; }
#open-count, #closed-count { color: var(--accent); font-size: .77rem; font-weight: 700; }
.cards { display: grid; width: 100%; gap: 7px; list-style: none; padding: 0; }
.card { display: flex; width: 100%; align-items: center; justify-content: space-between; min-width: 0; min-height: 61px; gap: 8px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(112deg,#211631,#1a1227); }
.card > div:first-child { min-width: 0; flex: 1; }
.card-title, .card-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title { font-size: .83rem; font-weight: 730; line-height: 1.22; }
.card-sub { color: var(--muted); font-size: .72rem; margin-top: 4px; line-height: 1.2; }
.card-value { min-width: 0; max-width: 45%; color: var(--ink); text-align: right; font-weight: 720; font-size: .87rem; }
.card-value > * { display: block; }
.card-value .card-sub { font-weight: 530; }
.positive { color: var(--green); }
.negative { color: var(--loss); }
.empty, .message { font-size: .81rem; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.empty { border: 1px dashed #3c2d50; border-radius: 12px; padding: 15px 11px; }
.message:not(:empty) { margin-bottom: 8px; }
.connection { margin: 8px 15px 0; font-size: .77rem; color: var(--loss); overflow-wrap: anywhere; }
.history { margin-top: 16px; padding: 0 10px 0; border: 1px solid var(--line); border-radius: 13px; background: #171020; }
.history[open] { padding-bottom: 10px; }
.history summary { display: list-item; padding: 14px 1px; color: var(--ink); font-size: .87rem; font-weight: 660; }
.history summary span { float: right; }
.dock { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 480px); z-index: 5; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); margin: 0; gap: 3px; padding: 12px 6px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid #452d66; background: #180f26f5; }
.dock button { min-width: 0; min-height: 54px; display: grid; align-content: center; justify-items: center; gap: 3px; padding: 2px; background: transparent; border-color: transparent; font-size: .67rem; white-space: nowrap; color: var(--muted); }
.dock button span { font-size: 1.18rem; line-height: 1; }
.dock button[aria-current="page"] { background: #35204e; color: #ecd8ff; border-color: #513275; }
.control-block { display: grid; gap: 9px; border: 1px solid var(--line); border-radius: 15px; padding: 13px; background: var(--surface); }
.controls-screen .control-block + .control-block { margin-top: 12px; }
.control-block label { font-size: .82rem; color: var(--muted); }
.control-block input, .control-block select { width: 100%; padding: 8px 10px; border: 1px solid #594273; border-radius: 10px; background: #120d1d; font-size: 1rem; }
.control-state { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#arm-state { color: var(--muted); font-size: .83rem; }
.primary, .secondary, .danger, .text-button { font-size: .88rem; font-weight: 720; padding: 9px 12px; }
.primary { background: #cfa8ff; border-color: #cfa8ff; color: #231333; }
.secondary { background: #291a3e; border-color: #51376e; color: #eddbff; }
.danger { background: #422033; color: #ffc4d0; border-color: #a14f69; }
.danger-block { border-color: #553047; }
.text-button { margin-top: 6px; padding-inline: 5px; background: transparent; border-color: transparent; color: var(--muted); }
.login { min-height: 100vh; min-height: 100dvh; padding: max(34px, env(safe-area-inset-top)) 19px 30px; background: radial-gradient(ellipse at top right,#332054 0%,#140d20 62%); }
.login .control-block { margin-top: 22px; }
dialog { width: min(440px,calc(100% - 28px)); max-width: none; padding: 0; color: var(--ink); border: 1px solid #654687; border-radius: 18px; background: #211530; }
dialog::backdrop { background: #08050cbb; }
.confirmation { display: grid; gap: 9px; padding: 16px; }
@media (min-width: 601px) { .app { box-shadow: 0 1px 60px #0008; } }
@media (max-width: 600px) {
  .app { width: 100%; max-width: 100%; margin: 0; border: none; border-radius: 0; box-shadow: none; }
  .screen { padding-left: 12px; padding-right: 12px; }
  .card, .market-arm-row { width: 100%; }
}


/* Market controls and the multi-market status feed */
.compact-heading { margin-bottom: 10px; }
.compact-heading h2 { margin: 0; font-size: 1rem; }
.bulk-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.market-arms { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.market-arm-row {
  display: grid; width: 100%; grid-template-columns: minmax(0, 1fr) auto 48px; align-items: center;
  gap: 8px; min-width: 0; padding: 7px; border: 1px solid var(--line, #332843);
  border-radius: 14px; background: rgba(255,255,255,.025);
}
.market-arm-row.selected { border-color: var(--accent, #c45cff); box-shadow: 0 0 0 1px rgba(196,92,255,.18); }
.market-arm-select { min-width: 0; min-height: 48px; padding: 8px; border: 0; text-align: left; background: transparent; color: var(--text, #f4edff); font-weight: 700; }
.market-arm-state { font-size: .68rem; font-weight: 800; letter-spacing: .04em; color: #a79db5; }
.market-arm-state:has(+ .arm-switch.is-armed) { color: #7cf0bd; }
.arm-switch { position: relative; width: 48px; min-width: 48px; height: 48px; padding: 0; border: 1px solid #554566; border-radius: 999px; background: #30273b; }
.arm-switch span { display: block; width: 20px; height: 20px; margin-left: 5px; border-radius: 50%; background: #b7aebe; transition: transform .16s ease, background .16s ease; }
.arm-switch.is-armed { border-color: #9c45cf; background: #58287a; }
.arm-switch.is-armed span { transform: translateX(16px); background: #f4c4ff; }
.arm-switch:disabled { opacity: .48; }
#limit-fields { display: grid; gap: 8px; }
#limit-fields[hidden] { display: none; }
.pills { scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }

.equity-baseline { gap: 8px; }
.baseline-value { margin: 0; font-weight: 800; color: #f3d7ff; line-height: 1.45; overflow-wrap: anywhere; }
#reset-equity-baseline { min-height: 48px; }

#worker-list .card { align-items: flex-start; }
#worker-list .card > div:first-child .card-sub {
  overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap: anywhere;
  line-height: 1.4;
}
#worker-list .card-value { flex: 0 0 auto; max-width: 38%; }

/* iPhone Safari can report a desktop-width layout viewport while using a
   coarse touch pointer. Keep the owner dashboard and dock edge-to-edge there. */
@media (pointer: coarse) {
  .app {
    width: 100vw;
    max-width: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .dock { width: 100vw; }
}
