:root {
  --salbei: #728361; --tanne: #204c23; --mitternacht: #19271d; --cashmere: #e3dec2;
  --sienna: #773d32; --terracotta: #e49c62;
  --bg: #f5f2e8; --surface: #ffffff; --surface-2: #faf8f1; --line: #e2ddcc; --line-strong: #cfc8b0;
  --text: #19271d; --muted: #66705f; --danger: #a33a2b; --warn: #b8741f; --ok: #3f6b2f;
  --radius: 10px; --shadow: 0 1px 2px rgba(25,39,29,.06), 0 6px 20px rgba(25,39,29,.07);
  --font: "Nudista", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --serif: "Le Monde Livre Std", "Le Monde Livre", Georgia, "Times New Roman", serif;
  --hour: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--tanne); }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }

/* ---------- Layout ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 56px;
  background: var(--mitternacht); color: var(--cashmere); }
.brand { font-family: var(--serif); font-weight: 700; font-size: 19px; letter-spacing: .01em; white-space: nowrap; }
.brand small { font-family: var(--font); font-weight: 400; font-size: 12px; opacity: .7; margin-left: 6px; letter-spacing: .08em; text-transform: uppercase; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a { color: var(--cashmere); text-decoration: none; padding: 8px 12px; border-radius: 8px; opacity: .78; white-space: nowrap; }
.nav a:hover { opacity: 1; background: rgba(227,222,194,.08); }
.nav a.on { opacity: 1; background: rgba(227,222,194,.14); }
.who { font-size: 12px; opacity: .8; white-space: nowrap; display: flex; gap: 10px; align-items: center; }
.who button { background: none; border: 1px solid rgba(227,222,194,.3); color: var(--cashmere); border-radius: 6px; padding: 3px 9px; cursor: pointer; }
.demo-flag { background: var(--terracotta); color: var(--mitternacht); font-weight: 600; font-size: 11px; padding: 2px 8px; border-radius: 99px; }
main { padding: 20px; max-width: 1600px; margin: 0 auto; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.pagehead { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); padding: 7px 13px;
  border-radius: 8px; cursor: pointer; white-space: nowrap; line-height: 1.2; text-decoration: none; color: var(--text); }
.btn:hover { border-color: var(--salbei); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--tanne); border-color: var(--tanne); color: #fff; }
.btn.primary:hover { background: var(--mitternacht); }
.btn.danger { color: var(--danger); border-color: #e3bdb6; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.icon { padding: 6px 9px; }
.seg { display: inline-flex; align-self: flex-start; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 7px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--tanne); color: #fff; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password], input[type=date], input[type=time], input[type=datetime-local], select, textarea {
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--salbei); outline-offset: 1px; }
textarea { resize: vertical; min-height: 64px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
label.f > span { text-transform: uppercase; font-size: 11px; }
label.chk { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.full { grid-column: 1 / -1; }

/* ---------- Cards / tables ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.tile .v { font-family: var(--serif); font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.requested { background: #fff4e0; border-color: #f0d29e; color: #7a4f12; }
.pill.confirmed { background: #eef3e8; border-color: #cfdcc2; color: var(--tanne); }
.pill.arrived { background: #e3eef6; border-color: #bcd3e6; color: #24506f; }
.pill.completed { background: #e9e9e4; border-color: #d6d6cc; color: #4b4b42; }
.pill.cancelled, .pill.noshow { background: #f8e8e5; border-color: #e8c3bb; color: var(--danger); }
.pill.billed { background: #e6f0e1; border-color: #bed6b1; color: var(--ok); }
.pill.open { background: #fff4e0; border-color: #f0d29e; color: #7a4f12; }
.pill.error { background: #f8e8e5; border-color: #e8c3bb; color: var(--danger); }
.pill.free { background: var(--surface-2); color: var(--muted); }
.pill.hotel { background: var(--tanne); border-color: var(--tanne); color: #fff; }
.pill.external { background: var(--cashmere); border-color: #d2cba9; color: var(--mitternacht); }

/* ---------- Kalender ---------- */
.calbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.calbar .date-title { font-family: var(--serif); font-size: 22px; font-weight: 700; min-width: 230px; }
.cal { display: grid; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 150px); }
.cal-head { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 8px; font-weight: 600;
  display: flex; align-items: center; gap: 7px; min-width: 0; }
.cal-head .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.cal-head .sub { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.cal-head.corner { left: 0; z-index: 6; }
.cal-times { position: sticky; left: 0; z-index: 4; background: var(--surface); border-right: 1px solid var(--line); }
.cal-times div:first-child { transform: none; }
.cal-times div { height: var(--hour); font-size: 11px; color: var(--muted); text-align: right; padding: 0 8px; transform: translateY(-7px); font-variant-numeric: tabular-nums; }
.cal-col { position: relative; border-right: 1px solid var(--line); cursor: copy;
  background-image: linear-gradient(to bottom, var(--line) 1px, transparent 1px), linear-gradient(to bottom, #f1eee3 1px, transparent 1px);
  background-size: 100% var(--hour), 100% calc(var(--hour) / 4); }
.cal-col:last-child { border-right: 0; }
.cal-off { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(135deg, rgba(25,39,29,.035) 0 6px, rgba(25,39,29,.07) 6px 12px); pointer-events: none; }
.cal-block { position: absolute; left: 2px; right: 2px; background: repeating-linear-gradient(135deg, #f3e2dc 0 6px, #ead1c8 6px 12px); border: 1px dashed #d6aa9d;
  border-radius: 6px; font-size: 11px; color: var(--sienna); padding: 3px 6px; cursor: pointer; overflow: hidden; z-index: 1; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--sienna); z-index: 3; pointer-events: none; }
.cal-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--sienna); }
.ev { position: absolute; border-radius: 7px; padding: 4px 7px; font-size: 12px; line-height: 1.25; overflow: hidden; cursor: pointer; z-index: 2;
  background: #fff; border: 1px solid var(--line-strong); border-left: 4px solid var(--salbei); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.ev:hover { box-shadow: 0 3px 10px rgba(25,39,29,.18); z-index: 4; }
.ev b { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev .m { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.ev .buf { position: absolute; left: 0; right: 0; bottom: 0; background: repeating-linear-gradient(135deg, transparent 0 4px, rgba(25,39,29,.06) 4px 8px); }
.ev.requested { border-style: dashed; background: #fffaf0; }
.ev.arrived { background: #f0f6fb; }
.ev.completed { opacity: .72; }
.ev.noshow { opacity: .55; text-decoration: line-through; }
.ev.cancelled { opacity: .45; text-decoration: line-through; }
.ev .badges { position: absolute; top: 4px; right: 5px; display: flex; gap: 3px; }
.ev .badges i { font-style: normal; font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 4px; background: var(--tanne); color: #fff; }
.ev .badges i.e { background: var(--cashmere); color: var(--mitternacht); }
.ev .badges i.ok { background: var(--ok); }
.slot-cap { font-variant-numeric: tabular-nums; }

.week { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 10px; overflow-x: auto; }
.week .day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 240px; }
.week .day h3 { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; cursor: pointer; }
.week .day.today h3 { color: var(--sienna); }
.week .wi { padding: 7px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.week .wi:hover { background: var(--surface-2); }
.week .wi .tm { font-variant-numeric: tabular-nums; font-weight: 600; margin-right: 4px; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(25,39,29,.45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 720px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 900px; }
.modal header { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal header h2 { flex: 1; }
.modal .body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal footer { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 14px 14px; }
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-bottom: -4px; }
.times { display: flex; flex-wrap: wrap; gap: 6px; max-height: 150px; overflow-y: auto; padding: 2px; }
.times button { border: 1px solid var(--line-strong); background: #fff; border-radius: 7px; padding: 5px 9px; cursor: pointer; font-variant-numeric: tabular-nums; }
.times button.on { background: var(--tanne); color: #fff; border-color: var(--tanne); }
.times button small { opacity: .7; margin-left: 3px; }
.guest-list { border: 1px solid var(--line); border-radius: 8px; max-height: 200px; overflow-y: auto; }
.guest-list div { padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; gap: 10px; align-items: center; }
.guest-list div:last-child { border-bottom: 0; }
.guest-list div:hover, .guest-list div.on { background: #eef3e8; }
.guest-list .room { font-weight: 700; min-width: 42px; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.items { border: 1px solid var(--line); border-radius: 8px; }
.items div { padding: 8px 10px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; }
.items div:last-child { border-bottom: 0; }
.log { font-size: 12px; color: var(--muted); max-height: 140px; overflow-y: auto; }
.notice { border-radius: 8px; padding: 10px 12px; background: #eef3e8; border: 1px solid #cfdcc2; }
.notice.warn { background: #fff4e0; border-color: #f0d29e; }
.notice.err { background: #f8e8e5; border-color: #e8c3bb; color: var(--danger); }
.sched { display: grid; grid-template-columns: 50px 30px minmax(0,150px) minmax(0,150px); gap: 6px 10px; align-items: center; }
.pkg-items .r { display: grid; grid-template-columns: 120px 1fr 110px 36px; gap: 8px; margin-bottom: 6px; }
pre.code { background: var(--mitternacht); color: var(--cashmere); padding: 14px; border-radius: 8px; overflow-x: auto; font-size: 12.5px; white-space: pre-wrap; word-break: break-all; }

/* ---------- Toast & Login ---------- */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--mitternacht); color: var(--cashmere); padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow); max-width: 380px; animation: tin .2s ease; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
.login { max-width: 360px; margin: 14vh auto; padding: 28px; }
.login h1 { margin-bottom: 4px; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }

@media (max-width: 760px) {
  main { padding: 12px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .brand small, .who span { display: none; }
  .kv { grid-template-columns: 1fr; }
  .calbar .date-title { min-width: 0; font-size: 18px; width: 100%; order: -1; }
}
@media print {
  .topbar, .calbar .btn, #toast-root { display: none !important; }
  .cal { max-height: none; box-shadow: none; }
}
