:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1b2130;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #3f5bd8;
  --accent-ink: #ffffff;
  --accent-soft: #eef1fd;
  --ok: #12805c;
  --ok-soft: #e7f6ef;
  --warn: #b54708;
  --warn-soft: #fef3e6;
  --bad: #c0362c;
  --bad-soft: #fdecea;
  --side: #151b2c;
  --side-ink: #c9cfdd;
  --side-active: #26304a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1320; --panel: #171c2b; --ink: #e6e9f2; --muted: #98a2b3; --line: #2a3246;
    --accent: #7b93ff; --accent-ink: #0f1320; --accent-soft: #232c4d;
    --ok: #4ade9b; --ok-soft: #14322a; --warn: #f5a45c; --warn-soft: #3a2a17; --bad: #ff8078; --bad-soft: #3b1d1c;
    --side: #0b0f1a; --side-ink: #aab3c7; --side-active: #1d2438;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* Layout */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; font-size: 15px; padding: 4px 8px 14px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, #7b93ff, #3f5bd8); display: grid; place-items: center; color: #fff; font-size: 13px; }
.side select { width: 100%; background: var(--side-active); color: #fff; border: 1px solid #333d57; border-radius: 8px; padding: 7px 8px; margin-bottom: 10px; }
.side nav a { display: flex; align-items: center; gap: 9px; color: var(--side-ink); padding: 7px 10px; border-radius: 7px; font-size: 13.5px; }
.side nav a:hover { background: var(--side-active); text-decoration: none; color: #fff; }
.side nav a.active { background: var(--side-active); color: #fff; font-weight: 600; }
.side .group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6b7590; margin: 14px 10px 4px; }
.side .foot { margin-top: 18px; border-top: 1px solid #262e44; padding-top: 10px; font-size: 12px; }
.side .foot a { color: var(--side-ink); }
.main { padding: 22px 28px 60px; min-width: 0; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.menu-toggle { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .main { padding: 14px 16px 60px; }
}

/* Components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 12.5px; }
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--accent); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 7px 12px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill.ok, .pill.confirmed, .pill.paid, .pill.done, .pill.accepted { background: var(--ok-soft); color: var(--ok); }
.pill.warn, .pill.invited, .pill.contacted, .pill.negotiating, .pill.reviewing, .pill.waitlist, .pill.replied, .pill.applied, .pill.proposed { background: var(--warn-soft); color: var(--warn); }
.pill.bad, .pill.declined, .pill.cancelled, .pill.rejected { background: var(--bad-soft); color: var(--bad); }
.pill.muted, .pill.idea, .pill.potential, .pill.prospect, .pill.todo, .pill.new { background: var(--line); color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }

table.t { width: 100%; border-collapse: collapse; background: var(--panel); }
.t th, .t td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--panel); position: sticky; top: 0; z-index: 1; }
.t tr:hover td { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.t td.wrap { max-width: 360px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.table-wrap.tall { max-height: 72vh; overflow: auto; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date], input[type=time], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%;
}
.filters input, .filters select { width: auto; min-width: 150px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
input[type=color] { width: 44px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 16px; }
.field label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 4px; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 3px; }
.field .err { color: var(--bad); font-size: 12px; }
.field.full { grid-column: 1 / -1; }
.field.check label { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 12px; }
.checks label { font-weight: 400 !important; display: flex !important; gap: 7px; align-items: center; }
.checks ul { list-style: none; padding: 0; margin: 0; display: contents; }
.checks li { display: block; }
select.multi, select[multiple] { min-height: 140px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 14px; background: var(--panel); }
legend { font-weight: 700; padding: 0 6px; }

.messages { list-style: none; padding: 0; margin: 0 0 14px; }
.messages li { padding: 9px 12px; border-radius: 8px; margin-bottom: 6px; background: var(--accent-soft); }
.messages li.success { background: var(--ok-soft); color: var(--ok); }
.messages li.error { background: var(--bad-soft); color: var(--bad); }
.messages li.warning { background: var(--warn-soft); color: var(--warn); }
.alert { padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); margin-bottom: 12px; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.info { background: var(--accent-soft); color: var(--ink); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.copy { display: flex; gap: 6px; }
.copy input { font-family: ui-monospace, monospace; font-size: 12px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-line; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }
.check-cell { cursor: pointer; user-select: none; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; }
.tabs a.active { border-color: var(--accent); color: var(--ink); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.overdue { color: var(--bad); font-weight: 600; }
.event-card h2 { margin-bottom: 2px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* Scheduler */
.sched { display: grid; grid-template-columns: 1fr 290px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .sched { grid-template-columns: 1fr; } }
.sched-grid-wrap { overflow: auto; max-height: calc(100vh - 170px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.sched-grid { position: relative; display: grid; min-width: 640px; }
.sched-head { position: sticky; top: 0; z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px; font-weight: 600; font-size: 12.5px; }
.sched-head .cap { color: var(--muted); font-weight: 400; }
.sched-time { font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-7px); }
.sched-cell { border-left: 1px solid var(--line); border-top: 1px dashed color-mix(in srgb, var(--line) 70%, transparent); }
.sched-cell.hour { border-top: 1px solid var(--line); }
.sched-cell.drop { background: var(--accent-soft); }
.sched-item { position: absolute; border-radius: 7px; padding: 4px 7px; font-size: 12px; line-height: 1.3; color: #fff; overflow: hidden; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.2); border: 1px solid rgba(0,0,0,.08); z-index: 2; }
.sched-item.allrooms { opacity: .92; z-index: 1; background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.08) 0 8px, transparent 8px 16px); }
.sched-item .t { font-weight: 600; }
.sched-item .m { opacity: .9; font-size: 11px; }
.sched-item.conflict { outline: 2px solid var(--bad); outline-offset: 1px; }
.sched-item .resize { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.sched-item .x { position: absolute; top: 2px; right: 4px; opacity: 0; font-weight: 700; cursor: pointer; }
.sched-item:hover .x { opacity: .9; }
.pool { position: sticky; top: 12px; max-height: calc(100vh - 110px); overflow: auto; }
.pool-item { border: 1px solid var(--line); border-left: 4px solid var(--c, var(--accent)); border-radius: 8px; padding: 6px 9px; margin-bottom: 6px; cursor: grab; background: var(--panel); font-size: 12.5px; }
.pool-item:hover { border-color: var(--muted); }
.pool .blocks { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.block-chip { font-size: 12px; padding: 4px 9px; border-radius: 99px; border: 1px dashed var(--muted); cursor: grab; background: var(--panel); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--muted); }

/* Print programme */
@media print {
  .side, .topbar .actions, .no-print { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; color: #000; }
}
