:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-alt: #f0f3ef;
  --border: #dce2da;
  --text: #1b221c;
  --text-muted: #5a655c;
  --primary: #1b4332;
  --primary-hover: #143326;
  --primary-soft: #e6efe9;
  --accent: #2d6a4f;
  --warn-bg: #fef3c7;
  --warn-text: #92400e;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --ok-bg: #dcfce7;
  --ok-text: #166534;
  --info-bg: #e0f2fe;
  --info-text: #075985;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  font-size: 14px;
}

header {
  background: var(--primary);
  color: #ffffff;
  padding: 14px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.brand p { margin: 2px 0 0; font-size: 12px; color: #cce3d4; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sync-badge { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,0.14); color: #ffffff; }
.sync-badge.offline { background: #92400e; }

nav.tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
}
nav.tabs button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
nav.tabs button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

main { max-width: 1280px; margin: 0 auto; padding: 20px 24px 48px; }

.setup-banner {
  background: var(--warn-bg);
  color: var(--warn-text);
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.kpi-value { font-size: 22px; font-weight: 700; color: var(--primary); margin-top: 4px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.panel-header h2 { margin: 0; font-size: 16px; font-weight: 600; }

.split-layout {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 960px) { .split-layout { grid-template-columns: 1fr; } }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
input[type="text"], input[type="number"], input[type="date"], input[type="url"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #ffffff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  gap: 6px;
}
.btn:hover { background: var(--surface-alt); }
.btn-primary { background: var(--primary); color: #ffffff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--danger-text); border-color: #fecaca; background: #fff5f5; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,0.3); color: #ffffff; }
.btn-ghost:hover { background: rgba(255,255,255,0.12); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--text-muted); background: var(--surface-alt); white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-active { background: var(--ok-bg); color: var(--ok-text); }
.badge-reserved { background: var(--info-bg); color: var(--info-text); }
.badge-picked { background: var(--warn-bg); color: var(--warn-text); }
.badge-damaged, .badge-out, .badge-cancelled { background: var(--danger-bg); color: var(--danger-text); }
.badge-completed { background: #e5e7eb; color: #374151; }

/* + / - Quantity Stepper */
.qty-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
}
.qty-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.qty-btn:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); }
.qty-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.qty-stepper input {
  width: 38px;
  height: 28px;
  border: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-radius: 0;
  text-align: center;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
}
.qty-stepper input:focus { outline: none; }

/* GitHub-Style Booking Calendar Heatmap */
.heatmap-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.heatmap-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}
.heatmap-container {
  display: inline-flex;
  gap: 8px;
  align-items: flex-start;
}
.heatmap-days-col {
  display: grid;
  grid-template-rows: repeat(7, 26px);
  gap: 4px;
  padding-top: 20px;
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  padding-right: 4px;
}
.heatmap-days-col span { line-height: 26px; }
.heatmap-months {
  display: flex;
  font-size: 11px;
  color: var(--text-muted);
  height: 16px;
  margin-bottom: 4px;
  position: relative;
}
.heatmap-month-label {
  position: absolute;
  top: 0;
  font-weight: 600;
}
.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 26px);
  grid-auto-flow: column;
  grid-auto-columns: 26px;
  gap: 4px;
}
.heatmap-cell {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid rgba(27, 34, 28, 0.08);
  transition: transform 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  user-select: none;
}
.heatmap-cell:hover {
  transform: scale(1.12);
  outline: 2px solid var(--primary);
  z-index: 2;
}
.heatmap-cell.selected {
  outline: 2px solid #111827;
  outline-offset: 1px;
}
.heatmap-cell.empty {
  background: transparent;
  border: none;
  cursor: default;
}
.heatmap-cell.empty:hover { transform: none; outline: none; }

.hm-0 { background: #e8f5e9; color: #1b221c; } /* 100% Free */
.hm-1 { background: #a7f3d0; color: #1b221c; } /* Lightly Booked (1-30%) */
.hm-2 { background: #34d399; color: #1b221c; } /* Moderate (31-65%) */
.hm-3 { background: #f59e0b; color: #451a03; } /* Busy (66-99%) */
.hm-4 { background: #dc2626; color: #ffffff; } /* Fully Booked (100%) */

.heatmap-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.legend-box {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
  border: 1px solid rgba(0,0,0,0.1);
}

/* Calendar Hover Tent Availability Popup */
.heatmap-tooltip {
  position: fixed;
  z-index: 300;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  width: 250px;
  pointer-events: none;
  font-size: 12px;
  color: var(--text);
}
.heatmap-tooltip-date {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}
.heatmap-tooltip-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.heatmap-tooltip-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.heatmap-tooltip-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.heatmap-tooltip-qty {
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
}
.heatmap-tooltip-qty.ok { background: var(--ok-bg); color: var(--ok-text); }
.heatmap-tooltip-qty.zero { background: var(--danger-bg); color: var(--danger-text); }

/* Inventory UI Enhancements */
.inv-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter-pill {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.filter-pill:hover { background: var(--surface-alt); }
.filter-pill.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}
.stock-cell {
  min-width: 130px;
}
.stock-numbers {
  display: flex;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 4px;
}
.stock-bar {
  height: 6px;
  width: 100%;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}
.stock-bar-active { background: var(--accent); height: 100%; }
.stock-bar-damaged { background: #dc2626; height: 100%; }

/* Mobile-Friendly Availability Cards */
.avail-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.avail-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
}
.avail-card.unavailable {
  opacity: 0.65;
  background: #fafafa;
}
.avail-card-info {
  flex: 1;
  min-width: 0;
}
.avail-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.avail-card-rate {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-top: 2px;
}
.avail-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  font-size: 11px;
}
.meta-chip {
  background: var(--surface-alt);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.meta-chip.avail-ok { background: var(--ok-bg); color: var(--ok-text); }
.meta-chip.avail-zero { background: var(--danger-bg); color: var(--danger-text); }

/* Redesigned Orders Page */
.orders-toolbar-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.order-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}
.order-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.order-card.status-reserved { border-left-color: #0284c7; }
.order-card.status-picked { border-left-color: #d97706; }
.order-card.status-inquiry { border-left-color: #6366f1; }
.order-card.status-completed { border-left-color: #6b7280; }
.order-card.status-cancelled { border-left-color: #dc2626; opacity: 0.78; }

.badge-inquiry { background: #e0e7ff; color: #3730a3; }

.order-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.order-card-id {
  display: inline-block;
  font-weight: 700;
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}
.order-card-customer {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-top: 6px;
}
.order-card-phone {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.wa-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
}
.wa-chip:hover { background: #bbf7d0; }

/* Date / Date-Range Filter Bar on Orders Page */
.orders-date-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  padding: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
}
.orders-date-bar .date-field {
  min-width: 140px;
  flex: 1;
  max-width: 190px;
}
.orders-date-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Structured Pickup -> Return Slot */
.order-slot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  background: var(--surface-alt);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.order-slot-box span {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}
.order-slot-box strong {
  display: block;
  font-size: 13px;
  color: var(--text);
  margin-top: 2px;
}
.order-nights-pill {
  background: var(--primary);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Itemized Gear Chips */
.order-gear-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.gear-chip {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #cce3d4;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}
.order-card-items {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  padding: 2px 0;
}
.order-card-pay {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--surface-alt);
  padding: 10px;
  border-radius: 8px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}
.order-card-pay strong {
  display: block;
  font-size: 13px;
  color: var(--text);
  margin-top: 2px;
}
.order-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Summary Tab Grid */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.summary-box { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 6px; padding: 12px; margin: 12px 0; }
.summary-line { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; }
.summary-line.total { font-size: 16px; font-weight: 700; color: var(--primary); border-top: 1px solid var(--border); padding-top: 8px; margin-top: 6px; margin-bottom: 0; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hidden { display: none !important; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal { background: var(--surface); border-radius: var(--radius); max-width: 500px; width: 100%; padding: 20px; box-shadow: 0 12px 30px rgba(0,0,0,0.18); }
.modal h3 { margin: 0 0 12px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast { position: fixed; bottom: 20px; right: 20px; background: #1b221c; color: #ffffff; padding: 10px 16px; border-radius: 6px; font-size: 13px; z-index: 200; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
