:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #64707d;
  --line: #e3e8ee;
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --primary-soft: #e8effd;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --warn: #b7791f;
  --warn-soft: #fff6e0;
  --ok: #2f855a;
  --ok-soft: #e7f6ed;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --cell: 38px;
  --roomcol: 120px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; color: var(--text); background: var(--bg); line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Raspored ---------- */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: #0f1e3d; color: #d7e0f2; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: #fff; font-weight: 700; font-size: 16px; }
.brand img { width: 30px; height: 30px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #cfdaf0;
  text-decoration: none; font-size: 15px;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav .sep { height: 1px; background: rgba(255,255,255,.1); margin: 10px 6px; }
.nav .ico { width: 20px; text-align: center; }
.sidebar .user { margin-top: auto; padding: 12px 10px 0; font-size: 13px; color: #9fb0d0; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar .user-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.sidebar .user-actions .btn, .sidebar .user-actions button { width: 100%; margin: 0; background: transparent; color: #cfdaf0; border: 1px solid rgba(255,255,255,.2); }
.sidebar .user-actions .btn:hover, .sidebar .user-actions button:hover { background: rgba(255,255,255,.08); color: #fff; }
.main { min-width: 0; padding: 22px 26px 60px; }
.backdrop { display: none; }
.content { min-width: 0; }
.topbar { display: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0; width: 260px; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 4px 0 20px rgba(0,0,0,.2);
  }
  .layout.menu-open .sidebar { transform: translateX(0); }
  .backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  .layout.menu-open .backdrop { display: block; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30;
    background: #0f1e3d; color: #fff; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
  }
  .topbar .title { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar button { background: transparent; border: 0; color: #fff; font-size: 22px; padding: 4px 8px; cursor: pointer; }
  .topbar .add { background: var(--primary); border-radius: 8px; font-size: 15px; padding: 7px 12px; font-weight: 600; }
  .main { padding: 14px 12px 80px; }
  h1 { font-size: 19px; }
  :root { --roomcol: 74px; --cell: 34px; }
}

/* ---------- Kartice ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.cols-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } .grid.cols-4 { grid-template-columns: 1fr 1fr; } }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .v { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }

/* ---------- Gumbi i polja ---------- */
button, .btn {
  font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 8px;
  text-decoration: none; font-weight: 500; white-space: nowrap; min-height: 38px;
}
button:hover, .btn:hover { background: #f7f9fb; }
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--primary-dark); }
button.danger { color: var(--danger); border-color: #f1c5c0; }
button.danger:hover { background: var(--danger-soft); }
button.link { border: 0; background: none; color: var(--primary); padding: 4px 6px; min-height: 0; }
button.sm, .btn.sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
button:disabled { opacity: .55; cursor: not-allowed; }
.sidebar button { background: transparent; color: #cfdaf0; border-color: rgba(255,255,255,.2); }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input, select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid #cfd7df; border-radius: 8px; background: #fff; color: var(--text);
  min-height: 38px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(29,78,216,.25); border-color: var(--primary); }
textarea { min-height: 90px; resize: vertical; }
input[type=checkbox] { width: auto; min-height: 0; margin: 0; transform: scale(1.15); }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text); margin: 6px 0; cursor: pointer; }
.field { margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }
.sticky-save {
  position: sticky; bottom: 0; background: rgba(244,246,248,.95); padding: 12px 0; display: flex; gap: 8px;
  justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); margin-top: 8px; z-index: 5;
}
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- Tablice i popisi ---------- */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #f6f8fd; }
.table-wrap { overflow-x: auto; }
.items { list-style: none; margin: 0; padding: 0; }
.items li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.items li:last-child { border-bottom: 0; }
.items li a { text-decoration: none; color: inherit; flex: 1; min-width: 0; }
.items .t { font-weight: 600; }
.empty { color: var(--muted); padding: 10px 0; font-size: 14px; }
@media (max-width: 700px) {
  table.responsive thead { display: none; }
  table.responsive tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 4px; }
  table.responsive td { display: flex; justify-content: space-between; gap: 10px; border: 0; padding: 3px 8px; }
  table.responsive td::before { content: attr(data-l); color: var(--muted); font-size: 13px; }
}

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; background: #eef1f4; color: #4a5562; white-space: nowrap; }
.badge.potvrdjena { background: #e0f2fe; color: #075985; }
.badge.na_cekanju { background: var(--warn-soft); color: var(--warn); }
.badge.prijavljen { background: var(--ok-soft); color: var(--ok); }
.badge.odjavljen { background: #eef1f4; color: #4a5562; }
.badge.otkazana { background: var(--danger-soft); color: var(--danger); }
.badge.paid { background: var(--ok-soft); color: var(--ok); }
.badge.unpaid { background: var(--danger-soft); color: var(--danger); }

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.alert.warn { background: var(--warn-soft); color: #7a5410; border: 1px solid #f3dca5; }
.alert.err { background: var(--danger-soft); color: #8b2a20; border: 1px solid #f1c5c0; }
.alert.ok { background: var(--ok-soft); color: #22603f; border: 1px solid #bfe3cd; }
.alert.info { background: var(--primary-soft); color: #1e3a8a; border: 1px solid #bfd3f5; }

/* ---------- Kalendar ---------- */
.cal-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.cal-toolbar input[type=date] { width: auto; }
.cal-toolbar select { width: auto; }
.cal-scroll { overflow: auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); max-height: calc(100vh - 170px); }
.cal { display: grid; position: relative; min-width: max-content; }
.cal .cell {
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); height: 44px; background: #fff;
}
.cal .cell.free { cursor: pointer; }
.cal .cell.free:hover { background: var(--primary-soft); }
.cal .cell.we { background: #fafbfc; }
.cal .cell.today { background: #fffbea; }
.cal .head {
  position: sticky; top: 0; z-index: 3; background: #fff; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line);
  text-align: center; font-size: 12px; padding: 4px 0; line-height: 1.2;
}
.cal .head .d { font-size: 15px; font-weight: 700; }
.cal .head.we { color: #b45309; background: #fffaf3; }
.cal .head.today { background: var(--primary); color: #fff; }
.cal .head.free-row { top: 47px; font-size: 11px; padding: 2px 0; color: var(--ok); font-weight: 700; }
.cal .head.free-row.full { color: #fff; background: var(--danger); }
.cal .roomh {
  position: sticky; left: 0; z-index: 2; background: #fff; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 4px 8px; font-size: 13px; display: flex; flex-direction: column; justify-content: center; line-height: 1.15;
}
.cal .roomh b { font-size: 14px; }
.cal .roomh span { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .corner { position: sticky; left: 0; top: 0; z-index: 4; background: #fff; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 12px; padding: 6px 8px; color: var(--muted); }
.cal .corner.free-row { top: 47px; padding: 2px 8px; font-size: 11px; }
.cal .bar {
  z-index: 1; margin: 6px 0; border-radius: 6px; padding: 0 7px; font-size: 12px; color: #fff; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; display: flex; align-items: center; cursor: pointer; text-decoration: none;
  background: #0891b2; box-shadow: 0 1px 2px rgba(0,0,0,.15); font-weight: 600;
}
.cal .bar:hover { filter: brightness(1.08); }
.cal .bar.na_cekanju { background: #d97706; }
.cal .bar.prijavljen { background: #15803d; }
.cal .bar.odjavljen { background: #7b8794; }
.cal .bar.ext { background: repeating-linear-gradient(135deg, #6d28d9, #6d28d9 8px, #7c3aed 8px, #7c3aed 16px); }
.cal .bar.unpaid::after { content: "€"; margin-left: auto; padding-left: 6px; opacity: .85; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

/* ---------- Modal i obavijesti ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,32,.45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 860px; }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-h h2 { margin: 0; }
.modal-b { padding: 18px; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
@media (max-width: 700px) { .modal-bg { padding: 0; } .modal { border-radius: 0; min-height: 100vh; } }
#toasts { position: fixed; z-index: 200; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { white-space: pre-line; background: #1f2933; color: #fff; padding: 12px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 14px; max-width: 420px; animation: tin .2s ease; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes tin { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Prijava ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, #0f1e3d, #1d4ed8); }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth h1 { margin-bottom: 6px; }
.auth .logo { width: 48px; height: 48px; margin-bottom: 10px; }

/* ---------- Rezervacija ---------- */
.room-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.room-pick label {
  display: block; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; margin: 0; color: var(--text); background: #fff;
}
.room-pick label:hover { border-color: var(--primary); }
.room-pick input { display: none; }
.room-pick label.sel { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.room-pick label.busy { opacity: .5; cursor: not-allowed; background: #f6f6f6; }
.room-pick .n { font-weight: 700; }
.room-pick .c { font-size: 12px; color: var(--muted); }
.money-sum { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; font-size: 15px; }
.money-sum .tot { font-weight: 700; border-top: 1px solid var(--line); padding-top: 6px; }
.guest-row { border: 1px solid var(--line); border-radius: 8px; padding: 12px 12px 0; margin-bottom: 10px; position: relative; }
.guest-row .rm { position: absolute; right: 8px; top: 8px; }
.email-preview { border: 1px solid var(--line); border-radius: 8px; width: 100%; height: 60vh; background: #fff; }

/* ---------- Statistika ---------- */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 180px; padding-top: 10px; }
.bars .b { background: var(--primary); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.bars .b span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.bars-l { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; font-size: 11px; color: var(--muted); text-align: center; margin-top: 4px; }
.hbar { display: grid; grid-template-columns: 130px 1fr 40px; gap: 8px; align-items: center; font-size: 14px; margin: 6px 0; }
.hbar .t { background: #eef1f4; border-radius: 4px; height: 10px; overflow: hidden; }
.hbar .t i { display: block; height: 100%; background: var(--primary); }

code, .mono { font-family: Consolas, "Courier New", monospace; font-size: 13px; }
.copy-box { display: flex; gap: 6px; }
.copy-box input { font-family: Consolas, monospace; font-size: 12px; }
.ph-list { display: flex; flex-wrap: wrap; gap: 6px; }
.ph-list button { font-family: Consolas, monospace; font-size: 12px; padding: 3px 8px; min-height: 0; }

/* ---------- Odabir datuma (hrvatski, tjedan od ponedjeljka) ---------- */
.dp-wrap { position: relative; display: flex; align-items: stretch; min-width: 150px; }
.dp-wrap .dp-text { border-top-right-radius: 0; border-bottom-right-radius: 0; flex: 1; min-width: 0; }
.dp-wrap .dp-btn { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0; padding: 0 10px; border-color: #cfd7df; }
.dp-text.dp-bad { border-color: var(--danger); outline: 2px solid rgba(192,57,43,.2); }
.dp-pop {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 80; width: 280px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(15,23,32,.18); padding: 10px;
}
.dp-pop.up { top: auto; bottom: calc(100% + 4px); }
.dp-head { display: flex; gap: 4px; align-items: center; margin-bottom: 8px; }
.dp-head select { padding: 4px 6px; min-height: 32px; font-size: 14px; }
.dp-head select[data-m] { flex: 1; }
.dp-head select[data-y] { width: 80px; }
.dp-head button { min-height: 32px; padding: 0 10px; font-size: 18px; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.dp-grid b { font-size: 12px; color: var(--muted); padding: 4px 0; font-weight: 600; }
.dp-grid b.we { color: #b45309; }
.dp-grid button { min-height: 34px; padding: 0; border: 0; border-radius: 6px; background: none; font-size: 14px; font-weight: 400; }
.dp-grid button:hover { background: var(--primary-soft); }
.dp-grid button.we { color: #b45309; }
.dp-grid button.today { box-shadow: inset 0 0 0 1px var(--primary); }
.dp-grid button.sel { background: var(--primary); color: #fff; font-weight: 600; }
.dp-foot { display: flex; justify-content: space-between; margin-top: 8px; }
.dp-foot button { min-height: 30px; padding: 2px 10px; font-size: 13px; }
.cal-toolbar .dp-wrap { width: 170px; }

/* ---------- No-show (gost se nije pojavio na dan dolaska) ---------- */
.badge.noshow { background: #dc2626; color: #fff; letter-spacing: .02em; }
table.list tr.noshow td { background: #fff1f0; }
table.list tr.noshow:hover td { background: #ffe4e1; }
.cal .bar.noshow { background: repeating-linear-gradient(135deg, #dc2626, #dc2626 8px, #ef4444 8px, #ef4444 16px); }
