:root {
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --text: #1F1F1F;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --accent: #2563EB;
  --accent-soft: #EFF4FE;
  --success: #16A34A;
  --danger: #DC2626;
  --cal-occupied: #2563EB;
  --cal-free: #E5E7EB;
  --radius: 12px;
  --shadow-card: 0 1px 2px rgba(31, 31, 31, 0.06), 0 1px 8px rgba(31, 31, 31, 0.04);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

a { color: inherit; text-decoration: none; }

/* ── Layout shell ─────────────────────────────────────────────── */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.sidebar-brand i { color: var(--accent); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  gap: 2px;
  flex: 1;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  transition: background-color .15s ease, color .15s ease;
}
.sidebar-nav .nav-link i { width: 18px; text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--accent-soft); color: var(--accent); }
.sidebar-nav .nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.sidebar-logout:hover { color: var(--danger); }

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-title { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.burger { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; }

.app-content {
  padding: 24px 28px 48px;
}

.fade-page { animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ── Section heading ─────────────────────────────────────────── */

.section-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 18px;
}

/* ── Cards ────────────────────────────────────────────────────── */

.card-surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.card-heading {
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
}

/* ── KPI grid ─────────────────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
}

.kpi-label {
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  transition: opacity .2s ease;
}

.kpi-value.positive { color: var(--success); }
.kpi-value.negative { color: var(--danger); }
.kpi-value.accent { color: var(--accent); }

@keyframes kpiPop {
  0% { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}
.kpi-value { animation: kpiPop .35s ease; }

/* ── Two-column overview blocks ───────────────────────────────── */

.overview-columns {
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  gap: 20px;
}

/* ── Mini calendar ────────────────────────────────────────────── */

.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 12px;
}

.mini-cal-dow {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.mini-cal-day {
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: var(--cal-free);
  color: var(--text-muted);
  cursor: default;
  transition: transform .1s ease, box-shadow .1s ease;
  position: relative;
}
.mini-cal-day.out-month { opacity: .35; }
.mini-cal-day.occupied {
  background: var(--cal-occupied);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.mini-cal-day.occupied:hover { transform: scale(1.08); box-shadow: 0 2px 8px rgba(37,99,235,.35); z-index: 2; }

.cal-legend { display: flex; gap: 16px; margin-top: 12px; font-size: 12px; color: var(--text-muted); }
.cal-legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: middle; }
.dot.occupied { background: var(--cal-occupied); }
.dot.free { background: var(--cal-free); }

/* Full calendar page */
.full-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 14px; }
.full-cal-day {
  min-height: 84px;
  border-radius: 8px;
  background: var(--cal-free);
  padding: 6px;
  font-size: 12px;
  color: var(--text-muted);
  position: relative;
}
.full-cal-day.out-month { opacity: .4; }
.full-cal-day.occupied { background: var(--accent-soft); border: 1px solid var(--accent); }
.full-cal-day .day-num { font-weight: 600; color: var(--text); font-size: 12px; }
.full-cal-day .booking-chip {
  margin-top: 4px;
  background: var(--cal-occupied);
  color: #fff;
  border-radius: 5px;
  padding: 2px 5px;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.full-cal-day .booking-chip:hover { filter: brightness(1.1); }

/* ── Tables ───────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
.table-app { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-app th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table-app td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table-app tbody tr { transition: background-color .12s ease; }
.table-app tbody tr:hover { background: var(--accent-soft); }

/* ── Badges ───────────────────────────────────────────────────── */

.badge-status { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-paid { background: #DCFCE7; color: var(--success); }
.badge-partial { background: #FEF3C7; color: #B45309; }
.badge-unpaid { background: #FEE2E2; color: var(--danger); }

/* ── Forms ────────────────────────────────────────────────────── */

.field-error {
  color: var(--danger);
  font-size: 12.5px;
  margin-top: 4px;
}
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--danger); }

/* ── Booking cards ────────────────────────────────────────────── */

.booking-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
  margin-bottom: 14px;
  transition: box-shadow .15s ease;
}
.booking-card:hover { box-shadow: 0 2px 12px rgba(31,31,31,.08); }

/* ── Empty state ──────────────────────────────────────────────── */

.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
}
.empty-steps { display: flex; gap: 20px; flex-wrap: wrap; margin: 20px 0; }
.empty-step {
  flex: 1 1 220px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.empty-step .step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13px;
  margin-bottom: 10px;
}

/* ── Spinner (PDF generation) ─────────────────────────────────── */

.btn-loading { position: relative; pointer-events: none; opacity: .75; }
.btn-loading .spinner-border { width: 14px; height: 14px; border-width: 2px; margin-right: 6px; }

/* ── Tooltip content for calendar ─────────────────────────────── */

.cal-tooltip-body { text-align: left; font-size: 12px; }

/* ── Responsive ───────────────────────────────────────────────── */

@media (max-width: 991.98px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 767.98px) {
  .app-content { padding: 16px; }
  .app-header { padding: 12px 16px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .overview-columns { grid-template-columns: 1fr; }
  .empty-steps { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .fade-page, .kpi-value, .mini-cal-day, .booking-card { animation: none !important; transition: none !important; }
}
