@import url('/workspace.css');

/* One CSS file, no build step, no external fonts/CDNs. Dark-only by design
   (spec/rulings.yml R32 — the retired web UI's look is an admitted design
   reference; its code is not). Every colour is a token on :root, painted
   explicitly (no reliance on the host page's own background) so the app holds
   on any embedding ground. `color-scheme: dark` lets native form controls
   (date pickers, scrollbars) pick a dark rendering on their own. */

:root {
  color-scheme: dark;

  /* Surfaces */
  --bg: #030712;          /* page background */
  --surface: #111827;     /* panels, cards, sidebar */
  --surface-alt: #1f2937; /* inputs, alt rows, chips */
  --surface-raised: #1a2130;

  /* Borders */
  --border: #374151;         /* inputs, emphasised panel borders */
  --border-subtle: #1f2937;  /* row dividers, quiet panel borders */

  /* Text */
  --fg: #f9fafb;
  --muted: #9ca3af;
  --muted-2: #6b7280;

  /* Brand / semantic */
  --accent: #4f46e5;
  --accent-hover: #6366f1;
  --accent-wash: rgba(79, 70, 229, .18);
  --accent-wash-border: rgba(99, 102, 241, .45);

  --success: #16a34a;
  --success-bright: #34d399;
  --success-wash: rgba(6, 95, 70, .32);
  --success-wash-border: rgba(6, 95, 70, .65);

  --warning-bright: #fbbf24;
  --warning-wash: rgba(120, 53, 15, .35);
  --warning-wash-border: rgba(146, 64, 14, .6);

  --stop-accent: #fb923c;
  --stop-wash: rgba(154, 52, 18, .3);
  --stop-wash-border: rgba(154, 52, 18, .6);

  --danger: #dc2626;
  --danger-hover: #ef4444;
  --danger-bright: #f87171;
  --danger-wash: rgba(127, 29, 29, .35);
  --danger-wash-border: rgba(153, 27, 27, .6);

  --info-bright: #93c5fd;
  --info-wash: rgba(29, 78, 216, .22);
  --info-wash-border: rgba(30, 64, 175, .5);

  --limit-bright: #d8b4fe;
  --limit-wash: rgba(126, 34, 206, .22);
  --limit-wash-border: rgba(107, 33, 168, .5);

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Radii */
  --radius-sm: .375rem;   /* inputs, buttons */
  --radius-lg: .75rem;    /* cards, panels */
  --radius-full: 999px;   /* pills, dots */

  /* Sidebar */
  --sidebar-w: 14rem;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over any other display rule (e.g. an id
   selector giving the sidebar `display: flex` would otherwise outrank the UA
   stylesheet's plain `[hidden] { display: none }`) — confirmed as a real bug
   by screenshot: the nav rendered even while logged out. Kept as the FIRST
   rule and `!important` on purpose; do not weaken it. */
[hidden] { display: none !important; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-hover); }

h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 .25rem; color: var(--fg); }
h2 { font-size: 1.125rem; font-weight: 600; margin: 0 0 .75rem; color: var(--fg); }
h3 { font-size: .95rem; font-weight: 600; margin: 1rem 0 .5rem; color: var(--fg); }
p { margin: .4rem 0; }

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */

button {
  font: inherit;
  font-weight: 600;
  font-size: .8125rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--muted);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

button:hover:not(:disabled) { background: #27303f; color: var(--fg); }
button:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 1px; }
button:disabled { opacity: .5; cursor: not-allowed; }

button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger:hover:not(:disabled) { background: var(--danger-hover); border-color: var(--danger-hover); }

/* Row-action pill: same translucent-wash + border + bright-text formula as a
   badge (Section 1/4 of the design brief), sized for a table cell. */
.btn-pill {
  padding: .3rem .65rem;
  font-size: .72rem;
  border-radius: var(--radius-sm);
}

.btn-pill-danger {
  background: var(--danger-wash);
  border-color: var(--danger-wash-border);
  color: var(--danger-bright);
}
.btn-pill-danger:hover:not(:disabled) { background: rgba(153, 27, 27, .5); color: #fff; }

.btn-pill-warn {
  background: var(--stop-wash);
  border-color: var(--stop-wash-border);
  color: var(--stop-accent);
}
.btn-pill-warn:hover:not(:disabled) { background: rgba(154, 52, 18, .5); color: #fff; }

.btn-pill-neutral {
  background: var(--surface-alt);
  border-color: var(--border);
  color: var(--muted);
}

/* ---------------------------------------------------------------------- */
/* Inputs                                                                  */
/* ---------------------------------------------------------------------- */

input, select, textarea {
  font: inherit;
  font-size: .8125rem;
  padding: .5rem .7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--fg);
}

input::placeholder, textarea::placeholder { color: var(--muted-2); }

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-hover);
  outline-offset: 1px;
  border-color: var(--accent-hover);
}

input[type="radio"], input[type="checkbox"] { accent-color: var(--accent); width: auto; }

label {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  margin: .5rem 0;
  max-width: 22rem;
  font-size: .8125rem;
  color: var(--muted);
}

/* A segmented radio choice (e.g. the stop-adjust mode): keeps the real
   `<input type=radio>` (the acceptance harness drives it with `.check()`),
   styled as a filled pill only while its own radio is checked. */
.toggle-row { flex-direction: row; align-items: center; gap: .4rem; max-width: none; }
.toggle-row:has(input:checked) { color: var(--fg); }
label.toggle-pill {
  flex-direction: row;
  align-items: center;
  gap: .4rem;
  display: inline-flex;
  padding: .3rem .6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--muted);
  max-width: none;
  cursor: pointer;
}
label.toggle-pill:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------------------------------------------------------------------- */
/* Shell — sidebar + content column (design brief §2)                     */
/* ---------------------------------------------------------------------- */

#app { min-height: 100vh; }

.shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.mobile-header, .nav-scrim { display: none; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border-subtle);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 1rem .9rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header .brand { font-weight: 700; font-size: 1rem; color: var(--fg); }
.sidebar-header .account-id { font-size: .7rem; color: var(--muted-2); }

/* Broker/stream status dot + label — main.js toggles `data-state` between
   "live"/"polling"; textContent (the same values) is unchanged, this is a
   pure styling hook. */
.stream-badge {
  position: relative;
  display: inline-block;
  font-size: .62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted-2);
  padding: .2rem .5rem .2rem 1.15rem;
  border-radius: var(--radius-full);
  background: var(--surface-alt);
}
.stream-badge::before {
  content: "";
  position: absolute;
  left: .5rem;
  top: 50%;
  transform: translateY(-50%);
  width: .4rem;
  height: .4rem;
  border-radius: var(--radius-full);
  background: var(--muted-2);
}
.stream-badge[data-state="live"] { color: var(--success-bright); }
.stream-badge[data-state="live"]::before { background: var(--success-bright); animation: pulse-dot 1.8s ease-in-out infinite; }
.stream-badge[data-state="polling"] { color: var(--warning-bright); }
.stream-badge[data-state="polling"]::before { background: var(--warning-bright); }

@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.sidebar-nav a {
  padding: .5rem .7rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: .8125rem;
  font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}
.sidebar-nav a:hover { background: var(--surface-alt); color: var(--fg); }
.sidebar-nav a.active { background: var(--accent); color: #fff; font-weight: 600; }

.sidebar-footer {
  padding: .9rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.sidebar-footer .whoami { font-size: .72rem; color: var(--muted-2); }

.content-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

main#view {
  flex: 1 0 auto;
  padding: 1.25rem 1.75rem 2rem;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

@media (max-width: 860px) {
  body { overflow-x: hidden; }
  .shell { display: block; }
  .mobile-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 3.5rem;
    padding: .55rem .85rem;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface);
  }
  .mobile-header button { min-height: 2.25rem; padding-inline: .75rem; }
  .mobile-brand { color: var(--fg); font-size: .95rem; font-weight: 700; }
  .mobile-brand small { margin-left: .3rem; color: var(--muted); font-size: .58rem; letter-spacing: .14em; }
  .nav-scrim {
    display: block;
    position: fixed;
    z-index: 9;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgb(2 7 15 / .65);
  }
  .sidebar {
    position: fixed;
    z-index: 10;
    inset: 0 auto 0 0;
    width: min(19rem, calc(100vw - 3rem));
    height: 100dvh;
    flex: 0 0 auto;
    overflow-y: auto;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    box-shadow: 1rem 0 2.5rem rgb(0 0 0 / .38);
  }
  .sidebar-header { border-right: 0; border-bottom: 1px solid var(--border-subtle); }
  .sidebar-nav { flex-direction: column; flex-wrap: nowrap; overflow: visible; }
  .sidebar-footer { margin-top: auto; border-top: 1px solid var(--border-subtle); border-left: 0; flex-direction: column; }
}

/* ---------------------------------------------------------------------- */
/* Panels / cards                                                         */
/* ---------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.card > h2:first-child, .card > h1:first-child { margin-top: 0; }

.panel-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}
.panel-header h2 { margin-bottom: 0; }

.stat-strip {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.stat-chip {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: .6rem .9rem;
  font-size: .78rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.stat-chip strong { color: var(--fg); font-size: .95rem; font-variant-numeric: tabular-nums; }
.stat-chip .stat-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted-2);
}

/* ---------------------------------------------------------------------- */
/* Tables — dense data surface (design brief §4, avoiding the DON'T list's  */
/* min-width hacks and sticky-column overlay hack: no sticky columns here) */
/* ---------------------------------------------------------------------- */

table { border-collapse: collapse; width: 100%; }

thead th {
  text-align: left;
  padding: .55rem .75rem;
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border-subtle); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, .03); }

td {
  padding: .6rem .75rem;
  vertical-align: middle;
  font-size: .8125rem;
}

td.num, th.num { text-align: right; }

/* Every formatted price (lib.js's formatPrice — level, avg cost, quotes,
   estimated cost) is wrapped in this so digits stay column-aligned instead of
   jittering as a proportional font gives "1" and "8" different widths. */
.num { font-variant-numeric: tabular-nums; }

/* Row tint by risk state (C5: the number itself is always shown too — this
   only decides how the row is highlighted). ONE tint layer per row: this is
   the sole "risk" signal on a Positions row — the side/stop-status badges
   below carry different, non-overlapping meanings rather than restating the
   same coverage fact a second and third time (design brief §6 DON'T). */
tr.uncovered-positive { background: var(--danger-wash); }
tr.uncovered-positive:hover { background: rgba(153, 27, 27, .28); }
tr.uncovered-zero { background: rgba(6, 95, 70, .12); }
tr.uncovered-zero:hover { background: rgba(6, 95, 70, .2); }

.uncovered-positive td[data-testid="uncovered"] { color: var(--danger-bright); font-weight: 700; }
.uncovered-zero td[data-testid="uncovered"] { color: var(--success-bright); }

tr.action-row td { padding: 0; border-bottom: 1px solid var(--border-subtle); }
tr.action-row:hover { background: transparent; }

.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.muted { color: var(--muted); }
.error { color: var(--danger-bright); font-size: .8125rem; }

/* w5e: non-blocking warnings shown before Confirm (feed/session/staleness/
   already-held/uncovered/quantity-cap) — amber, distinct from `.error`
   (which reports a REJECTED request) and from `.warning--danger` (the ONE
   red case: an adjust-stop level on the wrong side of the market, which
   would fire immediately). Never disables anything itself — see the pages
   that emit these for the "never blocking" rule. */
.warning { color: var(--warning-bright); font-size: .8125rem; font-weight: 500; }
.warning--danger { color: var(--danger-bright); font-weight: 700; }

/* ---------------------------------------------------------------------- */
/* Badges — the 3-part formula: translucent wash + matching border +      */
/* bright text (design brief §1/§3). One class per meaning, never a       */
/* one-off inline style.                                                  */
/* ---------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .12rem .5rem;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-success { background: var(--success-wash); border-color: var(--success-wash-border); color: var(--success-bright); }
.badge-warning { background: var(--warning-wash); border-color: var(--warning-wash-border); color: var(--warning-bright); }
.badge-danger  { background: var(--danger-wash);  border-color: var(--danger-wash-border);  color: var(--danger-bright); }
.badge-info    { background: var(--info-wash);    border-color: var(--info-wash-border);    color: var(--info-bright); }
.badge-limit   { background: var(--limit-wash);   border-color: var(--limit-wash-border);   color: var(--limit-bright); }
.badge-neutral { background: var(--surface-alt);  border-color: var(--border);              color: var(--muted); }

/* Long/short — a small chip beside the symbol (design brief: "SHORT ... tiny
   uppercase amber chip beside symbol"; long mirrors it in the success wash
   for the same at-a-glance read). */
.badge-long, .badge-short {
  font-size: .62rem;
  padding: .05rem .4rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-radius: var(--radius-sm);
}
.badge-long { background: rgba(6, 95, 70, .22); color: var(--success-bright); }
.badge-short { background: var(--warning-wash); color: var(--warning-bright); }

/* Existing semantic classes portfolio.js already emits — restyled to the
   same wash formula rather than the old solid fill. */
.badge-protective { background: var(--success-wash); border-color: var(--success-wash-border); color: var(--success-bright); }
.badge-foreign { background: var(--danger-wash); border-color: var(--danger-wash-border); color: var(--danger-bright); }

/* ---------------------------------------------------------------------- */
/* Confirm panels (inline expand rows — Close / Adjust stop)              */
/* ---------------------------------------------------------------------- */

.confirm-box {
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  margin: 0;
  background: var(--surface-raised);
}
.confirm-box--danger { border-left-color: var(--danger); }
.confirm-box--protect { border-left-color: var(--stop-accent); }

.confirm-box p[data-role="preview-text"] { color: var(--fg); font-weight: 500; }

/* ---------------------------------------------------------------------- */
/* Persistent status bar — pinned to the bottom of the content column,    */
/* colour-coded by kind, dismissed only by an explicit click. Never a     */
/* self-timing toast (design brief §4: "NOT floating auto-dismiss").      */
/* ---------------------------------------------------------------------- */

.status-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem 1.25rem;
  border-top: 1px solid var(--danger-wash-border);
  background: #2a1010;
  color: var(--danger-bright);
  font-size: .8125rem;
}
.status-bar-text { flex: 1; word-break: break-word; }
.status-bar-dismiss {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.1rem;
  line-height: 1;
  padding: .1rem .4rem;
}
.status-bar-dismiss:hover { background: rgba(255, 255, 255, .08); color: #fff; }

/* ---------------------------------------------------------------------- */
/* Auth pages (login)                                                     */
/* ---------------------------------------------------------------------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.auth-stack { width: 100%; max-width: 22rem; }
.auth-stack .brand-lockup { text-align: center; margin-bottom: 1.25rem; }
.auth-stack .brand-lockup h1 { margin-bottom: .2rem; }
.auth-stack .brand-lockup p { color: var(--muted); margin: 0; font-size: .85rem; }
.auth-stack .card { margin-bottom: 0; box-shadow: 0 20px 50px rgba(0, 0, 0, .45); }
.auth-stack button.primary { width: 100%; margin-top: .5rem; }

/* Error panel: shown above the fields it refers to (design brief §3), a
   plain inline box, never a toast. */
.form-error-panel {
  background: var(--danger-wash);
  border: 1px solid var(--danger-wash-border);
  color: var(--danger-bright);
  border-radius: var(--radius-sm);
  padding: .6rem .8rem;
  font-size: .8125rem;
  margin: 0 0 .75rem;
}

/* ---------------------------------------------------------------------- */
/* Terms                                                                  */
/* ---------------------------------------------------------------------- */

.tc-text {
  white-space: pre-wrap;
  max-height: 24rem;
  overflow: auto;
  border: 1px solid var(--border-subtle);
  padding: .9rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-size: .8125rem;
  margin-bottom: 1rem;
}

/* ---------------------------------------------------------------------- */
/* Misc                                                                   */
/* ---------------------------------------------------------------------- */

.build-footer {
  padding: .6rem 1.75rem;
  font-size: .68rem;
  font-family: var(--font-mono);
  color: var(--muted-2);
}

/* Penny workspace: compact, dark, and data-forward. Existing confirmation and
   admin primitives remain shared with these route-level surfaces. */
.content-col { min-width: 0; flex: 1; background: #050a14; }
.workspace-health { min-height: 2.25rem; display: flex; align-items: center; gap: .6rem; padding: .4rem 2rem; border-bottom: 1px solid #26364f; background: #0c1524; color: #bed0e9; font-size: .72rem; }
.workspace-health span { padding: .18rem .55rem; border: 1px solid #2a4760; border-radius: 999px; background: #102033; }
.workspace-page { width: 100%; max-width: 1220px; margin: 0 auto; padding: 2rem; }
.workspace-page.grouped-workspace { grid-template-columns: minmax(0, 1fr); }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.45rem; }
.page-heading h1 { font-size: 1.7rem; letter-spacing: -.035em; }
.page-heading p { max-width: 47rem; }
.workspace-card { overflow: hidden; margin: 0 0 .9rem; border: 1px solid #273a56; border-radius: .8rem; background: #101a29; box-shadow: 0 12px 32px rgb(0 0 0 / .16); }
.workspace-card > .panel-header, .workspace-card > .history-filter, .workspace-card > .monitor-add { padding: 1rem 1.1rem; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .85rem; margin-bottom: .9rem; }
.metric { min-height: 6.5rem; padding: 1rem; border: 1px solid #273a56; border-radius: .8rem; background: #101a29; }
.metric span, .metric small { display: block; color: #91a4bf; font-size: .75rem; }
.metric strong { display: block; margin: .35rem 0; color: #e9f0fb; font-size: 1.25rem; }
.pnl-card { min-height: 13rem; }
.report-state { padding: 1rem 1.1rem; color: #91a4bf; }
.pnl-series { padding: .25rem 1.1rem 1rem; }
.pnl-series > div { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.pnl-total { color: #49d5ad; font-size: 1.05rem; }
.pnl-caveats { margin: .55rem 0 0; padding-left: 1.1rem; color: #ffd084; font-size: .73rem; }
.management-receipt-section { margin-top: .9rem; }
[data-role=management-receipts] { display: grid; gap: .5rem; padding: .8rem 1rem 1rem; }
.management-receipt { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem .65rem; padding: .65rem .75rem; border: 1px solid #2d4764; border-radius: .5rem; background: #0d1828; }
.management-receipt p, .management-receipt small { grid-column: 1 / -1; margin: 0; color: #aebed2; overflow-wrap: anywhere; }
.management-receipt button { justify-self: start; }
.management-preview { margin-top: .7rem; padding: .65rem .75rem; border: 1px solid #315273; border-radius: .42rem; background: #0c1727; }
.management-preview p { margin: 0 0 .5rem; }
.management-preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .38rem .8rem; }
.management-preview-grid div { min-width: 0; }
.management-preview-grid b, .management-preview-grid span { display: block; }
.management-preview-grid b { color: #91a4bf; font-size: .65rem; letter-spacing: .04em; text-transform: uppercase; }
.management-preview-grid span { color: #e5edf8; font-size: .76rem; overflow-wrap: anywhere; }
.pnl-series svg { display: block; width: 100%; height: 8rem; margin-top: .5rem; border-bottom: 1px solid #273a56; }
.pnl-series polyline { fill: none; stroke: #7c8cff; stroke-width: 2; vector-effect: non-scaling-stroke; }
.pnl-series line { stroke: #273a56; stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-labels { display: grid; grid-template-columns: 1fr auto auto 1fr; gap: .45rem; color: #91a4bf; font: .67rem var(--font-mono); }
.chart-labels span:last-child { text-align: right; }
.compact-label { flex-direction: row; align-items: center; min-width: 9rem; margin: 0; }
.button-link { display: inline-flex; align-items: center; padding: .5rem .8rem; border: 1px solid #385170; border-radius: .42rem; color: #e7eef8; text-decoration: none; font-size: .8rem; font-weight: 600; }
.overview-summary table, .workspace-card table { width: 100%; min-width: 650px; border-collapse: collapse; }
.overview-summary th, .overview-summary td, .workspace-card th, .workspace-card td { padding: .82rem 1rem; border-bottom: 1px solid #1d2d44; white-space: nowrap; }
.overview-summary tr:last-child > *, .workspace-card tbody tr:last-child > * { border-bottom: 0; }
.overview-summary thead, .workspace-card thead { background: #0d1625; color: #8da0bd; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
.overview-position-row { display: grid; grid-template-columns: 5rem 1fr 1fr 1fr 1fr auto; align-items: center; gap: .8rem; padding: .85rem 1rem; border-bottom: 1px solid #1d2d44; font-variant-numeric: tabular-nums; }
.overview-position-row:last-child { border-bottom: 0; }
.overview-position-row > div { display: flex; justify-content: flex-end; gap: .35rem; }
.history-filter, .monitor-add { display: flex; align-items: end; gap: .65rem; border-bottom: 1px solid #273a56; }
.history-filter label, .monitor-add label { margin: 0; }
.history-filter button, .monitor-add button { margin-bottom: .05rem; }
.monitor-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 20rem)); align-items: start; gap: .5rem; padding: .7rem 1rem .9rem; }
.monitor-card { min-width: 0; padding: .55rem .65rem; border: 1px solid #2b415e; border-radius: .5rem; background: #0d1828; box-shadow: 0 5px 14px rgb(0 0 0 / .13); }
.monitor-card[data-readiness="ready"] { border-color: #21705b; }
.monitor-card header { display: flex; align-items: center; justify-content: space-between; gap: .55rem; margin-bottom: .35rem; }
.monitor-card header strong, .monitor-card header small { display: block; }
.monitor-card header small { margin-top: .1rem; color: #91a4bf; font-size: .66rem; }
.monitor-symbol { color: #8cddf3; font: 800 .82rem var(--font-mono); letter-spacing: .04em; }
.monitor-fields { display: flex; flex-wrap: wrap; align-items: baseline; gap: .22rem .48rem; min-width: 0; font: .72rem var(--font-mono); font-variant-numeric: tabular-nums; }
.monitor-field { display: inline-flex; align-items: baseline; gap: .22rem; min-width: 0; color: #dce5f1; }
.monitor-field:not(:last-of-type)::after { content: "|"; margin-left: .18rem; color: #47566f; }
.monitor-field strong { color: #f3f7ff; }
.monitor-field small { color: #91a4bf; font-size: .65rem; }
.monitor-label { font-size: .58rem; letter-spacing: .06em; color: #7d8da5; }
.monitor-label.bid { color: #69cda3; }
.monitor-label.ask { color: #e1ac58; }
.monitor-label.spread { color: #91a1b8; }
.monitor-age { color: #93a5bc; font-size: .64rem; white-space: nowrap; }
.sidebar-header .brand small { margin-left: .35rem; color: #9fb0c8; font-size: .6rem; letter-spacing: .16em; }
dialog#trade-dialog { width: min(52rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); padding: 0; overflow: hidden; border: 1px solid #425b7d; border-radius: .8rem; background: #101a29; color: #e9f0fb; box-shadow: 0 28px 90px rgb(0 0 0 / .65); }
dialog#trade-dialog::backdrop { background: rgb(2 7 15 / .74); }
.trade-dialog-content { display: grid; grid-template-rows: auto minmax(0, 1fr); box-sizing: border-box; max-height: calc(100dvh - 2rem); }
.trade-dialog-content > :last-child { min-width: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 1rem 1rem; }
.dialog-heading { display: flex; justify-content: space-between; gap: 1rem; margin: 0; padding: .85rem 1rem .7rem; border-bottom: 1px solid #273a56; background: #101a29; }
.dialog-heading h2 { margin-bottom: .2rem; }
.trade-dialog-content .card { max-width: none !important; margin: 0; border: 0; box-shadow: none; }
.not-found { display: grid; align-content: center; min-height: 55vh; max-width: 42rem; }
.not-found h1 { font-size: clamp(2rem, 5vw, 3.5rem); letter-spacing: -.05em; }
.not-found .button-link { width: fit-content; margin-top: .7rem; }
@media (max-width: 860px) { .workspace-health { position: sticky; top: 0; z-index: 2; overflow-x: auto; padding: .4rem 1rem; } }
@media (max-width: 760px) { .workspace-page { padding: 1.1rem .85rem 5rem; } .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .page-heading { align-items: center; } .page-heading > div { min-width: 0; } .page-heading h1 { font-size: 1.4rem; } .workspace-card > .panel-header { align-items: flex-start; } .overview-position-row { grid-template-columns: 1fr 1fr; } .overview-position-row > div { grid-column: 1 / -1; justify-content: flex-start; } .stat-chip { min-width: 0; max-width: 100%; } .stat-chip strong { overflow-wrap: anywhere; } .monitor-list { grid-template-columns: minmax(0, 1fr); padding-inline: .75rem; } .monitor-fields { gap: .2rem .38rem; } .monitor-age { white-space: normal; } }

/* Approved Penny desktop proportions: the workspace uses a broad, bounded
   reading surface instead of leaving a narrow column on wide screens. */
.workspace-page { width: 100%; max-width: none; padding-inline: clamp(1rem, 2.5vw, 2rem); }
.workspace-card, .workspace-group-list {
  border-color: #293c59;
  background: linear-gradient(145deg, #111b2b, #0d1625);
}
.workspace-card { box-shadow: 0 14px 32px rgb(0 0 0 / .15); }
.workspace-card > .panel-header { background: rgb(16 28 45 / .55); }

/* New trade stays compact, but its review has hierarchy instead of a tall
   stack of unlabelled unavailable values. */
.trade-card { width: 100%; max-width: none !important; box-sizing: border-box; padding: 1.1rem; border-color: #324966; background: linear-gradient(145deg, #111c2d, #0d1624); box-shadow: 0 16px 38px rgb(0 0 0 / .18); }
.trade-card .panel-header { padding-bottom: .65rem; border-bottom: 1px solid #293c59; }
.trade-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .15rem .8rem; }
.trade-fields label { max-width: none; }
.trade-fields label:last-child { grid-column: 1 / -1; max-width: 16rem; }
.trade-card .row-actions { margin-top: .6rem; }
.trade-ticket-actions { position: sticky; top: 0; z-index: 1; gap: .45rem; padding: .5rem 0; border-block: 1px solid #293c59; background: #101a29; }
.trade-confirm-blocker { flex-basis: 100%; margin: 0; color: #ffd084; font-size: .74rem; font-weight: 600; }
.trade-card .confirm-box { margin-top: .7rem; border-color: #314560; background: #101b2b; }
.trade-card .confirm-box--danger { border-left-color: var(--warning-bright); background: rgb(68 47 18 / .26); }
.trade-card .warning { margin: .35rem 0; color: #ffd084; }
.trade-card details { margin-top: .35rem; color: #9fb0c8; }
.trade-card summary { cursor: pointer; color: #b9c8dd; font-size: .72rem; }
.trade-card code { display: inline-block; margin-top: .25rem; color: #91a7c5; font: .66rem var(--font-mono); overflow-wrap: anywhere; }
.trade-decision-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .35rem .8rem; margin: .15rem 0 .55rem; }
.trade-decision-grid p { margin: 0; font-size: .76rem; }
.trade-decision-grid .num { color: #e7eef9; font-weight: 700; }
.trade-server-warning { padding: .45rem .55rem; border: 1px solid #704e27; border-radius: .35rem; background: rgb(87 56 17 / .25); }
.trade-server-warning p { margin: 0; }
.trade-card #trade-precalc { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .38rem .8rem; }
.trade-card #trade-precalc p { margin: 0; font-size: .74rem; }

/* Expandable history rows use the same compact dark details surface as the
   workspace, while linked and unlinked records remain visually distinct. */
[data-testid="history-trade-row"] { cursor: pointer; }
[data-testid="history-trade-row"]:hover { background: rgb(84 101 149 / .13); }
[data-testid="history-unlinked-row"] { background: rgb(99 65 20 / .15); }
.history-fill-details { padding: .65rem .9rem !important; background: #0b1422; color: #aebed2; white-space: normal !important; }
.history-fill-details > * { max-width: 100%; }

@media (max-width: 620px) {
  dialog#trade-dialog { width: calc(100vw - 1rem); max-height: calc(100dvh - 1rem); }
  .trade-dialog-content { max-height: calc(100dvh - 1rem); }
  .dialog-heading { gap: .6rem; padding: .7rem .75rem .6rem; }
  .dialog-heading p { font-size: .72rem; }
  .trade-dialog-content > :last-child { padding-inline: .5rem; padding-bottom: .5rem; }
  .trade-card { padding: .8rem; }
  .trade-fields { grid-template-columns: 1fr; }
  .trade-fields label:last-child { grid-column: auto; max-width: none; }
  .trade-decision-grid { grid-template-columns: 1fr; }
  .trade-card #trade-precalc { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .35rem .55rem; }
  .management-preview-grid { grid-template-columns: 1fr; }
  .management-receipt { grid-template-columns: minmax(0, 1fr); }
  .management-receipt .workspace-status { justify-self: start; }
}

@media (max-width: 390px), (max-height: 520px) {
  .dialog-heading > div { min-width: 0; }
  .dialog-heading p { display: none; }
  .trade-ticket-actions { top: 0; }
  .trade-card #trade-precalc { grid-template-columns: 1fr; }
}
