/* Layout: a two-column workbench — form + competence totals on the left,
   week overview + logbook on the right; stacks to one column on phones */

/* ---------- Design tokens (light theme) ---------- */
:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --ink: #1b2433;
  --muted: #5d6879;
  --line: #d6dce5;
  --accent: #2f4fd8;
  --accent-ink: #ffffff;
  --danger: #b4372b;
  --ok: #23845a;
  --warn: #b86e10;
  /* One colour per competence */
  --c-analyseren: #2f7dbd;
  --c-adviseren: #8a5cc7;
  --c-ontwerpen: #d0782a;
  --c-realiseren: #2f9a6b;
  --c-manage: #c4475f;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}

/* ---------- Dark theme (follows the operating system setting) ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d; --surface: #1b212b; --ink: #e6eaf1; --muted: #9aa5b6; --line: #2d3644;
    --accent: #7d95ff; --accent-ink: #0f1420; --danger: #ff8a7d; --ok: #5cc595; --warn: #f0a05a;
    --c-analyseren: #63a8e0; --c-adviseren: #b48ef0; --c-ontwerpen: #f0a05a;
    --c-realiseren: #5cc595; --c-manage: #ef7a90;
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}
[hidden] { display: none !important; }
.wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 28px 16px 48px;
  display: grid;
  gap: 24px;
}

/* ---------- Header ---------- */
header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; }
h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(28px, 5vw, 40px); line-height: 1.05; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
.sub { color: var(--muted); margin: 4px 0 0; }
.grand { text-align: right; }
.grand .num { font-family: var(--font-mono); font-weight: 600; font-size: 34px; font-variant-numeric: tabular-nums; line-height: 1; }
.grand .lbl { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ---------- Grid ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 820px) { .grid { grid-template-columns: minmax(0, 1fr); } }
.col { display: grid; gap: 24px; min-width: 0; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; min-width: 0; }
h2 { font-family: var(--font-display); font-weight: 700; font-size: 19px; margin: 0 0 14px; }

/* ---------- Form ---------- */
form { display: grid; gap: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label, .field-label { display: grid; gap: 5px; font-size: 13px; font-weight: 700; }
.field-label { margin-bottom: 6px; }
input, select, textarea {
  font: inherit; font-size: 15px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 7px; padding: 9px 10px; width: 100%;
}
select { width: auto; }
textarea { min-height: 96px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: 13px; cursor: pointer; border-radius: 999px; padding: 6px 12px;
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  display: inline-flex; align-items: center; gap: 7px;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.chip[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: #fff; }
.chip[aria-pressed="true"] .dot { background: #fff; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn {
  font: inherit; font-weight: 700; cursor: pointer; border-radius: 7px; padding: 10px 16px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  text-decoration: none; display: inline-block;
}
.btn:disabled { opacity: .6; cursor: wait; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.msg { font-size: 13px; color: var(--muted); min-height: 1.2em; margin: 0; }
.msg.err { color: var(--danger); }

/* ---------- Totals per competence ---------- */
.bars { display: grid; gap: 12px; }
.bar-row { display: grid; gap: 4px; }
.bar-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.bar-head .h { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.track { height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; border: 1px solid var(--line); }
.fill { height: 100%; background: var(--c); transition: width .4s ease; }

/* ---------- Weekly overview ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend span::before { content: ""; width: 9px; height: 9px; border-radius: 2px; background: var(--c); }
.weeks { display: grid; gap: 10px; }
.week {
  display: grid; grid-template-columns: 112px minmax(0, 1fr) 64px; gap: 12px; align-items: center;
}
.week .wk { line-height: 1.25; }
.week .wk b { font-family: var(--font-display); font-size: 15px; }
.week .wk small { display: block; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.stack { display: flex; height: 18px; border-radius: 4px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.stack i { display: block; height: 100%; background: var(--c); }
.week .tot { font-family: var(--font-mono); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.week-avg { font-size: 13px; color: var(--muted); margin: 14px 0 0; }
@media (max-width: 480px) {
  .week { grid-template-columns: minmax(0, 1fr) auto; }
  .week .stack { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- Logbook ---------- */
.log-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.log-head h2 { margin: 0; }
.entry {
  display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 4px 16px;
  padding: 14px 0; border-top: 1px solid var(--line);
}
.entry:first-child { border-top: 0; }
.entry .date { font-family: var(--font-mono); font-size: 13px; color: var(--muted); padding-top: 2px; font-variant-numeric: tabular-nums; }
.entry .body { min-width: 0; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--c); }
.tag::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.entry .desc { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry .side { display: grid; justify-items: end; gap: 6px; }
.entry .hrs { font-family: var(--font-mono); font-weight: 600; font-size: 17px; font-variant-numeric: tabular-nums; }
.entry .tools { display: flex; gap: 4px; }
.link { font: inherit; font-size: 13px; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 2px 4px; }
.link.del { color: var(--danger); }
@media (max-width: 520px) {
  .entry { grid-template-columns: minmax(0, 1fr) auto; }
  .entry .date { grid-column: 1 / -1; }
}
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty strong { display: block; color: var(--ink); font-family: var(--font-display); font-size: 18px; margin-bottom: 4px; }

/* ---------- Login screen ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; display: grid; gap: 18px; padding: 28px; }
.auth-card h1 { font-size: 32px; }
.auth-card .sub { margin-top: -10px; }
.hint { font-weight: 400; font-size: 12px; color: var(--muted); margin: 0; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab {
  font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 8px 12px; margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.count {
  font-size: 11px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--warn); color: var(--surface); display: inline-grid; place-items: center;
}

/* ---------- Header: logged-in user ---------- */
.who { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; color: var(--muted); }
.who #userName { color: var(--ink); font-weight: 700; }
.role-badge {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 4px; background: var(--accent); color: var(--accent-ink);
}

/* ---------- Clickable week rows on the "Uren invoeren" tab ---------- */
button.week {
  font: inherit; color: inherit; background: none; border: 0; width: 100%; text-align: left;
  cursor: pointer; border-radius: 6px; padding: 4px 6px; margin: 0 -6px; width: calc(100% + 12px);
}
button.week:hover { background: var(--bg); }

/* ---------- "Mijn weken": list on the left, detail on the right ---------- */
.weeks-layout { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 820px) { .weeks-layout { grid-template-columns: minmax(0, 1fr); } }
.week-list { display: grid; gap: 4px; margin-top: 12px; max-height: 70vh; overflow-y: auto; }
.week-item {
  font: inherit; color: var(--ink); text-align: left; cursor: pointer;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center;
  background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 9px 10px;
}
.week-item:hover { background: var(--bg); }
.week-item[aria-current="true"] { background: var(--bg); border-color: var(--accent); }
.week-item b { font-family: var(--font-display); }
.week-item small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.week-item .tot { font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; grid-row: 1 / span 2; grid-column: 2; }
.week-item.empty-week .tot { color: var(--muted); font-weight: 400; }
.week-item .stack { grid-column: 1 / -1; height: 6px; margin-top: 4px; }
.now-tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent); margin-left: 6px; font-family: var(--font-body);
}

/* ---------- Week detail (shared by "Mijn weken" and "Teamweken") ---------- */
.week-detail { display: grid; gap: 20px; }
.wd-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: start; gap: 12px 20px; }
.wd-title h2 { margin: 0; font-size: 24px; }
.wd-title p { margin: 2px 0 0; color: var(--muted); }
.wd-person { font-weight: 700; color: var(--ink); }
.wd-total { text-align: right; }
.wd-total .num { font-family: var(--font-mono); font-weight: 600; font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; }
.wd-total .lbl { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.wd-nav { display: flex; gap: 6px; }
.wd-section h3 { font-family: var(--font-display); font-size: 15px; margin: 0 0 10px; }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day { border: 1px solid var(--line); border-radius: 7px; padding: 8px 4px; text-align: center; background: var(--bg); }
.day small { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.day span { font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.day.zero span { color: var(--muted); font-weight: 400; }
.wd-group { border-top: 1px solid var(--line); padding-top: 12px; }
.wd-group + .wd-group { margin-top: 12px; }
.wd-group-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.wd-group-head .h { font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.wd-entry { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 12px; padding: 6px 0; font-size: 14px; }
.wd-entry .d { color: var(--muted); font-family: var(--font-mono); font-size: 12px; padding-top: 2px; }
.wd-entry p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.wd-entry .h { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- "Teamweken" table ---------- */
table.team-weeks { width: 100%; border-collapse: collapse; font-size: 14px; }
.team-weeks th, .team-weeks td { padding: 4px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.team-weeks th { font-size: 12px; color: var(--muted); font-weight: 700; padding: 8px 6px; vertical-align: bottom; }
/* Header text lines up with the numbers inside the cell buttons (4px cell + 10px button padding) */
.team-weeks th { padding-right: 14px; }
.team-weeks th:last-child { padding-right: 0; }
.team-weeks th:first-child, .team-weeks td:first-child { text-align: left; padding-left: 0; }
.team-weeks th small { display: block; font-weight: 400; font-size: 11px; }
.team-weeks td.wk-cell b { font-family: var(--font-display); }
.team-weeks td.wk-cell small { display: block; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.team-weeks td.total { font-family: var(--font-mono); font-weight: 600; font-variant-numeric: tabular-nums; padding-right: 0; }
.team-weeks tr.current td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.cell-btn {
  font: inherit; font-family: var(--font-mono); font-variant-numeric: tabular-nums; cursor: pointer;
  min-width: 64px; padding: 7px 10px; border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: var(--ink); text-align: right;
}
.cell-btn:hover { border-color: var(--line); background: var(--bg); }
.cell-btn.zero { color: var(--muted); }
.cell-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--bg); font-weight: 600; }

.pw-panel { max-width: 640px; }
@media (max-width: 520px) { .pw-panel .row2 { grid-template-columns: 1fr; } }
.role-badge.small { font-size: 10px; padding: 1px 6px; vertical-align: 1px; }
.team td.act { white-space: nowrap; text-align: right; }

/* ---------- Admin: pending requests ---------- */
.request {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.request:first-child { border-top: 0; }
.request .who-req { min-width: 0; }
.request .who-req b { display: block; }
.request .who-req small { color: var(--muted); overflow-wrap: anywhere; }

/* ---------- Admin: team table ---------- */
.table-wrap { overflow-x: auto; }
table.team { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 760px; }
.team th, .team td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.team th { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 700; white-space: nowrap; }
.team th.comp::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--c); margin-right: 5px; }
.team td.num, .team th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.team td.num.zero { color: var(--muted); }
.team td small { display: block; color: var(--muted); font-size: 12px; }
.team tr:last-child td { border-bottom: 0; }
.pill { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid currentColor; }
.pill.Approved { color: var(--ok); }
.pill.Pending { color: var(--warn); }
.pill.Blocked { color: var(--danger); }

@media (prefers-reduced-motion: reduce) { .fill { transition: none; } }
