/*======================================================================
 *| Kurztext      : Hallenplaner – Styles
 *|======================================================================
 *| Entwickler    : ZKI
 *|======================================================================
 *| Datum         : 31.10.2026
 *|======================================================================
 *| Beschreibung  : Mobile-first Layout, Hell-/Dunkelmodus, Kalenderraster.
 *|======================================================================
 *| ID    Entwickler   Datum
 *|
 *|======================================================================*/
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #1b1f24;
  --muted: #5d6673;
  --border: #dde1e6;
  --primary: #1f6feb;
  --primary-text: #ffffff;
  --danger: #cf222e;
  --ok: #1a7f37;
  --warn: #9a6700;
  --hour: 48px;
  --radius: 10px;
  --shadow: 0 4px 18px rgba(0,0,0,.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #20262e;
    --text: #e6e9ee;
    --muted: #9aa4b2;
    --border: #2c333d;
    --primary: #4c8dff;
    --danger: #ff6b6b;
    --ok: #4ac26b;
    --warn: #d4a72c;
    --shadow: 0 4px 18px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }

/* ---------- Buttons & Formulare ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; min-height: 38px;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.ok { color: var(--ok); border-color: var(--ok); }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn.icon { padding: 6px 10px; }
.btn:disabled { opacity: .5; cursor: default; }
label.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); min-height: 40px;
}
textarea { min-height: 70px; resize: vertical; }
/* Einheitlicher Auswahlpfeil mit genug Platz (statt gequetschtem Browser-Pfeil) */
select {
  -webkit-appearance: none; appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%238a94a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
}
/* Datum / Von / Bis im Buchungsformular */
.when { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
@media (max-width: 520px) { .when { grid-template-columns: 1fr 1fr; } .when-date { grid-column: 1 / -1; } }
input[type=checkbox] { width: auto; min-height: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stack { display: grid; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--danger); font-size: 14px; }

/* ---------- Ladezustand / Login ---------- */
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.login { width: 100%; max-width: 380px; }
.login h1 { margin: 8px 0 4px; font-size: 22px; }
.login .logo { width: 56px; height: 56px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 6px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Kopfzeile & Navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.brand img { width: 28px; height: 28px; }
.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tab { border: 0; background: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); position: relative; }
.tab.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; margin-left: 4px; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.userbox .who { text-align: right; line-height: 1.2; }
.role-pill { font-size: 11px; color: var(--muted); }
.banner { background: color-mix(in srgb, var(--warn) 15%, var(--surface)); border-bottom: 1px solid var(--border); padding: 8px 16px; font-size: 14px; white-space: pre-wrap; }

@media (max-width: 760px) {
  .tabs {
    position: fixed; bottom: 0; left: 0; right: 0; margin: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border);
    justify-content: space-around; padding: 6px 4px; padding-bottom: max(6px, env(safe-area-inset-bottom));
  }
  .tab { flex: 1; font-size: 12px; padding: 8px 4px; }
  .userbox .who { display: none; }
  main { padding-bottom: 80px; }
  .fab { bottom: calc(76px + env(safe-area-inset-bottom)) !important; }
}

main { padding: 12px 16px 24px; max-width: 1400px; margin: 0 auto; }

/* ---------- Kalender-Toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar .label { font-weight: 650; font-size: 17px; margin: 0 6px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--primary); color: var(--primary-text); }
.toolbar .spacer { flex: 1; }
.toolbar select { width: auto; min-width: 160px; }

/* ---------- Zeitraster (Tag/Woche) ---------- */
.tg { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 190px); }
.tg-head, .tg-body { display: grid; grid-template-columns: 52px repeat(var(--cols), minmax(var(--colmin, 110px), 1fr)); }
.tg-head { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--border); }
.tg-head > div { padding: 8px 6px; text-align: center; font-size: 13px; border-left: 1px solid var(--border); }
.tg-head > div:first-child { border-left: 0; }
.tg-head .today { color: var(--primary); font-weight: 700; }
.tg-head .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.tg-times { position: relative; }
.tg-times div { height: var(--hour); font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-7px); }
.tg-times div:first-child { transform: none; }
.tg-col {
  position: relative; border-left: 1px solid var(--border); cursor: cell;
  background-image: repeating-linear-gradient(to bottom, var(--border) 0 1px, transparent 1px calc(var(--hour) / 2), color-mix(in srgb, var(--border) 45%, transparent) calc(var(--hour) / 2) calc(var(--hour) / 2 + 1px), transparent calc(var(--hour) / 2 + 1px) var(--hour));
}
.tg-col.readonly { cursor: default; }
.tg-col.today { background-color: color-mix(in srgb, var(--primary) 5%, transparent); }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.ev {
  position: absolute; border-radius: 6px; padding: 3px 6px; font-size: 12px; line-height: 1.25; overflow: hidden;
  color: #fff; cursor: pointer; border: 1px solid rgba(0,0,0,.15); z-index: 2;
}
.ev b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev .t { opacity: .9; font-size: 11px; }
.ev.pending { background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.25) 0 6px, transparent 6px 12px); }
.ev.blackout { background: repeating-linear-gradient(45deg, #6e7781 0 8px, #57606a 8px 16px) !important; }
.ev:hover { filter: brightness(1.08); }

/* ---------- Monatsansicht ---------- */
.month { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.month .wd { padding: 6px; text-align: center; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); }
.month .cell { min-height: 96px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px; cursor: pointer; overflow: hidden; }
.month .cell:nth-child(7n) { border-right: 0; }
.month .cell.other { background: var(--surface-2); color: var(--muted); }
.month .num { font-size: 12px; font-weight: 600; }
.month .cell.today .num { background: var(--primary); color: #fff; border-radius: 10px; padding: 0 6px; }
.month .it { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
@media (max-width: 760px) { .month .cell { min-height: 64px; } .month .it span.tx { display: none; } }

/* ---------- Listen ---------- */
.list { display: grid; gap: 14px; }
.list h3 { margin: 4px 0; font-size: 14px; color: var(--muted); }
.item { display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; }
.item .bar { width: 5px; align-self: stretch; border-radius: 3px; flex: none; }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item .meta { font-size: 13px; color: var(--muted); }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--border); color: var(--muted); }
.tag.pending { color: var(--warn); border-color: var(--warn); }
.tag.blackout { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* ---------- Verwaltung ---------- */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
table.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.tbl th { background: var(--surface-2); font-size: 12px; color: var(--muted); font-weight: 600; }
.tbl select { width: auto; min-height: 32px; padding: 4px 8px; }
.tbl-wrap { overflow-x: auto; }
.bar-chart { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 70px; gap: 8px; align-items: center; font-size: 13px; }
.bar-row .b { height: 14px; border-radius: 4px; background: var(--primary); }
@media (max-width: 600px) { .bar-row { grid-template-columns: 100px 1fr 56px; } .grid2 { grid-template-columns: 1fr; } }

/* ---------- V2: Abteilungen, Serien, Freigaben ---------- */
.legend { display: flex; gap: 6px; flex-wrap: wrap; margin: -2px 0 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 16px; padding: 4px 10px; font-size: 13px; cursor: pointer; }
.chip.active { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); font-weight: 600; }
.access-card { margin-top: 12px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.warnbox { border: 1px solid var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.warnbox ul { margin: 6px 0; padding-left: 18px; }
.conflict { font-size: 13px; color: var(--warn); margin-top: 2px; }
fieldset.repeat { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px 12px; margin: 0; display: grid; gap: 10px; }
fieldset.repeat legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.weekdays { display: flex; gap: 6px; flex-wrap: wrap; }
.wdchip input { position: absolute; opacity: 0; pointer-events: none; }
.wdchip span { display: inline-grid; place-items: center; width: 42px; height: 38px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-weight: 600; user-select: none; }
.wdchip input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.wdchip input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.tag.rejected { color: var(--danger); border-color: var(--danger); }
.item.unseen { border-color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.item.approval .main { cursor: pointer; }
.welcome { border-color: var(--primary); }
.dept-list { display: grid; gap: 4px; }
.dept-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.dept-row:last-child { border-bottom: 0; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches .sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer; padding: 0; }
.month .it.pend { opacity: .7; font-style: italic; }
.ev i { font-style: italic; }

/* ---------- V3: Aushang (druckbar) ---------- */
.poster { background: #fff; color: #111; max-width: 720px; border-radius: 12px; padding: 40px 32px; text-align: center; border: 1px solid var(--border); }
.poster-logo { width: 84px; height: 84px; }
.poster h1 { margin: 10px 0 0; font-size: 40px; }
.poster h2 { margin: 2px 0 14px; font-size: 26px; font-weight: 600; color: #1f6feb; }
.poster-lead { font-size: 18px; margin: 0 auto 20px; max-width: 520px; }
.poster-qr { display: inline-block; padding: 10px; background: #fff; }
.poster-qr img, .poster-qr canvas { display: block; margin: 0 auto; }
.poster-url { font-size: 22px; font-weight: 700; margin-top: 8px; }
.poster-code { font-size: 22px; margin-top: 10px; }
.poster-code b { letter-spacing: 3px; }
.poster-steps { text-align: left; max-width: 520px; margin: 24px auto 0; font-size: 16px; display: grid; gap: 6px; }
@media print {
  @page { size: A4; margin: 15mm; }
  body { background: #fff !important; }
  body * { visibility: hidden; }
  .poster, .poster * { visibility: visible; }
  .poster { position: absolute; left: 0; top: 0; width: 100%; max-width: none; border: 0; }
}

/* ---------- Dialog / Toast / FAB ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 24px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow); max-height: calc(100vh - 40px); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.dlg-head h2 { margin: 0; font-size: 17px; }
.dlg-body { padding: 16px 18px; display: grid; gap: 12px; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--border); }
.dlg-foot .left { margin-right: auto; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #24292f; color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; transition: .25s; z-index: 100; max-width: calc(100vw - 32px); pointer-events: none; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); }
.fab { position: fixed; right: 20px; bottom: 24px; z-index: 25; border-radius: 28px; padding: 12px 20px; box-shadow: var(--shadow); font-weight: 600; }
