:root {
  --brand: #bc2336;
  --ink: #1d2433;
  --muted: #667085;
  --line: #e4e7ec;
  --bg: #f5f6f8;
  --card: #ffffff;
  --green: #1a7f4b;  --green-bg: #e3f4ea;
  --amber: #9a5b00;  --amber-bg: #fff1d6;
  --red: #b42318;    --red-bg: #fde8e7;
  --blue: #175cd3;   --blue-bg: #e4edfc;
  --grey: #667085;   --grey-bg: #f0f1f3;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }

/* top bar */
.topbar { background: var(--brand); color: #fff; display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 58px; position: sticky; top: 0; z-index: 20; }
.topbar .logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; font-size: 16px; }
.topbar .logo img { height: 34px; background: #fff; border-radius: 6px; padding: 3px 6px; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { color: #fff; opacity: .85; padding: 8px 12px; border-radius: 6px; }
.topbar nav a:hover, .topbar nav a.on { opacity: 1; background: rgba(255,255,255,.16); text-decoration: none; }
.topbar form.search input { border: 0; border-radius: 6px; padding: 7px 10px; width: 210px; }
.switch { display: flex; background: rgba(0,0,0,.18); border-radius: 8px; padding: 3px; }
.switch a { color: #fff; padding: 5px 10px; border-radius: 6px; font-size: 13px; opacity: .8; }
.switch a.on { background: #fff; color: var(--brand); opacity: 1; font-weight: 600; text-decoration: none; }
.topbar .me { font-size: 13px; opacity: .9; color: #fff; }
.topbar .me a { color: #fff; }

main { max-width: 1400px; margin: 0 auto; padding: 22px 20px 60px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--grey); border-radius: var(--radius); padding: 14px 16px; color: var(--ink); display: block; }
.tile:hover { text-decoration: none; box-shadow: 0 2px 10px rgba(16,24,40,.08); }
.tile .n { font-size: 28px; font-weight: 700; }
.tile .l { color: var(--muted); font-size: 13px; }
.tile.red { border-left-color: var(--red); } .tile.amber { border-left-color: var(--amber); }
.tile.blue { border-left-color: var(--blue); } .tile.green { border-left-color: var(--green); }

/* bars */
.bar { background: var(--grey-bg); border-radius: 99px; height: 8px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--green); }
.bar.mid > span { background: #d69e2e; } .bar.low > span { background: var(--red); }

/* tables */
table.list { width: 100%; border-collapse: collapse; background: var(--card); }
table.list th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.list td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:hover td { background: #fafbfc; }

/* status pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.s-in_date, .s-held { background: var(--green-bg); color: var(--green); }
.s-expiring { background: var(--amber-bg); color: var(--amber); }
.s-expired { background: var(--red-bg); color: var(--red); }
.s-booked { background: var(--blue-bg); color: var(--blue); }
.s-required { background: #fff; color: var(--red); box-shadow: inset 0 0 0 1.5px var(--red); }
.s-not_required { background: var(--grey-bg); color: var(--grey); }
.s-none { background: transparent; }

/* matrix */
.matrix-wrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table.matrix { border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.matrix th, table.matrix td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 6px 8px; background: var(--card); }
table.matrix thead th { position: sticky; z-index: 2; }
table.matrix thead tr.sec th { top: 0; background: var(--brand); color: #fff; text-align: center; font-size: 12px; }
table.matrix thead tr.crs th { top: 29px; height: 150px; vertical-align: bottom; }
table.matrix thead tr.crs th div { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-weight: 600; max-height: 140px; overflow: hidden; text-overflow: ellipsis; }
table.matrix .name { position: sticky; left: 0; z-index: 1; min-width: 190px; font-weight: 600; }
table.matrix thead .name { z-index: 3; }
table.matrix td.c { text-align: center; min-width: 74px; white-space: nowrap; }
table.matrix td.c.s-in_date, table.matrix td.c.s-held { background: var(--green-bg); color: var(--green); }
table.matrix td.c.s-expiring { background: var(--amber-bg); color: var(--amber); font-weight: 600; }
table.matrix td.c.s-expired { background: var(--red-bg); color: var(--red); font-weight: 600; }
table.matrix td.c.s-booked { background: var(--blue-bg); color: var(--blue); }
table.matrix td.c.s-required { color: var(--red); font-weight: 600; }
table.matrix td.c.s-not_required { background: var(--grey-bg); color: var(--grey); }

/* profile */
.strip { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; }
.strip b { font-size: 20px; }
details.group { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; }
details.group > summary { cursor: pointer; padding: 12px 16px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
details.group > summary::-webkit-details-marker { display: none; }
details.group table.list td:first-child { padding-left: 16px; }

/* forms */
form.stack label { display: block; font-weight: 600; margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], input[type=time], select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid #d0d5dd; border-radius: 7px; background: #fff; width: 100%; max-width: 420px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { width: auto; }
.btn { display: inline-block; font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; }
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.checks { columns: 3; max-width: 760px; }
.checks label { display: block; font-weight: 400; margin: 0 0 6px; break-inside: avoid; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.error { background: var(--red-bg); color: var(--red); }
.flash.ok { background: var(--green-bg); color: var(--green); }

/* login */
.auth { max-width: 400px; margin: 9vh auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 30px; border-top: 5px solid var(--brand); }
.auth img.logo { height: 54px; display: block; margin: 0 auto 14px; }
.auth h1 { text-align: center; }
.auth input { max-width: none; }
.auth .btn { width: 100%; margin-top: 18px; }
.qr { text-align: center; margin: 14px 0; } .qr svg { width: 200px; height: 200px; }
code.key { display: block; text-align: center; font-size: 15px; letter-spacing: 2px; background: var(--grey-bg); padding: 8px; border-radius: 6px; word-break: break-all; }

dialog { border: 0; border-radius: 12px; padding: 22px; width: min(480px, 92vw); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(16,24,40,.45); }

@media (max-width: 800px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 8px; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; }
  .topbar form.search { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .checks { columns: 1; }
  main { padding: 14px 10px 40px; }
}
