:root {
  --bg: #f2f7f4; --card: #fff; --text: #1f2937; --muted: #6b7280; --line: #dfe9e3;
  --primary: #1b5e3b; --primary-2: #2e7d4f; --accent: #c9a227;
  --ok: #15803d; --ok-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7;
  --bad: #b91c1c; --bad-bg: #fee2e2; --info: #1d4ed8; --info-bg: #dbeafe;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--primary-2); }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.2; }
h2 { font-size: 20px; } h3 { font-size: 16px; }

/* Top bar */
.topbar { background: var(--primary); color: #fff; display: flex; align-items: center; gap: 16px; padding: 0 20px; height: 56px; position: sticky; top: 0; z-index: 20; }
.topbar .brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
.topbar .brand small { font-weight: 400; opacity: .7; margin-left: 6px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; opacity: .9; text-align: right; }
.topbar .who b { display: block; font-size: 14px; }
.topbar button { background: transparent; border: 1px solid rgba(255,255,255,.4); color: #fff; }
.menu-toggle { display: none; }

/* Layout */
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidenav { width: 220px; background: var(--card); border-right: 1px solid var(--line); padding: 12px 8px; flex-shrink: 0; }
.sidenav a { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px; margin-bottom: 2px; }
.sidenav a:hover { background: #eaf4ee; }
.sidenav a.active { background: var(--primary); color: #fff; }
.sidenav .group { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 14px 12px 6px; }
.sidenav .badge { background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
main { flex: 1; padding: 24px; min-width: 0; max-width: 1200px; }

/* Cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .n { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat .l { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-2); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 70px; resize: vertical; }
.inline { width: auto; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; margin-top: 4px; }
.checks label { font-weight: 400; display: flex; gap: 8px; align-items: center; margin: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }
.checks input { width: auto; }

button, .btn { font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover { background: var(--primary-2); }
button.secondary { background: #fff; color: var(--primary); }
button.secondary:hover { background: #eaf4ee; }
button.danger { background: #fff; color: var(--bad); border-color: #fca5a5; }
button.danger:hover { background: var(--bad-bg); }
button.ok { background: var(--ok); border-color: var(--ok); }
button.sm { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #f9fafb; }
tr.week-start td { border-top: 2px solid #b9d4c3; }

/* Pills */
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; font-weight: 600; }
.pill.open { background: #f3f4f6; color: var(--muted); }
.pill.assigned { background: var(--info-bg); color: var(--info); }
.pill.invited, .pill.pending { background: var(--warn-bg); color: var(--warn); }
.pill.confirmed, .pill.accepted, .pill.active { background: var(--ok-bg); color: var(--ok); }
.pill.declined, .pill.cancelled, .pill.inactive { background: var(--bad-bg); color: var(--bad); }
.pill.admin { background: #ede9fe; color: #6d28d9; }
.pill.scheduler { background: #fdf2e0; color: #92400e; }
.pill.speaker { background: #e0f2fe; color: #0369a1; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 6px; background: #eaf4ee; margin: 1px 2px 1px 0; }
.tag.sched { background: #fdf2e0; }

/* Calendar (availability) */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { font-size: 12px; text-align: center; color: var(--muted); font-weight: 600; padding: 4px 0; }
.cal .day { min-height: 64px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; font-size: 13px; cursor: pointer; background: #fff; position: relative; display: flex; flex-direction: column; justify-content: space-between; }
.cal .day:hover { border-color: var(--primary-2); }
.cal .day.other { opacity: .35; }
.cal .day.past { cursor: default; opacity: .5; }
.cal .day.unavail { background: var(--bad-bg); border-color: #fca5a5; }
.cal .day.booked::after { content: ''; position: absolute; right: 6px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--info); }
.cal .day.today { outline: 2px solid var(--accent); }
.cal .day .lbl { font-size: 10px; color: var(--bad); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Board (cross-sector availability) */
.board td.d { text-align: center; padding: 4px; min-width: 34px; font-size: 12px; }
.board td.d.free { background: #f0fdf4; color: var(--ok); }
.board td.d.no { background: var(--bad-bg); color: var(--bad); }
.board td.d.bk { background: var(--info-bg); color: var(--info); font-weight: 700; }
.board th.d { text-align: center; padding: 6px 4px; font-size: 11px; }
.board td.name { position: sticky; left: 0; background: #fff; min-width: 180px; z-index: 1; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 540px; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Toast / alerts */
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; z-index: 100; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }
#toast.error { background: var(--bad); }
.alert { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin: 10px 0; }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.info { background: var(--info-bg); color: var(--info); }
.empty { text-align: center; color: var(--muted); padding: 24px; }

/* Auth pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, var(--primary) 0%, #0c3320 100%); }
.auth-card { background: #fff; border-radius: 14px; padding: 28px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-card h1 { font-size: 22px; color: var(--primary); }
.auth-card .sub { color: var(--muted); margin-bottom: 14px; font-size: 14px; }
.auth-card button { width: 100%; justify-content: center; margin-top: 16px; padding: 11px; }

.copybox { display: flex; gap: 6px; }
.copybox input { font-family: ui-monospace, monospace; font-size: 12px; }

@media (max-width: 820px) {
  .menu-toggle { display: inline-flex; }
  .sidenav { position: fixed; top: 56px; bottom: 0; left: 0; transform: translateX(-100%); transition: transform .2s; z-index: 30; box-shadow: 4px 0 20px rgba(0,0,0,.1); }
  .sidenav.open { transform: none; }
  main { padding: 16px; }
  .topbar .who { display: none; }
  .topbar .brand small { display: none; }
  .topbar { padding: 0 12px; gap: 10px; }
  .topbar .brand { overflow: hidden; text-overflow: ellipsis; min-width: 0; font-size: 15px; }
  .hide-sm { display: none; }
  .card { padding: 12px; }
  th, td { padding: 8px 6px; }
  td.nowrap { white-space: nowrap; }
}
