:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --border: #e0dcd2;
  --text: #2b2a27;
  --muted: #746f64;
  --primary: #2f6b4f;
  --primary-dark: #234f3b;
  --accent: #c97b3d;
  --free: #eef1ea;
  --reserved: #cfe3d6;
  --reserved-border: #6fa383;
  --danger: #b3423a;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--primary-dark);
  color: #fff;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.sidebar-header h1 { font-size: 18px; margin: 0 0 12px; }
.btn-add {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 9px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
}
.btn-add:hover { filter: brightness(1.08); }

.complex-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.complex-list li {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  color: #e9ebe6;
}
.complex-list li:hover { background: rgba(255,255,255,0.08); }
.complex-list li.active { background: var(--primary); color: #fff; font-weight: 600; }
.complex-list .cabin-badge { opacity: 0.75; font-size: 12px; }

/* Main */
.main { padding: 24px 28px; overflow-y: auto; }
.empty-state { color: var(--muted); margin-top: 60px; text-align: center; }

.complex-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}
.complex-header h2 { margin: 0; }
.muted { color: var(--muted); margin: 4px 0 0; font-size: 13px; }

.tabs { display: flex; gap: 6px; }
.tab-btn {
  background: transparent;
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.tab-content { margin-top: 16px; }

/* Calendar */
.calendar-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.calendar-toolbar button {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 7px 12px;
  border-radius: var(--radius);
  cursor: pointer;
}
.month-label { font-weight: 700; min-width: 160px; text-align: center; }
.legend { margin-left: auto; display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.swatch.free { background: var(--free); border: 1px solid var(--border); }
.swatch.reserved { background: var(--reserved); border: 1px solid var(--reserved-border); }

.calendar-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

#calendar-table { border-collapse: collapse; width: max-content; font-size: 12px; user-select: none; }
#calendar-table th, #calendar-table td {
  border: 1px solid var(--border);
  min-width: 36px;
  height: 34px;
  text-align: center;
  padding: 0;
}
#calendar-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.3;
}
#calendar-table thead th.weekend { background: #f1ede4; color: var(--accent); }
#calendar-table thead th.today { background: var(--primary); color: #fff; }
#calendar-table td.cabin-label,
#calendar-table th.cabin-col {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
  font-weight: 700;
  min-width: 90px;
  border-right: 2px solid var(--border);
  padding: 4px 8px;
  text-align: left;
}
.cabin-cap { font-weight: 400; color: var(--muted); font-size: 10px; }
.day-cell { cursor: pointer; background: var(--free); transition: background 0.1s ease; }
.day-cell.today-col { box-shadow: inset 0 0 0 1px var(--primary); }
.day-cell:hover { background: #dfe6da; }
.day-cell.reserved { background: var(--reserved); cursor: pointer; border-color: var(--reserved-border); }
.day-cell.reserved:hover { background: #bcd8c6; }
.day-cell.selecting { background: #f7d9b0 !important; }
.day-cell.reserved-start { font-size: 10px; font-weight: 600; text-align: left; padding-left: 4px; white-space: nowrap; overflow: hidden; color: var(--primary-dark); }
.day-cell.checkout-marker { position: relative; }
.day-cell.checkout-marker::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  border-width: 9px 9px 0 0;
  border-style: solid;
  border-color: var(--accent) transparent transparent transparent;
}

/* Clients table / generic data table */
.section-toolbar { margin-bottom: 12px; }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }
.data-table th { background: #f1ede4; color: var(--muted); font-weight: 600; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 640px; }
.form-grid label.full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
input, textarea, select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
}
input:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 9px 12px;
  border-radius: var(--radius);
  cursor: pointer;
}
.btn-danger { background: var(--danger); color: #fff; border: none; padding: 9px 12px; border-radius: var(--radius); cursor: pointer; }
.btn-icon { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--muted); }

/* Reservation side panel */
.reservation-panel {
  width: 320px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 18px;
  position: fixed;
  right: 0; top: 0; bottom: 0;
  overflow-y: auto;
  box-shadow: -4px 0 12px rgba(0,0,0,0.06);
  z-index: 10;
}
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
#form-reservation { display: flex; flex-direction: column; gap: 12px; }
.panel-actions { display: flex; gap: 8px; margin-top: 6px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Modals */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center; z-index: 20;
}
.modal-box {
  background: var(--surface); padding: 22px; border-radius: var(--radius);
  width: 420px; max-width: 90vw; max-height: 85vh; overflow-y: auto;
}
.modal-box form { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.modal-box h3 { margin: 0; }
