/* Layout: operator's console. Black brand sidebar with gold accents, one working pane. */
:root {
  --bg: #f5f4f1;
  --surface: #ffffff;
  --sunk: #eeece7;
  --ink: #1d1b18;
  --muted: #6b665d;
  --line: #e2dfd8;
  --accent: #8a6a2c;
  --accent-ink: #ffffff;
  --accent-soft: #f2ead9;
  --brand-bar: #1d1b18;
  --brand-gold: #d2b06c;
  --good: #2e7a4f; --good-soft: #e3f2e8;
  --warn: #a8670f; --warn-soft: #fbefd9;
  --bad: #b8322a; --bad-soft: #fbe6e3;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110; --surface: #1c1b19; --sunk: #171614; --ink: #f1eee8; --muted: #a8a196; --line: #322f2a;
    --accent: #d6b36a; --accent-ink: #15130f; --accent-soft: #33291a; --brand-bar: #0d0c0b; --brand-gold: #d6b36a;
    --good: #6cc28f; --good-soft: #1d3326; --warn: #e2a64b; --warn-soft: #3a2b14; --bad: #f07a70; --bad-soft: #3d1d1b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 14px; line-height: 1.45; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 1.65rem; } h2 { font-size: 1.12rem; } h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; }
pre.code, textarea.code { background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; word-break: break-all; width: 100%; margin: 0; }
.num, td.r { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.right { text-align: right; }

/* Shell */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.navtoggle { display: none; }
.side { background: var(--brand-bar); color: #efe9de; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand img { width: 48px; height: 48px; flex: none; border-radius: 50%; }
.brand div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.brand b { font-family: var(--font-display); font-size: 1.15rem; color: var(--brand-gold); line-height: 1.15; }
.brand span { font-size: 0.72rem; color: #a59e92; }
.menu-btn { display: none; margin-left: auto; border: 1px solid #3a362f; color: #e6e0d4; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-weight: 600; font-size: 0.84rem; }
.nav { display: flex; flex-direction: column; gap: 10px; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-label { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.1em; color: #8d877c; padding: 4px 10px; font-weight: 600; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 8px; text-decoration: none; color: #e6e0d4; font-weight: 500; }
.nav a:hover { background: rgba(210, 176, 108, 0.1); }
.nav a.on { background: rgba(210, 176, 108, 0.16); color: var(--brand-gold); font-weight: 600; box-shadow: inset 2px 0 0 var(--brand-gold); }
.cnt { font-size: 0.7rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--bad); color: #fff; }
.cnt.warn { background: var(--warn); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 10px 8px 0; font-size: 0.8rem; color: #a59e92; border-top: 1px solid #2c2925; }
.side-foot b { color: #efe9de; }
.side-foot a { color: #d8cfbf; }

main { padding-block: 24px 64px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); min-width: 0; }
main.bare { min-height: 100vh; }
.wrap { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.wrap.narrow { max-width: 720px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.head p { margin-top: 4px; color: var(--muted); max-width: 70ch; }
.brand-center { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding-top: 12px; }
.brand-center img { border-radius: 50%; }

/* Surfaces */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.panel > h2:first-child, .panel > .row:first-child { margin-bottom: 10px; }
.panel.stack > h2:first-child { margin-bottom: 0; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.grid-side { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 18px; align-items: start; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 18px; align-items: start; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi .v { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi.bad .v { color: var(--bad); } .kpi.warn .v { color: var(--warn); } .kpi.good .v { color: var(--good); }

.flash { border-radius: 8px; padding: 10px 14px; background: var(--good-soft); color: var(--good); font-weight: 500; }
.flash.bad { background: var(--bad-soft); color: var(--bad); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.flash a { color: inherit; font-weight: 700; }

/* Controls */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.86rem; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { background: var(--sunk); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.small { padding: 4px 9px; font-size: 0.8rem; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
form.inline { display: inline; margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 0.74rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--sunk); color: var(--muted); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.acc { background: var(--accent-soft); color: var(--accent); }
.pill.solid { background: var(--accent); color: var(--accent-ink); }

.list { display: flex; flex-direction: column; }
.item { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .main { min-width: 0; flex: 1; }
.item .main > b { display: block; }
.sub { color: var(--muted); font-size: 0.82rem; }
.stripe { width: 4px; align-self: stretch; border-radius: 4px; background: var(--line); flex: none; }
.stripe.bad { background: var(--bad); } .stripe.warn { background: var(--warn); } .stripe.good { background: var(--good); } .stripe.acc { background: var(--accent); }
.empty { padding: 18px; text-align: center; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th { text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.r, th.r { text-align: right; }
tfoot td { font-weight: 700; border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--sunk); }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label, .field .lbl { font-size: 0.74rem; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea, input.inp, select.inp, textarea.inp { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 9px; width: 100%; min-width: 0; }
.field textarea { resize: vertical; }
.full { grid-column: 1 / -1; }
.check { display: flex; align-items: flex-start; gap: 8px; }
.check input { margin-top: 3px; }
.hint { font-size: 0.76rem; color: var(--muted); }
ul.checks { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 4px; }
ul.checks .ok { color: var(--good); } ul.checks .no { color: var(--bad); font-weight: 600; }

.warnbox { border-radius: 8px; padding: 9px 12px; font-size: 0.86rem; }
.warnbox.bad { background: var(--bad-soft); color: var(--bad); }
.warnbox.warn { background: var(--warn-soft); color: var(--warn); }
.warnbox.good { background: var(--good-soft); color: var(--good); }
.warnbox.info { background: var(--sunk); color: var(--muted); }

/* Enquiries */
.lead { display: flex; gap: 10px; padding: 10px; border-radius: 8px; text-decoration: none; color: inherit; border: 1px solid transparent; }
.lead:hover { background: var(--sunk); }
.lead.on { border-color: var(--accent); background: var(--accent-soft); }
.lead .main { min-width: 0; flex: 1; }
.lead .main b { display: block; }
.chat { display: flex; flex-direction: column; gap: 8px; background: var(--sunk); border-radius: 8px; padding: 12px; max-height: 380px; overflow-y: auto; }
.msg { max-width: 82%; padding: 7px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 0.88rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.out { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.msg.auto { align-self: flex-end; border-style: dashed; }
.msg.note { align-self: center; background: transparent; border-style: dashed; color: var(--muted); }
.msg small { display: block; color: var(--muted); font-size: 0.7rem; margin-top: 2px; }

/* Quote builder */
.extras { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; padding-right: 4px; }
.extra { display: grid; grid-template-columns: minmax(0, 1fr) auto 72px; gap: 8px; align-items: center; font-size: 0.86rem; }
.extra input { width: 72px; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; text-align: right; background: var(--surface); }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-variant-numeric: tabular-nums; }
.totals .big { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; }

/* Calendars */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dow { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); text-align: center; padding: 4px 0; }
.day { min-height: 92px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 3px; text-align: left; min-width: 0; text-decoration: none; color: inherit; }
.day:hover { border-color: var(--accent); }
.day.out { opacity: 0.4; }
.day.today .d { background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 0 6px; }
.day.sel { outline: 2px solid var(--accent); }
.day.dayfull { background: var(--bad-soft); }
.day.hol { background: var(--sunk); }
.day .top { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; font-weight: 600; gap: 4px; }
.cap { font-size: 0.68rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.day.dayfull .cap { color: var(--bad); }
.ev { font-size: 0.7rem; border-radius: 4px; padding: 1px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--sunk); }
.ev.confirmed { background: var(--accent); color: var(--accent-ink); }
.ev.accepted { background: var(--accent-soft); color: var(--accent); }
.ev.quoted { border: 1px dashed var(--muted); background: transparent; color: var(--muted); }
.ev.completed { background: var(--good-soft); color: var(--good); }
.ev.leave-approved { background: var(--good-soft); color: var(--good); }
.ev.leave-pending { border: 1px dashed var(--warn); background: transparent; color: var(--warn); }
.ev.holiday { background: transparent; color: var(--muted); font-style: italic; }
.evcount { display: none; font-size: 0.68rem; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.78rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.meter { height: 8px; background: var(--sunk); border-radius: 99px; overflow: hidden; min-width: 80px; }
.meter i { display: block; height: 100%; background: var(--good); border-radius: 99px; }
.meter.warn i { background: var(--warn); } .meter.bad i { background: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--sunk); border-radius: 99px; padding: 3px 4px 3px 10px; font-size: 0.8rem; }
.chip button { border: 0; background: var(--surface); width: 20px; height: 20px; border-radius: 50%; cursor: pointer; line-height: 1; color: var(--muted); }

/* Documents: quotes, invoices, payslips, contracts */
.doc { background: #fff; color: #1d1b18; border: 1px solid var(--line); border-radius: 10px; padding: 28px; display: flex; flex-direction: column; gap: 16px; max-width: 860px; }
.doc a { color: #8a6a2c; }
.doc .dtop { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.doc .dbrand { display: flex; gap: 12px; align-items: center; }
.doc .dbrand img { width: 64px; height: 64px; border-radius: 50%; }
.doc .dbrand b { font-family: var(--font-display); font-size: 1.3rem; }
.doc .muted, .doc .sub { color: #6b665d; }
.doc table th { color: #6b665d; border-color: #e2dfd8; }
.doc table td { border-color: #e2dfd8; }
.doc .label { color: #6b665d; }
.doc h2, .doc h3 { color: #1d1b18; }
.doc .contract-body h3 { margin-top: 14px; margin-bottom: 4px; }
.doc .contract-body p { margin: 0 0 8px; }
.doc .grid2 { gap: 12px; }
.sigbox { border: 1px dashed #c9c3b8; border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.sigbox img { max-width: 260px; height: auto; background: #fff; }
.sigpad { border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; max-width: 520px; height: 180px; touch-action: none; cursor: crosshair; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font-body); }
.chart .grid { stroke: var(--line); }

@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2, .grid-side, .grid-main { grid-template-columns: minmax(0, 1fr); }
  .fields.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; height: auto; max-height: 100vh; z-index: 20; padding: 10px max(12px, env(safe-area-inset-right, 0px)) 10px max(12px, env(safe-area-inset-left, 0px)); gap: 10px; }
  .brand img { width: 36px; height: 36px; }
  .brand span { display: none; }
  .menu-btn { display: inline-block; }
  .nav, .side-foot { display: none; }
  .navtoggle:checked ~ .side .nav, .navtoggle:checked ~ .side .side-foot { display: flex; }
  .fields, .fields.three { grid-template-columns: minmax(0, 1fr); }
  .day { min-height: 56px; padding: 4px; } .day .ev { display: none; } .day .evcount { display: block; }
  h1 { font-size: 1.35rem; }
  .doc { padding: 16px; }
}
@media print {
  body { background: #fff; }
  .side, .no-print, .flash, .head .row { display: none !important; }
  .shell { display: block; }
  main { padding: 0; }
  .doc { border: 0; padding: 0; max-width: none; }
  .panel { border: 0; padding: 0; }
}
@media (prefers-reduced-motion: no-preference) { .btn, .nav a, .day { transition: background 0.12s, border-color 0.12s; } }
/* Event profitability register */
#register th { white-space: normal; vertical-align: bottom; line-height: 1.25; }
#register td:first-child { min-width: 170px; }
#register td.r, #register th.r { white-space: nowrap; }
#register th.r { white-space: normal; min-width: 72px; }
