/* ================= Back office ================= */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.btn--sm { padding: 0.7rem 1.1rem; font-size: 0.74rem; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---- Sign-in ---- */
.bo-auth { min-height: 100vh; background: radial-gradient(ellipse 70% 60% at 50% 0%, rgba(197,164,109,0.1), transparent 60%), var(--navy); }
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 16px; gap: 1.6rem; }
.auth__card { width: 100%; max-width: 420px; background: var(--slate); border: 1px solid var(--line); border-top: 2px solid var(--gold); padding: 2.6rem clamp(1.4rem, 5vw, 2.6rem) 2rem; }
.auth__brand { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 2.2rem; }
.auth__brand img { width: 56px; height: 56px; }
.auth__title { font-family: var(--serif); font-size: 2.4rem; margin: -0.4rem 0 1.8rem; }
.auth__submit { width: 100%; justify-content: center; margin-top: 0.4rem; }
.auth .form__status { margin-top: 1rem; min-height: 1.4em; }
.auth__foot { font-size: 0.8rem; margin: 1.6rem 0 0; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.auth__back { font-size: 0.85rem; color: var(--mist); }
.auth__back:hover { color: var(--gold); }

/* ---- App shell ---- */
.bo-app { min-height: 100vh; background: var(--navy); }
.bo-top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.8rem clamp(16px, 3vw, 32px); background: rgba(9,23,37,0.95); border-bottom: 1px solid rgba(197,164,109,0.35); }
.bo-top .brand__mark { width: 40px; height: 40px; }
.bo-top__user { display: flex; align-items: center; gap: 0.9rem; font-size: 0.9rem; color: var(--ivory); }
.bo-badge { font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); border: 1px solid rgba(197,164,109,0.5); padding: 0.2rem 0.55rem; }
.bo-link { background: none; border: 0; padding: 0; font: inherit; font-size: 0.85rem; color: var(--gold); cursor: pointer; border-bottom: 1px solid rgba(197,164,109,0.4); }
.bo-link:hover { color: var(--ivory); }

.bo-shell { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 65px); }
.bo-nav { display: flex; flex-direction: column; gap: 0.2rem; padding: 1.6rem 0.9rem; border-right: 1px solid var(--line); background: rgba(20,40,58,0.35); }
.bo-nav button { text-align: left; background: none; border: 0; border-left: 2px solid transparent; color: var(--mist); font: inherit; font-size: 0.92rem; padding: 0.7rem 0.9rem; cursor: pointer; transition: color .3s, background .3s; }
.bo-nav button:hover { color: var(--ivory); background: rgba(170,182,191,0.06); }
.bo-nav button.is-active { color: var(--ivory); border-left-color: var(--gold); background: rgba(197,164,109,0.08); }
.bo-nav.is-locked button:not([data-view="account"]) { opacity: 0.35; pointer-events: none; }

.bo-main { padding: clamp(1.6rem, 4vw, 3rem) clamp(16px, 4vw, 3rem); min-width: 0; }
.bo-h1 { font-family: var(--serif); font-size: clamp(2rem, 3.4vw, 2.6rem); margin-bottom: 0.4rem; }
.bo-h2 { font-family: var(--serif); font-size: 1.5rem; margin-bottom: 1.2rem; }
.bo-sub { margin-bottom: 2rem; max-width: 64ch; }
.bo-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; flex-wrap: wrap; }
.bo-head .bo-h1 { margin: 0; }
.bo-alert { border: 1px solid rgba(197,164,109,0.5); border-left: 3px solid var(--gold); background: rgba(197,164,109,0.08); padding: 0.9rem 1.2rem; margin-bottom: 1.8rem; font-size: 0.95rem; color: var(--ivory); }

.bo-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.bo-tile { text-align: left; font: inherit; color: inherit; cursor: pointer; background: var(--slate); border: 1px solid var(--line); padding: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; transition: border-color .3s, transform .3s; position: relative; }
.bo-tile:hover { border-color: rgba(197,164,109,0.5); transform: translateY(-2px); }
.bo-tile__k { font-family: var(--serif); font-size: 1.5rem; color: var(--ivory); }
.bo-tile__v { font-size: 0.9rem; color: var(--mist); }
.bo-tile__tag { position: absolute; top: 1rem; right: 1rem; font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); }
.bo-empty { border: 1px dashed var(--line-strong); padding: 3rem; text-align: center; color: var(--mist); }

.bo-panel { background: var(--slate); border: 1px solid var(--line); padding: 1.6rem; margin-bottom: 1.8rem; }
.bo-panel--narrow { max-width: 460px; }
.bo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.bo-hint { font-size: 0.82rem; margin: -0.6rem 0 1.2rem; }
.bo-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 0.8rem; }

.bo-table-wrap { overflow-x: auto; border: 1px solid var(--line); }
.bo-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.bo-table th { text-align: left; font-size: 0.68rem; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; color: var(--mist); padding: 0.9rem 1rem; background: rgba(20,40,58,0.6); border-bottom: 1px solid var(--line); white-space: nowrap; }
.bo-table td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--line); color: var(--ivory); vertical-align: middle; }
.bo-table tr:last-child td { border-bottom: 0; }
.bo-table tr.is-off td { opacity: 0.55; }
.bo-table select { font: inherit; font-size: 0.85rem; color: var(--ivory); background: var(--navy); border: 1px solid var(--line-strong); padding: 0.3rem 0.5rem; }
.bo-row-actions { white-space: nowrap; }
.bo-row-actions .bo-link + .bo-link { margin-left: 1rem; }
.bo-pill { font-size: 0.72rem; padding: 0.2rem 0.6rem; border: 1px solid rgba(170,182,191,0.4); color: var(--ivory); white-space: nowrap; }
.bo-pill--warn { border-color: rgba(197,164,109,0.6); color: var(--gold); }
.bo-pill--off { color: var(--mist); }
#usersStatus { margin-top: 1rem; }

@media (max-width: 760px) {
  .bo-shell { grid-template-columns: 1fr; }
  .bo-nav { flex-direction: row; overflow-x: auto; padding: 0.5rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .bo-nav button { white-space: nowrap; border-left: 0; border-bottom: 2px solid transparent; }
  .bo-nav button.is-active { border-bottom-color: var(--gold); }
  .bo-top .brand__sub { display: none; }
  #whoName { display: none; }
}

/* ---- Footer sign-in link + Trade Tools (public site) live in styles.css ---- */

/* ================= Trade Tally ================= */
.tt-h1sub { font-family: var(--sans, Inter, sans-serif); font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); margin-left: 0.6rem; vertical-align: middle; }
.tt-tabs { display: inline-flex; border: 1px solid var(--line-strong); }
.tt-tabs button { background: none; border: 0; color: var(--mist); font: inherit; font-size: 0.85rem; padding: 0.55rem 1.1rem; cursor: pointer; }
.tt-tabs button + button { border-left: 1px solid var(--line-strong); }
.tt-tabs button.is-active { background: rgba(197,164,109,0.14); color: var(--ivory); }
.tt-back { margin-bottom: 1.2rem; display: inline-block; }
.tt-meta { margin: 0.5rem 0 0; font-size: 0.88rem; color: var(--mist); display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.tt-dim { color: var(--mist); opacity: 0.8; }
.tt-neg { color: #e08a7a; }

.tt-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.tt-stat { background: var(--slate); border: 1px solid var(--line); border-top: 2px solid var(--gold); padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: 0.25rem; }
.tt-stat__k { font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--mist); }
.tt-stat__v { font-family: var(--serif); font-size: 1.7rem; color: var(--ivory); font-variant-numeric: tabular-nums; }
.tt-stat__s { font-size: 0.8rem; color: var(--mist); }

.tt-inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem 1rem; }
.tt-inline .field { margin: 0; min-width: 170px; }
.tt-new .bo-hint { margin: -0.6rem 0 1rem; }

.tt-table td.num, .tt-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tt-table th small { font-size: 0.6rem; letter-spacing: 0.08em; text-transform: none; opacity: 0.8; }
.tt-table tfoot td { font-weight: 600; background: rgba(20,40,58,0.6); border-top: 1px solid var(--line-strong); white-space: nowrap; }
.tt-click { cursor: pointer; }
.tt-click:hover td { background: rgba(197,164,109,0.06); }
.tt-totrow td { font-weight: 600; border-top: 1px solid var(--line-strong); }
.tt-grid th.tt-in { color: var(--gold); }
.tt-grid th { padding: 0.8rem 0.55rem; letter-spacing: 0.1em; }
.tt-grid td { padding: 0.5rem 0.55rem; }
.tt-grid td:first-child, .tt-grid th:first-child { padding-left: 1rem; }
.tt-grid .tt-name { white-space: nowrap; }

.tt-num { width: 7.4rem; max-width: 100%; text-align: right; font: inherit; font-size: 0.9rem; font-variant-numeric: tabular-nums; color: var(--ivory); background: var(--navy); border: 1px solid var(--line-strong); padding: 0.4rem 0.55rem; }
.tt-num:focus, .tt-f input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(197,164,109,0.25); }
.tt-num::placeholder { color: var(--mist); opacity: 0.6; font-size: 0.8rem; }

.tt-name { background: none; border: 0; padding: 0; font: inherit; color: var(--ivory); cursor: pointer; text-align: left; display: inline-flex; gap: 0.45rem; align-items: center; }
.tt-name:hover { color: var(--gold); }
.tt-caret { font-size: 0.7rem; color: var(--gold); transition: transform .2s; display: inline-block; }
.tt-row.is-open .tt-caret { transform: rotate(90deg); }
.tt-note, .tt-warn { margin-left: 0.45rem; font-size: 0.75rem; }
.tt-note { color: var(--mist); }
.tt-warn { display: inline-grid; place-items: center; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: #c9764f; color: #fff; font-weight: 700; }
.tt-detail > td { background: rgba(9,23,37,0.55); padding: 1.2rem 1.4rem !important; }
.tt-detailbox { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: 1.6rem 2.4rem; align-items: start; }
.tt-calc { font-size: 0.88rem; border: 1px solid var(--line); background: var(--slate); padding: 0.9rem 1.1rem; }
.tt-calc__l { display: flex; justify-content: space-between; gap: 1rem; padding: 0.22rem 0; font-variant-numeric: tabular-nums; }
.tt-calc__l i { display: inline-block; width: 1rem; color: var(--gold); font-style: normal; }
.tt-calc__l.is-total { border-top: 1px solid var(--line-strong); margin-top: 0.25rem; padding-top: 0.45rem; font-weight: 600; color: var(--ivory); }
.tt-calc__sub { margin-top: 0.7rem; padding-top: 0.6rem; border-top: 1px dashed var(--line-strong); font-size: 0.8rem; color: var(--mist); }
.tt-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.8rem 1rem; align-content: start; }
.tt-f { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.72rem; letter-spacing: 0.06em; color: var(--mist); }
.tt-f input { width: 100%; font: inherit; font-size: 0.9rem; letter-spacing: 0; color: var(--ivory); background: var(--navy); border: 1px solid var(--line-strong); padding: 0.4rem 0.55rem; }
.tt-f--wide { grid-column: 1 / -1; }
.tt-fields .bo-link { justify-self: start; grid-column: 1 / -1; }
.tt-cash input { width: 1.1rem; height: 1.1rem; accent-color: var(--gold); cursor: pointer; }
.tt-cash input:disabled { cursor: not-allowed; opacity: 0.4; }

.tt-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin: 0.4rem 0 1.4rem; }
.tt-step { display: flex; gap: 0.8rem; font-size: 0.88rem; color: var(--mist); background: rgba(20,40,58,0.45); border: 1px solid var(--line); padding: 0.9rem 1rem; }
.tt-step strong { color: var(--ivory); font-weight: 500; }
.tt-step__n { flex: none; width: 1.6rem; height: 1.6rem; border: 1px solid var(--gold); color: var(--gold); display: grid; place-items: center; font-size: 0.8rem; }
.tt-paste { margin-top: 0.7rem; }
.tt-paste summary { cursor: pointer; color: var(--gold); font-size: 0.85rem; }
.tt-paste textarea { width: 100%; margin: 0.6rem 0; font: 0.8rem/1.5 ui-monospace, Consolas, monospace; color: var(--ivory); background: var(--navy); border: 1px solid var(--line-strong); padding: 0.6rem; resize: vertical; }
.tt-days { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem 0.8rem; margin-bottom: 1rem; font-size: 0.85rem; color: var(--mist); }
.tt-days input { width: 5rem; font: inherit; color: var(--ivory); background: var(--navy); border: 1px solid var(--line-strong); padding: 0.35rem 0.5rem; }
.tt-days .bo-hint { margin: 0; }
.tt-legend { margin-top: 0.9rem; }
.tt-tgrid { gap: 0 1rem; }

@media (max-width: 900px) { .tt-detailbox { grid-template-columns: 1fr; } }

@media print {
  .bo-top, .bo-nav, .tt-noprint, .tt-steps, .tt-days, #mustChange { display: none !important; }
  .bo-shell { display: block; }
  body, .bo-app, .bo-main, .bo-table td, .bo-table th, .tt-calc { background: #fff !important; color: #000 !important; }
  .bo-table th, .bo-table td { border-color: #bbb !important; }
  .tt-num { border: 0; background: none; color: #000; width: auto; }
  .tt-neg { color: #b00020; }
  .bo-table-wrap { overflow: visible; border-color: #bbb; }
}
.tt-sub { font-size: 0.7rem; color: var(--gold); margin-top: 0.2rem; min-height: 0; white-space: nowrap; }

/* ---- Setup tools ---- */
.st-layout { display: grid; grid-template-columns: 220px 1fr; gap: 1.6rem; align-items: start; }
.st-menu { display: flex; flex-direction: column; gap: 0.3rem; position: sticky; top: 90px; }
.st-menu button { display: flex; align-items: center; gap: 0.7rem; text-align: left; background: var(--slate); border: 1px solid var(--line); color: var(--mist); font: inherit; font-size: 0.9rem; padding: 0.75rem 0.9rem; cursor: pointer; transition: border-color .2s, color .2s; }
.st-menu button:hover { color: var(--ivory); border-color: rgba(197,164,109,0.4); }
.st-menu button.is-active { color: var(--ivory); border-color: var(--gold); background: rgba(197,164,109,0.1); }
.st-ic { width: 1.6rem; height: 1.6rem; display: grid; place-items: center; border: 1px solid rgba(197,164,109,0.45); color: var(--gold); font-size: 0.8rem; flex: none; }
.st-body { min-width: 0; }
.st-head { align-items: flex-start; margin-bottom: 0.6rem; }
.st-desc { margin: 0.2rem 0 0; max-width: 70ch; }
.st-table td { vertical-align: middle; }
.st-table input:not([type=checkbox]), .st-table select { font: inherit; font-size: 0.88rem; color: var(--ivory); background: var(--navy); border: 1px solid var(--line-strong); padding: 0.4rem 0.5rem; max-width: 100%; }
.st-table input:not(.tt-num):not([type=checkbox]) { width: 100%; min-width: 8rem; }
.st-table .tt-num { width: 8.5rem; }
.st-edit td { background: rgba(197,164,109,0.06); }
.st-edit--foot td { border-top: 0; }
.st-commit { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.8rem; }
.st-comment { flex: 1 1 320px; }
.st-chip { display: inline-block; font-size: 0.72rem; padding: 0.12rem 0.45rem; border: 1px solid rgba(197,164,109,0.45); color: var(--ivory); margin: 0.1rem 0; white-space: nowrap; }
.st-checks { display: grid; grid-template-columns: repeat(2, minmax(120px, auto)); gap: 0.25rem 0.9rem; font-size: 0.82rem; }
.st-checks label { white-space: nowrap; cursor: pointer; }
.st-checks input { accent-color: var(--gold); }
.st-h3 { font-family: var(--serif); font-size: 1.3rem; font-weight: 500; margin: 2.2rem 0 0.8rem; }
.st-log { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); max-height: 420px; overflow: auto; }
.st-log li { padding: 0.8rem 1rem; border-bottom: 1px solid var(--line); font-size: 0.86rem; }
.st-log li:last-child { border-bottom: 0; }
.st-log__top { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.st-log__chg { color: var(--mist); margin: 0.2rem 0; font-variant-numeric: tabular-nums; }
.st-log__c { color: var(--gold); font-style: italic; }
@media (max-width: 980px) { .st-layout { grid-template-columns: 1fr; } .st-menu { flex-direction: row; overflow-x: auto; position: static; } .st-menu button { white-space: nowrap; } }
.tt-pdf { display: inline-block; margin-top: 0.8rem; }
.st-layout { grid-template-columns: 190px 1fr; gap: 1.2rem; }
.st-table th { letter-spacing: 0.08em; padding: 0.8rem 0.6rem; }
.st-table td { padding: 0.65rem 0.6rem; }
.st-table td:first-child { white-space: nowrap; }
.st-table td:has(.st-chip), .st-table td:has(.st-checks) { min-width: 230px; white-space: normal; }
.st-chip { margin: 0.12rem 0.1rem; }
.st-ic { font-size: 0.66rem; font-weight: 600; }

/* monthly package buttons */
.tt-pack { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; padding: 0.35rem 0.5rem; border: 1px solid rgba(197, 164, 109, 0.45); border-radius: 6px; }
.tt-pack-label { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold, #c5a46d); margin-right: 0.2rem; }

/* ================= Next-step banner / Overview ================= */
.hm-next { display: flex; align-items: center; justify-content: space-between; gap: 1rem 2rem; flex-wrap: wrap; padding: 1.3rem 1.5rem; margin-bottom: 1.4rem;
  background: linear-gradient(100deg, rgba(197,164,109,0.16), rgba(20,40,58,0.6) 70%); border: 1px solid rgba(197,164,109,0.45); border-left: 3px solid var(--gold); }
.hm-next:empty { display: none; }
.hm-next__k { font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); }
.hm-next__t { font-family: var(--serif); font-size: 1.6rem; font-weight: 500; color: var(--ivory); margin: 0.15rem 0 0.2rem; }
.hm-next__s { margin: 0; font-size: 0.88rem; color: var(--mist); }
.hm { margin-bottom: 2.4rem; }
.hm-h2 { margin-top: 0.4rem; }
.hm-traders { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.6rem; }
.hm-tr { display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 0.6rem; align-items: center; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: rgba(20,40,58,0.55); border: 1px solid var(--line); padding: 0.75rem 0.9rem; transition: border-color .2s, transform .2s; }
.hm-tr:hover { border-color: rgba(197,164,109,0.5); transform: translateY(-1px); }
.hm-tr__n { font-size: 0.88rem; color: var(--ivory); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-tr__v { font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.hm-tr .ld-bars { grid-column: 1 / -1; height: 26px; }

/* ================= Bars ================= */
.ld-bars { display: block; width: 100%; }
.ld-bars rect.is-pos { fill: var(--gold); opacity: 0.85; }
.ld-bars rect.is-neg { fill: #e08a7a; opacity: 0.9; }
.ld-bars rect[data-month] { cursor: pointer; }
.ld-bars rect:hover { opacity: 1; }
.ld-bars__zero { stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }

/* ================= Traders ================= */
.ld-bar { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.ld-lead { margin: 0; }
.ld-bar__r { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.ld-input { font: inherit; font-size: 0.88rem; color: var(--ivory); background: var(--navy); border: 1px solid var(--line-strong); padding: 0.5rem 0.65rem; min-width: 0; }
.ld-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(197,164,109,0.25); }
input.ld-input[type=month] { color-scheme: dark; }
#ldSearch { width: 220px; }
.ld-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.ld-card { background: var(--slate); border: 1px solid var(--line); border-top: 2px solid var(--gold); padding: 1.15rem 1.2rem 1rem; display: flex; flex-direction: column; gap: 0.85rem; cursor: pointer; transition: border-color .2s, transform .2s, box-shadow .2s; }
.ld-card:hover, .ld-card:focus-visible { border-color: rgba(197,164,109,0.6); transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0,0,0,0.25); outline: none; }
.ld-card.is-off { border-top-color: var(--line-strong); opacity: 0.75; }
.ld-card__head { display: flex; justify-content: space-between; gap: 0.6rem; align-items: flex-start; }
.ld-card__name { font-family: var(--serif); font-size: 1.45rem; font-weight: 500; color: var(--ivory); margin: 0; line-height: 1.15; }
.ld-card__sub { margin: 0.2rem 0 0; font-size: 0.75rem; color: var(--mist); letter-spacing: 0.04em; }
.ld-kv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; margin: 0; }
.ld-kv dt { font-size: 0.6rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--mist); }
.ld-kv dd { margin: 0.15rem 0 0; font-size: 0.9rem; color: var(--ivory); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ld-card__lbl { font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--mist); }
.ld-card__latest { border-top: 1px solid var(--line); padding-top: 0.7rem; }
.ld-card__nums { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-top: 0.2rem; font-size: 0.85rem; color: var(--mist); font-variant-numeric: tabular-nums; }
.ld-card__nums strong { font-weight: 600; margin-left: 0.25rem; }
.ld-card__chart .ld-bars { height: 46px; }
.ld-card__foot { display: flex; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; font-size: 0.8rem; color: var(--ivory); border-top: 1px solid var(--line); padding-top: 0.7rem; font-variant-numeric: tabular-nums; }

/* ================= One trader ================= */
.ld-thead { align-items: flex-start; }
.ld-chips { display: flex; flex-wrap: wrap; gap: 0.2rem; margin-top: 0.6rem; }
.ld-chip--lic { border-color: var(--line-strong); color: var(--mist); }
.ld-years { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line-strong); margin-bottom: 1.2rem; }
.ld-years button { background: none; border: 0; color: var(--mist); font: inherit; font-size: 0.82rem; padding: 0.45rem 0.9rem; cursor: pointer; }
.ld-years button + button { border-left: 1px solid var(--line-strong); }
.ld-years button.is-active { background: rgba(197,164,109,0.14); color: var(--ivory); }
.ld-chart { background: var(--slate); border: 1px solid var(--line); padding: 0.9rem 1.1rem 1rem; margin-bottom: 1.4rem; }
.ld-chart:empty { display: none; }
.ld-chart__h { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mist); margin-bottom: 0.6rem; }
.ld-chart__h .tt-dim { text-transform: none; letter-spacing: 0; }
.ld-chart .ld-bars { height: 120px; }
.ld-table th { padding: 0.8rem 0.6rem; letter-spacing: 0.1em; }
.ld-table td { padding: 0.55rem 0.6rem; }
.ld-table { font-size: 0.86rem; }
.ld-table td:nth-child(2) .ld-a, .ld-table td:first-child { white-space: nowrap; }
.ld-table td:first-child, .ld-table th:first-child { padding-left: 1rem; white-space: nowrap; }
.ld-c { text-align: center; }
.ld-ic { font: inherit; font-size: 0.62rem; letter-spacing: 0.1em; color: var(--gold); background: none; border: 1px solid rgba(197,164,109,0.45); padding: 0.18rem 0.4rem; cursor: pointer; }
.ld-ic:hover { background: rgba(197,164,109,0.15); color: var(--ivory); }

/* ================= Full ledger ================= */
.ld-filters { padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.ld-quick { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-bottom: 1rem; }
.ld-quick__k { font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); margin-right: 0.4rem; }
.ld-quick button { font: inherit; font-size: 0.8rem; color: var(--ivory); background: rgba(9,23,37,0.6); border: 1px solid var(--line-strong); padding: 0.35rem 0.75rem; cursor: pointer; border-radius: 999px; }
.ld-quick button:hover { border-color: var(--gold); color: var(--gold); }
.ld-fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.8rem 1rem; align-items: end; }
.ld-fgrid .ld-input { width: 100%; }
.ld-fbtns { padding-bottom: 0.55rem; }
.ld-sums { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.6rem; margin-bottom: 1rem; }
.ld-sum { display: flex; flex-direction: column; gap: 0.2rem; background: rgba(20,40,58,0.55); border: 1px solid var(--line); padding: 0.65rem 0.85rem; }
.ld-sum > span { font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--mist); }
.ld-sum strong { font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ivory); }
.ld-dl { margin-bottom: 0.9rem; }
.ld-scroll { max-height: 70vh; overflow: auto; }
.ld-scroll thead th { position: sticky; top: 0; z-index: 1; background: #12253a; }
.ld-scroll tfoot td { position: sticky; bottom: 0; background: #12253a; }
.ld-group td { background: rgba(197,164,109,0.08); padding-top: 0.7rem !important; font-family: var(--serif); font-size: 1.05rem; border-bottom: 1px solid rgba(197,164,109,0.25); }
.ld-group .bo-link { font-family: var(--serif); font-size: 1.05rem; }
.ld-sub td { font-size: 0.82rem; color: var(--mist); font-weight: 600; background: rgba(9,23,37,0.35); }
.ld-a { background: none; border: 0; padding: 0; font: inherit; color: var(--ivory); cursor: pointer; text-align: left; }
.ld-a:hover { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 760px) {
  .ld-kv { grid-template-columns: repeat(2, 1fr); }
  #ldSearch { width: 100%; }
  .ld-bar__r { width: 100%; }
}
@media print {
  .ld-filters, .ld-dl, .ld-years, .hm-next, .tt-tabs { display: none !important; }
  .ld-scroll { max-height: none; overflow: visible; }
  .ld-chart, .tt-stat, .ld-sum { background: #fff !important; color: #000 !important; }
}

/* ================= Add trader / close account forms ================= */
.pf-intro .bo-sub { margin-bottom: 1.4rem; }
.pf-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.6rem; align-items: start; }
.pf-form { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.pf-sec { background: var(--slate); border: 1px solid var(--line); padding: 1.2rem 1.3rem 1.3rem; }
.pf-sec__h { display: flex; gap: 0.9rem; align-items: flex-start; margin-bottom: 1rem; }
.pf-sec__h h3 { font-family: var(--serif); font-size: 1.3rem; font-weight: 500; color: var(--ivory); margin: 0; }
.pf-sec__h p { margin: 0.2rem 0 0; font-size: 0.84rem; color: var(--mist); max-width: 70ch; }
.pf-sec__n { flex: none; width: 1.7rem; height: 1.7rem; display: grid; place-items: center; border: 1px solid var(--gold); color: var(--gold); font-size: 0.8rem; margin-top: 0.15rem; }
.pf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.9rem 1rem; }
.pf { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.pf--wide { grid-column: 1 / -1; }
.pf__l { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--mist); }
.pf__h { font-size: 0.75rem; color: var(--mist); opacity: 0.85; }
.pf .ld-input { width: 100%; }
.pf--check { flex-direction: row; align-items: center; gap: 0.6rem; font-size: 0.88rem; color: var(--ivory); cursor: pointer; align-self: end; padding-bottom: 0.5rem; }
.pf--check input { width: 1.05rem; height: 1.05rem; accent-color: var(--gold); flex: none; }
.pf-lic { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.5rem; }
.pf-licbox { display: flex; align-items: center; gap: 0.55rem; padding: 0.55rem 0.7rem; border: 1px solid var(--line-strong); background: rgba(9,23,37,0.5); cursor: pointer; font-size: 0.86rem; color: var(--ivory); transition: border-color .2s, background .2s; }
.pf-licbox:has(input:checked) { border-color: var(--gold); background: rgba(197,164,109,0.1); }
.pf-licbox input { accent-color: var(--gold); }
.pf-licbox small { margin-left: auto; color: var(--mist); font-variant-numeric: tabular-nums; }
.pf-accts { display: flex; flex-direction: column; gap: 0.5rem; }
.pf-acct { display: grid; grid-template-columns: 1.1fr 0.6fr 0.8fr 1.4fr auto; gap: 0.5rem; align-items: center; }
.pf-add { justify-self: start; }
.pf-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.pf-preview { position: sticky; top: 90px; background: linear-gradient(180deg, rgba(197,164,109,0.1), rgba(20,40,58,0.7) 40%); border: 1px solid rgba(197,164,109,0.4); padding: 1.2rem 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.pf-pv__name { font-family: var(--serif); font-size: 1.5rem; font-weight: 500; margin: 0.1rem 0 0; color: var(--ivory); }
.pf-pv__block { border-top: 1px solid var(--line); padding-top: 0.75rem; display: flex; flex-direction: column; gap: 0.3rem; }
.pf-pv__k { font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--mist); margin-bottom: 0.15rem; }
.pf-pv__r { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.88rem; color: var(--ivory); font-variant-numeric: tabular-nums; }
.pf-pv__r.is-strong { font-weight: 600; border-top: 1px dashed var(--line-strong); padding-top: 0.3rem; }
.pf-pv__s { margin: 0; font-size: 0.82rem; color: var(--mist); }
.pf-pv__warn { border: 1px solid rgba(224,138,122,0.5); background: rgba(224,138,122,0.08); padding: 0.7rem 0.8rem; font-size: 0.82rem; color: #f0b3a7; }
.pf-pv__warn p { margin: 0; }
.pf-pv__warn p + p { margin-top: 0.4rem; }
.pf-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; border-top: 1px solid var(--line); padding-top: 0.8rem; }
.pf-checks li { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.82rem; color: var(--mist); padding-left: 1.4rem; position: relative; }
.pf-checks li::before { position: absolute; left: 0; top: 0.05rem; font-size: 0.8rem; }
.pf-checks li.is-ok::before { content: "✓"; color: var(--gold); }
.pf-checks li.is-warn::before { content: "!"; color: #e08a7a; font-weight: 700; left: 0.25rem; }
.pf-checks strong { color: var(--ivory); font-weight: 500; }

/* closed-account panel on a trader page */
.pf-exit { border: 1px solid var(--line-strong); border-left: 3px solid var(--mist); background: rgba(20,40,58,0.55); padding: 1.1rem 1.3rem; margin-bottom: 1.4rem; display: flex; flex-direction: column; gap: 0.9rem; }
.pf-exit.is-open { border-left-color: #e08a7a; }
.pf-exit__h { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.pf-exit__h h3 { font-family: var(--serif); font-size: 1.35rem; font-weight: 500; margin: 0.15rem 0 0; color: var(--ivory); }
.pf-exit__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.8rem; margin: 0; }
.pf-exit__grid dt { font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--mist); }
.pf-exit__grid dd { margin: 0.2rem 0 0; font-size: 1rem; color: var(--ivory); font-variant-numeric: tabular-nums; }
.pf-exit__note { margin: 0; font-size: 0.85rem; color: var(--mist); font-style: italic; }
.ld-contact { margin-top: 0.3rem; }
.ld-contact span + span::before { content: "·"; margin-right: 0.5rem; color: var(--mist); }
.ld-contact a { color: var(--ivory); }
.ld-danger { border-color: rgba(224,138,122,0.6) !important; color: #f0b3a7 !important; }
.ld-danger:hover { background: rgba(224,138,122,0.12) !important; }

@media (max-width: 1000px) {
  .pf-layout { grid-template-columns: 1fr; }
  .pf-preview { position: static; order: -1; }
  .pf-acct { grid-template-columns: 1fr 1fr; }
}

[hidden] { display: none !important; }

/* ================= Phones and small tablets ================= */
.bo-app { overflow-x: clip; }
.bo-shell > *, .st-layout > * { min-width: 0; }
.st-layout { grid-template-columns: 190px minmax(0, 1fr); }

@media (max-width: 980px) {
  .st-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .st-menu { flex-direction: row; overflow-x: auto; position: static; padding-bottom: 0.3rem; scrollbar-width: thin; }
  .st-menu button { white-space: nowrap; flex: none; }
}

@media (max-width: 700px) {
  .bo-main { padding: 1.2rem 16px 2.4rem; }
  .bo-h1 { font-size: 1.9rem; }
  .bo-head { gap: 0.8rem; }
  .bo-head .bo-actions { width: 100%; }
  .bo-actions { gap: 0.5rem; }
  .btn--sm { padding: 0.65rem 0.9rem; font-size: 0.7rem; }
  .bo-sub { font-size: 0.92rem; margin-bottom: 1.2rem; }
  .tt-h1sub { display: block; margin: 0.3rem 0 0; }

  /* Trade Tally tabs: full width, equal */
  .bo-view[data-view="tally"] > .bo-head { flex-direction: column; align-items: stretch; }
  .tt-tabs { display: flex; width: 100%; }
  .tt-tabs button { flex: 1; padding: 0.65rem 0.3rem; font-size: 0.82rem; }

  .tt-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .tt-stat { padding: 0.8rem 0.9rem; }
  .tt-stat__v { font-size: 1.3rem; word-break: break-word; }
  .hm-next { padding: 1rem 1.1rem; }
  .hm-next__t { font-size: 1.35rem; }
  .hm-next .btn { width: 100%; justify-content: center; }
  .bo-tiles { grid-template-columns: 1fr; }
  .hm-traders { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tt-pack { width: 100%; }
  .tt-steps { grid-template-columns: 1fr; }
  .tt-inline .field { min-width: 0; flex: 1 1 140px; }
  .ld-cards { grid-template-columns: 1fr; }
  .ld-sums { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ld-fgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ld-scroll { max-height: none; overflow: visible; }
  .pf-grid { grid-template-columns: 1fr; }
  .pf-sec { padding: 1rem; }
  .pf-acct { grid-template-columns: 1fr; padding-bottom: 0.6rem; border-bottom: 1px solid var(--line); }
  .pf-exit__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* every Trade Tally table becomes a stack of cards: heading on the left, value on the right */
  .bo-table-wrap:has(.tt-table) { border: 0; overflow: visible; }
  .tt-table, .tt-table tbody, .tt-table tfoot, .tt-table tr, .tt-table td { display: block; width: 100%; }
  .tt-table thead { display: none; }
  .tt-table tr { background: var(--slate); border: 1px solid var(--line); margin-bottom: 0.6rem; padding: 0.35rem 0; }
  .tt-table tfoot tr { border-color: rgba(197,164,109,0.5); }
  .tt-table td, .tt-grid td, .ld-table td, .st-table td { display: grid; grid-template-columns: minmax(96px, 42%) minmax(0, 1fr); align-items: center; gap: 0.6rem;
    padding: 0.4rem 0.95rem !important; border: 0; text-align: right; white-space: normal !important; min-width: 0 !important; }
  .tt-table td::before { content: attr(data-label); text-align: left; font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mist); font-weight: 400; }
  .tt-table td[data-label] { justify-items: end; }
  .tt-table td[data-label]::before { justify-self: start; }
  /* full ledger: trader name is the card title, month becomes a normal row */
  #ldBody tr:not(.ld-group):not(.ld-sub) { display: flex; flex-direction: column; }
  #ldBody tr:not(.ld-group):not(.ld-sub) td:nth-child(2) { order: -1; display: block; text-align: left; font-size: 1.02rem; padding-top: 0.55rem !important; padding-bottom: 0.45rem !important; border-bottom: 1px solid var(--line); margin-bottom: 0.2rem; }
  #ldBody tr:not(.ld-group):not(.ld-sub) td:nth-child(2)::before { content: none; }
  #ldBody tr:not(.ld-group):not(.ld-sub) td:first-child { display: grid; font-size: inherit; padding: 0.4rem 0.95rem !important; border: 0; margin: 0; }
  #ldBody tr:not(.ld-group):not(.ld-sub) td:first-child::before { content: attr(data-label); }
  .tt-table td:not([data-label]) { display: block; text-align: left; }
  .tt-table td:not([data-label])::before { content: none; }
  .tt-table td:empty, .tt-table td[data-label=""] { display: none; }
  /* first cell = the card title */
  .tt-table td:first-child { display: block; text-align: left; font-size: 1.02rem; padding-top: 0.55rem !important; padding-bottom: 0.45rem !important; border-bottom: 1px solid var(--line); margin-bottom: 0.2rem; }
  .tt-table td:first-child::before { content: none; }
  .tt-table .tt-num { width: 100%; }
  .tt-table .tt-sub { white-space: normal; }
  .tt-table .tt-cash { justify-self: end; }
  /* expanded trader details in a month */
  .tt-detail { padding: 0 !important; }
  .tt-detail > td { padding: 0.8rem !important; border: 0; }
  .tt-detailbox { grid-template-columns: 1fr; }
  .tt-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* ledger group heading + subtotal rows */
  .ld-group { background: none !important; border: 0 !important; margin: 1rem 0 0.3rem; padding: 0 !important; }
  .ld-group td { padding: 0 0.2rem !important; background: none !important; border: 0 !important; }
  .ld-sub { border-color: rgba(197,164,109,0.35) !important; }
  .ld-sub td:first-child { font-size: 0.85rem; }
  /* setup rows being edited: label above each input */
  .st-edit td { grid-template-columns: 1fr; text-align: left; }
  .st-edit td:first-child { font-size: 0.95rem; }
  .st-table input:not(.tt-num):not([type=checkbox]), .st-table select, .st-table .tt-num { width: 100%; min-width: 0; }
  .st-table td:has(.st-chip), .st-table td:has(.st-checks) { min-width: 0; }
  .st-checks { grid-template-columns: 1fr 1fr; }
  .bo-row-actions { text-align: left !important; display: flex !important; gap: 1.2rem; }
  .bo-row-actions::before { content: none !important; }
  .st-log__top { flex-direction: column; gap: 0.2rem; }
}

@media (max-width: 380px) {
  .tt-stats, .ld-sums, .hm-traders, .ld-fgrid, .tt-fields { grid-template-columns: 1fr; }
  .tt-tabs button { font-size: 0.76rem; }
}
