/* Tandem POC styles: "Calm Bento" design, light and dark themes. Colors only come from the tokens below. */
:root {
  color-scheme: light;
  --bg: #F6F7FB; --surface: #FFFFFF; --surface-2: #F3F5FA; --line: #E4E8F0; --ink: #151B2B; --muted: #5B6478;
  --accent: #3D6BE0; --btn: #3D6BE0; --btn-hover: #2F5BCB; --on-btn: #FFFFFF; --accent-text: #2B55C4; --accent-soft: #EAF0FD;
  --melon: #FF9E7A; --melon-soft: #FFEDE5; --melon-text: #A8431C; --melon-bar: #C4562D;
  --ok: #1F7A50; --ok-soft: #E3F4EC; --warn: #8A5300; --warn-soft: #FFF2DC; --warn-line: #F0C98A; --bad: #B83A34; --bad-soft: #FCE8E7; --bad-line: #F1C7C4;
  --col: #EEF1F7; --grid: #E9EDF4; --chip-on: #151B2B; --on-chip: #FFFFFF; --tip-bg: #151B2B; --tip-text: #FFFFFF;
  --scrim: rgba(21, 27, 43, .45); --topbar: rgba(246, 247, 251, .9);
  --shadow: 0 1px 2px rgba(21, 27, 43, .04), 0 6px 20px rgba(21, 27, 43, .06);
  --shadow-pop: 0 18px 50px rgba(21, 27, 43, .18);
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --radius: 20px; --radius-sm: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0B0F19; --surface: #121826; --surface-2: #182033; --line: #232C3F; --ink: #E8ECF4; --muted: #9AA4B8;
    --accent: #5B8CFF; --btn: #3D6BE0; --btn-hover: #4D7AEB; --on-btn: #FFFFFF; --accent-text: #8FB0FF; --accent-soft: #1A2747;
    --melon: #FF9E7A; --melon-soft: #3A2620; --melon-text: #FFB59A; --melon-bar: #FF9E7A;
    --ok: #5BD69A; --ok-soft: #0F2A1E; --warn: #F2B35B; --warn-soft: #2E2310; --warn-line: #5C4520; --bad: #FF8A84; --bad-soft: #3A1B1B; --bad-line: #5E2B2B;
    --col: #0F1522; --grid: #1E2638; --chip-on: #E8ECF4; --on-chip: #0B0F19; --tip-bg: #E8ECF4; --tip-text: #0B0F19;
    --scrim: rgba(0, 0, 0, .6); --topbar: rgba(11, 15, 25, .88);
    --shadow: none; --shadow-pop: 0 18px 50px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0F19; --surface: #121826; --surface-2: #182033; --line: #232C3F; --ink: #E8ECF4; --muted: #9AA4B8;
  --accent: #5B8CFF; --btn: #3D6BE0; --btn-hover: #4D7AEB; --on-btn: #FFFFFF; --accent-text: #8FB0FF; --accent-soft: #1A2747;
  --melon: #FF9E7A; --melon-soft: #3A2620; --melon-text: #FFB59A; --melon-bar: #FF9E7A;
  --ok: #5BD69A; --ok-soft: #0F2A1E; --warn: #F2B35B; --warn-soft: #2E2310; --warn-line: #5C4520; --bad: #FF8A84; --bad-soft: #3A1B1B; --bad-line: #5E2B2B;
  --col: #0F1522; --grid: #1E2638; --chip-on: #E8ECF4; --on-chip: #0B0F19; --tip-bg: #E8ECF4; --tip-text: #0B0F19;
  --scrim: rgba(0, 0, 0, .6); --topbar: rgba(11, 15, 25, .88);
  --shadow: none; --shadow-pop: 0 18px 50px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 'Plus Jakarta Sans', system-ui, sans-serif; font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; overflow: hidden; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 17px; }
p { margin: 0 0 6px; }
code { font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 6px; }
kbd { font: 600 11px/1 'Plus Jakarta Sans', system-ui, sans-serif; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.block { display: block; }

/* Shell: 72px icon rail + 64px top bar, only the content area scrolls */
.app { display: grid; grid-template-columns: 72px minmax(0, 1fr); height: 100vh; }
.rail { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 14px 0; position: relative; z-index: 25; }
.rail-logo { width: 42px; height: 42px; border-radius: 13px; background: var(--btn); color: #fff; display: grid; place-items: center; margin-bottom: 6px; }
.rail-logo:hover { text-decoration: none; background: var(--btn-hover); }
.rail-nav, .rail-foot { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.rail-foot { margin-top: auto; }
.rail-item { position: relative; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: var(--muted); border: 0; background: transparent; cursor: pointer; }
.rail-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.rail-item.on { background: var(--accent-soft); color: var(--accent-text); }
.rail-item .dot { position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--melon); box-shadow: 0 0 0 2px var(--surface); }
.rail [data-tip]:hover::after, .rail [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: var(--tip-bg); color: var(--tip-text); padding: 5px 9px; border-radius: 8px; font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none; z-index: 40;
}
.scrim { display: none; }
.main-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { height: 64px; flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 0 28px; background: var(--topbar); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); position: relative; z-index: 20; }
.topbar .menu-btn { display: none; }
.crumbs { min-width: 0; flex: 0 1 auto; margin-right: auto; }
.crumbs ol { list-style: none; display: flex; align-items: center; gap: 8px; margin: 0; padding: 0; font-size: 13.5px; white-space: nowrap; }
.crumbs li { overflow: hidden; text-overflow: ellipsis; }
.crumbs li + li::before { content: '/'; color: var(--muted); margin-right: 8px; }
.crumbs a { color: var(--muted); font-weight: 600; }
.crumbs [aria-current] { color: var(--ink); font-weight: 700; }
.palette-btn { display: flex; align-items: center; gap: 8px; height: 38px; width: min(340px, 30vw); padding: 0 8px 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); cursor: pointer; text-align: left; }
.palette-btn:hover { border-color: var(--accent); }
.palette-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.range select { height: 38px; padding: 0 30px 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer; }
.pop-wrap { position: relative; }
.bell .dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--melon); box-shadow: 0 0 0 2px var(--surface); }
.popover { position: absolute; right: 0; top: calc(100% + 8px); width: 360px; max-height: 70vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-pop); z-index: 50; padding: 6px; }
.pop-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 8px; }
.pop-list { list-style: none; margin: 0; padding: 0; }
.pop-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; color: var(--ink); }
.pop-item:hover { background: var(--surface-2); text-decoration: none; }
.pop-text { padding: 0 12px 10px; margin: 0; }
.dot-sm { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: transparent; }
.dot-sm.on { background: var(--melon); }
main { flex: 1; min-height: 0; overflow: auto; padding: 26px 28px 48px; outline: none; }

/* Page */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sub { margin: 4px 0 0; color: var(--muted); }
.sub b { color: var(--ink); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btns.end { justify-content: flex-end; margin-top: 16px; }
.narrow { max-width: 860px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer; white-space: nowrap; transition: background-color .15s, border-color .15s; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--btn); border-color: var(--btn); color: var(--on-btn); }
.btn.primary:hover { background: var(--btn-hover); }
.btn.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.btn.ok:hover { filter: brightness(.97); }
.btn.danger { color: var(--bad); border-color: var(--bad-line); background: var(--surface); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 9px; }
.icon-btn { position: relative; width: 38px; height: 38px; border: 0; background: transparent; border-radius: 10px; color: var(--muted); cursor: pointer; display: inline-grid; place-items: center; flex-shrink: 0; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 8px; }
.linklike { border: 0; padding: 0; background: none; color: var(--accent-text); font-weight: 600; cursor: pointer; text-align: left; }
.linklike:hover { text-decoration: underline; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 7px; background: var(--surface-2); color: var(--ink); font-size: 12px; font-weight: 600; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.seg button { height: 30px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); outline: 1px solid var(--line); }

/* Tiles and bento grid */
.bento { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; margin-bottom: 20px; }
.tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.tile-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); min-width: 0; }
.tile-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.tile-value { font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.tile-note { color: var(--muted); font-size: 12.5px; }
.meter { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter.ok span { background: var(--ok); }
.meter.melon span { background: var(--melon-bar); }
.dash-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(340px, 1fr); gap: 20px; align-items: start; margin-top: 20px; }
.dash-row.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.forecast header { align-items: flex-start; }
.hero { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: -2px 0 6px; }
.hero-num { font-family: var(--display); font-size: 40px; font-weight: 700; line-height: 1.1; }
.delta { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.delta.up { background: var(--ok-soft); color: var(--ok); }
.delta.down { background: var(--bad-soft); color: var(--bad); }
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .area { fill: var(--accent); opacity: .1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.dashed { stroke-dasharray: 5 5; }
.chart .pt { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .pt.cur { fill: var(--accent); }
.chart .xlab { fill: var(--muted); font-size: 11.5px; font-weight: 600; }
.chart .xlab.cur { fill: var(--ink); font-weight: 800; }
.chart .xhair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .hit { fill: transparent; cursor: crosshair; outline: none; }
.chart .hit:focus-visible { fill: var(--accent-soft); opacity: .5; }
.tip { position: absolute; pointer-events: none; background: var(--tip-bg); color: var(--tip-text); border-radius: 10px; padding: 6px 10px; font-size: 12px; white-space: nowrap; z-index: 5; }
.tip strong { display: block; font-size: 14px; }
.chart-key { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 8px 0 0; }
.key { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--accent); margin-left: 6px; }
.key:first-child { margin-left: 0; }
.key.dashed { border-top-style: dashed; }
.table tr.cur td { background: var(--accent-soft); }

/* Panels and grids */
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.grid-half { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); min-width: 0; }
.panel.flush { padding: 6px 12px; }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.panel > header a { font-size: 13px; font-weight: 600; }
.panel.warn { border-color: var(--warn-line); background: var(--warn-soft); }
.empty { color: var(--muted); margin: 2px 0 8px; font-size: 13.5px; }
.empty.pad { padding: 14px; margin: 0; }
.prose { white-space: pre-wrap; margin: 0; }
.notes { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.grow { flex: 1; min-width: 0; }
.num { text-align: right; }
.bad { color: var(--bad); }
.between { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Lists */
.rows { list-style: none; margin: 0; padding: 0; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.row-item:first-child { border-top: 0; padding-top: 2px; }
.row-item .right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.nba-kind { flex-shrink: 0; width: 86px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-text); }
.nba-kind.bad { color: var(--bad); }
.nba-item b { font-weight: 600; }
.checklist input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--btn); flex-shrink: 0; cursor: pointer; }
.checklist label { cursor: pointer; }

.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font: 700 12px/1 'Plus Jakarta Sans', system-ui, sans-serif; letter-spacing: 0; background: var(--surface-2); color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.pill.st-active, .pill.of-accepted, .pill.ct-client, .pill.op-won { background: var(--ok-soft); color: var(--ok); }
.pill.st-idea, .pill.of-sent, .pill.ct-lead, .pill.op-qualified, .pill.op-proposal, .pill.op-negotiation { background: var(--accent-soft); color: var(--accent-text); }
.pill.st-onhold { background: var(--warn-soft); color: var(--warn); }
.pill.of-rejected, .pill.op-lost { background: var(--bad-soft); color: var(--bad); }
.pill.ct-partner { background: var(--melon-soft); color: var(--melon-text); }

/* Filters */
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 32px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; }
.chip:hover { color: var(--ink); }
.chip.on { background: var(--chip-on); border-color: var(--chip-on); color: var(--on-chip); }
.input { height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-input { width: 280px; max-width: 100%; }
.search-input.wide { width: 560px; }

/* Cards and boards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-width: 0; transition: border-color .15s, box-shadow .15s; }
.card:hover { border-color: var(--accent); }
.card .title { font-weight: 700; font-size: 14.5px; color: var(--ink); min-width: 0; overflow-wrap: break-word; }
.meta-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 8px; }
.meta-row span { white-space: nowrap; }
a.card .title:hover, .card a.title:hover { color: var(--accent-text); }
.clamp { margin: 4px 0; color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.board { display: grid; gap: 12px; align-items: start; }
.board.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.board.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.board.mini { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.col { background: var(--col); border-radius: 16px; padding: 10px; display: flex; flex-direction: column; min-width: 0; }
.col > header { display: flex; flex-direction: column; gap: 1px; padding: 4px 6px 10px; }
.col > header span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.col-body { display: flex; flex-direction: column; gap: 8px; min-height: 120px; max-height: calc(100vh - 360px); overflow-y: auto; border-radius: 12px; transition: background-color .15s; padding: 1px; }
.board.mini .col-body { max-height: 320px; min-height: 90px; }
.col-body.drop-hover, .lost-bar.drop-hover { background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: 2px; }
.col-empty { margin: 0; padding: 26px 0; text-align: center; color: var(--muted); font-size: 12.5px; }
.card.opp, .card.contact { cursor: grab; padding: 12px; border-radius: 14px; }
.card.compact { gap: 3px; padding: 10px 10px 10px 12px; }
.card.compact .title { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card:active { cursor: grabbing; }
.card.dragging { opacity: .45; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.card-actions:empty { display: none; }
.lost-reason { color: var(--bad); }
.lost-bar { margin-top: 12px; display: flex; align-items: center; justify-content: center; gap: 8px; height: 46px; border: 1.5px dashed var(--bad-line); border-radius: 14px; color: var(--bad); font-weight: 600; font-size: 13px; background: var(--bad-soft); }
.lost-bar .muted { font-weight: 500; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.table tfoot td { border-bottom: 0; padding: 6px 10px; }
.table tfoot tr:first-child td { border-top: 1px solid var(--line); padding-top: 12px; }
.table tfoot tr.total td { font-weight: 700; font-size: 15px; }
.table tfoot tr.total td:last-child { border-top: 2px solid var(--ink); }

.dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.timeline li:first-child { border-top: 0; padding-top: 0; }
.timeline p { margin: 2px 0 0; white-space: pre-wrap; }
.tl-type { flex-shrink: 0; width: 68px; padding-top: 2px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-text); }
.tl-meta { font-size: 12.5px; color: var(--muted); }
.doc-ico { width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; font-size: 10.5px; font-weight: 800; text-transform: uppercase; }

.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.bars li { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; align-items: center; gap: 12px; font-size: 13.5px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar-val { text-align: right; font-weight: 600; white-space: nowrap; }
.bar-val small { color: var(--muted); font-weight: 500; }

/* Menus (Move to…) */
.menu { position: fixed; z-index: 60; min-width: 190px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-pop); display: flex; flex-direction: column; }
.menu-title { padding: 6px 10px 4px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.menu button { text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--ink); }
.menu button:hover:not([disabled]), .menu button:focus-visible { background: var(--accent-soft); color: var(--accent-text); outline: none; }
.menu button[disabled] { color: var(--muted); cursor: default; }

/* Dialogs and forms */
dialog { color: var(--ink); background: var(--surface); }
dialog#dlg { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); border: 1px solid var(--line); border-radius: 22px; padding: 0; box-shadow: var(--shadow-pop); }
dialog::backdrop { background: var(--scrim); }
.dlg-form { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px 8px; }
.dlg-form .form-grid { padding: 10px 22px 6px; overflow-y: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field > span, .field > legend { font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 0; }
.field i { color: var(--bad); font-style: normal; }
.field.wide { grid-column: 1 / -1; }
.field input:not([type=checkbox]), .field select, .field textarea, .item-row input { width: 100%; min-width: 0; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); color: var(--ink); }
.field textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.field input[type=file] { height: auto; padding: 8px; }
.field input:focus, .field select:focus, .field textarea:focus, .item-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.checks legend { margin-bottom: 6px; }
.check-list { display: flex; flex-wrap: wrap; gap: 8px 18px; max-height: 160px; overflow-y: auto; padding: 2px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13.5px; cursor: pointer; }
.check input { accent-color: var(--btn); }
.hint { margin: 0; padding: 10px 12px; background: var(--surface-2); border-radius: 11px; font-size: 13px; color: var(--muted); }
.hint b { color: var(--ink); }
.item-row { display: grid; grid-template-columns: minmax(0, 1fr) 80px 120px 32px; gap: 8px; align-items: center; }
.items { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.form-error { margin: 0; padding: 4px 22px 0; color: var(--bad); font-weight: 600; }
.form-error:empty { display: none; }
.dlg-foot { display: flex; align-items: center; gap: 8px; padding: 14px 22px 18px; border-top: 1px solid var(--line); margin-top: 10px; }
.chooser { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 10px 22px 22px; }
.chooser button { height: 96px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-weight: 700; cursor: pointer; color: var(--ink); }
.chooser button svg { color: var(--accent); }
.chooser button:hover { border-color: var(--accent); background: var(--accent-soft); }

/* Command palette */
dialog.palette { width: min(640px, calc(100vw - 32px)); margin-top: 12vh; padding: 0; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-pop); overflow: hidden; }
.pal-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.pal-input input { flex: 1; height: 56px; border: 0; outline: 0; background: transparent; font-size: 15.5px; color: var(--ink); }
.pal-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.pal-group { padding: 10px 12px 4px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.pal-item { display: flex; align-items: baseline; gap: 10px; padding: 9px 12px; border-radius: 10px; cursor: pointer; }
.pal-item b { font-weight: 600; }
.pal-item:hover { background: var(--surface-2); }
.pal-item.on { background: var(--accent-soft); color: var(--accent-text); }
.pal-item.on .muted { color: var(--accent-text); }
.pal-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--line); }

#toast { position: fixed; left: 50%; bottom: 24px; z-index: 70; max-width: calc(100vw - 32px); transform: translate(-50%, 16px); padding: 10px 16px; border-radius: 12px; background: var(--tip-bg); color: var(--tip-text); font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Offer document (PDF): always printed on white */
.paper-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; max-width: 820px; margin: 0 auto 16px; }
.paper { --ink: #151B2B; --muted: #5B6478; --line: #E4E8F0; --accent-text: #2B55C4; color: #151B2B; max-width: 820px; margin: 0 auto; padding: 56px 60px; background: #FFFFFF; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); font-size: 13.5px; }
.paper-head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 22px; border-bottom: 2px solid var(--ink); }
.paper-brand { font-family: var(--display); font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.paper-title { text-align: right; }
.paper-title h1 { font-size: 30px; color: #3D6BE0; }
.paper-title dl { display: grid; grid-template-columns: auto auto; gap: 2px 12px; margin: 8px 0 0; justify-content: end; }
.paper-title dt { color: var(--muted); }
.paper-title dd { margin: 0; font-weight: 600; }
.paper-to { margin: 24px 0 28px; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.paper h2 { font-size: 19px; margin-bottom: 12px; }
.paper .table th { color: var(--ink); border-bottom: 1.5px solid var(--ink); }
.paper .muted { color: var(--muted); }
.paper-notes { margin-top: 24px; }
.paper-terms { margin-top: 20px; font-size: 12.5px; color: var(--muted); }
.paper-foot { margin-top: 40px; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; font-size: 12.5px; }
.sign { margin-top: 48px; padding-top: 6px; border-top: 1px solid var(--ink); color: var(--muted); }
body.print-mode .app { grid-template-columns: minmax(0, 1fr); }
body.print-mode .rail, body.print-mode .topbar { display: none; }

@media print {
  @page { size: A4; margin: 14mm; }
  html, body { height: auto; overflow: visible; background: #fff; }
  .app { display: block; height: auto; }
  .rail, .topbar, .paper-actions, #toast { display: none !important; }
  main { overflow: visible; padding: 0; }
  .paper { max-width: none; padding: 0; border: 0; box-shadow: none; }
  .paper .table tr { break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Smaller windows: designed for 1280px+, stays usable below */
@media (max-width: 1180px) {
  .bento { grid-template-columns: minmax(0, 1fr); }
  .board.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .tile-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .dash-row, .dash-row.even { grid-template-columns: minmax(0, 1fr); }
  .palette-text { display: none; }
  .palette-btn { width: auto; }
  .board.mini { grid-template-columns: repeat(5, minmax(150px, 1fr)); overflow-x: auto; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; left: 0; top: 0; bottom: 0; width: 72px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-pop); z-index: 40; }
  body.nav-open .rail { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: var(--scrim); }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding: 0 12px; gap: 6px; }
  .crumbs { display: none; }
  .palette-btn { margin-right: auto; }
  .palette-btn kbd { display: none; }
  main { padding: 18px 16px 40px; }
  h1 { font-size: 23px; }
  .grid-half, .tile-grid, .board.four, .board.six { grid-template-columns: minmax(0, 1fr); }
  .tile-row { gap: 10px; }
  .tile { padding: 12px 14px; }
  .tile-value { font-size: 22px; }
  .hero-num { font-size: 30px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .item-row { grid-template-columns: minmax(0, 1fr) 56px 84px 32px; gap: 6px; }
  .search-input, .search-input.wide { width: 100%; }
  .row-item { flex-wrap: wrap; }
  .row-item .right { align-items: flex-start; text-align: left; width: 100%; }
  .bars li { grid-template-columns: 84px minmax(0, 1fr) auto; gap: 8px; }
  .chooser { grid-template-columns: repeat(2, 1fr); }
  .popover { position: fixed; left: 12px; right: 12px; top: 70px; width: auto; }
  .col-body { max-height: none; }
  .paper { padding: 24px 18px; }
  .paper-head { flex-direction: column; }
  .paper-title { text-align: left; }
  .paper-title dl { justify-content: start; }
  .paper-foot { grid-template-columns: 1fr; }
}
