
/* Layout: Buchaufschlag mit zwei Tagesseiten nebeneinander, unter 900px nur eine Seite. */
:root {
  --desk: #dfe5ec;
  --paper: #ffffff;
  --paper-edge: #c5cdd8;
  --ink: #1c2530;
  --muted: #647182;
  --rule: #d3dae2;
  --accent: #1d6aae;
  --accent-ink: #ffffff;
  --accent-soft: #e3eef9;
  --holiday: #b3412e;
  --warn-bg: #fff3d6;
  --warn-ink: #6f4500;
  --danger: #b3261e;
  --shadow: rgba(20, 30, 45, 0.18);
  --font-ui: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #0f1419;
    --paper: #1a212a;
    --paper-edge: #2c3744;
    --ink: #e6ebf1;
    --muted: #9aa7b6;
    --rule: #2f3a47;
    --accent: #5aa6e6;
    --accent-ink: #0b1620;
    --accent-soft: #1d3247;
    --holiday: #ff8f7a;
    --warn-bg: #3a2f12;
    --warn-ink: #f3d58a;
    --danger: #ff8f86;
    --shadow: rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --desk: #0f1419;
  --paper: #1a212a;
  --paper-edge: #2c3744;
  --ink: #e6ebf1;
  --muted: #9aa7b6;
  --rule: #2f3a47;
  --accent: #5aa6e6;
  --accent-ink: #0b1620;
  --accent-soft: #1d3247;
  --holiday: #ff8f7a;
  --warn-bg: #3a2f12;
  --warn-ink: #f3d58a;
  --danger: #ff8f86;
  --shadow: rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--desk); color: var(--ink); font: 16px/1.35 var(--font-ui); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Obere Leiste */
.bar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 16px; background: var(--paper); border-bottom: 2px solid var(--accent); }
.bar h1 { margin: 0 6px 0 0; font-size: 21px; font-weight: 600; color: var(--accent); letter-spacing: 0.01em; }
.nav { display: flex; align-items: center; gap: 6px; }
.nav input[type="date"] { width: auto; }
.search { position: relative; flex: 1 1 220px; max-width: 380px; }
.grow { flex: 1; }
.sync { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.sync[data-k="ok"]::before { background: #2e9d5b; }
.sync[data-k="slow"]::before, .sync[data-k="local"]::before { background: #d68a00; }
.sync[data-k="error"]::before { background: var(--danger); }

.btn { border: 1px solid var(--rule); background: var(--paper); border-radius: 6px; padding: 7px 13px; min-height: 38px; }
.btn:hover { background: var(--accent-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: 0.6; cursor: default; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 14px; }
.btn.icon { width: 38px; padding: 0; display: grid; place-items: center; font-size: 22px; line-height: 1; }
.btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.link { border: 0; background: none; color: var(--accent); padding: 2px 4px; text-decoration: underline; }
input, textarea { width: 100%; border: 1px solid var(--rule); background: var(--paper); border-radius: 6px; padding: 8px 10px; min-height: 38px; }
input:focus, textarea:focus { border-color: var(--accent); }

.results { position: absolute; top: 44px; left: 0; right: 0; z-index: 30; max-height: 60vh; overflow: auto; background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; box-shadow: 0 10px 28px var(--shadow); }
.results .rh { padding: 8px 12px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--rule); }
.results button { display: block; width: 100%; text-align: left; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--rule); background: none; }
.results button:hover, .results button:focus-visible { background: var(--accent-soft); }
.results .r1 { font-weight: 600; font-variant-numeric: tabular-nums; }
.results .r2 { font-size: 14px; color: var(--muted); }

/* Buchaufschlag */
.spread { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 1500px; margin: 18px auto 40px; padding: 0 16px; }
.page { position: relative; container-type: inline-size; background: var(--paper); border: 1px solid var(--paper-edge); padding: 18px 20px 14px; }
.page.left { border-right: 0; border-radius: 4px 0 0 4px; box-shadow: inset -28px 0 26px -28px var(--shadow); }
.page.right { border-left: 0; border-radius: 0 4px 4px 0; box-shadow: inset 28px 0 26px -28px var(--shadow); }
@media (max-width: 899px) {
  .spread { grid-template-columns: minmax(0, 1fr); padding: 0 10px; margin-top: 10px; }
  .page.right { display: none; }
  .page.left { border: 1px solid var(--paper-edge); border-radius: 4px; box-shadow: none; padding: 14px 12px 12px; }
}

.phead { display: flex; align-items: flex-start; gap: 16px; padding-bottom: 8px; border-bottom: 2px solid var(--accent); }
.meta { min-width: 96px; padding-left: 10px; border-left: 6px solid var(--accent); }
.mon { color: var(--accent); font-size: 22px; font-weight: 500; line-height: 1.1; }
.kw { margin-top: 12px; font-size: 18px; font-weight: 600; }
.kw .of { font-weight: 300; color: var(--muted); }
.doy { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dnum { font-size: 56px; font-weight: 400; line-height: 0.95; font-variant-numeric: tabular-nums; }
.dnum.red { color: var(--accent); }
.dname { flex: 1; min-width: 0; padding-top: 2px; }
.dname .wd { font-size: 17px; }
.dname .hol { margin-top: 2px; font-size: 14px; color: var(--muted); }
.dname .hol.legal { color: var(--holiday); font-weight: 600; }
.dname .cnt { margin-top: 6px; font-size: 13px; color: var(--accent); font-weight: 600; }
.badge { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 600; vertical-align: 2px; }
.page.right .phead { flex-direction: row-reverse; }
.page.right .meta { border-left: 0; border-right: 6px solid var(--accent); padding-left: 0; padding-right: 10px; text-align: right; }

.pbody { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 0 16px; }
@container (max-width: 620px) {
  .pbody { grid-template-columns: minmax(0, 1fr); }
  .notes { margin-top: 14px; }
  .dnum { font-size: 46px; }
}
.hrow { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr); min-height: 46px; border-bottom: 1px solid var(--rule); cursor: cell; }
.hrow:hover { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.hl { padding-top: 7px; font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.slot { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 4px 26px 4px 4px; }
.addslot { position: absolute; right: 2px; top: 6px; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--accent); font-size: 20px; line-height: 1; opacity: 0; }
.hrow:hover .addslot, .addslot:focus-visible { opacity: 1; }
@media (hover: none) { .addslot { opacity: 0.55; } }

.entry { display: block; width: 100%; min-width: 0; text-align: left; padding: 5px 8px; border: 1px solid transparent; border-left: 4px solid var(--accent); border-radius: 3px; background: var(--accent-soft); }
.entry:hover { border-color: var(--accent); }
.e1 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.e1 .t { font-weight: 700; font-variant-numeric: tabular-nums; }
.e1 .nm { font-weight: 600; overflow-wrap: anywhere; }
.e1 .ph { font-size: 13px; color: var(--muted); }
.e2 { font-size: 14.5px; overflow-wrap: anywhere; }
.e2 .arr { padding: 0 4px; color: var(--accent); font-weight: 700; }
.e3 { font-size: 13px; color: var(--muted); font-style: italic; overflow-wrap: anywhere; }
.e3 .drv { font-style: normal; font-weight: 600; color: var(--ink); }

.notes { display: flex; flex-direction: column; }
.notes label { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding-bottom: 6px; }
.notes textarea { flex: 1; min-height: 340px; resize: none; border: 0; border-radius: 0; padding: 0 4px; line-height: 32px; background: repeating-linear-gradient(to bottom, transparent 0, transparent 31px, var(--rule) 31px, var(--rule) 32px) local; }
.notes textarea:focus { outline: none; background-color: color-mix(in srgb, var(--accent-soft) 40%, transparent); }

.pfoot { margin-top: 14px; padding-top: 8px; border-top: 2px solid var(--accent); }
.mt { margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--accent); }
.mini { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; max-width: 280px; font-size: 12px; font-variant-numeric: tabular-nums; }
.mini .mw { text-align: center; color: var(--muted); font-size: 11px; }
.mini button { position: relative; border: 0; border-radius: 3px; background: none; padding: 4px 0; }
.mini button:hover { background: var(--accent-soft); }
.mini .we { color: var(--accent); }
.mini .today { outline: 1px solid var(--accent); }
.mini .cur { background: var(--accent); color: var(--accent-ink); }
.mini .has::after { content: ""; position: absolute; left: 50%; bottom: 1px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
.mini .cur.has::after { background: var(--accent-ink); }

/* Dialog */
.overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 3vh 12px; overflow: auto; background: rgba(10, 16, 24, 0.55); }
.dlg { width: 100%; max-width: 880px; background: var(--paper); border: 1px solid var(--paper-edge); border-top: 4px solid var(--accent); border-radius: 6px; box-shadow: 0 20px 60px var(--shadow); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 4px; }
.dlg-head h2 { margin: 0; font-size: 21px; font-weight: 600; }
.dlg-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; padding: 10px 18px 6px; }
@media (max-width: 720px) { .dlg-body { grid-template-columns: minmax(0, 1fr); } }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start; }
.fields label, .typed label { display: block; margin-bottom: 3px; font-size: 13px; font-weight: 600; color: var(--muted); }
.fields .wide { grid-column: 1 / -1; }
.fields textarea { min-height: 64px; resize: vertical; }
.dates h3 { margin: 0; font-size: 15px; font-weight: 600; }
.dates-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.cal-title { font-weight: 600; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal .cw { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; }
.cd { min-height: 38px; border: 1px solid transparent; border-radius: 6px; background: none; font-variant-numeric: tabular-nums; }
.cd:hover { background: var(--accent-soft); }
.cd.we { color: var(--accent); }
.cd.today { border-color: var(--accent); }
.cd.sel { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.cd.anchor { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent); }
.hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.typed { margin-top: 10px; }
.typed-row { display: flex; gap: 6px; }
.chips-head { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 14px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 118px; overflow: auto; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 10px; border-radius: 14px; background: var(--accent-soft); font-size: 14px; font-variant-numeric: tabular-nums; }
.chip button { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: none; font-size: 17px; line-height: 1; }
.chip button:hover { background: var(--accent); color: var(--accent-ink); }
.dlg-foot { padding: 8px 18px 16px; }
.dup { margin: 4px 0 10px; padding: 8px 12px; border-radius: 6px; background: var(--warn-bg); color: var(--warn-ink); font-size: 14px; }
.formmsg { min-height: 20px; margin-bottom: 6px; color: var(--danger); font-weight: 600; font-size: 14px; }
.foot-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.delpanel { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--danger); border-radius: 6px; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; font-size: 14.5px; }
.check input { width: 20px; min-height: 20px; margin-top: 2px; }
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 60; max-width: calc(100% - 32px); transform: translateX(-50%); padding: 10px 18px; border-radius: 8px; background: var(--ink); color: var(--paper); font-size: 15px; box-shadow: 0 8px 24px var(--shadow); }
.toast.err { background: var(--danger); color: #fff; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: no-preference) {
  .btn, .entry, .cd { transition: background-color 0.12s, border-color 0.12s; }
}

/* Anmeldung */
.loginwrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; padding: 26px 24px 22px; background: var(--paper); border: 1px solid var(--paper-edge); border-top: 4px solid var(--accent); border-radius: 6px; box-shadow: 0 16px 48px var(--shadow); }
.login h1 { margin: 0 0 4px; font-size: 24px; font-weight: 600; color: var(--accent); }
.login p { margin: 0 0 16px; color: var(--muted); font-size: 15px; }
.login label { display: block; margin: 12px 0 3px; font-size: 13px; font-weight: 600; color: var(--muted); }
.login .btn { width: 100%; margin-top: 18px; }
.login .formmsg { margin: 10px 0 0; }
/* Konto und Benutzer */
.acc { max-width: 640px; }
.acc-body { padding: 4px 18px 18px; display: grid; gap: 18px; }
.acc h3 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.acc label { display: block; margin: 8px 0 3px; font-size: 13px; font-weight: 600; color: var(--muted); }
.acc .formmsg { min-height: 0; margin: 8px 0 0; }
.formmsg.ok { color: #2e7d4f; }
.urow { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.urow.off .uname { opacity: 0.6; }
.ulogin { color: var(--muted); font-size: 14px; }
.uact { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.uact select { width: auto; min-height: 32px; padding: 3px 8px; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); }
.pwrow { display: flex; gap: 6px; }
.umsg { color: var(--danger); font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.audit { margin: 0 0 8px; }
/* Nur lesen */
.ro .addslot { display: none; }
.ro .hrow { cursor: default; }
.ro .hrow:hover { background: none; }
.sel { width: 100%; min-height: 38px; padding: 7px 10px; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); }
