/* Design tokens follow audit-app so the two apps feel alike. */
:root {
  --accent: #47735f;
  --accent-strong: #3a6150;
  --accent-soft: #e4f0ea;
  --bg: #f4f6f4;
  --surface: #fff;
  --surface-alt: #f7f9f8;
  --text: #17222b;
  --muted: #5f6c66;
  --border: #d3d9d5;
  --border-strong: #b4bdb8;
  --ink: #1b1b1b;
  --orange: #b96100;
  --orange-soft: #fdefd9;
  --red: #c9303a;
  --red-soft: #fde7e8;
  --success: #1c8f4b;
  --focus: #2b6fdb;
  --shadow: 0 18px 40px rgb(17 29 39 / 14%);
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0 0 8px; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h4 { font-size: 13px; text-transform: uppercase; margin-top: 18px; }
a { color: var(--accent-strong); }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; }
.form-error { color: var(--red); min-height: 1em; margin: 6px 0; }
.warn-text { color: var(--orange); font-weight: 600; }

input, select, textarea, button { font: inherit; color: inherit; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  min-height: 36px;
}
textarea { resize: vertical; }
/* Locked fields read like filled-in paper, not like inputs. */
input:disabled:not([type="checkbox"]):not([type="radio"]), select:disabled, textarea:disabled {
  background: var(--surface-alt); border-color: transparent; border-bottom-color: var(--border-strong); border-radius: 4px 4px 0 0; color: var(--text); opacity: 1;
}
input:disabled::placeholder, textarea:disabled::placeholder { color: transparent; }
select:disabled { appearance: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

button {
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-strong); }
button.danger-btn { color: var(--red); border-color: var(--red); background: var(--surface); }
button.link { border: 0; background: none; padding: 0; color: var(--accent-strong); text-decoration: underline; }
button.link.danger, .danger { color: var(--red); }
.small-btn { padding: 6px 12px; }

label { display: block; }
label.check { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0; }
label.check input { margin-top: 3px; flex: none; width: 16px; height: 16px; }

/* -- sign-in ---------------------------------------------------------------- */
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(380px, 100%); background: var(--surface); padding: 28px; border-radius: 12px; box-shadow: var(--shadow); display: grid; gap: 12px; }

/* -- shell -------------------------------------------------------------------- */
.topbar { display: flex; align-items: center; gap: 18px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--accent-strong); font-size: 17px; }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.tabs a { padding: 15px 12px 13px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.topbar-right { display: flex; gap: 12px; align-items: center; }
.who { color: var(--muted); font-size: 13px; }
.badge { background: var(--red); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 12px; margin-left: 4px; }
.page { max-width: 1180px; margin: 0 auto; padding: 20px 16px 120px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
form.filters input:not([type="checkbox"]):not([type="radio"]) { width: 240px; }
form.filters select { width: auto; }
.empty { color: var(--muted); padding: 10px 0; }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; text-transform: uppercase; color: var(--muted); background: var(--accent-soft); padding: 8px; }
table.list td { padding: 9px 8px; border-top: 1px solid var(--border); vertical-align: top; }
table.list tr[data-open] { cursor: pointer; }
table.list tr[data-open]:hover td { background: var(--surface-alt); }
table.list tr.is-task td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.inactive td { color: var(--muted); }

.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eceff0; white-space: nowrap; }
.pill.accent { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.pill.warn { background: var(--orange-soft); color: var(--orange); }
.status-approved { background: #dcf3e5; color: var(--success); }
.status-rejected, .status-cancelled { background: var(--red-soft); color: var(--red); }
.status-on_hold, .status-board { background: var(--orange-soft); color: var(--orange); }

.details { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0 0 8px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.narrow { max-width: 380px; display: grid; gap: 10px; }
.row-buttons { display: flex; gap: 10px; align-items: center; margin-top: 10px; }

/* -- the form ------------------------------------------------------------------ */
.request-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; }
.request-head h1 { letter-spacing: 0.3px; margin-top: 6px; }
.ref { font-size: 15px; color: var(--accent-strong); margin-left: 8px; }
.stage-hint { background: var(--accent-soft); border-radius: 6px; padding: 8px 12px; margin: 8px 0 14px; }
.steps { display: flex; list-style: none; padding: 0; margin: 0; gap: 4px; flex-wrap: wrap; }
.steps li { font-size: 12px; padding: 4px 10px; border-radius: 12px; background: #e6e9e8; color: var(--muted); }
.steps li.done { background: var(--accent-soft); color: var(--accent-strong); }
.steps li.now { background: var(--accent); color: #fff; font-weight: 600; }

.pr-form { display: grid; gap: 18px; }
.form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 20px 18px; overflow: hidden; }
.sec-title { background: var(--ink); color: #fff; margin: 0 -20px 14px; padding: 9px 20px; font-size: 14px; letter-spacing: 0.3px; }
.sec-title.sub { margin: 22px -20px 12px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; color: #333; letter-spacing: 0.2px; }
.readonly { min-height: 36px; padding: 7px 9px; border-bottom: 1px solid var(--border-strong); background: var(--surface-alt); border-radius: 4px 4px 0 0; }
.readonly.multiline { white-space: pre-wrap; min-height: 80px; }
.grid2, .grid3, .grid4 { display: grid; gap: 4px 16px; }
.grid2 { grid-template-columns: repeat(2, 1fr); }
.grid3 { grid-template-columns: repeat(3, 1fr); }
.grid4 { grid-template-columns: repeat(4, 1fr); }
.grid-desc { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.stack { display: grid; gap: 2px; }
.indent { margin: 0 0 6px 26px; }
.notice { margin: 12px 0 0; }
.callout { background: #f1f1f1; border: 1px solid #9a9a9a; padding: 10px 14px; margin: 12px 0; font-size: 13px; }
.callout.warn { background: var(--orange-soft); border-color: var(--orange); }
.tier { margin: 12px 0 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--surface-alt); }
.objective { display: grid; grid-template-columns: 210px 1fr; gap: 10px; align-items: center; margin: 3px 0; }
.requirements { margin: 0; padding-left: 22px; display: grid; gap: 4px; }
.later-hint { text-align: center; padding: 14px; }

.sig-row { display: grid; gap: 18px; margin-top: 12px; }
.sig-row.one { grid-template-columns: minmax(0, 1fr); }
.sig-row.two { grid-template-columns: repeat(2, 1fr); }
.sig-row.three { grid-template-columns: repeat(3, 1fr); }
.sig-box { display: grid; gap: 4px; }
.sig-area { height: 84px; border: 1px solid var(--border-strong); display: grid; place-items: center; background: #fff; }
.sig-img { max-height: 78px; max-width: 100%; }
.sig-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.table-scroll { overflow-x: auto; }
table.quotes { width: 100%; border-collapse: separate; border-spacing: 10px 6px; min-width: 760px; }
table.quotes th { text-align: left; font-size: 12px; vertical-align: top; padding-top: 8px; }
table.quotes thead th { font-size: 14px; }
table.quotes tbody th { width: 190px; }
table.quotes td { vertical-align: top; }

.attachments { margin: 8px 0; }
.attachments ul { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 3px; }
.attachments li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.file-btn { display: inline-block; padding: 5px 12px; border: 1px dashed var(--border-strong); border-radius: 6px; cursor: pointer; font-size: 13px; }
.history { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13.5px; }

.action-bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -6px 18px rgb(0 0 0 / 6%); padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; z-index: 4; }
.action-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* -- dialogs ------------------------------------------------------------------- */
.dialog { border: 0; border-radius: 12px; box-shadow: var(--shadow); padding: 22px; width: min(640px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgb(17 29 39 / 45%); }
.dialog form { display: grid; gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.sig-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 4px; }
.sig-pad { width: 100%; max-width: 600px; aspect-ratio: 10 / 3; border: 1px solid var(--border-strong); border-radius: 6px; touch-action: none; background: #fff; display: block; }
fieldset.roles { border: 1px solid var(--border); border-radius: 6px; }

.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 20; box-shadow: var(--shadow); max-width: 90vw; }
.toast.error { background: var(--red); }

@media (max-width: 760px) {
  .grid2, .grid3, .grid4, .grid-desc, .sig-row.two, .sig-row.three { grid-template-columns: 1fr; }
  .objective { grid-template-columns: 1fr; }
  .topbar { padding: 0 10px; }
  .who { display: none; }
  .form-section { padding: 0 12px 14px; }
  .sec-title { margin: 0 -12px 12px; padding: 9px 12px; }
}

/* -- print: the form as paper ----------------------------------------------------- */
@media print {
  @page { size: A4; margin: 12mm; }
  :root { background: #fff; font-size: 11px; }
  .topbar, .action-bar, .stage-hint, .steps, .file-btn, .request-head a, [data-remove-file], .toast, .later-hint { display: none !important; }
  .page { padding: 0; max-width: none; }
  .form-section { border: 0; padding: 0; break-inside: auto; }
  .sec-title { margin: 0 0 8px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #sec-b, #sec-b1, #sec-c, #sec-q { break-before: page; }
  input:not([type="checkbox"]):not([type="radio"]), select, textarea, .readonly { border: 0; border-bottom: 1px solid #888; border-radius: 0; background: #fff !important; padding: 2px 4px; min-height: 0; }
  textarea { resize: none; overflow: hidden; }
  select { appearance: none; }
  .callout { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sig-row, .sig-box, .objective, .field, table.quotes tr { break-inside: avoid; }
  .sec-title { break-after: avoid; }
  .table-scroll { overflow: visible; }
  table.quotes { min-width: 0; border-spacing: 6px 4px; }
  table.quotes tbody th { width: 150px; }
}
