/* Layout: a slim app bar, one working column, tables that scroll inside their own box on narrow screens. */
:root {
  --bg: #F6F8FB; --surface: #FFFFFF; --fg: #14202E; --muted: #556274; --line: #D8E0EA;
  --accent: #1F3A5F; --accent-soft: #E6EDF6; --on-accent: #FFFFFF;
  --ok: #1E6B52; --ok-soft: #E1F1EA; --warn: #8A5A12; --warn-soft: #F6ECD8;
  --bad: #A3322B; --bad-soft: #F8E4E2; --off: #556274; --off-soft: #E9EDF2;
  --display: "Space Grotesk", "Segoe UI", Arial, sans-serif;
  --body: "Inter", "Segoe UI", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1620; --surface: #16202D; --fg: #E6ECF3; --muted: #9AA8B8; --line: #263447;
    --accent: #9CBDEB; --accent-soft: #1C2B3F; --on-accent: #0F1620;
    --ok: #7FD1B0; --ok-soft: #163229; --warn: #E6BE78; --warn-soft: #33290F;
    --bad: #F0A39C; --bad-soft: #3A1E1B; --off: #9AA8B8; --off-soft: #202B39;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 15px; line-height: 1.5; }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; margin-top: 18px; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 24px 16px; }
.banner { background: var(--warn-soft); color: var(--warn); font-size: 0.85rem; text-align: center; padding: 6px 16px; }

.bar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.bar-in { max-width: 1040px; margin: 0 auto; padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; }
.brand { font-family: var(--display); font-weight: 700; font-size: 1.1rem; color: var(--accent); }
.tag { font-family: var(--body); font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; padding: 2px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); vertical-align: middle; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a { text-decoration: none; font-weight: 600; padding: 6px 12px; border-radius: 6px; color: var(--muted); }
.tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

.btn { font: inherit; font-weight: 600; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--on-accent); }
.link { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; text-align: left; }

.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 18px 0; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; border-top: 4px solid var(--accent); min-width: 0; }
.tile.assigned { border-top-color: var(--accent); }
.tile.available { border-top-color: var(--ok); }
.tile.repair { border-top-color: var(--warn); }
.tile.retired { border-top-color: var(--off); }
.tile b { display: block; font-family: var(--display); font-size: 1.9rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile span { font-size: 0.85rem; color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 12px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 28px; gap: 10px; align-items: center; }
.bar-label { font-size: 0.9rem; }
.bar-track { height: 12px; background: var(--accent-soft); border-radius: 6px; overflow: hidden; display: block; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.bar-num { text-align: right; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.due { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.due li { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; gap: 6px 14px; padding: 8px 0; border-top: 1px solid var(--line); align-items: baseline; }
.due li:first-child { border-top: 0; }
.late { color: var(--bad); font-weight: 600; white-space: nowrap; }
.soon { color: var(--warn); font-weight: 600; white-space: nowrap; }

.filters { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; margin: 16px 0 6px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 0.85rem; font-weight: 600; }
input, select, textarea { font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; width: 100%; min-width: 0; }
textarea { resize: vertical; }
.count { font-size: 0.85rem; margin: 8px 0; }
.empty { padding: 28px 16px; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin-top: 10px; }
table { border-collapse: collapse; width: 100%; min-width: 620px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; white-space: nowrap; }
th.num, td.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }

.pill { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.pill.assigned { background: var(--accent-soft); color: var(--accent); }
.pill.available { background: var(--ok-soft); color: var(--ok); }
.pill.repair { background: var(--warn-soft); color: var(--warn); }
.pill.retired { background: var(--off-soft); color: var(--off); }

dialog { border: 1px solid var(--line); border-radius: 10px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); background: var(--surface); color: var(--fg); }
dialog::backdrop { background: rgba(10, 16, 26, 0.55); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.dlg-body { padding: 16px 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.facts { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 6px 14px; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.9rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.history li { display: grid; grid-template-columns: 104px 120px minmax(0, 1fr); gap: 4px 12px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 0.9rem; }
.error { color: var(--bad); font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-weight: 600; z-index: 20; max-width: calc(100vw - 32px); }
.foot { font-size: 0.85rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 16px; }

@media (max-width: 640px) {
  .filters { grid-template-columns: minmax(0, 1fr); }
  .tabs { order: 3; flex-basis: 100%; }
  .due li { grid-template-columns: minmax(0, 1fr); }
  .history li { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: minmax(0, 1fr); }
  .facts dt { margin-top: 6px; }
}
@media (prefers-reduced-motion: no-preference) {
  .bar-fill { transition: width 0.3s ease; }
}

td.mono { white-space: nowrap; }

/* ----- shared additions for the demo menu, purchase orders and hiring ----- */
.tabs a.back { margin-left: auto; font-weight: 500; }
.intro { max-width: 62ch; color: var(--muted); margin: 10px 0 22px; font-size: 1.02rem; }
.hub { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.hub a { display: flex; flex-direction: column; gap: 8px; height: 100%; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 8px; text-decoration: none; color: var(--fg); }
.hub a:hover { border-color: var(--accent); }
.hub b { font-family: var(--display); font-size: 1.25rem; }
.hub-team { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.hub-go { margin-top: auto; padding-top: 6px; font-weight: 600; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.pill.bad { background: var(--bad-soft); color: var(--bad); }
.rolebar { margin: 14px 0 0; max-width: 360px; }
.filters.one { grid-template-columns: minmax(0, 260px); }
.lab { font-size: 0.85rem; font-weight: 600; }
.po-rows { display: flex; flex-direction: column; gap: 8px; }
.po-row { display: grid; grid-template-columns: minmax(0, 3fr) 72px minmax(0, 1.3fr) auto; gap: 8px; align-items: center; }
.po-total { font-weight: 600; font-variant-numeric: tabular-nums; }
.po-top { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.po-co { font-family: var(--display); font-weight: 700; font-size: 1.1rem; color: var(--accent); }
.po-meta { text-align: right; display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }
.table-wrap.flat { margin-top: 0; }
table.tight { min-width: 0; }
tfoot td { border-bottom: 0; padding-top: 4px; padding-bottom: 4px; font-variant-numeric: tabular-nums; }
tfoot tr.grand td { font-weight: 700; border-top: 1px solid var(--line); padding-top: 8px; }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(210px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; margin-top: 14px; }
.col { background: var(--accent-soft); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.col h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; display: flex; justify-content: space-between; color: var(--accent); }
.card { font: inherit; text-align: left; width: 100%; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.card:hover { border-color: var(--accent); }
.card b { font-family: var(--display); }
.card span { font-size: 0.83rem; color: var(--muted); }
.card .when { color: var(--warn); font-weight: 600; }
.col-empty { font-size: 0.83rem; color: var(--muted); padding: 6px 2px; }
.stars { font-variant-numeric: tabular-nums; font-weight: 600; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media (max-width: 640px) {
  .po-row { grid-template-columns: 72px minmax(0, 1fr) auto; }
  .po-row input:first-child { grid-column: 1 / -1; }
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media print {
  .no-print, .banner, .bar, main, footer, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  dialog { position: static; border: 0; width: 100%; max-height: none; color: #000; background: #fff; }
  dialog::backdrop { display: none; }
  .dlg-head { position: static; border: 0; padding: 0 0 12px; }
  .pill { border: 1px solid #000; background: none; color: #000; }
}

/* ----- guides, costs dashboard ----- */
.guides { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; padding-bottom: 0; }
.guide { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 14px; min-width: 0; }
.guide summary { font-family: var(--display); font-weight: 600; cursor: pointer; }
.guide ol, .guide ul { margin: 8px 0 4px; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 0.93rem; }
.guide p { font-size: 0.9rem; margin-top: 6px; }
.filters.two { grid-template-columns: repeat(2, minmax(0, 260px)); }
.bar-row.wide { grid-template-columns: minmax(0, 190px) minmax(0, 1fr) 96px; }
.bar-fill.strong { background: var(--ok); }
.good { color: var(--ok); font-weight: 600; white-space: nowrap; }
.tile b { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .filters.two { grid-template-columns: minmax(0, 1fr); }
  .bar-row.wide { grid-template-columns: minmax(0, 1fr) 84px; }
  .bar-row.wide .bar-track { grid-column: 1 / -1; order: 3; }
}
.guides { align-items: start; }
@media (max-width: 640px) { .tile b { font-size: 1.3rem; overflow-wrap: normal; } }
