:root {
  --sidebar-bg: #141722;
  --sidebar-active: #262b3d;
  --sidebar-fg: #e7e9f0;
  --sidebar-muted: #9aa0b5;
  --sidebar-border: #30364c;
  --accent: #8fd6cd;
  --bg: #eef0f4;
  --fg: #1b1f2a;
  --muted: #6b7280;
  --faint: #9aa0b5;
  --card: #ffffff;
  --border: #dde1e8;
  --row-border: #eef0f4;
  --link: #2563a8;
  --red: #b2372f;
  --red-bg: #f9e7e5;
  --amber: #a8842c;
  --amber-strong: #c4941f;
  --amber-bg: #f8efd8;
  --green: #2f7f6f;
  --green-bg: #e2f0ec;
  --purple: #6b5b8f;
  --purple-bg: #eeeaf6;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Schibsted Grotesk', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--fg);
  background: var(--bg);
}
h1, h2, h3, .stat-value, .brand {
  font-family: 'Space Grotesk', 'Schibsted Grotesk', system-ui, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.error { color: var(--red); background: var(--red-bg); padding: 0.5rem 0.75rem; border-radius: 6px; }

/* --- App shell -------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 216px; flex-shrink: 0; background: var(--sidebar-bg);
  color: var(--sidebar-fg); display: flex; flex-direction: column;
  padding: 22px 14px; gap: 24px; position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
}
.brand { font-weight: 700; font-size: 17px; padding: 0 10px; color: var(--sidebar-fg); }
.sidenav { display: flex; flex-direction: column; gap: 2px; }
.sidenav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px;
  border-radius: 8px; color: var(--sidebar-muted); font-weight: 500;
}
.sidenav a:hover { color: var(--sidebar-fg); text-decoration: none; }
.sidenav a.active { background: var(--sidebar-active); color: var(--sidebar-fg); font-weight: 600; }
.sidenav a svg { flex-shrink: 0; }
.sidenav a.active svg path, .sidenav a.active svg rect, .sidenav a.active svg circle { stroke: var(--accent); }

.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 0 10px; font-size: 13px; }
.sidebar-bottom a, .sidebar-bottom button { color: var(--sidebar-muted); }
.sidebar-bottom a:hover { color: var(--sidebar-fg); text-decoration: none; }

.sem-picker { position: relative; }
.sem-picker summary {
  display: flex; align-items: center; justify-content: space-between;
  background: #1d2231; border: 1px solid var(--sidebar-border); border-radius: 8px;
  padding: 8px 12px; color: var(--sidebar-fg); font-weight: 600; cursor: pointer;
  list-style: none;
}
.sem-picker summary::-webkit-details-marker { display: none; }
.sem-picker .menu {
  position: absolute; bottom: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: #1d2231; border: 1px solid var(--sidebar-border); border-radius: 8px;
  overflow: hidden; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: flex; flex-direction: column;
}
.sem-picker .menu button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--sidebar-fg); font: inherit; padding: 9px 12px; cursor: pointer;
}
.sem-picker .menu button:hover { background: var(--sidebar-active); }
.sem-picker .menu button.current { color: var(--accent); font-weight: 700; }
.sem-picker .menu a { display: block; padding: 9px 12px; color: var(--sidebar-muted); border-top: 1px solid var(--sidebar-border); font-size: 12px; }

main.content { flex-grow: 1; min-width: 0; padding: 26px 32px 48px; display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 700; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 13px; }
h2 { font-size: 16px; font-weight: 700; margin: 12px 0 0; }
h3 { font-size: 14px; margin: 0 0 8px; }

/* --- Stat cards -------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 18px; display: flex; flex-direction: column; gap: 3px;
}
.stat .label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; }
.stat .stat-value { font-size: 26px; font-weight: 700; line-height: 1.15; }
.stat .stat-value.red { color: var(--red); }
.stat .stat-value.amber { color: var(--amber); }
.stat .note { font-size: 12px; color: var(--muted); }
.hourbars { display: flex; flex-direction: column; gap: 5px; font-size: 12px; margin-top: 3px; }
.hourbar { display: flex; align-items: center; gap: 8px; }
.hourbar .name { width: 58px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hourbar .track { flex-grow: 1; height: 5px; background: #e8ebf0; border-radius: 3px; overflow: hidden; }
.hourbar .fill { height: 5px; background: var(--green); border-radius: 3px; }
.hourbar .fill.yellow { background: var(--amber-strong); }
.hourbar .fill.red { background: var(--red); }
.hourbar .val { color: var(--muted); font-variant-numeric: tabular-nums; }
.hourbar .val.yellow { color: var(--amber); font-weight: 700; }
.hourbar .val.red { color: var(--red); font-weight: 700; }

/* --- Filter bar --------------------------------------------------- */
.filterbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.segmented { display: flex; background: var(--card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; font-size: 13px; }
.segmented a { padding: 7px 14px; color: #4b5563; border-left: 1px solid var(--border); }
.segmented a:first-child { border-left: none; }
.segmented a:hover { text-decoration: none; background: var(--bg); }
.segmented a.on { background: var(--fg); color: #ffffff; font-weight: 600; }
.filterbar select, .filterbar .clear { font-size: 13px; }
.filterbar select {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; color: var(--fg); font-family: inherit;
}

/* --- Cards and tables --------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; }
.tablecard { background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 12px; vertical-align: middle; }
thead th {
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--border); padding-top: 12px;
}
tbody td { border-bottom: 1px solid var(--row-border); }
tbody tr:last-child td { border-bottom: none; }
.tablecard > table > thead th:first-child, .tablecard td:first-child { padding-left: 18px; }
.tablecard > table > thead th:last-child, .tablecard td:last-child { padding-right: 18px; }
tr.inactive { opacity: 0.5; }

tr.status-unfilled > td:first-child { box-shadow: inset 3px 0 0 var(--red); }
tr.status-partial > td:first-child { box-shadow: inset 3px 0 0 var(--amber-strong); }
tr.status-filled > td:first-child { box-shadow: inset 3px 0 0 var(--green); }

.status-text { font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-text.unfilled { color: var(--red); }
.status-text.partial { color: var(--amber); }
.status-text.filled { color: var(--green); }

.badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  border-radius: 3px; padding: 1px 5px; vertical-align: middle;
}
.badge.danish { color: var(--purple); background: var(--purple-bg); }
.coursename { font-size: 12px; font-weight: 700; color: var(--link); white-space: nowrap; }
.warn-inline {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
  font-weight: 700; color: var(--amber); white-space: nowrap;
}
.warn-yellow { background: var(--amber-bg); color: var(--amber); padding: 1px 6px; border-radius: 4px; font-weight: 600; }
.warn-red { background: var(--red-bg); color: var(--red); padding: 1px 6px; border-radius: 4px; font-weight: 600; }

/* --- Assignee chips ----------------------------------------------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--bg);
  border-radius: 999px; padding: 3px 9px 3px 11px; font-size: 12px; font-weight: 600;
}
.chip form { display: inline-flex; }
.chip button { background: none; border: none; padding: 0; cursor: pointer; display: inline-flex; align-items: center; }
.chip button:hover svg path { stroke: var(--red); }

/* --- Assign menu --------------------------------------------------- */
.assign-cell { text-align: right; position: relative; }
.assign-menu { position: relative; display: inline-block; }
.assign-menu summary {
  display: inline-flex; align-items: center; gap: 6px; background: var(--fg);
  color: #ffffff; border-radius: 7px; padding: 6px 14px; font-size: 13px;
  font-weight: 600; cursor: pointer; list-style: none;
}
.assign-menu summary::-webkit-details-marker { display: none; }
.assign-menu .menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 200px;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(27, 31, 42, 0.18); overflow: hidden;
  display: flex; flex-direction: column; text-align: left;
}
.assign-menu .menu .head { padding: 8px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--row-border); }
.assign-menu .menu form { display: block; }
.assign-menu .menu button {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  background: none; border: none; font: inherit; font-size: 13px; padding: 8px 12px;
  cursor: pointer; color: var(--fg);
}
.assign-menu .menu button:hover { background: #f0f4fa; }
.assign-menu .menu .hours { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.assign-menu .menu .hours.yellow { color: var(--amber); font-weight: 700; }
.assign-menu .menu .hours.red { color: var(--red); font-weight: 700; }

/* --- Forms --------------------------------------------------------- */
form.stack { display: flex; flex-direction: column; gap: 0.7rem; max-width: 34rem; }
form.stack label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 13px; font-weight: 600; color: #374151; }
form.stack label small { font-weight: 400; }
label.check { flex-direction: row; align-items: center; gap: 0.45rem; }
label.check.inline { display: inline-flex; margin-right: 0.8rem; font-weight: 500; }
form.inline { display: inline; }
input, select, textarea {
  font: inherit; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--card); color: var(--fg);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b9c6da; border-color: #94a6bf; }
button.btn, .btn {
  font: inherit; font-weight: 600; font-size: 13px; padding: 8px 16px;
  border: 1px solid var(--fg); background: var(--fg); color: #ffffff;
  border-radius: 8px; cursor: pointer; align-self: flex-start;
}
button.btn:hover { background: #2c3245; }
.btn.secondary { background: var(--card); color: var(--fg); border-color: var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--red); border-color: var(--red); }
button.linklike {
  background: none; border: none; color: var(--link); padding: 0;
  font: inherit; text-decoration: underline; cursor: pointer;
}
fieldset { border: 1px solid var(--border); border-radius: 8px; }
legend { font-size: 12px; color: var(--muted); }
details.panel-toggle summary { cursor: pointer; color: var(--link); font-weight: 600; margin-bottom: 10px; }

.panel { border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; background: var(--card); }
ul.plain { list-style: none; padding-left: 0; margin: 0.25rem 0; }
ul.plain li { padding: 0.2rem 0; }

/* --- Grid ----------------------------------------------------------- */
.scroll-x { overflow-x: auto; }
table.grid th:first-child, table.grid td:first-child {
  position: sticky; left: 0; background: var(--card); z-index: 2;
}
table.grid th:last-child, table.grid td:last-child {
  position: sticky; right: 0; background: var(--card); z-index: 2;
  box-shadow: -1px 0 0 var(--border);
}
table.grid th.week { text-align: center; padding: 8px 4px; }
table.grid th.week .wk { display: block; font-size: 11px; }
table.grid th.week .wkdate { display: block; font-size: 10px; font-weight: 500; color: var(--faint); text-transform: none; letter-spacing: 0; }
table.grid td.cell { text-align: center; min-width: 2.6rem; font-variant-numeric: tabular-nums; }
table.grid td.has-hours { background: #e9f3f1; color: var(--green); font-weight: 600; cursor: pointer; }
table.grid td.has-hours:hover { background: #d5e9e4; }
table.grid td.has-unfilled { background: var(--amber-bg); color: var(--amber); font-weight: 700; cursor: pointer; }
table.grid tr.unfilled-row td:first-child { font-weight: 700; }
table.grid td.total { font-weight: 700; white-space: nowrap; }

/* --- Calendar -------------------------------------------------------- */
.cal-toolbar { display: flex; align-items: center; gap: 10px; }
.cal-toolbar .btn { display: inline-flex; align-items: center; gap: 5px; }
.cal-toolbar .btn:hover { text-decoration: none; }
.cal-month {
  font-family: 'Space Grotesk', 'Schibsted Grotesk', system-ui, sans-serif;
  font-size: 16px; font-weight: 700; min-width: 150px; text-align: center;
}
.cal-wrap { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--card); }
.cal-head {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--card); border-bottom: 1px solid var(--border);
}
.cal-head div {
  padding: 8px 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted);
}
.cal {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px; background: var(--row-border);
}
.cal-day {
  background: var(--card); min-height: 104px; padding: 6px 7px;
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.cal-day.out { background: #f7f8fa; }
.cal-day.out .daynum { color: var(--faint); }
.daynum {
  font-size: 11px; font-weight: 700; width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
}
.cal-day.today .daynum { background: var(--fg); color: #ffffff; border-radius: 999px; }
.cal-session {
  display: block; font-size: 11px; line-height: 1.4; color: var(--fg);
  border-radius: 4px; padding: 3px 6px 4px; border-left: 3px solid var(--faint);
  background: var(--bg); min-width: 0;
}
.cal-session:hover { text-decoration: none; filter: brightness(0.96); }
.cal-session.unfilled { border-left-color: var(--red); background: #fdf1f0; }
.cal-session.partial { border-left-color: var(--amber-strong); background: #fbf4e3; }
.cal-session.filled { border-left-color: var(--green); background: #e9f3f0; }
.cal-session .line1 { display: flex; align-items: center; gap: 5px; }
.cal-session .t { font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-session .c { color: var(--link); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-session .cal-title, .cal-session .who {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-session .who { color: var(--muted); }

/* --- Login / share (no sidebar) ------------------------------------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar-bg); }
.login-box { background: var(--card); border-radius: 12px; padding: 32px 36px; width: 22rem; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35); }
.login-box h1 { margin: 0 0 16px; font-size: 20px; }
.login-box form { display: flex; flex-direction: column; gap: 0.9rem; }

.share-page { max-width: 980px; margin: 0 auto; padding: 28px 24px 64px; display: flex; flex-direction: column; gap: 16px; }
.share-page h1 { font-size: 22px; margin: 0; }
.share-page h2 { margin-top: 16px; }
.share-page h3 { margin: 14px 0 4px; }
