/* ============================================================
   COMPONENTS — buttons, tags, chips, panels, blotter, shell.
   ============================================================ */

/* ---------------- App shell ---------------- */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* nav rail */
.rail {
  background: var(--panel);
  border-right: var(--hair) solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 14px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--clay); color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-weight: 700; font-size: 15px;
  box-shadow: inset 0 0 0 1px #00000018, 0 1px 2px #0003;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; line-height: 1; }
.brand-sub { font-family: var(--font-mono); font-size: 10px; color: var(--muted); letter-spacing: .12em; margin-top: 3px; }

/* primary CTA in rail — gives the nav color + purpose */
.rail-cta {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 11px 13px; margin-bottom: 22px; white-space: nowrap;
  background: var(--clay); color: #fff; border: 0; border-radius: var(--radius);
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 600; cursor: pointer;
  box-shadow: inset 0 1px 0 #ffffff2a, 0 1px 2px #0003; transition: background .14s, transform .06s;
}
.rail-cta:hover { background: color-mix(in oklab, var(--clay) 90%, #fff); }
.rail-cta:active { transform: translateY(1px); }
.rail-cta-key { margin-left: auto; font-family: var(--font-mono); font-size: 10px; opacity: .7; border: 1px solid #ffffff40; border-radius: 3px; padding: 1px 5px; }

.rail-section {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--faint); font-weight: 600; padding: 0 10px; margin-bottom: 8px;
}

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--radius);
  color: var(--muted); background: none; border: 0; cursor: pointer; text-align: left;
  position: relative; transition: background .12s, color .12s;
}
.nav-ico { display: grid; place-items: center; width: 18px; color: var(--muted); transition: color .12s; }
.nav-label { display: flex; flex-direction: column; line-height: 1.1; font-size: 13.5px; font-weight: 600; }
.nav-hint { font-size: 10.5px; font-weight: 500; color: var(--faint); margin-top: 3px; }
.nav-item:hover { background: var(--inset); color: var(--ink); }
.nav-item:hover .nav-ico { color: var(--ink-2); }
.nav-item.active { background: var(--clay-bg); color: var(--ink); }
.nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--clay);
}
.nav-item.active .nav-ico { color: var(--clay); }
[data-theme="dark"] .nav-item.active .nav-ico { color: color-mix(in oklab, var(--clay) 88%, #fff); }
.nav-key { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--faint);
  border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; align-self: center; }
.nav-item.active .nav-key { color: var(--clay); border-color: color-mix(in oklab, var(--clay) 40%, transparent); }

/* Today snapshot */
.rail-today { margin-top: 24px; }
.today-card {
  background: var(--inset); border: var(--hair) solid var(--border-2); border-radius: var(--radius-lg);
  padding: 13px 14px;
}
.today-net { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.today-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 9px;
  font-family: var(--font-mono); font-size: 11px; color: var(--muted); white-space: nowrap; gap: 10px; }
.today-rec { white-space: nowrap; }
.today-rec b { font-weight: 600; }
.empty-today { font-size: 12px; color: var(--faint); font-style: italic; padding: 14px; }

.rail-foot { margin-top: auto; padding-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.theme-toggle {
  display: flex; align-items: center; background: var(--inset);
  border: var(--hair) solid var(--border); border-radius: 99px; padding: 3px; gap: 2px;
}
.theme-toggle button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 8px; border: 0; background: none; border-radius: 99px;
  color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 600; font-family: var(--font-mono);
  letter-spacing: .06em; transition: all .14s;
}
.theme-toggle button.on { background: var(--panel-2); color: var(--ink); box-shadow: var(--shadow); }

.acct { display: flex; align-items: center; gap: 9px; padding: 6px 8px; min-width: 0; }
.acct-av {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 99px; background: var(--inset);
  border: var(--hair) solid var(--border); display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-2); font-weight: 600;
}
.acct-txt { line-height: 1.25; min-width: 0; }
.acct-mail { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-plan { font-family: var(--font-mono); font-size: 10px; color: var(--clay); letter-spacing: .08em; }

/* main column */
.main { overflow-y: auto; position: relative; }
.main-inner { max-width: 1180px; margin: 0 auto; padding: 0 40px 80px; }

/* page header */
.phead {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px) saturate(1.2);
  border-bottom: var(--hair) solid var(--border);
}
.phead-in { max-width: 1180px; margin: 0 auto; padding: 20px 40px 18px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.phead h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin: 0; line-height: 1; }
.phead .sub { color: var(--muted); font-size: 13px; margin-top: 7px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius); font-weight: 600; cursor: pointer; border: var(--hair) solid transparent;
  transition: transform .06s, background .14s, border-color .14s, color .14s;
  white-space: nowrap; font-family: var(--font-sans);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-md { padding: 9px 15px; font-size: 13.5px; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-primary { background: var(--clay); color: #fff; box-shadow: inset 0 1px 0 #ffffff28, 0 1px 2px #0002; }
.btn-primary:hover { background: color-mix(in oklab, var(--clay) 90%, #fff); }
.btn-ghost { background: var(--panel-2); color: var(--ink); border-color: var(--border); box-shadow: var(--shadow); }
.btn-ghost:hover { background: var(--inset); border-color: var(--muted); }
.btn-quiet { background: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--ink); background: var(--inset); }
.btn-danger { background: var(--short-soft); color: var(--short); }
.btn-danger:hover { background: color-mix(in oklab, var(--short) 22%, transparent); }

/* ---------------- Panels ---------------- */
.panel {
  background: var(--panel); border: var(--hair) solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 15px 18px; border-bottom: var(--hair) solid var(--border);
}
.panel-title { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.panel-hint { font-size: 12px; color: var(--muted); }
.panel-body { padding: 18px; }

/* ---------------- Direction tag ---------------- */
.dirtag {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: .02em;
  padding: 2px 7px 2px 5px; border-radius: 3px;
}
.dirtag.is-long { color: var(--long); background: var(--long-soft); }
.dirtag.is-short { color: var(--short); background: var(--short-soft); }

/* pnl text */
.pos { color: var(--long); }
.neg { color: var(--short); }

/* ---------------- Confluence chips ---------------- */
.cchip {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
  padding: 3px 8px; border-radius: 3px; border: var(--hair) solid var(--border-2);
  background: var(--inset); color: var(--ink-2); letter-spacing: .01em;
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
}
.cchip.click { cursor: pointer; transition: all .12s; }
.cchip.big { font-size: 13px; padding: 9px 13px; border-radius: var(--radius); font-weight: 500; }
.cchip.click:hover { border-color: var(--muted); color: var(--ink); }
.cchip.on { background: var(--clay-bg); border-color: color-mix(in oklab, var(--clay) 55%, transparent); color: var(--clay); }
[data-theme="dark"] .cchip.on { color: color-mix(in oklab, var(--clay) 88%, #fff); }
.cchip.dim { opacity: .5; }

/* threshold pips */
.pips { display: inline-flex; gap: 3px; align-items: center; }
.pip { width: 6px; height: 6px; border-radius: 1.5px; background: var(--border); transform: rotate(45deg); }
.pip.fill { background: var(--ink-2); }
.pip.thr { box-shadow: 0 0 0 1.5px var(--bg), 0 0 0 2.5px var(--clay); }

/* ---------------- Shared summary stat ---------------- */
.ovstat-k { font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.ovstat-v { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin-top: 9px; line-height: 1; white-space: nowrap; }

/* ---------------- P&L Calendar ---------------- */
.cal-page { padding-top: 20px; }
.cal-summary {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 40px;
  padding-bottom: 22px; margin-bottom: 20px; border-bottom: var(--hair) solid var(--border); flex-wrap: wrap;
}
.cal-sum-hero { min-width: 230px; }
.cal-sum-net { font-size: 40px; font-weight: 600; letter-spacing: -0.035em; line-height: 1; margin-top: 10px; }
.cal-sum-sub { color: var(--muted); font-size: 13px; margin-top: 10px; }
.cal-sum-stats { display: flex; gap: 40px; padding-bottom: 4px; }

.cal-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.cal-arrow {
  width: 34px; height: 34px; border-radius: var(--radius); border: var(--hair) solid var(--border);
  background: var(--panel-2); color: var(--ink-2); display: grid; place-items: center; cursor: pointer;
  box-shadow: var(--shadow); transition: all .12s;
}
.cal-arrow:hover { border-color: var(--muted); color: var(--ink); background: var(--inset); }
.cal-month { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; min-width: 150px; }
.cal-year { color: var(--muted); font-weight: 600; }
.cal-today-btn {
  margin-left: auto; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); white-space: nowrap;
  background: var(--panel-2); border: var(--hair) solid var(--border); border-radius: var(--radius);
  padding: 8px 13px; cursor: pointer; transition: all .12s;
}
.cal-today-btn:hover { color: var(--ink); border-color: var(--muted); }

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr) 124px; gap: 7px;
}
.cal-dow {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); padding: 4px 4px 8px; font-weight: 500;
}
.cal-dow-week { text-align: right; color: var(--faint); }

.cal-cell {
  min-height: 92px; border-radius: var(--radius); border: var(--hair) solid var(--border-2);
  background: var(--panel); padding: 9px 10px; display: flex; flex-direction: column; gap: 6px;
  text-align: left; cursor: default; position: relative; transition: transform .1s, box-shadow .12s, border-color .12s;
}
.cal-cell.out { background: transparent; border-color: transparent; }
.cal-cell.click { cursor: pointer; }
.cal-cell.click:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); border-color: var(--muted); z-index: 2; }
.cal-num { font-family: var(--font-mono); font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.cal-cell.out .cal-num { color: var(--faint); opacity: .5; }
.cal-todaytag { font-size: 8px; letter-spacing: .1em; color: #fff; background: var(--clay); padding: 1px 4px; border-radius: 2px; }
.cal-cell.today { border-color: var(--clay); box-shadow: inset 0 0 0 1px var(--clay); }
.cal-cell-body { margin-top: auto; }
.cal-pnl { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.cal-count { display: block; font-family: var(--font-mono); font-size: 10px; color: var(--muted); margin-top: 5px; }
.cal-cell.has.pos { background: color-mix(in oklab, var(--long) 12%, var(--panel)); border-color: color-mix(in oklab, var(--long) 28%, var(--border-2)); }
.cal-cell.has.neg { background: color-mix(in oklab, var(--short) 11%, var(--panel)); border-color: color-mix(in oklab, var(--short) 26%, var(--border-2)); }
.cal-empty-dot { margin-top: auto; width: 4px; height: 4px; border-radius: 9px; background: var(--border); opacity: .6; }

.cal-week {
  border-radius: var(--radius); border: var(--hair) dashed var(--border); background: var(--inset);
  padding: 9px 11px; display: flex; flex-direction: column; justify-content: center; gap: 4px; align-items: flex-end; text-align: right;
}
.cal-week.flat { opacity: .5; }
.cal-week-k { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.cal-week-net { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.cal-week-c { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }

.cal-legend { display: flex; align-items: center; gap: 20px; margin-top: 18px; font-size: 12px; color: var(--muted); }
.cal-legend span { display: flex; align-items: center; gap: 7px; }
.cal-key { width: 11px; height: 11px; border-radius: 3px; }
.cal-key.pos { background: color-mix(in oklab, var(--long) 30%, var(--panel)); border: 1px solid color-mix(in oklab, var(--long) 45%, transparent); }
.cal-key.neg { background: color-mix(in oklab, var(--short) 28%, var(--panel)); border: 1px solid color-mix(in oklab, var(--short) 42%, transparent); }
.cal-legend-hint { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--faint); }

/* ---------------- Day drill-down ---------------- */
.dayview { padding-top: 26px; }
.dv-back {
  display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; cursor: pointer;
  font-family: var(--font-mono); font-size: 12px; color: var(--muted); padding: 4px 0; transition: color .12s; letter-spacing: .02em;
}
.dv-back:hover { color: var(--clay); }
.dv-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-top: 16px; padding-bottom: 24px; border-bottom: var(--hair) solid var(--border); }
.dv-date { font-size: 26px; font-weight: 800; letter-spacing: -0.025em; margin: 6px 0 0; white-space: nowrap; }
.dv-net { font-size: 38px; font-weight: 600; letter-spacing: -0.035em; line-height: 1; }
.dv-stats { display: flex; gap: 44px; padding: 24px 0 30px; }
.dv-list { margin-top: 4px; }

/* ---------------- Ledger head + rows (day view) ---------------- */
.ledger-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0 4px 12px; border-bottom: 2px solid var(--ink);
}
.ledger-title { font-size: 16px; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; }
.ledger-sub { font-family: var(--font-mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.ledger { margin-top: 4px; }

/* list view day groups (sticky headers) */
.lgroup { margin-top: 0; }
.lgroup-head {
  position: sticky; top: 85px; z-index: 12;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 14px 12px 4px; margin-top: 8px;
  background: var(--bg); border-bottom: var(--hair) solid var(--border);
}
.lgroup-left { display: flex; align-items: baseline; gap: 11px; }
.lgroup-day {
  font-size: 14px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink);
  white-space: nowrap; position: relative; padding-left: 13px;
}
.lgroup-day::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 5px; height: 5px; border-radius: 1.5px; background: var(--clay); rotate: 45deg;
}
.lgroup-date { font-size: 11.5px; color: var(--muted); white-space: nowrap; letter-spacing: .02em; }
.lgroup-right { display: flex; align-items: baseline; gap: 18px; white-space: nowrap; }
.lgroup-rec { font-size: 11.5px; color: var(--muted); }
.lgroup-rec b { font-weight: 600; }
.lgroup-net { font-size: 14px; font-weight: 600; }

/* header actions + view toggle */
.phead-actions { display: flex; align-items: center; gap: 12px; }
.seg-toggle { display: flex; background: var(--inset); border: var(--hair) solid var(--border); border-radius: var(--radius); padding: 3px; gap: 2px; }
.seg-toggle button {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px; border: 0; background: none;
  border-radius: 3px; color: var(--muted); cursor: pointer; font-family: var(--font-sans);
  font-size: 12.5px; font-weight: 600; transition: all .14s;
}
.seg-toggle button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.seg-toggle button:not(.on):hover { color: var(--ink); }

.lrow {
  display: grid; grid-template-columns: 58px 76px 1fr auto; align-items: center; gap: 18px;
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  padding: 14px 14px 14px 4px; border-bottom: var(--hair) solid var(--border-2);
  border-radius: 6px; transition: background .12s; position: relative;
}
.lrow:hover { background: var(--inset); }
.lrow.below::before {
  content: ""; position: absolute; left: -4px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 2px; background: var(--warn); opacity: .9;
}
.lr-time { font-size: 12.5px; color: var(--muted); }
.lr-inst { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.lr-dir { font-size: 9px; line-height: 1; }
.lr-conf { display: flex; align-items: baseline; gap: 12px; min-width: 0; overflow: hidden; }
.lr-confnames {
  font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-2); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.lr-more { font-family: var(--font-mono); font-size: 12px; color: var(--faint); white-space: nowrap; }
.lr-none { font-size: 12.5px; color: var(--faint); font-style: italic; }
.lr-below { font-family: var(--font-mono); font-size: 10px; letter-spacing: .04em; color: var(--warn); white-space: nowrap; flex-shrink: 0; }
.lr-pnl { font-size: 15px; font-weight: 600; text-align: right; min-width: 92px; }

/* empty */
.empty { text-align: center; padding: 90px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); font-size: 17px; margin: 0 0 6px; font-weight: 700; }

.section-gap { height: 22px; }

/* language toggle (EN / NL) */
.lang-toggle { display: inline-flex; background: var(--inset); border: var(--hair) solid var(--border); border-radius: 99px; padding: 3px; gap: 2px; }
.lang-toggle button { padding: 5px 11px; border: 0; background: none; border-radius: 99px; color: var(--muted); cursor: pointer; font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: .04em; transition: all .14s; }
.lang-toggle button.on { background: var(--panel-2); color: var(--ink); box-shadow: var(--shadow); }
.lang-toggle button:not(.on):hover { color: var(--ink); }

/* small inline flag (trade detail) */
.t-flag { font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; padding: 2px 6px; border-radius: 3px; }
.t-flag.below { color: var(--warn); background: var(--warn-soft); }
