/* Design system. Visual language modeled on an admin panel the project
   owner chose as reference: teal gradient, Inter, 8px cards, dark sidebar.
   Tenant pages override --brand; the derived tokens below recompute from
   it, so they're declared on every element that may set its own --brand. */

:root {
  --brand: #008b84;
  --sidebar: #064e4a;
  --bg: #f7faf9;
  --surface: #ffffff;
  --surface-2: #fafbfb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --ok-line: #86efac;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-line: #fecaca;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --warn-line: #fde68a;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgb(0 0 0 / .08), 0 1px 2px -1px rgb(0 0 0 / .08);
  --shadow-lg: 0 20px 40px -12px rgb(0 0 0 / .25);
  /* Floating panels (menus, dropdown lists): a hairline plus two soft layers, so the panel lifts off the page without a heavy smudge. */
  --shadow-pop: 0 0 0 1px rgb(16 24 40 / .02), 0 4px 8px -2px rgb(16 24 40 / .08), 0 14px 28px -6px rgb(16 24 40 / .14);
  /* Inter has no Arabic letters; the browser falls through to Noto Sans Arabic
     for those, and only downloads it on a page that actually shows Arabic. */
  --font: "Inter", "Noto Sans Arabic", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root, .brand-scope {
  --brand-dark: color-mix(in srgb, var(--brand) 77%, #000);
  --brand-soft: color-mix(in srgb, var(--brand) 10%, #fff);
  --brand-ring: color-mix(in srgb, var(--brand) 22%, transparent);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-font-smoothing: antialiased; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3, p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.icon { flex-shrink: 0; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---------- App shell ---------- */

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

.sidebar {
  width: 256px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 20px 12px;
  background: var(--sidebar);
  color: #fff;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid rgb(255 255 255 / .08);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.wordmark .icon { color: #5eead4; }

.sidebar-badge {
  padding: 2px 8px;
  border-radius: 4px;
  background: rgb(255 255 255 / .12);
  color: rgb(255 255 255 / .85);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.nav-section {
  padding: 20px 12px 8px;
  color: rgb(255 255 255 / .35);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 2px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: rgb(255 255 255 / .85);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgb(255 255 255 / .08); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: var(--shadow); }
.nav-end { margin-left: auto; display: flex; opacity: .75; }
.sidebar-backdrop { display: none; }
/* A platform admin inside one business: the way back out, and whose panel this is. */
.nav-back { margin-top: 14px; color: rgb(255 255 255 / .7); font-size: 13px; }
.nav-scope { margin: 6px 0 2px; padding: 10px 12px; border-radius: var(--radius-sm); background: rgb(255 255 255 / .08); }
.nav-scope-label { display: block; color: rgb(255 255 255 / .5); font-size: 10px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.nav-scope strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 600; color: var(--text-2); }
.topbar .menu-btn { display: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

.user-menu { position: relative; margin-left: auto; }

.user-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 4px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: 500 14px var(--font);
  cursor: pointer;
}
.user-trigger:hover { background: var(--bg); }

.avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 600;
}

.dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 230px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}
.user-menu.open .dropdown { display: block; }
.dropdown-head { margin-bottom: 6px; padding: 8px 10px 12px; border-bottom: 1px solid var(--border); }
.dropdown-name { font-weight: 600; }
.dropdown-email { margin-bottom: 8px; color: var(--muted); font-size: 12px; word-break: break-all; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-2);
  font: 500 14px var(--font);
  text-align: left;
  cursor: pointer;
}
.dropdown-item:hover { background: #f3f4f6; color: var(--text); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-soft); }

.content { width: 100%; max-width: 1200px; padding: 24px; }

/* Shell renders instantly; page content waits for the /me role check. */
body.auth-pending .content,
body.auth-pending .user-menu { visibility: hidden; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.page-sub { margin-top: 4px; color: var(--muted); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: 500 14px/1 var(--font);
  white-space: nowrap;
  text-decoration: none !important;
  cursor: pointer;
  transition: filter .15s, background .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
/* Every form disables its submit button while the request is in flight (so a
   second click can't send it twice); the spinner tells the user why. */
.btn[type="submit"]:disabled::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); box-shadow: var(--shadow); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); }
.btn-secondary { color: var(--text-2); background: var(--surface); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); border-color: var(--border-strong); }
.btn-ghost { height: 30px; padding: 0 10px; color: var(--muted); background: none; font-size: 13px; }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.btn-danger { color: #fff; background: var(--danger); box-shadow: var(--shadow); }
.btn-danger:hover:not(:disabled) { filter: brightness(1.07); }
.btn-ghost.danger { color: var(--danger); }
.btn-ghost.danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.btn-lg { height: 40px; }
.btn-block { width: 100%; }

/* Segmented control (Upcoming | Past), like the reference's 7d/30d/90d. */
.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.segmented button {
  height: 30px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font: 500 13.5px var(--font);
  cursor: pointer;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--brand); color: #fff; }

.stack { display: flex; flex-direction: column; gap: 16px; }

/* Weekly hours editor */
.week-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.week-row:last-child { border-bottom: 0; }
.week-day { display: flex; align-items: center; gap: 8px; margin: 0; padding-top: 7px; cursor: pointer; }
.week-day input { width: 16px; height: 16px; accent-color: var(--brand); }
.week-windows { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding-top: 2px; }
.week-windows > .text-muted { padding-top: 5px; }
.week-window { display: flex; align-items: center; gap: 8px; }
.week-window input { width: 120px; }
@media (max-width: 560px) {
  .week-row { grid-template-columns: 1fr; gap: 4px; }
}

.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.toolbar select, .toolbar input[type="date"] { width: auto; min-width: 160px; }
.toolbar input[type="search"] { flex: 1; min-width: 0; max-width: 420px; }
.toolbar .spacer { flex: 1; }
/* Appointments: the day stepper (‹ calendar › Today) and the time-of-day range. */
.day-nav, .time-range { display: inline-flex; align-items: center; gap: 6px; }
.day-nav input[type="date"] { min-width: 0; }
.time-range { color: var(--muted); white-space: nowrap; }
.time-range input[type="time"] { width: auto; }
.time-range .field-error { margin: 0; }
.toolbar #apptSearch { min-width: 220px; }
.text-muted { color: var(--muted); }

/* ---------- Forms ---------- */

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
}
.req { color: var(--danger); }
.hint { margin-top: 8px; color: var(--muted); font-size: 12.5px; }

input, select, textarea {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: 14px var(--font);
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 8px 12px; }
input::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
input[readonly] { background: var(--bg); color: var(--text-2); }
/* A field whose value was checked and found wrong (fieldError() in ui.js). */
[aria-invalid="true"] { border-color: var(--danger); }
[aria-invalid="true"]:focus { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.field-error { margin-top: 6px; color: var(--danger); font-size: 12.5px; }
.field-error:not([hidden]) + .hint { display: none; }   /* the message already says what the hint would */

/* Dropdowns draw their list inside the page (Chrome, Edge and Android from
   version 135) instead of handing it to the operating system's pop-up menu,
   which can't be styled and which the page can't keep open. The list sits in
   the browser's top layer, so a modal's scrolling box doesn't cut it off.
   Browsers without this skip the whole block and keep their built-in list.

   The look follows the usual pattern for a select menu: a quiet field, a
   floating panel with a soft shadow, a grey highlight under the pointer or
   the arrow keys, and a tick beside the current choice. */
@supports (appearance: base-select) {
  select, ::picker(select) { appearance: base-select; }

  /* The arrow is pinned to the end, on its own patch of the field's background:
     a choice too long for the field is cut off under it, not pushed over it. */
  select {
    position: relative;
    align-items: center;
    padding-inline-end: 36px;
    overflow: hidden;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgb(16 24 40 / .05);
    cursor: pointer;
  }
  select:hover:not(:disabled, :focus) { border-color: var(--border-strong); }
  select:open { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
  select:disabled { background: var(--bg); color: var(--muted); box-shadow: none; cursor: not-allowed; }
  select::picker-icon {
    content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    position: absolute;
    inset-block: 0;
    inset-inline-end: 1px;
    display: flex;
    align-items: center;
    padding-inline: 8px 10px;
    background: inherit;
  }

  ::picker(select) {
    margin-block: 6px;
    padding: 4px;
    max-block-size: 304px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-pop);
    /* Fades in over a tenth of a second, sliding 4px into place. */
    opacity: 0;
    translate: 0 -4px;
    transition: opacity .12s ease-out, translate .12s ease-out, display .12s allow-discrete, overlay .12s allow-discrete;
  }
  ::picker(select):popover-open { opacity: 1; translate: 0; }
  @starting-style { ::picker(select):popover-open { opacity: 0; translate: 0 -4px; } }

  select option {
    gap: 12px;
    min-block-size: 34px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 14px;
    line-height: 20px;
    cursor: pointer;
  }
  select option:hover, select option:focus-visible { background: #f3f4f6; color: var(--text); outline: none; }
  select option:checked { color: var(--text); font-weight: 500; }
  select option:disabled { color: var(--muted-2); cursor: not-allowed; }
  /* The tick, moved to the end of the row and drawn in the brand colour. */
  select option::checkmark {
    order: 1;
    margin-inline-start: auto;
    content: "";
    width: 16px;
    height: 16px;
    background: var(--brand);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  }
}
}
input[type="color"] { width: 44px; padding: 3px; flex-shrink: 0; cursor: pointer; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.input-wrap { position: relative; }
.input-wrap input { padding-right: 40px; }
.input-wrap .icon-btn { position: absolute; top: 1px; right: 1px; }
.inline-field { display: flex; gap: 8px; }

/* ---------- Cards, stats, grids ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 15px; font-weight: 600; }
.card-sub { margin-top: 2px; color: var(--muted); font-size: 13px; }
.card-body { padding: 20px; }
.card-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.stats {
  display: grid;
  /* 200px: room for a figure like "AED 128,450" beside its icon. Four tiles
     sit in one row on a wide screen and fold to two by two below that. */
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
/* Exactly four tiles: one row, or two by two — never three and a straggler. */
.stats.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .stats.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .stats.four { grid-template-columns: minmax(0, 1fr); } }
.stat {
  --accent: var(--brand);
  --accent-soft: var(--brand-soft);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
}
.stat.amber { --accent: #d97706; --accent-soft: #fef3c7; }
.stat.violet { --accent: #7c3aed; --accent-soft: #ede9fe; }
.stat.red { --accent: #dc2626; --accent-soft: #fee2e2; }
.stat-label { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); font-weight: 500; }
.stat-value { margin-top: 10px; font-size: 28px; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; white-space: nowrap; }
.stat > div:first-child { min-width: 0; }
.stat-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}

.grid-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 16px; }
.grid-2, .grid-even { margin-bottom: 16px; }
.grid-2:last-child, .grid-even:last-child { margin-bottom: 0; }

/* Under a headline figure: how it compares with the period before. The arrow
   and the wording carry the direction; the colour only repeats it. */
.stat-sub, .stat-delta { margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.stat-delta strong { font-weight: 600; }
.stat-delta.up strong { color: var(--ok); }
.stat-delta.down strong { color: var(--danger); }

/* ---------- Charts (assets/charts.js) ---------- */
/* One hue for "how many" (--chart); four tested apart for booking outcomes —
   picked with a colour-blindness check, not by eye. Marks stay thin, the
   grid stays a hairline: the numbers are the only loud thing. */
:root {
  --chart: #00a397;
  --chart-soft: #e6f6f4;
  --chart-completed: #00a397;
  --chart-upcoming: #7c3aed;
  --chart-no-show: #d67d00;
  --chart-cancelled: #dc2626;
}

.chart-empty { padding: 28px 0; color: var(--muted); text-align: center; }
.chart-key { width: 10px; height: 10px; flex: none; border-radius: 3px; }

.chart-columns {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 10px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.chart-y { display: flex; flex-direction: column; justify-content: space-between; height: 200px; text-align: end; }
.chart-y span { line-height: 1; translate: 0 -50%; }
.chart-y span:last-child { translate: 0 50%; }
.chart-plot {
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  height: 200px;
  /* Three hairlines: top of the scale, halfway, and the baseline. */
  background:
    linear-gradient(var(--border), var(--border)) top / 100% 1px no-repeat,
    linear-gradient(var(--border), var(--border)) center / 100% 1px no-repeat;
  border-bottom: 1px solid var(--border-strong);
}
/* The whole slot is the hover target, not just the painted column. */
.chart-slot { display: flex; align-items: flex-end; justify-content: center; padding: 0 1px; border-radius: 4px 4px 0 0; outline: none; cursor: default; }
.chart-slot:hover, .chart-slot:focus-visible { background: color-mix(in srgb, var(--chart) 8%, transparent); }
.chart-column { width: 100%; max-width: 24px; border-radius: 4px 4px 0 0; background: var(--chart); }
.chart-slot:hover .chart-column, .chart-slot:focus-visible .chart-column { filter: brightness(.88); }
.chart-x { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
.chart-x span { overflow: visible; white-space: nowrap; text-align: center; justify-self: center; }

.chart-row { display: block; padding: 9px 0; color: inherit; }
.chart-row + .chart-row { border-top: 1px solid var(--border); }
.chart-row:first-child { padding-top: 0; }
.chart-row:last-child { padding-bottom: 0; }
a.chart-row:hover { text-decoration: none; }
a.chart-row:hover .chart-row-label { color: var(--brand); }
.chart-row-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 7px; }
.chart-row-label { min-width: 0; flex: 1; overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.chart-row-note { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.chart-row-value { min-width: 2.5ch; font-variant-numeric: tabular-nums; text-align: end; }
.chart-row-track { height: 8px; border-radius: 0 4px 4px 0; background: var(--chart-soft); }
.chart-row-track i { display: block; height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--chart); }

.chart-share { display: flex; gap: 2px; height: 12px; margin-bottom: 16px; }
.chart-share i { min-width: 3px; outline: none; }
.chart-share i:first-child { border-radius: 4px 0 0 4px; }
.chart-share i:last-child { border-radius: 0 4px 4px 0; }
.chart-share i:only-child { border-radius: 4px; }
.chart-share i:hover, .chart-share i:focus-visible { filter: brightness(.88); }
.chart-legend-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.chart-legend-row span:first-of-type { flex: 1; color: var(--text-2); }
.chart-legend-row strong { font-variant-numeric: tabular-nums; }
.chart-legend-share { width: 4ch; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; text-align: end; }

.chart-tip {
  position: absolute;
  z-index: 70;
  max-width: 240px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: #111827;
  color: #fff;
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: var(--shadow-pop);
  pointer-events: none;
}
.chart-tip-head { margin-bottom: 2px; color: rgb(255 255 255 / .7); }
.chart-tip-row { display: flex; align-items: center; gap: 6px; }
.chart-tip-row span { color: rgb(255 255 255 / .7); }

/* ---------- One staff member's bookings (Appointments page) ---------- */
.staff-focus {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 28px;
  margin-bottom: 16px;
  padding: 14px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.staff-focus-who { margin-inline-end: auto; }
.staff-focus-stat strong { display: block; font-size: 18px; line-height: 1.2; }
.staff-focus-stat span { color: var(--muted); font-size: 12.5px; }

.meta-list { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; font-weight: 500; word-break: break-word; }

.brand-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
}

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }

th {
  height: 40px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcfb; }
/* Action buttons sit side by side in a column only as wide as they need, and
   start at the same point on every row — so "Edit" lines up whether the
   button after it says "Activate" or "Deactivate". (Right-aligning them made
   each row start wherever its own labels happened to end.) A table too wide
   for a phone scrolls inside .table-wrap. */
td.actions { width: 1%; white-space: nowrap; }
td.actions .btn { margin: 1px 0; }
.nowrap { white-space: nowrap; }
a.row-title { color: var(--text); font-weight: 600; }
a.row-title:hover { color: var(--brand); text-decoration: none; }
.cell-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; }
.empty { padding: 40px 16px !important; color: var(--muted); text-align: center; }

/* ---------- Pills, tags, notices, toasts ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  text-transform: capitalize;
  white-space: nowrap;
}
.pill-ok { color: var(--ok); background: var(--surface); border-color: var(--ok-line); }
.pill-muted { color: #4b5563; background: #f3f4f6; }
.pill-brand { color: var(--brand-dark); background: var(--brand-soft); }
.pill-danger { color: var(--danger); background: var(--danger-soft); }
.pill-warn { color: var(--warn); background: var(--warn-soft); }

.sample-tag {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  vertical-align: middle;
}

.notice {
  display: none;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.notice.show { display: block; }
.notice.error { color: #b91c1c; background: var(--danger-soft); border-color: var(--danger-line); }
.notice.ok { color: var(--ok); background: var(--ok-soft); border-color: #bbf7d0; }
.notice.info { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }

.toast-host {
  position: fixed;
  inset-inline-end: 20px; /* right in English, left in Arabic */
  bottom: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  max-width: 360px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #111827;
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease;
}
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgb(17 24 39 / .45);
  backdrop-filter: blur(3px);
}
.modal.open { display: flex; }
body.modal-open { overflow: hidden; }

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  animation: modal-in .18s ease;
}
.modal-card.wide { max-width: 720px; }
tr.row-link { cursor: pointer; }
.pick-list { margin-top: 6px; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius); }
.pick-list:empty { display: none; }
.picked { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border: 1px solid var(--brand); border-radius: var(--radius); background: var(--brand-soft); }
fieldset.plain { min-width: 0; margin: 0; padding: 0; border: 0; }
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 16px; }
.mini-stats div { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.mini-stats strong { display: block; font-size: 20px; line-height: 1.2; }
.mini-stats span { color: var(--muted); font-size: 12.5px; }
@media (max-width: 560px) { .mini-stats { grid-template-columns: repeat(2, 1fr); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 6px 24px; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { padding: 12px 24px 8px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 24px 20px; }

/* ---------- Sign-in page ---------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  background: linear-gradient(170deg, var(--brand-soft) 0%, var(--bg) 45%, #fff 100%);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 30px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  box-shadow: 0 10px 25px -8px color-mix(in srgb, var(--brand) 55%, transparent);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.auth-context { display: flex; align-items: center; gap: 8px; margin-top: 14px; color: var(--muted); font-size: 15px; }
.auth-card {
  width: 100%;
  max-width: 420px;
  margin-top: 32px;
  padding: 24px 20px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 18px; font-weight: 600; }
.auth-card .page-sub { margin-bottom: 20px; }
.auth-foot { margin-top: 16px; text-align: center; font-weight: 500; }
.auth-note { max-width: 420px; margin-top: 20px; color: var(--muted); font-size: 12.5px; text-align: center; }

/* ---------- Public booking page ---------- */

.public-top {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.biz { display: flex; align-items: center; gap: 12px; min-width: 0; font-size: 16px; font-weight: 600; }
.biz-mark {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  font-weight: 700;
}

.hero { padding: 36px 24px 28px; background: linear-gradient(180deg, var(--brand-soft), var(--bg)); }
.hero-inner { max-width: 1080px; margin: 0 auto; }
.hero h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.hero p { margin-top: 6px; color: var(--muted); font-size: 15px; }

.booking-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
  gap: 20px;
  max-width: 1128px; /* 1080 content + 2×24 padding, aligns with .hero-inner */
  margin: 0 auto;
  padding: 0 24px 48px;
}
.steps { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.step-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 15px; font-weight: 600; }
.step-num {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 600;
}

.service-list { display: grid; gap: 10px; }
.service-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: start; /* left in English, right in Arabic */
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.service-option:hover { border-color: var(--border-strong); }
.service-option.selected { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand); }
.check {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
}
.service-option.selected .check { background: var(--brand); border-color: var(--brand); }
.service-option.selected .check::after {
  content: "";
  width: 5px;
  height: 9px;
  margin-top: -2px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.service-info { flex: 1; min-width: 0; }
.service-name { display: block; font-weight: 600; }
.service-meta { display: block; color: var(--muted); font-size: 13px; }
.service-price { font-weight: 600; white-space: nowrap; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font: 500 13.5px var(--font);
  cursor: pointer;
}
.chip:hover { border-color: var(--brand); color: var(--brand-dark); }
.chip.selected { background: var(--brand); border-color: var(--brand); color: #fff; }

.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.week-nav .label { font-weight: 600; color: var(--text-2); }
.day-strip { display: grid; grid-template-columns: repeat(7, minmax(64px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; }
.day-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  font: 500 12px var(--font);
  cursor: pointer;
}
.day-chip .dnum { font-size: 17px; font-weight: 700; color: var(--text); }
.day-chip .dcount { color: var(--ok); }
.day-chip:hover:not(:disabled) { border-color: var(--brand); }
.day-chip.selected { background: var(--brand); border-color: var(--brand); color: #fff; }
.day-chip.selected .dnum, .day-chip.selected .dcount { color: #fff; }
.day-chip:disabled { cursor: default; background: var(--surface-2); }
.day-chip:disabled .dnum, .day-chip:disabled .dcount { color: var(--muted-2); }

.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.slot {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font: 500 13.5px var(--font);
  cursor: pointer;
}
.slot:hover { border-color: var(--brand); color: var(--brand-dark); }
.slot.selected { background: var(--brand); border-color: var(--brand); color: #fff; }

.summary { position: sticky; top: 20px; }
.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.summary-row span:first-child { color: var(--muted); }
.summary-row span:last-child { font-weight: 500; text-align: end; }
.summary-total { display: flex; justify-content: space-between; margin-bottom: 16px; padding: 14px 0 4px; font-size: 16px; font-weight: 700; }
.summary-total:has(+ .summary-vat:not([hidden])) { margin-bottom: 2px; }
.summary-vat { display: flex; justify-content: space-between; margin-bottom: 16px; color: var(--muted); font-size: 12.5px; }

.success-wrap { max-width: 560px; margin: 0 auto; padding: 0 24px 48px; }
.success-wrap > .card + .card, .success-wrap > .card + form.card { margin-top: 16px; }
.hero-inner.manage-narrow { max-width: 512px; } /* lines the heading up with the 560px column below */
.success { padding: 40px 24px; text-align: center; }
.success h2 { font-size: 20px; font-weight: 600; }
.success .page-sub { margin: 8px 0 24px; }
.success-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--ok-soft);
  color: var(--ok);
}
.public-foot { padding: 0 24px 32px; color: var(--muted); font-size: 12.5px; text-align: center; }

/* Languages. The customer pages can run in Arabic, which reads right to left
   (<html dir="rtl">): flex and grid mirror by themselves, so only the few
   rules below are needed. */
.public-actions { display: flex; align-items: center; gap: 4px; }
body.lang-pending > *:not(.public-top) { visibility: hidden; } /* until the language is known — no flash of the wrong one */
[dir="rtl"] .week-nav button { transform: scaleX(-1); }          /* ‹ › point the other way */
[dir="rtl"] input[dir="ltr"] { text-align: right; }              /* numbers stay left-to-right, but sit where Arabic text starts */

/* ---------- Responsive ---------- */

@media (max-width: 1000px) {
  .grid-2, .grid-even { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgb(17 24 39 / .45);
  }
  .topbar .menu-btn { display: inline-flex; margin-left: -8px; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px; }
  /* minmax(0, …), not plain 1fr: a 1fr column refuses to be narrower than its
     widest content (the 7-day strip), which pushed the whole page wider than
     a phone screen. Now the strip scrolls inside its card instead. */
  .booking-layout { grid-template-columns: minmax(0, 1fr); }
  .summary { position: static; }
}

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .user-trigger .user-name,
  .user-trigger > .icon { display: none; }
  .public-top, .hero { padding-left: 16px; padding-right: 16px; }
  .booking-layout, .success-wrap { padding: 0 16px 40px; }
  .hero h1 { font-size: 22px; }
}

/* The privacy notice: plain reading text. */
.privacy-text p { margin: 6px 0 18px; line-height: 1.6; }
.privacy-text .card-title { margin-top: 4px; }

/* A tick or radio with its label on one line (e.g. who performs a service). */
.pick { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-weight: 400; cursor: pointer; }
.pick input { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--brand); }
.pick-list { margin: 4px 0 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; max-height: 220px; overflow-y: auto; }

