:root {
  --bg: #f7f6f3;
  --surface: #fffefb;
  --ink: #1f2330;
  --ink-soft: #4a4f5c;
  --muted: #9a968d;
  --line: #e5e3dd;
  --sage: #6b8f71;
  --sage-dk: #527058;
  --blue: #5b7693;
  --amber: #b08948;
  --danger: #a4543f;
  --shadow: 0 1px 2px rgba(31,35,48,.05), 0 4px 16px rgba(31,35,48,.04);
}

* { box-sizing: border-box; }
body {
  margin: 0; font-family: Inter, system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 24px; background: var(--surface);
  border-bottom: 1px solid var(--line); padding: 0 28px; height: 56px;
}
.brand { font-weight: 600; letter-spacing: -.01em; }
.brand .sub { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 12px; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a { padding: 6px 12px; border-radius: 7px; color: var(--ink-soft); font-weight: 500; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: #eef1ec; color: var(--sage-dk); }

.wrap { max-width: 1080px; margin: 28px auto; padding: 0 28px; }
.wrap.narrow { max-width: 720px; }

h1 { font-size: 20px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; text-transform: uppercase;
     letter-spacing: .04em; color: var(--muted); }
.lede { color: var(--muted); margin: 0 0 22px; }
.pagehead { display: flex; align-items: flex-start; justify-content: space-between;
            gap: 16px; margin-bottom: 20px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; scroll-margin-top: 70px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
             margin: -2px 0 14px; }
.card-head h2 { margin: 0; display: flex; align-items: center; gap: 9px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase;
     letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: #faf9f6; }
tr:last-child td { border-bottom: none; }

.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 11px;
        font-weight: 600; white-space: nowrap; }
.pill.draft    { background: #efeeea; color: var(--muted); }
.pill.approved { background: #eaf0f4; color: var(--blue); }
.pill.paid     { background: #f6efe1; color: var(--amber); }
.pill.received { background: #eef2ec; color: var(--sage-dk); }
.pill.closed   { background: #e3efe4; color: var(--sage-dk); }
.pill.hot      { background: #f6e3dd; color: var(--danger); }
.pill.role     { background: #efeae0; color: var(--amber); }

.rolechip { padding: 4px 11px; border-radius: 99px; background: #efeae0; color: var(--amber);
            font-size: 12px; font-weight: 600; margin-left: 4px; }
.lockmsg { color: var(--muted); font-size: 12.5px; background: #f6f5f1; border: 1px dashed var(--line);
           border-radius: 8px; padding: 9px 12px; margin: 12px 0 0; display: inline-block; }

.btn { display: inline-block; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line);
       background: var(--surface); color: var(--ink); font-weight: 500; cursor: pointer;
       font-family: inherit; font-size: 13px; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--sage); border-color: var(--sage); color: #fff; }
.btn.primary:hover { background: var(--sage-dk); }
.btn.danger { color: var(--danger); border-color: #e3cfc8; background: var(--surface); }
.btn.sm { padding: 4px 10px; font-size: 12px; }

label { display: block; font-weight: 500; margin: 14px 0 5px; font-size: 13px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 400;
               margin: 8px 0 0; cursor: pointer; }
label.inline input { width: auto; }
input[type=text], input[type=number], input[type=password], input[type=date],
input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 13px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #cfe0d3; border-color: var(--sage); }
.field-help { color: var(--muted); font-size: 12px; margin-top: 3px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 18px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 24px; margin-top: 10px; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; align-items: center; }

.flash { background: #eef2ec; border: 1px solid #cfe0d3; color: var(--sage-dk);
         padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.banner { background: #f6efe1; border: 1px solid #ead9b8; color: #7a5b22;
          padding: 10px 14px; border-radius: 8px; margin-bottom: 18px; font-size: 13px; }

/* login */
.login-wrap { max-width: 360px; margin: 12vh auto; padding: 0 20px; }

/* stage rail */
.rail { display: flex; gap: 0; margin-bottom: 22px; flex-wrap: wrap; }
.rail .step { flex: 1; min-width: 120px; position: relative; padding: 10px 12px;
              border: 1px solid var(--line); border-right: none; background: var(--surface); }
.rail .step:first-child { border-radius: 10px 0 0 10px; }
.rail .step:last-child { border-radius: 0 10px 10px 0; border-right: 1px solid var(--line); }
.rail .step.done { background: #eef2ec; border-color: #d5e3d8; }
.rail .step .n { display: inline-flex; width: 18px; height: 18px; border-radius: 50%;
                 background: var(--line); color: #fff; font-size: 11px; font-weight: 700;
                 align-items: center; justify-content: center; margin-right: 7px; }
.rail .step.done .n { background: var(--sage); }
.rail .step .t { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.rail .step a { color: inherit; }

/* documents */
.doclist { list-style: none; padding: 0; margin: 0 0 14px; }
.doclist li { display: flex; align-items: center; gap: 10px; padding: 8px 0;
              border-bottom: 1px dashed var(--line); }
.doclist .dt { font-size: 11px; font-weight: 600; text-transform: uppercase;
               letter-spacing: .03em; color: var(--muted); width: 130px; flex: none; }
.doclist .dn { flex: 1; }
.doclist .du { color: var(--muted); font-size: 12px; }

/* 3-way match */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match .m { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.match .m .lbl { color: var(--muted); font-size: 11px; text-transform: uppercase;
                 letter-spacing: .04em; }
.match .m .v { font-size: 16px; font-weight: 600; margin-top: 4px; }
.tag-ok  { color: var(--sage-dk); font-weight: 600; }
.tag-bad { color: var(--danger); font-weight: 600; }

.events { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.events li { padding: 6px 0; border-bottom: 1px dashed var(--line); color: var(--ink-soft); }
.events .ts { color: var(--muted); }

.muted { color: var(--muted); }
.signoff { background: #f3f6f3; border: 1px solid #d5e3d8; border-radius: 10px;
           padding: 12px 14px; font-size: 13px; }
.line-add { color: var(--blue); cursor: pointer; font-size: 13px; font-weight: 500; }

/* dashboard KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
       padding: 16px 18px; box-shadow: var(--shadow); border-left: 3px solid var(--line); }
.kpi.accent-amber { border-left-color: var(--amber); }
.kpi.accent-sage { border-left-color: var(--sage); }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 25px; font-weight: 600; margin-top: 6px; letter-spacing: -.02em;
              font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 3px; }

.dgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.queue table { font-size: 12.5px; }

/* status pipeline bar */
.statusbar { display: flex; height: 30px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.statusbar .seg { display: flex; align-items: center; justify-content: center; color: #fff;
                  font-size: 12px; font-weight: 600; min-width: 2px; }
.statusbar .seg.draft { background: #c9c6bd; } .statusbar .seg.approved { background: var(--blue); }
.statusbar .seg.paid { background: var(--amber); } .statusbar .seg.received { background: #7fa886; }
.statusbar .seg.closed { background: var(--sage-dk); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--ink-soft); }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.dot.draft { background: #c9c6bd; } .dot.approved { background: var(--blue); }
.dot.paid { background: var(--amber); } .dot.received { background: #7fa886; } .dot.closed { background: var(--sage-dk); }

/* document checklist */
.docchecklist { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.dc { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); }
.dc.have { background: #eef2ec; color: var(--sage-dk); border-color: #d5e3d8; }
.dc.miss { background: var(--surface); color: var(--muted); }

/* print document */
.ptitle { display: flex; justify-content: space-between; align-items: flex-start;
          border-bottom: 2px solid var(--ink); padding-bottom: 10px; margin-bottom: 14px; }
.pbrand { font-weight: 700; letter-spacing: .14em; font-size: 18px; }
.psub { color: var(--ink-soft); font-size: 13px; }
.pmeta { text-align: right; font-size: 12px; }
.psec { background: #eef1ec; color: var(--sage-dk); font-weight: 600; font-size: 12px;
        text-transform: uppercase; letter-spacing: .04em; padding: 4px 10px; border-radius: 5px; margin: 16px 0 8px; }
.pgrid { width: 100%; border-collapse: collapse; margin: 0; }
.pgrid td { border: 1px solid var(--line); padding: 7px 10px; font-size: 12.5px; vertical-align: top; width: 25%; }
.pgrid td b { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.pchecks { font-size: 12.5px; line-height: 1.9; }
.cbx { font-size: 14px; margin-right: 2px; }
.plines { width: 100%; border-collapse: collapse; margin-top: 6px; }
.plines th, .plines td { border: 1px solid var(--line); padding: 6px 9px; font-size: 12px; text-align: left; }
.plines .num { text-align: right; }
.pdocs { font-size: 12px; margin: 0; padding-left: 18px; }

@media screen { .print-doc { max-width: 820px; } }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; font-size: 11px; }
  .wrap { margin: 0; max-width: 100%; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .psec { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .statusbar .seg, .kpi, .pill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: var(--ink); text-decoration: none; }
}
