/* Purchasing desk - styles.
   Look: industrial paperwork. Cool grey paper, deep ink, and signal colours
   (teal = done, amber = late, red = blocked) that mean the same thing everywhere. */

:root {
  --paper: #e9edf1;
  --panel: #ffffff;
  --ink: #15212c;
  --soft: #5c6b79;
  --line: #d3dae1;
  --accent: #0e5f63;
  --accent-ink: #ffffff;
  --done: #1b8a6b;
  --wait: #4a6482;
  --late: #c77d00;
  --blocked: #b83227;
  --future: #d9dfe5;
  --font: "Bahnschrift", "DIN Alternate", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #10171e; --panel: #1a232c; --ink: #e6ecf1; --soft: #9aa8b5; --line: #2c3946;
    --accent: #3fb6b0; --accent-ink: #062a2b; --done: #35b48d; --wait: #7f9bbd;
    --late: #e6a11f; --blocked: #ef6a5c; --future: #2c3946;
  }
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); line-height: 1.45; }
a { color: var(--accent); }
h1 { font-size: 1.7rem; margin: 0 0 .25rem; font-weight: 600; letter-spacing: .005em; }
h2 { font-size: 1.05rem; margin: 0; font-weight: 600; }
h3 { font-size: .95rem; margin: 1rem 0 .3rem; }
.h1-sub { display: block; font-size: 1.05rem; font-weight: 400; color: var(--soft); margin-top: .1rem; }
.muted { color: var(--soft); }
.small-text { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.amber { color: var(--late); }
.red { color: var(--blocked); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- top bar ---- */
.topbar { display: flex; align-items: center; gap: 1.25rem; padding: .6rem 1.25rem; background: var(--ink); color: var(--paper); flex-wrap: wrap; }
.topbar a { color: inherit; text-decoration: none; }
.brand { font-weight: 700; font-size: 1.1rem; margin-right: .5rem; }
.topbar nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.topbar nav a { padding: .35rem .7rem; border-radius: 4px; opacity: .8; }
.topbar nav a:hover { opacity: 1; background: rgba(255,255,255,.08); }
.topbar nav a.on { opacity: 1; background: rgba(255,255,255,.14); }
.topbar .inline { margin: 0; }

main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.page-head { margin-bottom: 1.1rem; }
.page-head p { margin: .25rem 0 0; }

/* ---- panels ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1rem 1.15rem; margin-bottom: 1rem; }
.panel.narrow { max-width: 520px; margin: 2rem auto; }
.panel.empty { text-align: left; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .6rem; gap: 1rem; }

/* ---- buttons & forms ---- */
.btn, button.btn { font: inherit; padding: .45rem .9rem; border-radius: 4px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { border-color: var(--soft); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; color: var(--soft); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
button.link { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; opacity: .8; text-decoration: underline; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: .4rem .55rem; max-width: 100%; }
label { display: block; font-size: .9rem; color: var(--soft); }
label input, label select, label textarea { display: block; width: 100%; margin-top: .25rem; color: var(--ink); }
.stack { display: grid; gap: .8rem; }
.stack-col { display: grid; gap: 0; align-content: start; }
.inline { display: inline; margin: 0; }
.inline-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .3rem 0; }
.inline-row input:not([type=date]) { flex: 1; min-width: 10rem; }
.inline-label { display: flex; gap: .5rem; align-items: center; }
.inline-label select { width: auto; margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: .9rem 0; }

.flash { padding: .6rem .9rem; border-radius: 4px; margin: 0 0 1rem; border: 1px solid var(--line); background: var(--panel); }
.flash.ok { border-left: 4px solid var(--done); }
.flash.error { border-left: 4px solid var(--blocked); }
.notice { border: 1px solid var(--late); border-left-width: 4px; background: var(--panel); padding: .6rem .9rem; border-radius: 4px; margin-top: .6rem; }

/* ---- dashboard ---- */
.dash { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.chase { list-style: none; margin: 0; padding: 0; }
.chase li { display: flex; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.chase li:first-child { border-top: 0; }
.chase-main { min-width: 0; }
.reqno { font-weight: 600; text-decoration: none; margin-right: .4rem; }
.reqno:hover { text-decoration: underline; }
.meta { display: flex; gap: .4rem 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--soft); margin-top: .15rem; }
.days { font-weight: 600; font-variant-numeric: tabular-nums; }
.chase-actions { display: flex; flex-direction: column; gap: .3rem; align-items: stretch; flex-shrink: 0; }
.chase-actions form { margin: 0; }
.chase-actions .btn { width: 100%; text-align: center; }

.pipeline { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; }
.pipeline a { display: grid; grid-template-columns: 1fr 70px 46px; gap: .6rem; align-items: center; padding: .4rem .3rem; text-decoration: none; color: var(--ink); border-radius: 4px; }
.pipeline a:hover { background: var(--paper); }
.pl-label small { display: block; }
.pl-bar { height: 8px; background: var(--future); border-radius: 2px; overflow: hidden; }
.pl-bar b { display: block; height: 100%; background: var(--wait); }
.pl-count { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.pl-count small { display: block; font-weight: 400; }

/* ---- progress strip ---- */
.track { display: inline-flex; gap: 2px; vertical-align: middle; }
.seg { width: 15px; height: 9px; background: var(--future); border-radius: 1px; display: block; }
.seg.done { background: var(--done); }
.seg.now { background: var(--wait); }
.seg.late { background: var(--late); }
.seg.blocked { background: var(--blocked); }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 3px; font-size: .82rem; border: 1px solid var(--line); white-space: nowrap; }
.b-done { border-color: var(--done); color: var(--done); }
.b-wait { border-color: var(--wait); color: var(--wait); }
.b-late { border-color: var(--late); color: var(--late); font-weight: 600; }
.b-blocked { border-color: var(--blocked); color: var(--blocked); font-weight: 600; }
.b-off { color: var(--soft); text-decoration: line-through; }
.flag { margin-left: .4rem; font-size: .72rem; border: 1px solid var(--late); color: var(--late); border-radius: 3px; padding: 0 .3rem; cursor: help; }

/* ---- table ---- */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input[type=search] { flex: 1; min-width: 14rem; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
table.grid { width: 100%; min-width: 1150px; border-collapse: collapse; font-size: .92rem; }
table.grid.compact { min-width: 0; }
.table-wrap table.grid:not(.compact) { table-layout: fixed; }
.reqcell { overflow-wrap: break-word; }
.table-wrap .badge { white-space: normal; }
table.grid td:nth-child(2) { min-width: 220px; }
.table-wrap table.grid:not(.compact) th:nth-child(1) { width: 170px; }
.table-wrap table.grid:not(.compact) th:nth-child(3) { width: 95px; }
.table-wrap table.grid:not(.compact) th:nth-child(4) { width: 105px; }
.table-wrap table.grid:not(.compact) th:nth-child(5) { width: 150px; }
.table-wrap table.grid:not(.compact) th:nth-child(6) { width: 125px; }
.table-wrap table.grid:not(.compact) th:nth-child(7) { width: 110px; }
.table-wrap table.grid:not(.compact) th:nth-child(8) { width: 190px; }
table.grid th { text-align: left; font-weight: 600; color: var(--soft); padding: .55rem .7rem; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; }
table.grid td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid form { margin: 0; }
table.compact td, table.compact th { padding: .35rem .5rem; }
.empty-row { text-align: center; color: var(--soft); padding: 1.6rem; }

/* ---- detail page ---- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.steps { list-style: none; margin: 0; padding: 0; }
.step { display: flex; gap: .9rem; padding-bottom: 1.1rem; position: relative; }
.step:last-child { padding-bottom: 0; }
.step::before { content: ""; position: absolute; left: 8px; top: 20px; bottom: -2px; width: 2px; background: var(--line); }
.step:last-child::before { display: none; }
.step.done::before { background: var(--done); }
.node { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); background: var(--panel); flex-shrink: 0; margin-top: 2px; z-index: 1; }
.step.done .node { background: var(--done); border-color: var(--done); }
.step.current .node { border-color: var(--wait); box-shadow: 0 0 0 3px color-mix(in srgb, var(--wait) 25%, transparent); }
.step-title { font-weight: 600; }
.step-title .muted { font-weight: 400; margin-left: .35rem; }
/* ---- step panel: click a step to open its notes and files ---- */
.step-body { flex: 1; min-width: 0; }
.step-panel > summary { cursor: pointer; padding: .05rem 0; }
.step-panel > summary:hover .step-title { color: var(--accent); }
.step-sub { display: block; font-size: .88rem; margin-left: 1.1rem; }
.step-inside { margin: .5rem 0 .2rem 1.1rem; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); }
.step-inside h3 { margin: .9rem 0 .35rem; font-size: .9rem; }
.step-inside .hint { margin: .1rem 0 0; }
.file-list, .note-list { list-style: none; margin: 0 0 .4rem; padding: 0; }
.file-list li, .note-list li { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; padding: .3rem 0; border-top: 1px solid var(--line); }
.file-list li:first-child, .note-list li:first-child { border-top: 0; }
.file-list a { overflow-wrap: anywhere; }
.note-date { white-space: nowrap; font-size: .85rem; min-width: 6.5rem; }
.note-text { flex: 1; min-width: 12rem; white-space: pre-line; overflow-wrap: anywhere; }
.note-form { display: flex; gap: .5rem; align-items: flex-end; margin-bottom: .5rem; flex-wrap: wrap; }
.note-form textarea { flex: 1; min-width: 12rem; resize: vertical; }
.reminder-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; margin: .2rem 0; }
.reminder-form label { flex: 0 1 12rem; }
.follow-up-panel { border-left: 4px solid var(--accent); }
.follow-ups li { padding: .3rem 0; }
/* ---- accounts, alarms, history ---- */
.topbar .who { opacity: .85; font-size: .9rem; }
.topbar .who:hover { opacity: 1; text-decoration: underline; }
.watch-row { margin-top: .5rem; }
.watch-on { color: var(--accent); font-weight: 600; }
.history-list { list-style: none; margin: 0; padding: 0; max-height: 22rem; overflow-y: auto; }
.history-list li { padding: .3rem 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.history-list li:first-child { border-top: 0; }
.user-list { list-style: none; margin: 0; padding: 0; }
.user-list > li { padding: .7rem 0; border-top: 1px solid var(--line); }
.user-list > li:first-child { border-top: 0; }
.user-head { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.temp-password { border-left: 4px solid var(--accent); }
.temp-line code { font-size: 1.15rem; padding: .15rem .45rem; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); user-select: all; }
.btn.danger { color: var(--blocked); }
.latest-note { display: block; font-size: .85rem; color: var(--soft); margin-top: .15rem; overflow-wrap: anywhere; }
.latest-note b { font-weight: 600; color: var(--ink); }
.numbers { margin-bottom: .9rem; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; padding: 0; margin: .35rem 0; }
.chips li { border: 1px solid var(--line); border-radius: 3px; padding: .1rem .2rem .1rem .5rem; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: .15rem; }
.chips li.none { border: 0; padding: 0; }
.chips .x { background: none; border: 0; color: var(--soft); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 .3rem; }
.chips .x:hover { color: var(--blocked); }
.related ul, .plain { margin: .3rem 0 0; padding-left: 1.1rem; }
.plain { list-style: none; padding: 0; }
.plain li { padding: .15rem 0; }

/* ---- small screens ---- */
@media (max-width: 860px) {
  .dash, .detail { grid-template-columns: 1fr; }
  .chase li { flex-direction: column; }
  .chase-actions { flex-direction: row; }
  .topbar { gap: .6rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

