/* ===== Design tokens ===== */
:root {
  --color-bg: #f4f5f7;
  --color-surface: #ffffff;
  --color-border: #e2e5eb;
  --color-text: #1f2430;
  --color-text-muted: #6b7280;
  --color-primary: #7c3aed;
  --color-primary-dark: #5b21b6;
  --color-danger: #dc2626;

  --status-enquiry: #3b82f6;
  --status-tentative: #f59e0b;
  --status-confirmed: #f87171;
  --status-cancelled: #9ca3af;
  --status-completed: #0d9488;
  --status-conflict: #dc2626;
  --status-open: #22c55e;

  --sidebar-width: 250px;
  --topbar-height: 60px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #14161c;
    --color-surface: #1d2028;
    --color-border: #2c3040;
    --color-text: #e8e9ee;
    --color-text-muted: #9aa0ae;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
button { font-family: inherit; }

/* ===== App shell / layout ===== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform .25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: .5rem .5rem 1.25rem; }
.brand-mark {
  background: var(--color-primary); color: #fff; font-weight: 700;
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand-mark--lg { width: 56px; height: 56px; font-size: 1.2rem; }
.brand-text { font-size: .85rem; font-weight: 600; line-height: 1.2; }

.nav-section-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--color-text-muted); margin: 1rem .6rem .25rem;
}
.nav-link {
  display: block; padding: .65rem .6rem; border-radius: 8px;
  color: var(--color-text); font-size: .92rem; min-height: 44px; line-height: 1.6;
}
.nav-link:hover { background: var(--color-bg); text-decoration: none; }
.nav-link.active { background: var(--color-primary); color: #fff; }
.btn-new-booking { background: #ecfdf5; color: #047857; font-weight: 600; margin: .5rem 0 .75rem; }
.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--color-border); }
.sidebar-overlay { display: none; }

.app-body { flex: 1; min-width: 0; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: var(--topbar-height); flex-shrink: 0; background: var(--color-surface);
  border-bottom: 1px solid var(--color-border); display: flex; align-items: center;
  gap: 1rem; padding: 0 1.25rem; position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1.05rem; font-weight: 600; margin: 0; flex: 1; }
.topbar-user { font-size: .85rem; color: var(--color-text-muted); }
.hamburger {
  display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer;
  width: 44px; height: 44px; align-items: center; justify-content: center; color: var(--color-text);
}
.main-content { padding: 1.25rem; flex: 1; min-width: 0; }
.main-content--auth {
  margin: 0 auto; display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem;
  background-image: url('../img/IMG_7424.JPG'); background-size: cover; background-position: center; background-repeat: no-repeat;
}

/* ===== Login ===== */
.login-card {
  background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 2rem; width: 100%; max-width: 380px;
}
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand h1 { font-size: 1.15rem; margin-top: .75rem; }
.login-brand p { color: var(--color-text-muted); margin: .25rem 0 0; font-size: .9rem; }

/* ===== Cards / surfaces ===== */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.stat-tile { text-align: left; }
.stat-tile .stat-value { font-size: 1.7rem; font-weight: 700; color: var(--color-text); }
.stat-tile .stat-label { color: var(--color-text-muted); font-size: .85rem; display: flex; align-items: center; gap: .4rem; }

/* Validated 8-color categorical set (fixed order: blue, aqua, yellow, green, violet,
   red, magenta, orange). Identity is carried by the border + dot, never by recoloring
   the value text (several of these fail text-contrast on a light surface — see
   dataviz palette). Reused anywhere a rotating per-item color is needed (stat tiles,
   per-rep report sections, etc). */
.stat-tile--blue, .accent-blue { --tile-hue: #2a78d6; --tile-bg: #dbe9fb; }
.stat-tile--aqua, .accent-aqua { --tile-hue: #1baf7a; --tile-bg: #daf5ea; }
.stat-tile--yellow, .accent-yellow { --tile-hue: #eda100; --tile-bg: #fdedd2; }
.stat-tile--green, .accent-green { --tile-hue: #008300; --tile-bg: #dcf0dc; }
.stat-tile--violet, .accent-violet { --tile-hue: #4a3aa7; --tile-bg: #e6e2f7; }
.stat-tile--red, .accent-red { --tile-hue: #e34948; --tile-bg: #fbdedd; }
.stat-tile--magenta, .accent-magenta { --tile-hue: #e87ba4; --tile-bg: #fbe3ec; }
.stat-tile--orange, .accent-orange { --tile-hue: #eb6834; --tile-bg: #fce4d8; }
.stat-tile[class*="stat-tile--"] {
  border-left: 4px solid var(--tile-hue);
  background: color-mix(in srgb, var(--tile-hue) 10%, var(--color-surface));
}
.stat-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--tile-hue); flex-shrink: 0;
}

@media (prefers-color-scheme: dark) {
  .stat-tile--blue, .accent-blue { --tile-hue: #3987e5; }
  .stat-tile--aqua, .accent-aqua { --tile-hue: #199e70; }
  .stat-tile--yellow, .accent-yellow { --tile-hue: #c98500; }
  .stat-tile--green, .accent-green { --tile-hue: #008300; }
  .stat-tile--violet, .accent-violet { --tile-hue: #9085e9; }
  .stat-tile--red, .accent-red { --tile-hue: #e66767; }
  .stat-tile--magenta, .accent-magenta { --tile-hue: #d55181; }
  .stat-tile--orange, .accent-orange { --tile-hue: #d95926; }
}

/* ===== Rep/section card with a colored accent (professional report styling) ===== */
.rep-card {
  border-left: 4px solid var(--tile-hue);
}
.rep-card-header {
  display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem;
}
.rep-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--tile-hue); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem;
  flex-shrink: 0;
}
.rep-card-header h3 { margin: 0; }
.rep-card-meta { color: var(--color-text-muted); font-size: .82rem; }

/* ===== Simple horizontal bar (leaderboard-style comparison) ===== */
.bar-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .6rem; }
.bar-row-label { width: 150px; flex-shrink: 0; font-size: .85rem; font-weight: 600; }
.bar-track { flex: 1; background: var(--color-bg); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--tile-hue); }
.bar-row-value { width: 110px; flex-shrink: 0; text-align: right; font-size: .85rem; font-weight: 700; }

/* ===== Column chart (FY revenue, month-wise) ===== */
.fy-chart { display: flex; align-items: flex-end; gap: .6rem; padding-top: 2rem; overflow-x: auto; }
.fy-col { flex: 1; min-width: 60px; display: flex; flex-direction: column; align-items: center; }
.fy-col-bar-wrap { width: 100%; height: 180px; display: flex; align-items: flex-end; }
.fy-col-bar {
  position: relative; width: 100%; min-height: 3px; border-radius: 6px 6px 0 0;
  background: var(--tile-hue);
}
.fy-col-value {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 4px;
  font-size: .68rem; font-weight: 700; white-space: nowrap; color: var(--color-text);
}
.fy-col-label { margin-top: .5rem; font-size: .8rem; font-weight: 600; color: var(--color-text-muted); }

/* ===== Dashboard-only font override ===== */
.dashboard-page, .dashboard-page * { font-family: 'Century Gothic', 'Apple Gothic', var(--font); }

/* ===== Side-by-side half-width dashboard cards (e.g. the two pie charts) ===== */
.dashboard-row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.dashboard-row > .half-card { flex: 1 1 0; min-width: 320px; margin-bottom: 0; }
@media (max-width: 900px) { .dashboard-row > .half-card { flex-basis: 100%; } }

/* ===== Pie chart (CSS conic-gradient, no chart library) ===== */
.pie-chart-row { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; margin-top: 1rem; }
.pie-chart { width: 180px; height: 180px; border-radius: 50%; flex-shrink: 0; }
.pie-legend { display: flex; flex-direction: column; gap: .5rem; flex: 1; min-width: 180px; }
.pie-legend-row { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.pie-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pie-legend-label { font-weight: 600; flex: 1; }
.pie-legend-value { color: var(--color-text-muted); white-space: nowrap; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1.1rem; border-radius: 8px; border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text); cursor: pointer;
  font-size: .9rem; font-weight: 600; min-height: 44px;
}
.btn:hover { background: var(--color-bg); text-decoration: none; }
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-danger { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }
.btn-sm { padding: .4rem .75rem; font-size: .82rem; min-height: 36px; }
.btn-block { width: 100%; }

/* ===== Badges / status ===== */
.badge {
  display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
}
.badge-status { background: color-mix(in srgb, var(--badge-color) 18%, transparent); color: var(--badge-color); }
.conflict-outline { outline: 2px solid var(--status-conflict); outline-offset: 2px; }

/* ===== Flash messages ===== */
.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.flash-success { background: #ecfdf5; color: #047857; }
.flash-error { background: #fef2f2; color: #b91c1c; }
.flash-warning { background: #fffbeb; color: #b45309; }
.flash-info { background: #eff6ff; color: #1d4ed8; }

/* ===== Tables ===== */
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .5rem; text-align: left; border-bottom: 1px solid var(--color-border); font-size: .88rem; }
th { color: var(--color-text-muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; }
tbody tr:hover { background: var(--color-bg); }
.total-row td { background: color-mix(in srgb, var(--tile-hue, var(--color-primary)) 12%, var(--color-surface)); border-top: 2px solid var(--color-border); }

/* ===== Filter bar ===== */
.filter-bar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin-bottom: 1rem; }
.filter-bar label { font-size: .78rem; color: var(--color-text-muted); display: flex; flex-direction: column; gap: .25rem; }
.filter-bar input, .filter-bar select { min-height: 44px; }

/* ===== Mini calendar ===== */
.mini-calendar { max-width: 320px; }
.mini-cal-header { font-weight: 600; margin-bottom: .5rem; text-align: center; }
.mini-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.mini-cal-dow { text-align: center; font-size: .68rem; color: var(--color-text-muted); font-weight: 600; padding-bottom: 2px; }
.mini-cal-cell {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 6px; font-size: .72rem; color: var(--color-text); position: relative;
  background: color-mix(in srgb, var(--status-tentative) calc(var(--fill, 0) * 100%), var(--color-bg));
}
.mini-cal-cell:hover { outline: 1px solid var(--color-primary); text-decoration: none; }
.mini-cal-cell--blank { background: transparent; pointer-events: none; }
.mini-cal-cell.is-today { outline: 2px solid var(--color-primary); }
.mini-cal-cell.is-active, .week-day-cell.is-active { outline: 2px solid var(--color-primary); }
.mini-cal-count { font-size: .6rem; font-weight: 700; }

/* ===== Month navigation (Prev/title/Next row) ===== */
.qa-month-nav { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.qa-month-nav .btn {
  border-radius: 999px; padding: .6rem 1.3rem; font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.1);
  border-color: var(--color-primary); color: var(--color-primary);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.qa-month-nav .btn:hover {
  transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,.15);
  background: var(--color-primary); color: #fff; text-decoration: none;
}

/* ===== Quick-add month table (all venues visible for the month at once) ===== */
.qa-month-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.qa-month-tabs { display: flex; flex-wrap: wrap; gap: .5rem; }
.qa-year-picker { position: relative; flex-shrink: 0; }
.qa-year-picker-btn {
  display: flex; align-items: center; gap: .4rem; font-size: .9rem; font-weight: 700;
  padding: .6rem .9rem; border-radius: 8px; border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text); cursor: pointer; min-height: 44px;
}
.qa-year-picker-btn:hover { background: var(--color-bg); }
.qa-year-popup {
  display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 10px;
  box-shadow: var(--shadow); padding: .6rem; grid-template-columns: repeat(4, 1fr); gap: .4rem;
  width: 260px; max-height: 260px; overflow-y: auto;
}
.qa-year-popup.is-open { display: grid; }
.qa-year-cell {
  display: flex; align-items: center; justify-content: center; padding: .5rem .3rem;
  border-radius: 6px; font-weight: 600; font-size: .85rem; color: var(--color-text);
  background: var(--color-bg);
}
.qa-year-cell:hover { background: color-mix(in srgb, var(--color-primary) 20%, var(--color-bg)); text-decoration: none; }
.qa-year-cell.is-active { background: var(--color-primary); color: #fff; }
.qa-month-tab {
  padding: .5rem 1rem; border-radius: 8px; font-weight: 700; font-size: .85rem;
  color: var(--tile-hue); background: color-mix(in srgb, var(--tile-hue) 14%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--tile-hue) 35%, transparent);
}
.qa-month-tab:hover { background: color-mix(in srgb, var(--tile-hue) 24%, var(--color-surface)); text-decoration: none; }
.qa-month-tab.is-active {
  background: var(--tile-hue); color: #fff; border: 2px solid #000;
  transform: scale(1.12); font-weight: 800;
}
.qa-month-table-wrap { overflow: auto; max-height: 75vh; }
.qa-month-table { border-collapse: separate; border-spacing: 6px; }
.qa-month-table thead th {
  position: sticky; top: 0; z-index: 4; background: var(--color-surface);
}
.qa-month-table th {
  text-align: center; font-size: .78rem; color: var(--color-text-muted); font-weight: 600;
  padding: .3rem .5rem; white-space: nowrap;
}
.qa-month-table th.is-highlighted { color: var(--color-primary); }
.qa-month-table th[class*="accent-"] {
  color: var(--tile-hue);
  background: var(--tile-bg, var(--color-surface));
  border-radius: 8px 8px 0 0;
  border-bottom: 3px solid var(--tile-hue);
}
.qa-month-table th[class*="accent-"] .qa-day-num { color: var(--tile-hue); }
.qa-month-table td {
  border: 1px solid var(--color-border); border-radius: 8px; padding: .35rem;
  vertical-align: top; background: var(--color-surface); min-width: 150px;
}
.qa-month-table td.is-highlighted { outline: 2px solid var(--color-primary); }
.qa-month-table th.qa-month-venue-col,
.qa-month-table td.qa-month-venue-col {
  width: 140px; min-width: 140px; text-align: left !important; vertical-align: middle !important;
  position: sticky; left: 0; z-index: 2;
}
.qa-month-table td.qa-month-venue-col {
  font-weight: 600; border-left: 6px solid var(--tile-hue, var(--color-border));
  background: color-mix(in srgb, var(--tile-hue, var(--color-border)) 30%, var(--color-surface));
}
.qa-month-table th.qa-month-venue-col { background: var(--color-surface); z-index: 5; }
.qa-venue-label { display: flex; align-items: center; gap: .4rem; }
.qa-month-table th.is-today, .qa-month-table td.is-today { outline: 2px solid var(--color-primary); }
.qa-month-table td.is-past { background: #d1d5db; border-color: #9ca3af; }
.qa-month-table th.is-past { color: #4b5563; }
.qa-month-table th.is-past .qa-day-num { color: #4b5563; }
.qa-slot.is-disabled { background: var(--color-bg); color: var(--color-text-muted); cursor: not-allowed; }
.qa-day-num { font-weight: 700; font-size: .82rem; }
.qa-slots { display: flex; flex-direction: column; gap: .25rem; }
.qa-slot {
  font-family: inherit; font-size: .68rem; font-weight: 700; text-align: left; border-radius: 5px;
  padding: .3rem .4rem; border: none; cursor: pointer; min-height: 30px; line-height: 1.3;
}
.qa-slot.is-open { background: color-mix(in srgb, var(--status-open) 20%, var(--color-bg)); color: color-mix(in srgb, var(--status-open) 70%, var(--color-text)); }
.qa-slot.is-open:hover { background: color-mix(in srgb, var(--status-open) 35%, var(--color-bg)); }
.qa-slot.is-booked {
  background: color-mix(in srgb, var(--dot-color) 20%, transparent); color: var(--dot-color);
  display: flex; flex-direction: column; gap: 1px; min-height: 34px;
}
.qa-slot.is-booked:hover { text-decoration: none; outline: 1px solid var(--dot-color); }
.qa-slot-client {
  font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qa-slot-session {
  font-weight: 700; font-size: .62rem; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

@media (max-width: 768px) {
  .qa-month-table td { min-width: 120px; }
}

/* ===== Right-click context menu (confirmed booking slots in New Booking calendar) ===== */
.qa-context-menu {
  display: none; position: fixed; z-index: 400; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: 8px; box-shadow: var(--shadow);
  padding: .3rem; min-width: 170px;
}
.qa-context-menu.is-open { display: block; }
.qa-context-menu a {
  display: block; padding: .55rem .75rem; border-radius: 6px; font-size: .85rem;
  font-weight: 600; color: var(--color-text);
}
.qa-context-menu a:hover { background: var(--color-bg); text-decoration: none; }

/* ===== Modal ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 300;
  align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.25rem; width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto;
}

/* ===== Heat-map ===== */
.heatmap { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.heatmap-cell {
  aspect-ratio: 1; border-radius: 6px; background: var(--color-bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
  font-size: .68rem; font-weight: 600; color: var(--color-text-muted); text-decoration: none;
  border: 1px solid var(--color-border); transition: transform .1s ease;
}
.heatmap-cell:hover { transform: scale(1.05); text-decoration: none; }
.heatmap-cell[style*="background"] { color: #1f2430; border-color: transparent; }
.heatmap-count {
  font-size: .62rem; font-weight: 700; background: rgba(0,0,0,.12); border-radius: 999px;
  padding: 0 .35rem; line-height: 1.3;
}
.heatmap-client {
  font-size: .64rem; font-weight: 700; max-width: 92%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center;
}

/* ===== Responsive breakpoints ===== */
@media (max-width: 1024px) {
  .card-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 2px 0 12px rgba(0,0,0,.15);
  }
  .sidebar.open { transform: translateX(0); }
  .app-body { margin-left: 0; }
  .hamburger { display: flex; }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 90;
  }
  .sidebar-overlay.visible { display: block; }
  .main-content { padding: 1rem .75rem; }
  table:not(.qa-month-table) { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 375px) {
  .main-content { padding: .75rem .5rem; }
  .login-card { padding: 1.25rem; }
}
