:root {
  /* Token fallback when tokens.css is not included */
  --color-primary: #0f766e;
  --color-primary-strong: #0b5f59;
  --color-secondary: #0891b2;
  --color-accent: #f59e0b;
  --color-accent-soft: #fde7b2;
  --color-bg: #fffdf8;
  --color-bg-muted: #f7f4ea;
  --color-surface: #ffffff;
  --color-surface-soft: #f3f7f6;
  --color-border: #d7e3df;
  --color-text: #1f2937;
  --color-text-muted: #5b6b72;
  --color-text-soft: #84949b;
  --color-success: #0f766e;
  --color-warning: #b45309;
  --color-danger: #b91c1c;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-round: 999px;
  --elev-sm: 0 10px 24px rgba(16, 60, 55, 0.08);
  --elev-md: 0 20px 50px rgba(16, 60, 55, 0.14);
  --elev-lg: 0 34px 80px rgba(16, 60, 55, 0.18);
  --ui-ring: 0 0 0 3px rgba(15, 118, 110, 0.22);

  /* Bridge legacy variable names to new token system */
  --dark: var(--color-text);
  --ink: var(--color-text);
  --accent: var(--color-primary);
  --accent-2: var(--color-accent);
  --bg: var(--color-bg);
  --surface: var(--color-surface);
  --surface-2: var(--color-surface-soft);
  --border: var(--color-border);
  --text-soft: var(--color-text-soft);
  --text-mid: var(--color-text-muted);
  --shadow-sm: var(--elev-sm);
  --shadow-md: var(--elev-md);
  --shadow-lg: var(--elev-lg);

  --status-success: var(--color-success);
  --status-amber: var(--color-warning);
  --status-danger: var(--color-danger);
}

body {
  background:
    radial-gradient(1100px 560px at 7% -15%, #eef8f4 0%, transparent 60%),
    radial-gradient(820px 460px at 96% -18%, #fdf1da 0%, transparent 60%),
    var(--color-bg);
}

.sidebar {
  background: #ffffff !important;
  border-right: 1px solid var(--color-border) !important;
  box-shadow: 8px 0 24px rgba(11, 46, 41, 0.08) !important;
}

.nav-item {
  border-radius: var(--radius-sm) !important;
  color: var(--color-text-muted) !important;
}

.nav-item.active {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%) !important;
  color: #fff !important;
}

.nav-item:hover {
  background: rgba(15, 118, 110, 0.1) !important;
  color: var(--color-text) !important;
}

.topbar {
  gap: 14px !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 120 !important;
  background: rgba(255, 253, 248, 0.9) !important;
  backdrop-filter: blur(8px) !important;
  padding-top: 8px !important;
  padding-bottom: 12px !important;
  border-bottom: 1px solid var(--color-border) !important;
  box-shadow: 0 10px 24px rgba(16, 60, 55, 0.08) !important;
  padding-left: 2px !important;
  padding-right: 2px !important;
}

.topbar + .section-title,
.topbar + .filter-box,
.topbar + .panel {
  margin-top: 16px !important;
}

.btn, .btn-add, .btn-filter, .btn-export, .btn-save {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%) !important;
  color: #fff !important;
  border-radius: var(--radius-round) !important;
  padding: 12px 20px !important;
  font-weight: 700 !important;
  letter-spacing: 0.2px !important;
}

.btn-link, .btn-reset, .btn-modal, .act {
  border-radius: var(--radius-round) !important;
  background: var(--color-surface) !important;
  border: 1px solid var(--color-border) !important;
}

input, select, textarea {
  background: #ffffff !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md) !important;
  padding: 12px 14px !important;
  min-height: 44px !important;
  font-size: 14px !important;
  color: var(--color-text) !important;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--color-primary) !important;
  box-shadow: var(--ui-ring) !important;
}

input::placeholder, textarea::placeholder {
  color: var(--color-text-soft) !important;
  opacity: 1 !important;
}

.page-title {
  font-weight: 700 !important;
  letter-spacing: -0.2px !important;
}

.page-sub {
  margin-top: 6px !important;
  color: var(--color-text-muted) !important;
}

.section-title, .panel-header h2 {
  margin-top: 10px !important;
  margin-bottom: 14px !important;
  letter-spacing: -0.2px !important;
}

.status-badge.active { background: rgba(15, 118, 110, 0.12) !important; color: #0d6b63 !important; }
.status-badge.upcoming { background: rgba(8, 145, 178, 0.12) !important; color: #0f4c81 !important; }
.status-badge.past { background: rgba(132, 148, 155, 0.18) !important; color: #475569 !important; }

.text-success { color: var(--color-success) !important; }
.text-danger { color: var(--color-danger) !important; }
.text-amber { color: var(--color-warning) !important; }

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.badge, .status-badge, .review-badge, .ical-badge, .count-badge {
  border-radius: var(--radius-round) !important;
}

.panel, .filter-box, .calendar-section, .rev-section, .stat-card, .prop-card, .house-card, .booking-tile {
  background: var(--color-surface) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-sm) !important;
}

.booking-tile {
  text-decoration: none !important;
  color: inherit !important;
}

.todo-list {
  display: grid;
  gap: 6px;
  max-height: 40vh;
  overflow: auto;
  padding-right: 4px;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--color-border);
  font-size: 13px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.todo-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
}

.todo-item .todo-text {
  color: var(--color-text);
}

.todo-item input[type="checkbox"]:checked + .todo-text {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

.todo-item:hover {
  border-color: rgba(15, 118, 110, 0.35);
  box-shadow: 0 8px 20px rgba(16, 60, 55, 0.08);
  transform: translateY(-1px);
}

.todo-empty, .todo-loading {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Booking detail drawer */

.detail-drawer {
  width: 520px;
}

.detail-drawer-header {
  background: linear-gradient(135deg, #0b3f3a 0%, #1c6f66 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.detail-drawer-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.detail-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.detail-drawer-body {
  background: var(--color-surface);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.detail-section {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.detail-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-muted);
  font-weight: 700;
  margin-bottom: 10px;
}

.detail-row {
  padding: 8px 0;
  border-bottom: 1px solid rgba(15, 118, 110, 0.12);
  align-items: start;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  font-size: 11px;
  letter-spacing: 0.08em;
}

.detail-value strong {
  font-size: 16px;
}

.detail-actions {
  background: var(--color-surface-soft);
  gap: 10px;
  flex-wrap: wrap;
}

.detail-actions .btn-modal {
  border-radius: 12px;
  min-width: 140px;
}

.detail-actions .btn-modal.primary {
  box-shadow: 0 10px 20px rgba(12, 90, 82, 0.2);
}


@media (max-width: 600px) {
  .todo-list {
    max-height: 32vh;
  }
  .detail-drawer {
    width: 100%;
  }
}

@media (min-width: 980px) {
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.detail-drawer .todo-item {
  padding: 6px 10px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid rgba(15, 118, 110, 0.14);
}

.detail-drawer .todo-item .todo-text {
  font-size: 13px;
}

/* Keep dashboard highlight KPI readable even when base cards are overridden */
.stat-card.highlight {
  background: var(--color-text) !important;
  color: #ffffff !important;
}

.stat-card.highlight .stat-value,
.stat-card.highlight .stat-label,
.stat-card.highlight .stat-sub {
  color: #ffffff !important;
}

.stat-card.highlight .stat-value {
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}

/* Unified filter/control heights for calendar, bookings and revenues */
.filter-box .filter-group select,
.filter-box .filter-group input[type="date"],
.filter-box .filter-group input[type="text"],
.filter-box .btn-filter,
.filter-box .btn-reset,
.calendar-toolbar .filter-form select,
.calendar-toolbar .range-btn,
.calendar-toolbar .nav-btn,
.filter-box .btn-quick {
  min-height: 46px !important;
  border-radius: 10px !important;
  font-size: 13px !important;
  line-height: 1.2 !important;
  box-sizing: border-box !important;
}

.filter-box .filter-group select,
.filter-box .filter-group input[type="date"],
.filter-box .filter-group input[type="text"],
.calendar-toolbar .filter-form select {
  height: 46px !important;
  padding: 10px 12px !important;
  line-height: 24px !important;
  background: #ffffff !important;
  border-color: var(--color-border) !important;
}

.filter-box .btn-filter,
.filter-box .btn-reset,
.calendar-toolbar .range-btn,
.calendar-toolbar .nav-btn,
.filter-box .btn-quick {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 14px !important;
}

.filter-box {
  padding: 18px 20px !important;
}

.filter-box .filter-group,
.calendar-toolbar .filter-group {
  gap: 6px !important;
}

.filter-box .filter-group label,
.calendar-toolbar .filter-group label {
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  color: var(--color-text-soft) !important;
}

.filter-box .quick-filters {
  margin-top: 12px !important;
  gap: 10px !important;
}

.filter-box .btn-quick {
  border: 1px solid var(--color-border) !important;
  background: var(--color-surface-soft) !important;
  color: var(--color-text-muted) !important;
  border-radius: 999px !important;
  padding: 0 16px !important;
  font-weight: 700 !important;
}

.filter-box .btn-quick:hover {
  background: var(--color-surface-soft) !important;
  color: var(--color-text) !important;
}

.filter-box .btn-filter {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%) !important;
  color: #ffffff !important;
  border: 1px solid transparent !important;
  font-weight: 700 !important;
}

.filter-box .btn-reset {
  background: #ffffff !important;
  color: var(--color-text) !important;
  border: 1px solid var(--color-border) !important;
  font-weight: 600 !important;
}

.calendar-toolbar .range-btn,
.calendar-toolbar .nav-btn {
  background: var(--color-surface-soft) !important;
  color: var(--color-text) !important;
  border: 1px solid var(--color-border) !important;
}

.calendar-toolbar .range-btn.active,
.calendar-toolbar .nav-btn.today-btn {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%) !important;
  color: #ffffff !important;
  border-color: transparent !important;
  box-shadow: 0 8px 18px rgba(16, 60, 55, 0.18) !important;
}

/* Calendar toolbar should feel like same filter container family */
.calendar-toolbar {
  background: var(--color-surface) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: 16px !important;
  padding: 14px 16px !important;
  box-shadow: var(--shadow-sm) !important;
}

@media (max-width: 880px) {
  .filter-box {
    padding: 14px 12px !important;
  }

  .filter-box .filter-row,
  .filter-box .filter-row.has-verified,
  .calendar-toolbar .filter-form {
    grid-template-columns: 1fr !important;
    display: grid !important;
    gap: 10px !important;
  }

  .filter-box .filter-actions,
  .calendar-toolbar .toolbar-left,
  .calendar-toolbar .toolbar-right {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    align-items: stretch !important;
  }

  .calendar-toolbar .range-switch,
  .calendar-toolbar .nav-group {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important;
  }

  .calendar-toolbar .view-switch {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 600px) {
  .filter-box .btn-filter,
  .filter-box .btn-reset,
  .filter-box .btn-quick,
  .calendar-toolbar .range-btn,
  .calendar-toolbar .nav-btn {
    width: 100% !important;
  }
}
