:root {
  --navy: #0b2530;
  --accent: #0f766e;
  --accent2: #14b8a6;
  --sand: #fbbf24;
  --bg: #f3f6f7;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5eaee;

  --st-available: #16a34a;
  --st-reserved: #2563eb;
  --st-occupied: #dc2626;
  --st-cleaning: #d97706;
  --st-oos: #6b7280;
}

body { background: var(--bg); color: var(--text); font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--accent); }
.btn-primary { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: #0d5f59; --bs-btn-hover-border-color: #0d5f59; --bs-btn-active-bg: #0b524d; --bs-btn-disabled-bg: #0f766e; --bs-btn-disabled-border-color: #0f766e; }
.btn-outline-primary { --bs-btn-color: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: var(--accent); --bs-btn-hover-border-color: var(--accent); --bs-btn-active-bg: var(--accent); }
.text-primary { color: var(--accent) !important; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--navy); color: #fff; flex-shrink: 0; padding: 20px 0; }
.sidebar .brand { padding: 0 16px 20px; }
.brand-logo { height: 36px; width: auto; display: block; }
.sidebar a { display: flex; align-items: center; gap: 10px; color: #cbd5e1; padding: 11px 20px; text-decoration: none; font-size: 0.95rem; border-left: 3px solid transparent; }
.sidebar a:hover, .sidebar a.active { background: rgba(255,255,255,0.08); color: #fff; border-left-color: var(--accent2); }
.sidebar .nav-section { color: #64748b; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; padding: 16px 20px 6px; }
.sidebar .badge-count { margin-left: auto; background: var(--sand); color: #111; border-radius: 10px; font-size: 0.72rem; padding: 1px 7px; font-weight: 700; }

.content { flex: 1; padding: 76px 28px 28px; max-width: 1400px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.topbar h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.topbar .subtitle { color: var(--muted); font-size: 0.9rem; }

.card-box { background: var(--card); border-radius: 14px; padding: 18px 22px; box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04); }
.card-box h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }

.user-badge { position: fixed; top: 14px; right: 20px; display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 999px; padding: 6px 8px 6px 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); z-index: 1030; font-size: 0.88rem; }
.user-badge .role-pill { background: #ccfbf1; color: #115e59; border-radius: 999px; padding: 2px 10px; font-size: 0.75rem; font-weight: 600; }
.user-badge button, .user-badge .user-badge-btn { border: none; background: #f1f5f9; border-radius: 50%; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; color: var(--text); text-decoration: none; }
.user-badge .user-badge-btn:hover, .user-badge button:hover { background: #e2e8f0; }
.user-badge .venue-switcher { width: auto; max-width: 240px; font-weight: 600; }
.user-badge .venue-name { font-weight: 600; color: var(--accent); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

.admin-only, .super-admin-only { display: none !important; }

/* ---------- KPIs / dashboard ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-card { background: var(--card); border-radius: 14px; padding: 16px 18px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.kpi-card .label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.kpi-card .value { font-size: 1.8rem; font-weight: 700; margin-top: 2px; }
.kpi-card .hint { font-size: 0.8rem; color: var(--muted); }
.kpi-card.warn .value { color: #b45309; }
.kpi-card.danger .value { color: #b91c1c; }

.insight-row { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.insight-row:last-child { border-bottom: none; }
.insight-row i { font-size: 1.1rem; }
.sev-danger i { color: #dc2626; } .sev-warning i { color: #d97706; } .sev-info i { color: #2563eb; } .sev-success i { color: #16a34a; }

.period-bar { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }

/* ---------- Status pills ---------- */
.status-pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.status-Booked { background: #e0e7ff; color: #3730a3; }
.status-Confirmed { background: #dbeafe; color: #1e40af; }
.status-Seated { background: #fee2e2; color: #991b1b; }
.status-Completed { background: #e5e7eb; color: #374151; }
.status-Cancelled { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }
.status-NoShow { background: #fef3c7; color: #92400e; }
.dep-Pending { color: #b45309; } .dep-Paid { color: #15803d; } .dep-Failed { color: #b91c1c; }

.res-row.is-cancelled td { opacity: 0.55; }
.tag-chip { display: inline-block; background: #f1f5f9; color: #334155; border-radius: 6px; padding: 0 6px; font-size: 0.72rem; margin-right: 3px; }
.allergy-chip { background: #fee2e2; color: #991b1b; }
.vip-chip { background: #fef3c7; color: #92400e; }

/* ---------- Timeline (reservations) ---------- */
.timeline-wrap { overflow-x: auto; }
.timeline { position: relative; min-width: 900px; }
.timeline-header, .timeline-row { display: flex; }
.timeline-label { width: 90px; flex-shrink: 0; font-weight: 600; font-size: 0.85rem; padding: 6px 8px; border-right: 1px solid var(--line); background: #fafbfc; }
.timeline-track { position: relative; flex: 1; height: 38px; border-bottom: 1px solid var(--line); }
.timeline-header .timeline-track { height: 26px; }
.timeline-hour { position: absolute; top: 0; bottom: 0; border-left: 1px dashed #e2e8f0; font-size: 0.7rem; color: var(--muted); padding-left: 3px; }
.timeline-block { position: absolute; top: 4px; height: 30px; border-radius: 6px; padding: 3px 6px; font-size: 0.75rem; color: #fff; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.15); }
.timeline-block.st-Booked { background: #6366f1; } .timeline-block.st-Confirmed { background: #2563eb; }
.timeline-block.st-Seated { background: #dc2626; } .timeline-block.st-Completed { background: #9ca3af; }
.timeline-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--sand); z-index: 2; }

/* ---------- Slots / table options ---------- */
.slot-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.slot-btn { min-width: 64px; }
.slot-btn.full { text-decoration: line-through; opacity: 0.45; }
.option-card { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; margin-bottom: 6px; display: flex; justify-content: space-between; }
.option-card.selected { border-color: var(--accent); background: #f0fdfa; box-shadow: 0 0 0 2px rgba(15,118,110,0.15); }

/* ---------- Floor plan ---------- */
.floor-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); }
.floor-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: var(--c); }
.floor-canvas { position: relative; width: 100%; aspect-ratio: 16 / 9; background:
  linear-gradient(#eef2f4 1px, transparent 1px) 0 0 / 5% 8.88%,
  linear-gradient(90deg, #eef2f4 1px, transparent 1px) 0 0 / 5% 8.88%, #fff;
  border-radius: 14px; border: 1px solid var(--line); overflow: hidden; user-select: none; }
.floor-canvas.outdoor { background-color: #fffbeb; }
.floor-table { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff;
  font-weight: 700; font-size: 0.85rem; border-radius: 10px; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.18); border: 3px solid transparent; line-height: 1.1; text-align: center; padding: 2px; transition: transform .08s; }
.floor-table:hover { transform: scale(1.04); }
.floor-table.shape-Round { border-radius: 50%; }
.floor-table .ft-sub { font-size: 0.68rem; font-weight: 500; opacity: 0.95; }
.floor-table.fs-free { background: var(--st-available); }
.floor-table.fs-reserved { background: var(--st-reserved); }
.floor-table.fs-occupied { background: var(--st-occupied); }
.floor-table.fs-cleaning { background: var(--st-cleaning); }
.floor-table.fs-oos { background: var(--st-oos); opacity: 0.7; }
.floor-table.soon { border-color: var(--sand); }
.floor-table.selected { outline: 3px solid #111; outline-offset: 2px; }
.floor-canvas.editing .floor-table { cursor: move; background: #334155; }
.floor-canvas.editing .floor-table.inactive { opacity: 0.4; }
.floor-panel .kv { display: flex; justify-content: space-between; padding: 4px 0; font-size: 0.9rem; }

/* ---------- Waitlist ---------- */
.wait-card { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.wait-pos { width: 36px; height: 36px; border-radius: 50%; background: #ccfbf1; color: #115e59; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.wait-card.overdue .wait-pos { background: #fee2e2; color: #991b1b; }

/* ---------- Charts (reports) ---------- */
.bar-chart { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding-top: 8px; }
.bar-chart .bar { flex: 1; background: var(--accent2); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bar-chart .bar:hover { background: var(--accent); }
.hbar { display: flex; align-items: center; gap: 8px; margin: 5px 0; font-size: 0.85rem; }
.hbar .hbar-label { width: 90px; flex-shrink: 0; }
.hbar .hbar-track { flex: 1; background: #f1f5f9; border-radius: 4px; height: 14px; }
.hbar .hbar-fill { background: var(--accent2); height: 100%; border-radius: 4px; }

/* ---------- Login ---------- */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(11,37,48,0.25) 0%, rgba(11,37,48,0.55) 100%), url("../img/login-bg.jpg") center 55% / cover no-repeat fixed, #0b2530; }
.login-card { width: 380px; max-width: calc(100% - 32px); background: rgba(255,255,255,0.9); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 12px 40px rgba(0,0,0,0.35); }
.login-card .brand { padding: 14px 18px; }
.login-card .brand-logo { height: 54px; max-width: 100%; }
.login-tagline { color: rgba(255,255,255,0.85); font-size: 0.8rem; text-align: center; margin-top: 14px; text-shadow: 0 1px 3px rgba(0,0,0,0.6); }
.login-card .brand { background: var(--navy); border-radius: 12px; padding: 12px 16px; }

/* ---------- AI quick action ---------- */
.quick-action-fab { position: fixed; right: 24px; bottom: 24px; width: 56px; height: 56px; border-radius: 50%; border: none; background: linear-gradient(135deg, var(--accent2), var(--accent)); color: #fff; font-size: 1.4rem; box-shadow: 0 6px 18px rgba(15,118,110,0.4); z-index: 1040; }
.quick-action-summary-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #f0fdfa; }
.quick-action-message { font-size: 0.95rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; display: flex; overflow-x: auto; padding: 8px 0; }
  .sidebar .brand, .sidebar .nav-section { display: none; }
  .sidebar a { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; padding: 10px 14px; }
  .sidebar a.active { border-bottom-color: var(--accent2); }
  .content { padding: 70px 14px 90px; }
  .user-badge .user-badge-name { display: none; }
}

/* ---------- Tablet mode (Settings → UI mode) ---------- */
html.ui-tablet body { font-size: 1.08rem; }
html.ui-tablet .btn { padding: 0.6rem 1.1rem; font-size: 1.02rem; }
html.ui-tablet .btn-sm { padding: 0.45rem 0.8rem; font-size: 0.95rem; }
html.ui-tablet .form-control, html.ui-tablet .form-select { min-height: 46px; font-size: 1.05rem; }
html.ui-tablet .sidebar a { padding: 15px 20px; font-size: 1.05rem; }
html.ui-tablet .floor-table { font-size: 1rem; }

/* Reservations: day header rows when a period spans several days */
.res-date-row td { background: #f1f5f9; font-weight: 700; font-size: 0.9rem; border-top: 2px solid #e2e8f0; }
.res-date-row .text-muted { font-weight: 500; }
.res-date-row.is-today td { background: #ccfbf1; }
