/* SchichtenBalance – plain CSS, no build step. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1c2330;
  --muted: #5b6575;
  --border: #d9dee6;
  --accent: #2463d1;
  --accent-hover: #1b4fae;
  --accent-text: #ffffff;
  --accent-soft: #e3ecfb;
  --danger: #c22f2f;
  --danger-hover: #a12424;
  --ok-bg: #e2f4e8;   --ok-fg: #17602f;   --ok: #2f9e55;
  --warn-bg: #fdf1d6; --warn-fg: #7a5200; --warn: #e0a21b;
  --bad-bg: #fbe3e3;  --bad-fg: #9b1c1c;  --bad: #d64545;
  --info-bg: #e3ecfb; --info-fg: #1b4fae;
  --slot0: #eceff3;   --slot0-fg: #5b6575;
  --slot1: #bfe5cb;   --slot1-fg: #14532d;
  --slot2: #1f8a4c;   --slot2-fg: #ffffff;
  --cov-none: #eef0f3;
  --focus: #2463d1;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1b2129;
    --surface-2: #232a34;
    --text: #e6e9ee;
    --muted: #a0a9b8;
    --border: #333c48;
    --accent: #6ea2ff;
    --accent-hover: #8db6ff;
    --accent-text: #0b1220;
    --accent-soft: #1f2d47;
    --danger: #f07171;
    --danger-hover: #f59090;
    --ok-bg: #173323;   --ok-fg: #8fe0aa;   --ok: #3fbf6a;
    --warn-bg: #3a2e10; --warn-fg: #f3cd72; --warn: #d9a425;
    --bad-bg: #3d1a1a;  --bad-fg: #f5a3a3;  --bad: #e05a5a;
    --info-bg: #1f2d47; --info-fg: #a9c6ff;
    --slot0: #262d37;   --slot0-fg: #a0a9b8;
    --slot1: #23553a;   --slot1-fg: #d4f5df;
    --slot2: #3fbf6a;   --slot2-fg: #0b1a10;
    --cov-none: #232a34;
    --focus: #8db6ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  overflow-x: hidden;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
img, svg { max-width: 100%; }
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; margin-top: .25em; }
h2 { font-size: 1.25rem; margin-top: 1.25em; }
h3 { font-size: 1.05rem; margin-top: 1em; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
p { margin: 0 0 .75em; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Layout */
header.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  padding: .6rem 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}
.topbar nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem .75rem;
}
.topbar nav a { text-decoration: none; padding: .35rem .25rem; }
.topbar nav a:hover { text-decoration: underline; }
.lang-switch { display: inline-flex; gap: 2px; margin-left: .25rem; }
.lang-switch a {
  font-size: .8rem;
  padding: .15rem .45rem !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
}
.lang-switch a.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

main.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 16px 2rem;
}
footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 16px 2rem;
  font-size: .85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 1rem;
  min-width: 0;
}
@media (min-width: 640px) { .card { padding: 1.25rem 1.5rem; } }

.stack > * + * { margin-top: .75rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.grid-2 > * { min-width: 0; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* Buttons */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 44px;
  padding: .5rem 1rem;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
button:hover, .btn:hover { border-color: var(--muted); color: var(--text); }
button:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }
@media (prefers-color-scheme: dark) {
  .btn-danger, .btn-danger:hover { color: #1a0b0b; }
}
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn-small { min-height: 32px; padding: .25rem .6rem; font-size: .875rem; }
form.inline { display: inline; }
.btn-icon { min-height: 36px; min-width: 36px; padding: .35rem; }
.btn-ghost-danger { color: var(--danger); }
.btn-ghost-danger:hover { color: var(--danger); background: var(--accent-soft); }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.row.tight { gap: .15rem; flex-wrap: nowrap; }

/* Forms */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field label { font-weight: 600; }
.field .hint { font-size: .85rem; color: var(--muted); }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%;
  min-height: 44px;
  padding: .5rem .75rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
textarea { min-height: 6rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 0;
  border-color: var(--focus);
}
input[readonly] { background: var(--surface-2); }
input[type="checkbox"], input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
  margin: 0;
}


/* Tables */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
table.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td {
  padding: .45rem .6rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.table th { font-size: .85rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table tbody tr:nth-child(even) { background: var(--surface-2); }

/* Badges */
.badge {
  display: inline-block;
  padding: .1rem .5rem;
  font-size: .8rem;
  font-weight: 600;
  line-height: 1.5;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge-bad { background: var(--bad-bg); color: var(--bad-fg); }
.badge-info { background: var(--info-bg); color: var(--info-fg); }

/* Flash messages */
.flash {
  padding: .75rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left-width: 4px;
  background: var(--surface);
}
.flash-ok { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok); }
.flash-error { background: var(--bad-bg); color: var(--bad-fg); border-color: var(--bad); }

/* Copy field */
.copy { display: flex; gap: .5rem; align-items: stretch; }
.copy input { flex: 1 1 auto; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; }
.copy button, .copy .btn { flex: none; }

/* Stats */
.stats { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }
.stat {
  flex: 1 1 120px;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .85rem; color: var(--muted); }

/* Availability painting */
.paint-tools {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: .75rem;
}
label.tool {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 44px;
  padding: .4rem .9rem;
  background: var(--surface);
  cursor: pointer;
  font-weight: 500;
  border-right: 1px solid var(--border);
}
label.tool:last-child { border-right: 0; }
label.tool input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
label.tool:has(input:checked) { background: var(--accent); color: var(--accent-text); font-weight: 700; }
label.tool:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; }

.slotgrid {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding-bottom: .5rem;
  -webkit-overflow-scrolling: touch;
}
.day { flex: 0 0 auto; display: flex; flex-direction: column; gap: 3px; min-width: 84px; }
.day-title {
  font-size: .85rem;
  font-weight: 700;
  text-align: center;
  padding: .25rem 0;
  position: sticky;
  top: 0;
  background: var(--surface);
}
.slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  min-width: 84px;
  padding: 0 .4rem;
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.slot.s0, .swatch.s0 { background: var(--slot0); color: var(--slot0-fg); border-color: var(--border); }
.slot.s1, .swatch.s1 { background: var(--slot1); color: var(--slot1-fg); border-color: var(--ok); }
.slot.s2, .swatch.s2 { background: var(--slot2); color: var(--slot2-fg); border-color: var(--slot2); }
.slot.s2 { font-weight: 700; }

.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; font-size: .85rem; color: var(--muted); margin: .5rem 0; }
.legend > * { display: inline-flex; align-items: center; gap: .35rem; }
.swatch { display: inline-block; width: 1rem; height: 1rem; border-radius: 3px; border: 1px solid; vertical-align: middle; }

/* Coverage overview */
.coverage { display: flex; flex-direction: column; gap: 1rem; }
.cov-day { display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.cov-date { margin: 0; font-size: 1rem; }
.cov-task { min-width: 0; }
.cov-title { font-weight: 600; margin-bottom: .3rem; }
.cov-bar {
  display: flex;
  gap: 1px;
  height: 28px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--border);
}
.cov-cell { flex: 1 1 0; min-width: 3px; height: 28px; background: var(--cov-none); }
.cov-cell.c-none { background: var(--cov-none); }
.cov-cell.c-ok { background: var(--ok); }
.cov-cell.c-tight { background: var(--warn); }
.cov-cell.c-short { background: var(--bad); }
.cov-axis {
  display: flex;
  justify-content: space-between;
  gap: .25rem;
  margin-top: .2rem;
  font-size: .75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Shift list */
ul.shifts { list-style: none; padding: 0; margin: 0; }
ul.shifts li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem .75rem;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
}
ul.shifts li:last-child { border-bottom: 0; }
.pref { color: var(--warn); font-weight: 700; }
.pref:empty::before { content: "\2605"; }

@media (max-width: 480px) {
  h1 { font-size: 1.4rem; }
  .copy { flex-wrap: wrap; }
  .copy button, .copy .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Additions used by the templates */
.card-link { display: block; text-decoration: none; color: inherit; }
.card-link:hover { border-color: var(--accent); }
ul.plain { list-style: none; padding: 0; margin: 0 0 1rem; }
ul.plain > li { padding: .35rem 0; border-bottom: 1px solid var(--border); }
/* List entry: text on the left (title, details below), buttons on the right */
.item { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.item-text { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.item > .row { flex: none; }
.item > .item-text { flex: 1; }
/* Role select with save button next to it (access list on the event page). */
.role-form { display: flex; align-items: center; gap: .3rem; }
.role-form select { width: auto; min-height: 32px; padding: .2rem .5rem; font-size: .875rem; }
/* Drag handle of sortable lists (shown by app.js) */
.drag-handle { flex: none; cursor: grab; touch-action: none; color: var(--muted); margin: -.2rem 0; }
.drag-handle[hidden] { display: none; }
ul.sorting, ul.sorting .drag-handle { cursor: grabbing; user-select: none; }
ul.plain > li.dragging { background: var(--surface-2); border-radius: var(--radius-sm); opacity: .85; }
.prewrap { white-space: pre-wrap; }
fieldset.field { border: 0; padding: 0; margin: 0 0 .9rem; min-width: 0; }
fieldset.field legend { padding: 0; margin-bottom: .3rem; }
.legend .swatch.cov-cell { height: 1rem; width: 1rem; flex: none; min-width: 0; }
.field .paint-tools { align-self: flex-start; }
.field input[type="number"] { max-width: 12rem; }
.input-unit { display: flex; align-items: center; gap: .6rem; }
.input-unit input[type="number"] { max-width: 7rem; }

/* Task choice on the helper sign-up */
.task-options { display: flex; flex-direction: column; gap: .5rem; margin-top: .3rem; }
label.task-option {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  min-height: 44px;
  padding: .65rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: normal;
  cursor: pointer;
}
label.task-option:hover { border-color: var(--muted); }
label.task-option:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
label.task-option:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
label.task-option input { flex: none; width: 1.15rem; height: 1.15rem; margin: .15rem 0 0; accent-color: var(--accent); }
.task-option-name { display: block; font-weight: 600; }
.task-option-desc { display: block; margin-top: .15rem; font-size: .9rem; color: var(--muted); white-space: pre-line; }
label.radio { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem 0; font-weight: normal; cursor: pointer; }
label.radio input { margin-top: .3rem; flex: none; }

/* Timetable (SVG) in the plan preview */
.timetable { margin-bottom: 1rem; }
.timetable svg.tt { display: block; width: 100%; min-width: 720px; height: auto; font-family: var(--font); }
.tt text { font-size: 13px; fill: var(--text); }
.tt .tt-tick { fill: var(--muted); text-anchor: middle; font-size: 12px; }
.tt .tt-task { font-weight: 700; }
.tt .tt-missing { fill: var(--bad-fg); font-style: italic; }
.tt-grid { stroke: var(--border); stroke-width: 1; }
.tt-band { fill: var(--surface-2); }
.tt-bar text { fill: #fff; font-weight: 600; pointer-events: none; }
.tt-pref rect { stroke: var(--text); stroke-width: 1.5; }
.tt-gap rect { fill: var(--bad-bg); stroke: var(--bad); stroke-width: 1; stroke-dasharray: 4 3; }
.tt-gap text { fill: var(--bad-fg); font-weight: 700; }
.tt-c0 rect { fill: #2463d1; } .tt-c1 rect { fill: #1f8a4c; } .tt-c2 rect { fill: #b4541a; } .tt-c3 rect { fill: #7a3fc2; }
.tt-c4 rect { fill: #0f7c86; } .tt-c5 rect { fill: #b3306b; } .tt-c6 rect { fill: #5b6575; } .tt-c7 rect { fill: #8a6d00; }
@media (prefers-color-scheme: dark) {
  .tt-c0 rect { fill: #3b6fd6; } .tt-c1 rect { fill: #23854b; } .tt-c2 rect { fill: #b8612a; } .tt-c3 rect { fill: #8452c8; }
  .tt-c4 rect { fill: #188a94; } .tt-c5 rect { fill: #b8457a; } .tt-c6 rect { fill: #657084; } .tt-c7 rect { fill: #96780c; }
}
