:root {
  --bg: #ebe4d8;
  --paper: #fbf8f2;
  --ink: #1c2430;
  --muted: #5e6a78;
  --line: #d5cbbd;
  --nav: #1b2a26;
  --navink: #e7f3ee;
  --gold: #8d6232;
  --teal: #1f6f62;
  --danger: #9a3b34;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--teal); }
button, select, input, textarea { font: inherit; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
button { background: var(--teal); color: white; border: 0; font-weight: 650; cursor: pointer; }
button.ghost { background: white; color: var(--ink); border: 1px solid var(--line); }
.hidden { display: none !important; }
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: #1b2a26; }
.gate form, .sheet { width: min(440px, 100%); background: var(--paper); color: var(--ink); border-radius: 12px; padding: 22px; }
.brand { margin: 0 0 8px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); font-size: 12px; }
.gate .brand { color: var(--gold); }
h1, h2, h3 { margin: 8px 0; }
.note { color: var(--muted); }
.field { display: block; margin: 10px 0; }
.field span, .nav-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.nav-label { margin: 14px 8px 4px; letter-spacing: 0.06em; text-transform: uppercase; color: #c9b48a; }
.field input, .field select, .field textarea, .line input, .line select { width: 100%; }
.warn { min-height: 1.2em; color: var(--danger); }
#app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
aside { padding: 14px 10px 28px; background: var(--nav); color: var(--navink); }
aside .brand { padding: 4px 8px; }
aside button { display: block; width: 100%; text-align: left; margin: 2px 0; background: transparent; color: var(--navink); border: 0; border-radius: 6px; }
aside button.active { background: #2f4a43; color: #f3d7a1; }
button.nav-label-btn { width: auto; margin: 14px 8px 4px; padding: 0; background: transparent; color: #c9b48a; border-radius: 0; letter-spacing: 0.06em; text-transform: uppercase; font-size: 12px; }
button.nav-label-btn.active { background: transparent; color: #f3d7a1; box-shadow: inset 0 -2px 0 var(--gold); }
.work { padding: 16px 20px 48px; }
header { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
header a, header button, header select { font-size: 14px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; color: var(--muted); background: white; }
.chip.off { color: var(--gold); border-color: var(--gold); }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: center; }
.toolbar form { display: flex; gap: 8px; align-items: center; margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.co-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.co-tools input { min-width: 200px; flex: 1; }
.co-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
button.co-card { display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-height: 132px; text-align: left; background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 14px; font-weight: 400; }
button.co-card:hover { border-color: var(--teal); }
button.co-card strong { display: block; font-size: 16px; margin: 8px 0 0; }
button.co-card p { margin: 6px 0 0; color: var(--muted); font-size: 13px; font-weight: 400; }
.co-tag { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold); }
#app.picking { grid-template-columns: 1fr; }
#app.picking aside { display: none; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.card span { color: var(--muted); font-size: 13px; }
.card b { display: block; font-size: 20px; margin-top: 4px; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; align-items: start; }
.paper { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin: 12px 0; }
.paper h2 { margin-top: 0; }
.statement { max-width: 760px; }
.statement .row, .total { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.total { font-weight: 700; border-bottom: 3px double var(--ink); margin-top: 6px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; margin: 8px 0 16px; background: white; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 650; background: #f3eee6; }
form.grid, .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin: 12px 0; }
.line { display: grid; grid-template-columns: 1.6fr 0.5fr 0.8fr 1.2fr 1fr; gap: 6px; margin: 6px 0; align-items: center; }
.line.journal { grid-template-columns: 2fr 1fr 1fr; }
.line.head { color: var(--muted); font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr[data-act] { cursor: pointer; }
tr[data-act]:hover td { background: #f6f1e8; }
.co { text-align: center; }
.statement h2, .statement h3 { text-align: center; }
.statement .row span { color: var(--ink); }
.statement .row.section { font-weight: 700; border-bottom: 2px solid var(--ink); margin-top: 10px; }
.statement .row.indent { padding-left: 18px; }
.totals { margin: 8px 0 16px; font-weight: 650; }
.widgets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
.widget { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 14px; min-height: 168px; }
.widget-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.widget h3 { margin: 0; font-size: 14px; }
.period { color: var(--muted); font-size: 12px; }
.stat { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; font-size: 13px; }
.stat b { font-variant-numeric: tabular-nums; }
.stat.late b { color: var(--danger); }
.meter { height: 8px; background: #e7e1d6; border-radius: 99px; margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--danger); }
.donut-row { display: flex; gap: 12px; align-items: center; }
.donut-wrap { position: relative; width: 84px; height: 84px; flex: 0 0 auto; }
.donut { width: 84px; height: 84px; border-radius: 50%; background: #e7e1d6; -webkit-mask: radial-gradient(circle at center, transparent 26px, #000 27px); mask: radial-gradient(circle at center, transparent 26px, #000 27px); }
.donut-mid { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 650; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.trade-row { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sparkline { width: 100%; height: 78px; display: block; }
.spark-labels { display: flex; gap: 2px; }
.spark-labels span { flex: 1; min-width: 0; font-size: 10px; color: var(--muted); text-align: center; }
.legend { font-size: 13px; }
.legend div { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.spark { display: flex; align-items: flex-end; gap: 6px; height: 96px; }
.spark-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.spark-col i { display: block; width: 100%; border-radius: 4px 4px 0 0; background: var(--teal); }
.spark-col i.exp { background: var(--gold); }
.spark-col span { font-size: 10px; color: var(--muted); margin-top: 4px; text-align: center; }
.mini-row { display: flex; justify-content: space-between; gap: 8px; width: 100%; padding: 5px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; text-align: left; font-weight: 400; }
.mini-row b { font-variant-numeric: tabular-nums; }
.bars { display: grid; grid-template-columns: 72px 1fr; gap: 6px; align-items: center; margin: 6px 0; }
.track { display: grid; gap: 3px; }
.track i { display: block; height: 8px; border-radius: 99px; }
.track i.rev { background: var(--teal); }
.track i.exp { background: var(--gold); }
.settings-pop { position: fixed; z-index: 30; width: min(420px, calc(100vw - 24px)); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(28, 36, 48, 0.18); padding: 14px 14px 16px; }
.company-pop { width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 16px); overflow: auto; }
.ledger-pop { width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 16px); overflow: auto; }
.settings-pop h2 { margin: 0 0 8px; font-size: 18px; }
.settings-tab { display: inline-block; margin: 0 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--gold); font-weight: 650; }
button.settings-tab { background: transparent; color: var(--ink); border: 0; border-bottom: 2px solid var(--gold); border-radius: 0; padding: 0 0 6px; }
.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.company-pop .settings-grid { grid-template-columns: repeat(5, 1fr); }
.company-pop button.tile { min-height: 92px; font-size: 12px; padding: 8px 4px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 8px; }
.cal .dow, .cal .pad { min-height: 28px; text-align: center; color: var(--muted); font-size: 12px; }
button.day { min-height: 64px; background: var(--paper); color: var(--ink); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 650; padding: 6px 2px; }
button.day.due { border-color: var(--gold); }
button.day small { font-weight: 400; font-size: 10px; color: var(--muted); }
.row-actions button { margin: 8px 8px 0 0; }
button.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 108px; background: #f6f1e8; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; font-weight: 650; font-size: 13px; text-align: center; padding: 10px; }
button.tile:hover { border-color: var(--teal); }
button.tile svg { width: 28px; height: 28px; stroke: var(--gold); fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet button { margin-right: 8px; }
@media (max-width: 1100px) {
  .widgets { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .widgets, .trade-row, .pair { grid-template-columns: 1fr; }
  .company-pop .settings-grid { grid-template-columns: repeat(3, 1fr); }
  button.nav-label-btn { padding: 8px 10px; }
  #app { display: block; }
  aside { display: flex; gap: 6px; overflow: auto; }
  aside .brand, aside .nav-label { display: none; }
  aside button { width: auto; white-space: nowrap; }
  .line { grid-template-columns: 1fr 1fr; }
}
@media print {
  aside, header, #flash, form, .modal, .settings-pop, .company-pop { display: none !important; }
  #app { display: block; }
  body, .paper { background: white; }
}
