/* Studio Ledger — deep theatrical plum + stage brass on warm playbill paper.
   Signature: the "barre meter". Profit = viridian, loss = rust. */

:root {
  --ink:      #2A2230;
  --ink-soft: #6A5E6E;
  --mute:     #8A7E86;
  --plum:     #5B2A4E;
  --plum-soft:#7A3D68;
  --brass:    #B98729;
  --brass-lt: #E4B85A;
  --paper:    #F3EEE7;
  --paper-2:  #ECE4D8;
  --card:     #FFFFFF;
  --line:     #E4DACb;
  --line-2:   #EFE7DB;
  --profit:   #2E7D5B;
  --profit-lt:#E4F0EA;
  --loss:     #B4432A;
  --loss-lt:  #F6E6E1;
  --warn:     #B9812B;
  --radius:   14px;
  --radius-sm: 9px;
  --shadow:   0 1px 2px rgba(42,34,48,.05), 0 8px 24px -14px rgba(42,34,48,.28);
  --font-disp: "Fraunces", Georgia, "Times New Roman", serif;
  --font-ui:   "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 82% -10%, rgba(185,135,41,.10), transparent 60%),
    radial-gradient(900px 500px at 5% 0%, rgba(91,42,78,.08), transparent 55%),
    var(--paper);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}
.figure, .num, .hero__net, .pnl__row span:last-child, .fact__v, .ministat__v {
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--plum); outline-offset: 2px; border-radius: 4px; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex; flex-wrap: wrap; gap: 16px 24px;
  align-items: center; justify-content: space-between;
  padding: 16px clamp(16px, 4vw, 40px);
  background: linear-gradient(180deg, rgba(255,255,255,.75), rgba(255,255,255,.35));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 30;
}
.topbar__brand { display: flex; align-items: center; gap: 14px; }
.brand__mark {
  font-size: 30px; line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(91,42,78,.35));
}
.brand__name {
  font-family: var(--font-disp); font-weight: 600; font-size: 25px;
  letter-spacing: -.01em; margin: 0; color: var(--plum);
}
.brand__sub { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-soft); letter-spacing: .01em; }

.topbar__scenario { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.scenariopick { display: flex; flex-direction: column; gap: 3px; }
.scenario-select {
  font-family: var(--font-disp); font-size: 16px; font-weight: 500; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 34px 8px 12px; max-width: 260px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%235B2A4E' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.scenario-meta { font-size: 11px; color: var(--mute); padding-left: 2px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.toolbar__sep { width: 1px; height: 20px; background: var(--line); margin: 0 3px; }
.tbtn {
  font-size: 12.5px; font-weight: 500; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 11px; transition: .14s;
}
.tbtn:hover { border-color: var(--plum); color: var(--plum); background: #fff; }
.tbtn--danger:hover { border-color: var(--loss); color: var(--loss); }
.savestate { font-size: 11.5px; color: var(--mute); min-width: 96px; text-align: right; }
.savestate.is-dirty { color: var(--brass); }

/* ------------------------------------------------------------------ layout */
.layout { max-width: 1320px; margin: 0 auto; padding: clamp(18px, 3vw, 34px) clamp(14px, 4vw, 40px) 60px; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 22px; margin-top: 22px; }
@media (min-width: 1024px) { .grid2 { grid-template-columns: minmax(0, 1.55fr) minmax(320px, .95fr); align-items: start; } }
.inputs { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* --------------------------------------------------------------------- hero */
.hero {
  display: grid; gap: 20px 30px; align-items: center;
  grid-template-columns: 1fr; padding: clamp(20px, 3vw, 30px);
  border-radius: var(--radius); box-shadow: var(--shadow);
  background:
    linear-gradient(135deg, #4E2444 0%, #5B2A4E 46%, #3C1C36 100%);
  color: #F7EFE8; position: relative; overflow: hidden;
  border: 1px solid rgba(255,255,255,.06);
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(500px 240px at 88% -30%, rgba(228,184,90,.28), transparent 62%);
  pointer-events: none;
}
@media (min-width: 780px) { .hero { grid-template-columns: 1.1fr .9fr; grid-template-areas: "verdict figure" "barre barre"; } }
.hero__verdict { grid-area: verdict; position: relative; z-index: 1; }
.hero__figure { grid-area: figure; position: relative; z-index: 1; }
.hero__barre { grid-area: barre; position: relative; z-index: 1; }
.hero__eyebrow { font-size: 11.5px; text-transform: uppercase; letter-spacing: .18em; color: var(--brass-lt); font-weight: 600; }
.hero__label { font-family: var(--font-disp); font-weight: 600; font-size: clamp(28px, 5vw, 40px); margin: 8px 0 6px; letter-spacing: -.015em; }
.hero__blurb { margin: 0; color: rgba(247,239,232,.82); font-size: 14.5px; max-width: 46ch; }

.hero__figure { text-align: left; }
@media (min-width: 780px) { .hero__figure { text-align: right; } }
.hero__net { font-family: var(--font-disp); font-weight: 600; font-size: clamp(34px, 6vw, 52px); line-height: 1; display: block; letter-spacing: -.02em; }
.hero__net.pos { color: #7FE3B0; }
.hero__net.neg { color: #F0A48D; }
.hero__caption { display: block; font-size: 12.5px; letter-spacing: .04em; color: rgba(247,239,232,.7); margin-top: 8px; text-transform: uppercase; }
.hero__monthly { display: inline-block; margin-top: 10px; font-size: 13px; font-weight: 500; color: #F7EFE8; background: rgba(255,255,255,.1); padding: 4px 10px; border-radius: 999px; }

/* barre meter */
.barre { margin-top: 4px; }
.barre__track {
  position: relative; height: 16px; border-radius: 999px;
  background: rgba(255,255,255,.14); box-shadow: inset 0 1px 3px rgba(0,0,0,.28);
}
.barre__fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; transition: width .35s cubic-bezier(.4,0,.2,1); }
.barre__fill.ok  { background: linear-gradient(90deg, #2E7D5B, #57C48C); }
.barre__fill.near{ background: linear-gradient(90deg, #B9812B, #E4B85A); }
.barre__fill.low { background: linear-gradient(90deg, #93331F, #C7563A); }
.barre__line {
  position: absolute; top: -7px; bottom: -7px; width: 3px; margin-left: -1.5px;
  background: var(--brass-lt); border-radius: 3px;
  box-shadow: 0 0 0 3px rgba(228,184,90,.22);
}
.barre__handle {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  background: #fff; color: var(--plum); font-size: 11.5px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0,0,0,.3); transition: left .35s cubic-bezier(.4,0,.2,1);
}
.barre__scale { display: flex; justify-content: space-between; font-size: 10.5px; color: rgba(247,239,232,.62); margin-top: 12px; letter-spacing: .04em; }
.barre__scalemid { color: var(--brass-lt); font-weight: 600; }
.barre__caption { margin: 12px 0 0; font-size: 13.5px; color: rgba(247,239,232,.86); }
.barre__caption strong { color: #fff; }

/* --------------------------------------------------------------------- card */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--line-2);
}
.card__title { font-family: var(--font-disp); font-weight: 600; font-size: 17.5px; margin: 0; letter-spacing: -.01em; display: flex; align-items: baseline; gap: 10px; }
.card__num {
  font-family: var(--font-ui); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--brass); background: rgba(185,135,41,.1); border: 1px solid rgba(185,135,41,.25);
  padding: 3px 7px; border-radius: 6px; position: relative; top: -1px;
}
.card__toggle { border: none; background: none; font-size: 20px; line-height: 1; color: var(--mute); width: 28px; height: 28px; border-radius: 6px; }
.card__toggle:hover { background: var(--paper-2); color: var(--plum); }
.card__body { padding: 18px; }
.card.is-collapsed .card__body { display: none; }
.card.is-collapsed .card__toggle { transform: none; }
.card__intro { margin: -2px 0 16px; font-size: 13px; color: var(--ink-soft); max-width: 66ch; }
.card__intro em { color: var(--plum); font-style: normal; font-weight: 600; }

.stackgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 6px; }
.stack--sm { gap: 4px; }
.stack__label { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.stack__hint { font-size: 11.5px; color: var(--mute); }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* -------------------------------------------------------------------- tables */
.table { display: flex; flex-direction: column; }
@media (max-width: 700px) { .table { overflow-x: auto; -webkit-overflow-scrolling: touch; } }
.grid { display: grid; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--line-2); }
@media (max-width: 700px) { .grid { min-width: 620px; } }
.grid--head { border-bottom: 1.5px solid var(--line); padding-top: 2px; padding-bottom: 8px; }
.grid--head span { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--mute); }
.grid--class   { grid-template-columns: minmax(120px,1.5fr) 52px 62px 66px 74px 148px minmax(84px,1fr) 30px; }
.grid--fixed   { grid-template-columns: minmax(150px,1.6fr) 108px 128px minmax(84px,1fr) 30px; }
.grid--startup { grid-template-columns: minmax(150px,1fr) 150px 30px; }
.ta-c { text-align: center; } .ta-r { text-align: right; }
.grid .figure { font-weight: 600; font-size: 14px; color: var(--ink); }

.tablefoot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 4px 2px; }
.foot-tot { font-size: 12.5px; color: var(--ink-soft); }
.foot-tot strong { color: var(--plum); font-size: 14px; }

/* ------------------------------------------------------------------- fields */
.field { display: inline-flex; align-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; height: 36px; min-width: 0; }
.field:focus-within { border-color: var(--plum); background: #fff; box-shadow: 0 0 0 3px rgba(91,42,78,.1); }
.field--xs { width: 100%; } .field--sm { width: 100%; }
.affix { font-size: 12px; color: var(--mute); font-weight: 600; }
.affix--suf { margin-left: 3px; } .field .affix:first-child { margin-right: 2px; }
.num { border: none; background: none; width: 100%; min-width: 0; font: inherit; font-size: 14px; color: var(--ink); text-align: right; padding: 0; }
.num:focus { outline: none; }
.field.is-disabled { opacity: .4; }
.txt {
  width: 100%; min-width: 0; font: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px; height: 36px; padding: 0 10px;
}
.txt:focus { outline: none; border-color: var(--plum); background: #fff; box-shadow: 0 0 0 3px rgba(91,42,78,.1); }
.sel {
  width: 100%; min-width: 0; font: inherit; font-size: 13px; color: var(--ink); height: 36px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 0 8px;
}
.sel:focus { outline: none; border-color: var(--plum); }
/* hide number spinners for a cleaner ledger look */
.num::-webkit-outer-spin-button, .num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num[type=number] { -moz-appearance: textfield; }

.pairwrap { display: flex; align-items: center; gap: 6px; min-width: 0; }
.muted-rate { color: var(--mute); font-size: 14px; }
.chip { font-size: 11px; font-weight: 700; letter-spacing: .02em; border: 1px solid var(--line); background: var(--paper); color: var(--ink-soft); border-radius: 999px; padding: 6px 9px; white-space: nowrap; }
.chip--on { background: rgba(91,42,78,.1); border-color: var(--plum); color: var(--plum); }

.iconbtn { border: none; background: none; color: var(--mute); font-size: 18px; line-height: 1; width: 28px; height: 28px; border-radius: 6px; }
.iconbtn:hover { background: var(--loss-lt); color: var(--loss); }
.ghostbtn { font-size: 13px; font-weight: 600; color: var(--plum); background: none; border: 1px dashed var(--plum-soft); border-radius: 8px; padding: 8px 14px; }
.ghostbtn:hover { background: rgba(91,42,78,.06); }

/* ------------------------------------------------------------------ finance */
.finance { margin-top: 16px; }
.toggle { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; color: var(--ink-soft); background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px 7px 8px; }
.toggle__dot { width: 30px; height: 18px; border-radius: 999px; background: var(--line); position: relative; transition: .18s; }
.toggle__dot::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: .18s; }
.toggle--on { color: var(--plum); border-color: var(--plum); }
.toggle--on .toggle__dot { background: var(--plum); }
.toggle--on .toggle__dot::after { left: 14px; }
.finrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px; margin-top: 14px; }

.ministats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 18px; }
.ministat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 14px; }
.ministat__k { display: block; font-size: 11.5px; color: var(--ink-soft); font-weight: 600; }
.ministat__v { display: block; font-family: var(--font-disp); font-size: 22px; font-weight: 600; color: var(--plum); margin: 3px 0 2px; letter-spacing: -.01em; }
.ministat__h { display: block; font-size: 11px; color: var(--mute); }

/* ------------------------------------------------------------------ summary */
.summary { min-width: 0; }
@media (min-width: 1024px) { .summary__inner { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 18px; } }
.summary__inner { display: flex; flex-direction: column; gap: 18px; }
.card--summary .card__head { background: linear-gradient(180deg, rgba(91,42,78,.05), transparent); }

.pnl { display: flex; flex-direction: column; }
.pnl__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.pnl__row span:first-child { color: var(--ink-soft); }
.pnl__row .figure { font-weight: 600; }
.pnl__row .figure.pos { color: var(--profit); }
.pnl__row .figure.cost { color: var(--ink); }
.pnl__row--net { border-top: 2px solid var(--line); border-bottom: none; margin-top: 4px; padding-top: 13px; font-family: var(--font-disp); font-size: 17px; font-weight: 600; }
.pnl__row--net span:first-child { color: var(--ink); }
.pnl__row--net .figure.pos { color: var(--profit); }
.pnl__row--net .figure.neg { color: var(--loss); }

.chartwrap { width: 100%; }
#chart { width: 100%; height: 240px; display: block; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.fact { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.fact__k { display: block; font-size: 11px; color: var(--ink-soft); font-weight: 600; }
.fact__v { display: block; font-weight: 700; font-size: 14.5px; color: var(--plum); margin-top: 3px; }

/* tone accents on hero by verdict */
.hero.tone-loss    { background: linear-gradient(135deg, #6A2A22 0%, #5B2A4E 60%, #3C1C36 100%); }
.hero.tone-warn    { background: linear-gradient(135deg, #6A4A22 0%, #5B2A4E 62%, #3C1C36 100%); }
.hero.tone-profit  { background: linear-gradient(135deg, #24513E 0%, #4E2444 55%, #3C1C36 100%); }

/* -------------------------------------------------------------------- footer */
.pagefoot { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 12px; color: var(--mute); max-width: 90ch; }
.pagefoot p { margin: 0 0 8px; }
.pagefoot__save strong { color: var(--plum); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
