/* =====================================================================
   RPB Engagement Letters: staff app styles
   Matches the RPB Workflow app's "new look" (IBM Plex Sans, white sidebar,
   1px borders and no shadows, 6px buttons, 10px cards, sentence-case pills).

   THEMES
     Light is the default (tokens on :root). <body class="gray"> and
     <body class="dark"> swap the tokens. The sidebar toggle calls
     setTheme('light'|'gray'|'dark') and remembers it in localStorage
     (key "rpb_theme", shared with Workflow on purpose).

   TOKENS (always use these, never raw hex, so all three themes work)
     --bg --surface --surface-2 --border --border-light
     --text --text-muted --primary --primary-dark --accent --accent-text
     --m-ok / --m-ok-bg      green  (executed, signed, success)
     --m-warn / --m-warn-bg  amber  (draft pending, changes requested)
     --m-bad / --m-bad-bg    red    (declined, void, errors)
     --m-info / --m-info-bg  blue   (in review, informational)
     --m-neutral / --m-neutral-bg   gray (draft, inactive)
     --m-purple(-bg) --m-teal(-bg)  extra status colors used by pills
     --m-radius (8px)  --m-focus (focus ring box-shadow)

   COMPONENTS
     Page header   <div class="view-header"><div><h1 class="view-title">Title</h1>
                   <div class="view-subtitle">One line</div></div><div class="btn-row">…</div></div>
                   Breadcrumb above it: <div class="crumb"><a href="#/x">Parent</a></div>
     Buttons       .btn (primary) · .btn.secondary · .btn.danger · .btn.success · add .sm for small.
                   Group with <div class="btn-row">.
     Card          <div class="card"><div class="card-title">Heading <button …></div>…</div>
     Stats         <div class="stats"><a class="stat"><div class="stat-label"/><div class="stat-value"/>
                   <div class="stat-sub"/></a></div>
     Table         <div class="table-wrap"><table>…</table></div>; rows: tr.clickable; numbers: td.num
     Pill          <span class="pill green|blue|yellow|red|gray|purple|teal">Sentence case</span>
     Banner        <div class="banner info|warn|ok|err">…</div>
     Tabs          <div class="tabs"><button class="tab active">…<span class="count">3</span></button></div>
     Segmented     <div class="seg"><button class="on">A</button><button>B</button></div>
     Form field    <div class="field"><label class="field-label">Label</label><input>
                   <div class="field-help">Hint</div></div>; two columns: <div class="field-row">
     Checkbox row  <label class="check"><input type="checkbox"><div><div class="label">…</div>
                   <div class="field-help">…</div></div></label>
     Choice cards  <div class="kind-pick"><label class="kind-card on">…</label></div>  (good for wizard steps)
     Section label <div class="q-group">Group name</div>
     Panel         <div class="panel"><div class="tabs">…</div><div class="panel-body">…</div></div>
     Modal         openModal(html) fills #modal; use .modal-title and .modal-actions.
     Toast         toast('Saved') / toast('Problem', true)
     Helpers       .muted .small .mono .right .mt .hidden .empty .loading

   LETTERS ARE OFF-LIMITS: letters, governance letters and clause previews render in
   iframes (srcdoc) with their own LETTER_CSS, so nothing here reaches them. Keep it
   that way: never inline letter HTML into the app page.
   ===================================================================== */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f3f3f0;
  --border: #e3e3de;
  --border-light: #eeeeea;
  --text: #1c2430;
  --text-muted: #667085;
  --primary: #114678;
  --primary-dark: #0c355c;
  --primary-light: #1b5a94;
  --on-primary: #ffffff;
  --accent: #e9eff6;
  --accent-text: #114678;
  --shadow: rgba(16, 24, 40, 0.04);
  --shadow-strong: rgba(16, 24, 40, 0.14);
  --modal-bg: rgba(16, 24, 40, 0.38);
  --m-ok: #1f7a4d;      --m-ok-bg: #e7f4ec;
  --m-warn: #9a6200;    --m-warn-bg: #fdf3dd;
  --m-bad: #b42318;     --m-bad-bg: #fdecea;
  --m-info: #175c94;    --m-info-bg: #e8f1fa;
  --m-neutral: #475467; --m-neutral-bg: #f0f1f3;
  --m-purple: #6b3fa0;  --m-purple-bg: #f1ebf9;
  --m-teal: #0f6b66;    --m-teal-bg: #e3f4f2;
  --m-radius: 8px;
  --m-focus: 0 0 0 3px rgba(17, 70, 120, 0.18);
  /* legacy names still used by a few inline styles */
  --grey: var(--text-muted);
  --danger: var(--m-bad);
  --warning: var(--m-warn);
  --success: var(--m-ok);
}
body.gray {
  --bg: #cfd4da;
  --surface: #e2e6ea;
  --surface-2: #d7dce1;
  --border: #b9c0c8;
  --border-light: #c9cfd6;
  --text: #1f2731;
  --text-muted: #55606d;
  --accent: #c7d5e3;
  --m-neutral-bg: #d3d8de;
  --m-ok-bg: #d3e6da;
  --m-warn-bg: #ece0bf;
  --m-bad-bg: #ecd3d0;
  --m-info-bg: #d0dfec;
  --m-purple-bg: #ddd3ea;
  --m-teal-bg: #cbe2df;
  --shadow-strong: rgba(16, 24, 40, 0.2);
}
body.dark {
  color-scheme: dark;
  --bg: #12161c;
  --surface: #191e26;
  --surface-2: #151a21;
  --border: #29303a;
  --border-light: #20262f;
  --text: #e3e7ec;
  --text-muted: #8d97a5;
  --primary: #8cc3ec;
  --primary-dark: #6fb0e0;
  --primary-light: #a8d3f3;
  --on-primary: #0d1620;
  --accent: #1d2937;
  --accent-text: #cfe6f8;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-strong: rgba(0, 0, 0, 0.55);
  --modal-bg: rgba(0, 0, 0, 0.6);
  --m-ok: #6fcf97;      --m-ok-bg: #173023;
  --m-warn: #f0c060;    --m-warn-bg: #352c16;
  --m-bad: #f28b82;     --m-bad-bg: #3a1d1b;
  --m-info: #8cc3ec;    --m-info-bg: #1a2a3a;
  --m-neutral: #aab4c0; --m-neutral-bg: #232a33;
  --m-purple: #c9a8f0;  --m-purple-bg: #2a2138;
  --m-teal: #6fd3c9;    --m-teal-bg: #15302e;
  --m-focus: 0 0 0 3px rgba(140, 195, 236, 0.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'IBM Plex Sans', -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  letter-spacing: -0.005em;
  background: var(--bg);
  color: var(--text);
  transition: background .2s, color .2s;
}
button, input, select, textarea { font-family: inherit; letter-spacing: inherit; }
a { color: var(--primary); }
.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 248px; flex-shrink: 0;
  background: var(--surface); color: var(--text);
  border-right: 1px solid var(--border);
  padding: 1.1rem .75rem;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
body.gray .sidebar { background: #d9dee3; }
.brand { display: flex; align-items: center; gap: .6rem; padding: .25rem .5rem; margin-bottom: .15rem; text-decoration: none; }
.brand .mark { width: 50px; height: auto; flex-shrink: 0; }
.brand-name { color: var(--primary); font-weight: 700; font-size: 1.2rem; letter-spacing: .02em; line-height: 1; }
.brand-sub { color: var(--text-muted); font-size: .72rem; margin-top: 3px; }
body.dark .brand .mark { filter: brightness(0) invert(0.92); }
.tagline { font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); padding: 0 .5rem; margin: .35rem 0 .9rem; }
.nav-section { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; color: var(--text-muted); opacity: .85; padding: 1rem .65rem .35rem; }
.nav-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .65rem; margin-bottom: 1px; border-radius: 6px;
  font-size: .88rem; color: var(--text); text-decoration: none;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.nav-item .m-icon { width: 17px; height: 17px; flex-shrink: 0; stroke: currentColor; fill: none; opacity: .8; }
.nav-item.active .m-icon { opacity: 1; }
.nav-item .soon { margin-left: auto; font-size: .62rem; background: var(--m-ok-bg); color: var(--m-ok); padding: 1px 6px; border-radius: 999px; }
.sidebar-footer { margin-top: auto; padding-top: 1rem; }
.user-card { background: var(--surface-2); border: 1px solid var(--border-light); border-radius: var(--m-radius); padding: .65rem .75rem; font-size: .84rem; color: var(--text); }
.user-card:empty { display: none; }
.user-card .label { font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: .2rem; }
.user-card .role { font-size: .74rem; color: var(--text-muted); text-transform: capitalize; margin-top: .1rem; }
.theme-toggle-group { display: flex; gap: 2px; margin-top: .6rem; background: var(--surface-2); border: 1px solid var(--border-light); border-radius: 6px; padding: 2px; }
.theme-toggle-group button { flex: 1; background: transparent; border: none; color: var(--text-muted); padding: .4rem .25rem; border-radius: 4px; cursor: pointer; font-size: .74rem; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: .3rem; }
.theme-toggle-group button svg { width: 13px; height: 13px; stroke: currentColor; fill: none; }
.theme-toggle-group button:hover { color: var(--text); background: var(--surface); }
.theme-toggle-group button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px var(--shadow-strong); }
.mobile-bar, .sidebar-backdrop { display: none; }

/* ---------- Main canvas ---------- */
.main { flex: 1; padding: 2rem 2.25rem 3rem; min-width: 0; }
.loading { color: var(--text-muted); padding: 3rem 0; text-align: center; }
.view-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.view-title { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.02em; margin: 0; color: var(--text); }
.view-subtitle { color: var(--text-muted); font-size: .88rem; margin-top: .25rem; }
.crumb { font-size: .8rem; color: var(--text-muted); margin-bottom: .35rem; }
.crumb a { color: var(--text-muted); text-decoration: none; }
.crumb a:hover { color: var(--text); text-decoration: underline; }

/* ---------- Buttons ---------- */
.btn {
  background: var(--primary); color: var(--on-primary);
  border: 1px solid transparent; border-radius: 6px;
  padding: .5rem .95rem; font-size: .86rem; font-weight: 500; line-height: 1.25;
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--primary-dark); }
.btn:focus-visible { outline: none; box-shadow: var(--m-focus); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.success { background: var(--m-ok); color: #fff; }
.btn.success:hover { filter: brightness(.92); background: var(--m-ok); }
body.dark .btn.success { color: #0d1620; }
.btn.danger { background: var(--surface); color: var(--m-bad); border-color: var(--border); }
.btn.danger:hover { background: var(--m-bad-bg); border-color: var(--m-bad); }
.btn.sm { padding: .32rem .65rem; font-size: .8rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- Cards, stats, tables ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.35rem 1.5rem; margin-bottom: 1rem; }
.card-title { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 .8rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); padding: 1rem 1.15rem; border-radius: 10px; text-decoration: none; color: inherit; display: block; transition: border-color .12s; }
a.stat:hover { border-color: var(--primary); }
.stat-label { font-size: .76rem; font-weight: 500; color: var(--text-muted); letter-spacing: .01em; margin-bottom: .3rem; }
.stat-value { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.stat-sub { font-size: .76rem; color: var(--text-muted); margin-top: .15rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--surface-2); padding: .55rem .85rem; text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: .65rem .85rem; border-bottom: 1px solid var(--border-light); font-size: .87rem; vertical-align: top; }
tr:last-child td { border-bottom: none; }
.card table td:first-child, .card table th:first-child { padding-left: 0; }
.card table td:last-child, .card table th:last-child { padding-right: 0; }
.card .table-wrap table td:first-child, .card .table-wrap table th:first-child { padding-left: .85rem; }
.card .table-wrap table td:last-child, .card .table-wrap table th:last-child { padding-right: .85rem; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
tr.selected td { background: var(--accent); }
td.mono { white-space: nowrap; word-break: normal; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }

/* ---------- Pills: calm, sentence case ---------- */
.pill { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 500; line-height: 1.45; white-space: nowrap; text-transform: none; letter-spacing: 0; background: var(--m-neutral-bg); color: var(--m-neutral); }
.pill.gray { background: var(--m-neutral-bg); color: var(--m-neutral); }
.pill.blue { background: var(--m-info-bg); color: var(--m-info); }
.pill.green { background: var(--m-ok-bg); color: var(--m-ok); }
.pill.yellow { background: var(--m-warn-bg); color: var(--m-warn); }
.pill.red { background: var(--m-bad-bg); color: var(--m-bad); }
.pill.purple { background: var(--m-purple-bg); color: var(--m-purple); }
.pill.teal { background: var(--m-teal-bg); color: var(--m-teal); }

/* ---------- Filters / tabs ---------- */
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input, .toolbar select { width: auto; }
.tabs { display: flex; gap: .15rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; scrollbar-width: none; }
.tab { padding: .55rem .8rem; cursor: pointer; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--text-muted); font-size: .86rem; font-weight: 500; white-space: nowrap; background: none; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-text); border-bottom-color: var(--primary); font-weight: 600; }
body.dark .tab.active { color: var(--text); }
.tab .count { font-size: .7rem; background: var(--surface-2); border: 1px solid var(--border-light); border-radius: 999px; padding: 0 6px; margin-left: 4px; }

/* ---------- Forms ---------- */
.field { margin-bottom: .9rem; }
.field-label { display: block; font-size: .82rem; font-weight: 500; margin-bottom: .3rem; color: var(--text-muted); }
.field-help { font-size: .77rem; color: var(--text-muted); margin-top: .3rem; line-height: 1.45; }
input, select, textarea { width: 100%; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: 6px; font-size: .88rem; background: var(--surface); color: var(--text); }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: .75; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--text-muted); }
textarea { resize: vertical; min-height: 70px; line-height: 1.45; }
textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; min-height: 260px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--m-focus); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--primary); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--m-radius); margin-bottom: .45rem; cursor: pointer; background: var(--surface); transition: border-color .12s; }
.check:hover { border-color: var(--primary); }
.check:has(input:checked) { background: var(--accent); border-color: var(--primary); }
.check input { margin-top: 3px; }
.check .label { font-weight: 500; }
.q-group { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; margin: 1.2rem 0 .5rem; }
.q-group:first-child { margin-top: 0; }

/* ---------- Letter workspace ---------- */
.workspace { display: grid; grid-template-columns: minmax(340px, 440px) 1fr; gap: 1rem; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.panel-body { padding: 1.1rem 1.2rem; }
.panel .tabs { padding: 0 .7rem; margin-bottom: 0; }
.preview-wrap { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; position: sticky; top: 1rem; }
.preview-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; gap: .5rem; flex-wrap: wrap; }
.preview-bar .muted { font-size: .78rem; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface); padding: 2px; gap: 2px; }
.seg button { font: inherit; font-size: .8rem; padding: .3rem .7rem; border: 0; border-radius: 4px; background: transparent; color: var(--text-muted); cursor: pointer; }
.seg button:hover { color: var(--text); background: var(--surface-2); }
.seg button.on { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.seg button:focus-visible { outline: none; box-shadow: var(--m-focus); }
.preview-note { font-size: .78rem; color: var(--text-muted); margin: -.2rem 0 .5rem; }
/* The iframe is the paper: always white, whatever the theme. */
.preview-frame { width: 100%; height: calc(100vh - 170px); min-height: 520px; border: 1px solid var(--border); background: #fff; color-scheme: light; border-radius: 4px; display: block; }
.banner { border-radius: var(--m-radius); padding: .75rem .95rem; margin-bottom: 1rem; font-size: .86rem; line-height: 1.45; border: 1px solid transparent; }
.banner.info { background: var(--m-info-bg); color: var(--text); border-color: color-mix(in srgb, var(--m-info) 25%, transparent); }
.banner.warn { background: var(--m-warn-bg); color: var(--text); border-color: color-mix(in srgb, var(--m-warn) 25%, transparent); }
.banner.ok { background: var(--m-ok-bg); color: var(--text); border-color: color-mix(in srgb, var(--m-ok) 25%, transparent); }
.banner.err { background: var(--m-bad-bg); color: var(--text); border-color: color-mix(in srgb, var(--m-bad) 25%, transparent); }
.banner.info strong { color: var(--m-info); }
.banner.warn strong { color: var(--m-warn); }
.banner.ok strong { color: var(--m-ok); }
.banner.err strong { color: var(--m-bad); }
.banner ul { margin: .35rem 0 0; padding-left: 1.1rem; }
.fee-line { display: grid; grid-template-columns: 1fr 120px 32px; gap: .4rem; margin-bottom: .4rem; }
.fee-total { display: flex; justify-content: space-between; font-weight: 600; padding: .55rem .2rem; border-top: 1px solid var(--text); margin-top: .35rem; font-variant-numeric: tabular-nums; }
.clause-list { list-style: none; margin: 0; padding: 0; }
.clause-list li { padding: .4rem 0; border-bottom: 1px solid var(--border-light); font-size: .83rem; display: flex; justify-content: space-between; gap: .5rem; }
.clause-list li.off { color: var(--text-muted); text-decoration: line-through; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: .5rem 0 .5rem 1rem; border-left: 2px solid var(--border); position: relative; font-size: .84rem; }
.timeline li::before { content: ''; position: absolute; left: -5px; top: .85rem; width: 8px; height: 8px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); box-sizing: border-box; }
.timeline .when { color: var(--text-muted); font-size: .75rem; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: .4rem .8rem; font-size: .87rem; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }
.muted { color: var(--text-muted); }
.small { font-size: .8rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; word-break: break-all; letter-spacing: 0; }
.right { text-align: right; }
.mt { margin-top: 1rem; }
.hidden { display: none !important; }
.placeholder { text-align: center; padding: 3rem 1.5rem; }
.placeholder h2 { margin: .5rem 0; font-weight: 600; }
.placeholder p { color: var(--text-muted); max-width: 520px; margin: .4rem auto; }

/* ---------- Modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: var(--modal-bg); backdrop-filter: blur(2px); z-index: 1000; display: none; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 3rem 1rem; }
.modal-bg.show { display: flex; }
.modal { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; max-width: 620px; width: 100%; padding: 1.5rem 1.6rem; box-shadow: 0 16px 48px var(--shadow-strong); }
.modal.wide { max-width: 980px; }
.modal-title { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 1rem; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border-light); flex-wrap: wrap; }
.toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%) translateY(12px); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 3px solid var(--m-ok); padding: .7rem 1rem; border-radius: 10px; font-size: .86rem; box-shadow: 0 8px 24px var(--shadow-strong); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 1100; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-left-color: var(--m-bad); }
.copy-box { display: flex; gap: .4rem; }
.copy-box input { font-family: ui-monospace, Menlo, monospace; font-size: .78rem; }

/* ---------- Proposals editor ---------- */
.kind-pick { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.kind-card { display: flex; gap: .6rem; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: .8rem .9rem; cursor: pointer; background: var(--surface); transition: border-color .12s; }
.kind-card:hover { border-color: var(--primary); }
.kind-card.on { border-color: var(--primary); background: var(--accent); box-shadow: inset 0 0 0 1px var(--primary); }
.kind-card input { margin-top: 3px; }
.kind-card .label { font-weight: 600; margin-bottom: .15rem; }
.tier-edit { border: 1px solid var(--border); border-radius: 10px; padding: .8rem .9rem; margin-bottom: .75rem; background: var(--surface-2); }
.tier-edit.rec { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.tier-edit-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; flex-wrap: wrap; }
.price-in { display: flex; align-items: center; gap: .3rem; }
.price-in > span { color: var(--text-muted); }
.price-in input { min-width: 0; }
.price-in select { width: auto; }
.svc-list { list-style: none; margin: .3rem 0 .5rem; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.svc-list li { display: flex; justify-content: space-between; gap: .5rem; padding: .45rem .65rem; border-bottom: 1px solid var(--border-light); font-size: .84rem; }
.svc-list li:last-child { border-bottom: none; }
.icon-x { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: .85rem; padding: 0 .3rem; align-self: flex-start; }
.icon-x:hover { color: var(--m-bad); }
.add-row { display: flex; gap: .4rem; margin-top: .3rem; }
.add-row select { flex: 1; }
.addon-edit, .fee-edit { border: 1px solid var(--border); border-radius: var(--m-radius); padding: .6rem .65rem; margin-bottom: .5rem; background: var(--surface-2); }
.addon-edit .field-row { grid-template-columns: 1fr auto; gap: .5rem; margin-bottom: .35rem; }
.small-in { font-size: .8rem; padding: .35rem .5rem; }
.fee-edit-top { display: flex; gap: .4rem; margin-bottom: .4rem; }
.yr-grid { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: .4rem; margin-bottom: .4rem; }
.yr-grid label span { display: block; font-size: .7rem; color: var(--text-muted); margin-bottom: .15rem; }
.yr-labels { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.yr-labels input { width: 90px; }
.sec-card { border: 1px solid var(--border); border-radius: var(--m-radius); padding: .55rem; margin-bottom: .6rem; background: var(--surface-2); }
.sec-head { display: flex; gap: .3rem; margin-bottom: .4rem; }
.sec-head input { font-weight: 600; }
.fmt-help { background: var(--surface-2); border: 1px solid var(--border-light); border-radius: 6px; padding: .55rem .7rem; margin-bottom: .9rem; line-height: 1.6; }
.fmt-help code { font-size: .72rem; background: var(--surface); border: 1px solid var(--border); border-radius: 3px; padding: 0 3px; }
.ph-sample { background: var(--m-warn-bg); color: var(--m-warn); padding: 0 3px; border-radius: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-wrap { position: static; }
  .preview-frame { height: 70vh; }
}
@media (max-width: 760px) {
  .app { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 900; transform: translateX(-100%); transition: transform .2s; box-shadow: none; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px var(--shadow-strong); }
  body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: var(--modal-bg); z-index: 899; }
  .mobile-bar { display: flex; gap: .65rem; align-items: center; padding: .55rem 1rem; background: var(--surface); color: var(--text); border-bottom: 1px solid var(--border); font-weight: 600; font-size: .92rem; position: sticky; top: 0; z-index: 800; }
  .mobile-bar .mark { width: 34px; height: auto; }
  body.dark .mobile-bar .mark { filter: brightness(0) invert(0.92); }
  .mobile-bar .btn { padding: .4rem .55rem; }
  .mobile-bar .btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }
  .main { padding: 1.1rem 1rem 3rem; }
  .view-title { font-size: 1.35rem; }
  .card { padding: 1.05rem 1.1rem; }
  .grid-2, .field-row, .kind-pick { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: .1rem; }
  .kv dd { margin-bottom: .45rem; }
  .stats { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .stat { padding: .8rem .9rem; }
  .stat-value { font-size: 1.35rem; }
  .toolbar > input:not([type=checkbox]), .toolbar > select { max-width: none !important; flex: 1 1 140px; }
  .table-wrap table { min-width: 620px; }
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; border: none; }
  input, select, textarea { font-size: 16px; } /* prevents iOS zoom */
}