/* Raaj Orders: office paper + ink, one deep-teal accent. System fonts only (works offline, no external requests). */
:root {
  --bg: #f6f5f1; --panel: #ffffff; --ink: #1b1f24; --muted: #646b73; --line: #dedbd2; --soft: #efede6;
  --accent: #0e6b62; --accent-ink: #ffffff; --accent-soft: #e2f1ee;
  --ok: #1f7a4a; --ok-soft: #e3f3e9; --warn: #8a5a00; --warn-soft: #fff4dc; --bad: #b3261e; --bad-soft: #fde8e6;
  --mem: #5b3fa8; --mem-soft: #efeafc; --user: #9a4a00; --user-soft: #fdeedd;
  --paper: #ffffff; --paper-ink: #111;
  --r: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 20px rgba(0,0,0,.05);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Cambria", "Georgia", "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #121417; --panel: #1a1d21; --ink: #e8e6e1; --muted: #9aa1a8; --line: #2e3238; --soft: #22262b;
    --accent: #4fb8aa; --accent-ink: #06211e; --accent-soft: #143a35; --ok: #6fd39a; --ok-soft: #173326; --warn: #f0c060; --warn-soft: #3a2f14;
    --bad: #ff8a80; --bad-soft: #3d1d1b; --mem: #b9a4ff; --mem-soft: #2a2347; --user: #ffb26b; --user-soft: #3a2a18; --paper: #fbfaf7; --shadow: none; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #121417; --panel: #1a1d21; --ink: #e8e6e1; --muted: #9aa1a8; --line: #2e3238; --soft: #22262b;
  --accent: #4fb8aa; --accent-ink: #06211e; --accent-soft: #143a35; --ok: #6fd39a; --ok-soft: #173326; --warn: #f0c060; --warn-soft: #3a2f14;
  --bad: #ff8a80; --bad-soft: #3d1d1b; --mem: #b9a4ff; --mem-soft: #2a2347; --user: #ffb26b; --user-soft: #3a2a18; --paper: #fbfaf7; --shadow: none; color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; }
h2 { font-size: 1.25rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.6rem 0 .6rem; }
h3 small, h2 small { font-weight: 400; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--panel); padding: 6px 10px; z-index: 9; }
[hidden] { display: none !important; }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 14px; padding: 10px max(16px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand .logo { width: 32px; height: 32px; flex: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.1; }
.brand small { color: var(--muted); font-size: .72rem; }
.topnav { display: flex; gap: 2px; margin-left: 8px; }
.topnav a { padding: 6px 12px; border-radius: 99px; text-decoration: none; color: var(--muted); font-weight: 500; }
.topnav a.on { background: var(--ink); color: var(--bg); }
.chips { margin-left: auto; display: flex; gap: 6px; }
.chip { font-size: .75rem; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); white-space: nowrap; text-decoration: none; color: var(--muted); }
.chip.ok::before { content: "●"; color: var(--ok); margin-right: 5px; font-size: .7em; vertical-align: 1px; }
.chip.sync { color: var(--mem); border-color: color-mix(in srgb, var(--mem) 40%, transparent); }
.iconbtn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 1rem; }
.iconbtn.sm { width: 28px; height: 28px; font-size: .8rem; }

main { max-width: 1320px; margin: 0 auto; padding: 18px max(16px, env(safe-area-inset-left)) 40px; }
.foot { max-width: 1320px; margin: 0 auto; padding: 20px 16px 40px; color: var(--muted); font-size: .82rem; border-top: 1px solid var(--line); }

/* intro */
.intro { max-width: 860px; margin: 18px auto 10px; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; color: var(--accent); font-weight: 700; margin: 0 0 8px; }
.intro h1 { font-family: var(--serif); font-size: clamp(1.7rem, 4.2vw, 2.6rem); font-weight: 600; margin: 0 0 12px; letter-spacing: -.01em; }
.lead { font-size: 1.07rem; color: var(--muted); margin: 0 0 16px; }
.facts { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.facts li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; font-size: .9rem; color: var(--muted); }
.facts li b { color: var(--ink); display: block; margin-bottom: 2px; }

/* start */
.start { max-width: 860px; margin: 18px auto; }
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 34px 18px; border: 2px dashed color-mix(in srgb, var(--accent) 50%, var(--line)); border-radius: 14px; background: var(--panel); cursor: pointer; text-align: center; transition: .15s; }
.drop:hover, .drop.over, .drop:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.drop b { font-size: 1.15rem; }
.drop span { color: var(--muted); }
.drop-ico { font-size: 2rem; color: var(--accent) !important; }
.drop .busy-note { display: none; }
.drop.busy .busy-note { display: block; color: var(--accent); font-weight: 600; }
.start-alt { display: flex; gap: 8px; justify-content: center; margin: 14px 0 6px; flex-wrap: wrap; }
.start > p { text-align: center; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 9px 15px; border-radius: 9px; font: 500 .92rem var(--sans); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: .85rem; }
.btn.danger, .linkish.danger { color: var(--bad); }
.btn:disabled { opacity: .6; cursor: default; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: .85rem; text-decoration: underline; text-underline-offset: 2px; }

/* draft layout */
.bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.bar-l { display: flex; flex-direction: column; min-width: 0; }
.bar-l b { font-size: 1.1rem; }
.bar-l span { font-size: .85rem; }
.bar-r { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs { display: none; gap: 4px; margin: 6px 0 12px; position: sticky; top: 55px; z-index: 4; background: var(--bg); padding: 6px 0; }
.tabs button { flex: 1; padding: 9px 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 9px; font: 600 .85rem var(--sans); color: var(--muted); cursor: pointer; }
.tabs button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 20px; align-items: start; }
.col-b { position: sticky; top: 70px; max-height: calc(100vh - 86px); display: flex; flex-direction: column; }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.next { margin: 18px 0 0; text-align: right; }
@media (max-width: 980px) {
  .tabs { display: flex; }
  .grid { display: block; }
  .grid [data-pane] { display: none; }
  .grid[data-tab-on="sheet"] [data-pane="sheet"], .grid[data-tab-on="clauses"] [data-pane="clauses"], .grid[data-tab-on="wo"] [data-pane="wo"] { display: block; }
  .col-b { position: static; max-height: none; }
  .topnav { display: none; }
  .chips .chip.ok { display: none; }
}
@media (max-width: 560px) {
  .facts { grid-template-columns: 1fr; }
  .brand small { display: none; }
  .pane { padding: 14px; }
  .bar-r .btn.primary { display: none; }
}
@media (max-width: 980px) { .topnav.show { display: flex; } }

/* fields */
.fields { display: grid; gap: 10px 14px; }
.fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fields .wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .fields.two, .fields.three { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.field small { font-size: .75rem; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 0; border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; margin: 10px 0; font-size: .92rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.row input { max-width: 340px; }
.warn { background: var(--warn-soft); color: var(--warn); padding: 8px 12px; border-radius: 8px; font-size: .88rem; margin: 0 0 10px; }
.bad { color: var(--bad); }

/* bidders table */
.table-wrap { overflow-x: auto; }
table.bidders { width: 100%; border-collapse: collapse; font-size: .9rem; }
.bidders th { text-align: left; font-size: .75rem; color: var(--muted); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.bidders td { padding: 5px 6px; border-bottom: 1px solid var(--soft); vertical-align: middle; white-space: nowrap; }
.bidders td input:not([type="radio"]) { padding: 5px 8px; background: transparent; border-color: transparent; }
.bidders td input:not([type="radio"]):hover, .bidders td input:focus { border-color: var(--line); background: var(--bg); }
.bidders td small { display: block; padding-left: 9px; font-size: .72rem; }
.bidders tr.sel { background: var(--accent-soft); }
.num, .bidders td.num input { text-align: right; }
.pill { display: inline-block; font-size: .7rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.ok, .pill.st-agreed { background: var(--ok-soft); color: var(--ok); }
.pill.st-proposed, .pill.st-deviated { background: var(--accent-soft); color: var(--accent); }
.pill.st-notagreed { background: var(--bad-soft); color: var(--bad); }
.pill.src-memory { background: var(--mem-soft); color: var(--mem); }
.pill.src-user { background: var(--user-soft); color: var(--user); }

/* terms */
.terms { display: grid; gap: 8px; }
.term { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; }
.term-h { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.term p { margin: 4px 0 6px; }
.term textarea { field-sizing: content; min-height: 2.2em; padding: 6px 9px; font-size: .9rem; }

/* facts box */
.facts-box { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.facts-box > div { background: var(--soft); border-radius: 9px; padding: 9px 11px; display: flex; flex-direction: column; min-width: 0; }
.facts-box b { font-size: 1.02rem; }
.facts-box small { color: var(--muted); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) { .facts-box { grid-template-columns: 1fr; } }

/* clause cards */
.clause { border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 10px; padding: 10px 12px; margin-bottom: 9px; background: var(--panel); }
.clause.out { border-left-color: var(--line); background: color-mix(in srgb, var(--soft) 55%, var(--panel)); }
.clause.out .ct b { color: var(--muted); }
.clause.changed { border-left-color: var(--user); }
.clause header { display: flex; gap: 10px; align-items: center; }
.ct { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ct b { font-size: .96rem; }
.ct .no { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--soft); font-size: .7rem; margin-right: 7px; vertical-align: 1px; color: var(--muted); }
.ct .state { font-size: .78rem; color: var(--muted); }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .15s; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.why { list-style: none; margin: 8px 0 4px; padding: 0; font-size: .85rem; }
.why li { display: flex; gap: 7px; padding: 2px 0; color: var(--ink); }
.why li i { font-style: normal; width: 16px; flex: none; text-align: center; color: var(--muted); }
.why li.t-memory { color: var(--mem); } .why li.t-memory i { color: var(--mem); }
.why li.t-user { color: var(--user); } .why li.t-user i { color: var(--user); }
.opts { display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 6px 0; align-items: flex-end; }
.mini { display: flex; flex-direction: column; font-size: .74rem; color: var(--muted); font-weight: 600; gap: 2px; }
.mini span { display: flex; align-items: center; gap: 5px; color: var(--muted); font-weight: 400; }
.mini input, .mini select { padding: 5px 8px; font-size: .88rem; font-weight: 400; }
.mini input[type="number"] { width: 84px; }
.mini.wide { flex: 1; min-width: 200px; }
.params { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.params.col { flex-direction: column; align-items: stretch; width: 100%; }
.stage { display: grid; grid-template-columns: 64px 12px minmax(0, 1fr) 28px; gap: 6px; align-items: center; font-size: .85rem; }
.stage input { padding: 5px 8px; font-size: .88rem; }
.stage-foot { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.fb { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.fb input { flex: 1; padding: 6px 9px; font-size: .85rem; background: transparent; border-style: dashed; }
.wording textarea { margin-top: 8px; font-family: var(--serif); font-size: .9rem; }

/* paper */
.paper-tools { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 8px; flex-wrap: wrap; }
.paper { background: var(--paper); color: var(--paper-ink); border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 10px 30px rgba(0,0,0,.08); padding: 46px 52px; font: 13.4px/1.5 var(--serif); overflow-y: auto; flex: 1; }
.paper p { margin: 0 0 8px; text-align: justify; hyphens: auto; }
.wo-title { text-align: center; font-size: 1.15rem; text-decoration: underline; letter-spacing: .04em; margin: 0 0 14px; }
.wo-center { text-align: center !important; font-weight: 700; }
.wo-meta { display: flex; justify-content: space-between; gap: 10px; }
.paper .wo-plain { margin: 0; text-align: left; }
.wo-gap { height: 8px; }
.wo-label { display: grid; grid-template-columns: 92px minmax(0, 1fr); margin: 0 0 4px; text-align: left !important; }
.wo-h { font: 700 13.4px/1.4 var(--serif); margin: 14px 0 6px; display: flex; gap: 14px; break-after: avoid; }
.wo-h span { min-width: 28px; }
.paper .wo-li { padding-left: 42px; text-indent: -26px; }
.wo-li span { display: inline-block; width: 26px; text-indent: 0; }
.wo-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 26px 0 10px; break-inside: avoid; }
.wo-note { font-style: italic; font-size: .9em; }
.wo-encl-list { margin: 0 0 8px; padding-left: 22px; }
.wo-break { border: 0; border-top: 1px dashed #bbb; margin: 26px 0; }
.wo-table { width: 100%; border-collapse: collapse; font-size: .92em; }
.wo-table th, .wo-table td { border: 1px solid #666; padding: 4px 6px; }
.wo-table th { background: #eee; }
.wo-table .a-r { text-align: right; } .wo-table .a-c { text-align: center; }
.wo-table tr.tot td { font-weight: 700; }
@media (max-width: 560px) { .paper { padding: 24px 18px; font-size: 12.6px; } .wo-sign { grid-template-columns: 1fr; } }

/* rules, memory */
.page { max-width: 920px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; box-shadow: var(--shadow); }
.wordbox { border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; margin-bottom: 6px; }
.wordbox summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.wordbox textarea { margin: 8px 0 4px; font-family: var(--serif); font-size: .9rem; }
.insights { display: grid; gap: 8px; }
.insight { background: var(--mem-soft); border-radius: 9px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.insight p { margin: 0; color: var(--mem); font-size: .9rem; }
.cases { display: grid; gap: 6px; }
.case { border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; }
.case summary { cursor: pointer; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.case summary span:first-of-type { color: var(--muted); font-size: .85rem; }
.case-d { font-size: .85rem; padding-left: 18px; }
.case-d li.chg { color: var(--user); }
.syncbox { background: var(--soft); border-radius: 12px; padding: 14px 16px; font-size: .9rem; }
.syncbox p { margin: 0 0 10px; }
.code { font: 600 1rem ui-monospace, Consolas, monospace; background: var(--panel); padding: 3px 8px; border-radius: 6px; letter-spacing: .04em; }
.prose p { max-width: 70ch; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .9rem; z-index: 20; max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.25); }

/* print: only the work order */
@media print {
  @page { size: A4; margin: 18mm 18mm 16mm; }
  body { background: #fff; }
  .top, .foot, .bar, .tabs, .col-a, .paper-tools, .intro, .toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .grid { display: block; }
  .grid [data-pane="wo"] { display: block !important; }
  .col-b { position: static; max-height: none; }
  .paper { box-shadow: none; padding: 0; overflow: visible; font-size: 10.5pt; }
  .wo-break { border: 0; break-after: page; margin: 0; }
}
