:root {
  --bg: #f6f4f1;
  --panel: #ffffff;
  --ink: #1f2430;
  --ink-2: #5b6170;
  --line: #e4e0da;
  --line-2: #efece7;
  --brand: #0b4f6c;        /* Bootshaus-Petrol */
  --brand-2: #e8f1f5;
  --accent: #f2a541;

  --st-reservierung: #1e88e5;
  --st-buchung: #3949ab;
  --st-paid: #e53935;
  --st-angebot: #43a047;
  --st-sperre: #fb8c00;
  --st-kontingent: #00acc1;

  --sat: #e9d5f5;
  --sun: #fbd3e4;
  --today: #d32f2f;

  --room-col: 210px;
  --day-w: 44px;
  --row-h: 34px;
  --radius: 8px;
  font-family: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  height: 54px; padding: 0 20px;
  background: var(--brand); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.brand-mark { width: 26px; height: 26px; border-radius: 6px;
  background: conic-gradient(var(--st-reservierung) 0 25%, var(--st-angebot) 0 50%, var(--st-sperre) 0 75%, var(--st-paid) 0); }
.nav { display: flex; gap: 2px; overflow-x: auto; }
.nav a { color: #d6e6ee; text-decoration: none; padding: 8px 12px; border-radius: 6px; white-space: nowrap; }
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.topbar .spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #d6e6ee; white-space: nowrap; }
.userbox button { background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 6px; padding: 4px 10px; cursor: pointer; }

main { height: calc(100% - 54px); overflow: auto; }
.page { padding: 20px; max-width: 1300px; margin: 0 auto; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 24px 0 10px; }

/* ---------- Schaltflächen & Formulare ---------- */
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 7px 14px; cursor: pointer; }
.btn:hover { border-color: #c9c3ba; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }
.btn.primary:hover { background: #0a4560; }
.btn.danger { color: #b71c1c; border-color: #f0c4c4; }
.btn.icon { padding: 7px 10px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; background: #fff; min-width: 0;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid #7fb3c9; outline-offset: 0; border-color: #7fb3c9; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.muted { color: var(--ink-2); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-2); font-size: 14px; }
table.list th { background: #faf8f5; font-weight: 600; color: var(--ink-2); font-size: 13px; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #f7fafb; }

/* ---------- Anmeldung ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(160deg, #0b4f6c 0%, #126b8f 55%, #f2a541 140%); }
.login { width: 100%; max-width: 360px; background: #fff; border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login .brand { color: var(--ink); font-size: 20px; }
.login .error { color: #b71c1c; font-size: 14px; min-height: 18px; }

/* ---------- Zimmerplan ---------- */
.plan-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; left: 0; }
.plan-toolbar .title { font-weight: 600; font-size: 17px; margin-right: 6px; min-width: 210px; }
.plan-toolbar .spacer { flex: 1; }
.plan-toolbar input[type=search] { width: 200px; }

.plan-wrap { height: calc(100% - 58px - 36px); overflow: auto; position: relative; background: var(--panel); }
.plan { position: relative; display: grid; grid-template-columns: var(--room-col) auto; min-width: max-content; user-select: none; }
.plan-corner { position: sticky; top: 0; left: 0; z-index: 6; background: var(--panel); border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  display: flex; align-items: flex-end; padding: 0 12px 8px; color: var(--ink-2); font-size: 13px; }
.plan-head { position: sticky; top: 0; z-index: 5; background: var(--panel); border-bottom: 1px solid var(--line); }
.months { display: flex; height: 22px; }
.months div { font-size: 12px; color: var(--ink-2); padding: 3px 6px; border-left: 1px solid var(--line-2); white-space: nowrap; overflow: hidden; }
.days { display: flex; }
.day { width: var(--day-w); flex: none; text-align: center; font-size: 12px; padding: 4px 0 6px; border-left: 1px solid var(--line-2); line-height: 1.15; }
.day b { display: block; font-size: 14px; color: var(--ink); }
.day.sat { background: var(--sat); }
.day.sun { background: var(--sun); }
.day.today b { color: #fff; background: var(--today); border-radius: 10px; display: inline-block; padding: 0 6px; }

.rooms-col { position: sticky; left: 0; z-index: 4; background: var(--panel); border-right: 1px solid var(--line); }
.room { height: var(--row-h); display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--line-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: none; opacity: .5; }
.room.over { color: var(--ink-2); font-style: italic; }
.room.over .dot { background: var(--ink-2); }

.grid-body { position: relative; }
.grow { display: flex; height: var(--row-h); border-bottom: 1px solid var(--line-2); }
.cell { width: var(--day-w); flex: none; border-left: 1px solid var(--line-2); }
.cell.sat { background: var(--sat); }
.cell.sun { background: var(--sun); }
.cell:hover { background: rgba(11,79,108,.08); }
.cell.sel { background: rgba(11,79,108,.22) !important; }
.today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--today); z-index: 2; pointer-events: none; opacity: .8; }

.bar { position: absolute; height: calc(var(--row-h) - 10px); border-radius: 12px; color: #fff; font-size: 12.5px; font-weight: 600;
  display: flex; align-items: center; gap: 6px; padding: 0 8px 0 3px; white-space: nowrap; overflow: hidden; cursor: grab; z-index: 3;
  box-shadow: 0 1px 2px rgba(0,0,0,.18); transition: filter .1s; }
.bar:hover { filter: brightness(1.08); z-index: 4; }
.bar.dragging { opacity: .85; cursor: grabbing; z-index: 10; box-shadow: 0 6px 16px rgba(0,0,0,.3); }
.bar .ch { flex: none; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 10px; background: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.bar .lbl { overflow: hidden; text-overflow: ellipsis; padding-left: 2px; }
.bar.st-reservierung { background: var(--st-reservierung); }
.bar.st-buchung { background: var(--st-buchung); }
.bar.st-angebot { background: var(--st-angebot); }
.bar.st-sperre { background: var(--st-sperre); }
.bar.st-kontingent { background: var(--st-kontingent); }
.bar.paid { background: var(--st-paid); }
.bar.dim { opacity: .25; }

.legend { height: 36px; display: flex; align-items: center; gap: 16px; padding: 0 16px; border-top: 1px solid var(--line); background: var(--panel); font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 10px; border-radius: 5px; display: inline-block; }
.legend .hint { margin-left: auto; }

/* ---------- Dialog ---------- */
dialog { border: none; border-radius: 12px; padding: 0; width: min(720px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(20,30,40,.45); }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.dlg-head h3 { margin: 0; font-size: 17px; flex: 1; }
.dlg-head .x { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--ink-2); }
.dlg-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; max-height: 70vh; overflow: auto; }
.dlg-foot { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: #faf8f5; border-radius: 0 0 12px 12px; }
.dlg-foot .spacer { flex: 1; }
.dlg-error { color: #b71c1c; font-size: 14px; }

.types { display: flex; gap: 6px; flex-wrap: wrap; }
.types button { border: 2px solid transparent; border-radius: 18px; padding: 6px 14px; cursor: pointer; color: #fff; font-weight: 600; opacity: .55; }
.types button.on { opacity: 1; border-color: rgba(0,0,0,.25); box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.types .t-reservierung { background: var(--st-reservierung); }
.types .t-buchung { background: var(--st-buchung); }
.types .t-angebot { background: var(--st-angebot); }
.types .t-sperre { background: var(--st-sperre); }
.types .t-kontingent { background: var(--st-kontingent); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
legend { font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 0 6px; }
.typeahead { position: relative; }
.ta-list { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 6px; z-index: 20; max-height: 220px; overflow: auto; box-shadow: 0 8px 20px rgba(0,0,0,.12); }
.ta-list div { padding: 8px 10px; cursor: pointer; font-size: 14px; }
.ta-list div:hover { background: var(--brand-2); }
.chip { display: inline-flex; align-items: center; gap: 8px; background: var(--brand-2); border-radius: 14px; padding: 4px 6px 4px 12px; font-size: 14px; }
.chip button { border: none; background: none; cursor: pointer; font-size: 16px; color: var(--ink-2); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1f2430; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 100; font-size: 14px; box-shadow: 0 8px 20px rgba(0,0,0,.3); }
.toast.err { background: #b71c1c; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: none; padding: 9px 14px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.keybox { font-family: ui-monospace, Consolas, monospace; background: #fff8e6; border: 1px solid #f1d38a; padding: 10px; border-radius: 6px; word-break: break-all; }
.status-pill { display: inline-block; padding: 2px 10px; border-radius: 10px; color: #fff; font-size: 12px; font-weight: 600; }

@media (max-width: 760px) {
  :root { --room-col: 120px; --day-w: 38px; }
  .topbar { gap: 10px; padding: 0 10px; }
  .brand span { display: none; }
  .userbox .who { display: none; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .plan-toolbar .title { min-width: 0; width: 100%; }
  .legend .hint { display: none; }
}

/* Familien-Zeilen (Termine) */
.room.person { font-weight: 600; background: #faf7fc; }
.room.person .dot { opacity: 1; width: 10px; height: 10px; }
.room.first, .grow.first { border-top: 3px solid #d9cfe3; }
.grow.person { background: #fcfaFD; }
.grow.person .cell.sat, .grow.person .cell.sun { opacity: .6; }
.bar.st-termin { padding-left: 8px; }
/* Kurze Termine: beim Darüberfahren ganzen Text zeigen */
.bar.st-termin:hover { width: max-content !important; min-width: var(--day-w); z-index: 8; padding-right: 10px; }

/* Typ-Auswahl nach Doppelklick */
.typemenu { position: fixed; z-index: 50; background: #fff; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  padding: 8px; display: flex; flex-direction: column; gap: 5px; min-width: 190px; }
.typemenu button { border: none; border-radius: 16px; padding: 7px 14px; color: #fff; font-weight: 600; cursor: grab; text-align: left; }
.typemenu button:hover { filter: brightness(1.1); }
.typemenu .t-reservierung { background: var(--st-reservierung); }
.typemenu .t-angebot { background: var(--st-angebot); }
.typemenu .t-sperre { background: var(--st-sperre); }
.typemenu .t-buchung { background: var(--st-buchung); }
.typemenu .t-kontingent { background: var(--st-kontingent); }
.typemenu .tm-hint { font-size: 11.5px; color: var(--ink-2); padding: 2px 4px 0; max-width: 190px; }

/* Entwurf & Griffe zum Ziehen */
.bar.draft { opacity: .9; outline: 2px dashed rgba(0,0,0,.35); outline-offset: 1px; z-index: 9; cursor: pointer; padding-left: 10px; }
.bar .rz { position: absolute; top: 0; bottom: 0; width: 9px; cursor: ew-resize; z-index: 2; }
.bar .rz-r { right: 0; border-radius: 0 12px 12px 0; }
.bar .rz-l { left: 0; border-radius: 12px 0 0 12px; }
.bar:hover .rz { background: rgba(255,255,255,.35); }
.bar.draft .rz-r { background: rgba(255,255,255,.5); }

/* Mouse-over-Info */
.bar-tip { position: fixed; z-index: 60; background: #fff; border-radius: 8px; box-shadow: 0 10px 28px rgba(0,0,0,.25); padding: 10px 12px; min-width: 240px; max-width: 340px; font-size: 13px; pointer-events: none; }
.bar-tip .tip-head { font-weight: 700; font-size: 14.5px; border-left: 4px solid; padding-left: 8px; margin-bottom: 6px; }
.bar-tip div:not(.tip-head) { display: flex; gap: 8px; padding: 1px 0; }
.bar-tip span { color: var(--ink-2); min-width: 92px; }
.bar-tip b { font-weight: 600; }

/* Karte nach Klick */
.bar-card { position: fixed; z-index: 55; background: #fff; border-radius: 12px; box-shadow: 0 14px 40px rgba(0,0,0,.3); padding: 16px; width: 320px; display: flex; flex-direction: column; gap: 8px; }
.bar-card .x { position: absolute; right: 10px; top: 6px; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink-2); }
.bar-card .bc-name { font-weight: 700; font-size: 17px; padding-right: 20px; }
.bar-card .bc-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; font-size: 14px; }
.bar-card .bc-actions { display: flex; gap: 8px; margin-top: 4px; }
.bar-card .bc-actions .btn { flex: 1; }

/* Seitenleiste „Neu erstellen“ */
.side-panel { position: fixed; z-index: 40; top: 54px; right: 0; bottom: 0; width: 340px; max-width: 100vw; background: #fff; box-shadow: -10px 0 30px rgba(0,0,0,.18); display: flex; flex-direction: column; }
.side-panel .sp-head { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.side-panel .sp-head h3 { margin: 0; flex: 1; font-size: 17px; }
.side-panel .x { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink-2); }
.side-panel .sp-body { flex: 1; overflow: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.side-panel .sp-sub { font-weight: 600; font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.side-panel .sp-room { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.side-panel .sp-room-top { display: flex; justify-content: space-between; align-items: center; }
.side-panel .sp-foot { padding: 12px 16px; border-top: 1px solid var(--line); }

/* Großes Fenster */
dialog.wide { width: min(1000px, calc(100vw - 32px)); }
dialog.wide .dlg-body { max-height: 74vh; }
.room-line { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 10px; }
.room-line .rl-head { display: flex; align-items: center; gap: 12px; }
.room-line .rl-head select { font-weight: 600; min-width: 220px; }
.room-line .rl-price { margin-left: auto; font-weight: 700; }
.with-btn { display: flex; gap: 6px; }
.with-btn input { flex: 1; }
table.list tr.sel td { background: var(--brand-2) !important; }
.stammgast { background: #fff8e1; border: 1px solid #f3d27a; border-radius: 8px; padding: 8px 10px; font-size: 13.5px; line-height: 1.5; }
.stammgast .btn { margin-left: 6px; padding: 3px 10px; font-size: 13px; }
.pay-add { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.pay-add #payAdd { grid-column: span 2; }
.pay-sum { display: flex; flex-direction: column; gap: 3px; font-size: 14px; }
.pay-sum div { display: flex; justify-content: space-between; }
.pay-sum .pay-open { margin-top: 4px; padding: 6px 8px; border-radius: 6px; font-weight: 700; }
.pay-sum .pay-open.open { background: #fdecea; color: #b71c1c; }
.pay-sum .pay-open.ok { background: #e8f5e9; color: #2e7d32; }
.pay-sum .pay-open.over { background: #fff3e0; color: #e65100; }
.x-mini { border: none; background: none; cursor: pointer; color: var(--ink-2); font-size: 16px; }
@media (max-width: 760px) { .pay-add { grid-template-columns: 1fr 1fr; } }
.map-row { display: grid; grid-template-columns: 220px 1fr; gap: 10px; align-items: start; border-top: 1px solid var(--line-2); padding-top: 8px; }
.map-label { font-weight: 600; font-size: 14px; }
.map-rooms { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.map-rooms label.check { font-size: 13px; }
@media (max-width: 760px) { .map-row { grid-template-columns: 1fr; } }

/* Abrechnung */
.report-cards { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.report-cards .rc { background: var(--panel, #fff); border: 1px solid var(--line, #dde3ea); border-radius: 10px; padding: 10px 14px; min-width: 160px; display: flex; flex-direction: column; gap: 4px; }
.report-cards .rc span { font-size: 13px; color: var(--muted, #667); }
.report-cards .rc b { font-size: 18px; }
.report-cards .rc.sum { border-color: var(--accent, #2b6cb0); background: #eef5ff; }
.taxrow { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 10px 0 4px; }
.taxrow label { max-width: 140px; }
@media print { .topbar, #mPrev, #mNext, #mVal, #mXlsx, #mPrint { display: none !important; } }
.dep-info { margin-top: 8px; font-size: 13.5px; line-height: 1.5; }
.dep-info:empty { display: none; }
table.list td[style*="text-align:right"] { white-space: nowrap; }
.inv-lines input, .inv-lines select { width: 100%; box-sizing: border-box; }
