/* 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; }
/* A part switched off for this business, as a platform admin sees it (§5.1). */
.nav-off { margin-left: auto; padding: 0 8px; border: 1px solid rgb(255 255 255 / .25); border-radius: 999px; color: rgb(255 255 255 / .65); font-size: 11px; line-height: 18px; }
.nav-off ~ .nav-end { margin-left: 0; }
.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; }
tfoot td { border-bottom: 0; font-weight: 600; }   /* a totals row (Dashboard Today, Reports by staff) */
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; flex-wrap: wrap; 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-logo { height: 40px; width: auto; max-width: min(220px, 50vw); object-fit: contain; }
.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; }

/* The receipt (views/booking/receipt.php): a narrow paper on screen, and the
   only thing that prints. The paper size is chosen by the page (an @page rule
   it writes itself); .narrow is the 80 mm roll. Mirrors in Arabic by itself:
   rows are flex, text is centred or start-aligned. */
.receipt-wrap { max-width: 460px; margin: 24px auto 0; padding: 0 16px 40px; }
.receipt-wrap > .page-sub, .receipt-wrap > .notice { margin-bottom: 16px; }
.receipt { max-width: 420px; margin: 0 auto; padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.receipt.narrow { max-width: 302px; padding: 16px; font-size: 12px; } /* 80 mm */
.receipt-head, .receipt-doc { text-align: center; }
.receipt-head p, .receipt-doc p { margin-top: 2px; color: var(--text-2); }
.receipt-head p:empty, .receipt-doc p:empty { display: none; }
.receipt-logo { display: block; max-width: 100%; max-height: 56px; margin: 0 auto 8px; object-fit: contain; }
.receipt-head .receipt-seller { font-size: 17px; font-weight: 700; color: var(--text); }
.receipt-doc { margin: 14px 0; padding: 12px 0; border-top: 1px dashed var(--border-strong); border-bottom: 1px dashed var(--border-strong); }
.receipt-doc h1 { font-size: 16px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
[dir="rtl"] .receipt-doc h1 { letter-spacing: 0; } /* spacing between letters breaks Arabic joining */
.receipt-doc .receipt-number { font-weight: 600; color: var(--text); }
.receipt-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.receipt-row span:last-child { text-align: end; white-space: nowrap; }
.receipt-line { padding: 5px 0; }
.receipt-line .receipt-row { padding-bottom: 0; }
.receipt-sub { color: var(--muted); font-size: .9em; }
.receipt-totals { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border-strong); }
.receipt-total { font-size: 1.15em; font-weight: 700; }
.receipt-paid { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border-strong); }
.receipt-paid:empty { display: none; }
.receipt-paid-title { font-weight: 600; }
.receipt-foot { margin-top: 14px; color: var(--muted); font-size: .9em; text-align: center; }
.receipt-tools { max-width: 420px; margin: 16px auto 0; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.receipt-tools .field { flex: 1 1 180px; margin: 0; }
.receipt-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

@media print {
  /* Only the receipt: no page frame, buttons or messages. */
  .public-top, .public-foot { display: none !important; }
  .receipt-wrap > :not(.receipt) { display: none !important; }
  body { background: #fff; color: #000; }
  .receipt-wrap { max-width: none; margin: 0; padding: 0; }
  .receipt { max-width: 140mm; margin: 0 auto; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  .receipt.narrow { max-width: none; margin: 0; padding: 0; } /* the roll is as wide as the page, edge to edge (beats the on-screen .narrow padding) */
}

/* 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); }
/* A checkbox with a line of explanation under its label (platform: Features). */
.feature-pick { align-items: flex-start; padding: 8px 0; }
.feature-pick input { margin-top: 2px; }
.feature-pick .hint { display: block; margin-top: 2px; }
.pick-list { margin: 4px 0 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; max-height: 220px; overflow-y: auto; }


/* ---------- calendar (admin ?page=calendar) ----------
   A CSS grid: the time gutter, then one column per staff member. Inside a
   column everything is placed by minutes (calendar.php sets top/height),
   so the hour lines are just a repeating background. */
.cal-title { font-size: 15px; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-left: auto; font-size: 12px; color: var(--muted); }
.cal-key { display: inline-flex; align-items: center; gap: 6px; }
.cal-key::before { content: ""; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--border-strong); }
.cal-key.booked::before { background: var(--brand-soft); border-color: var(--brand); }
.cal-key.completed::before { background: var(--ok-soft); border-color: var(--ok); }
.cal-key.no_show::before { background: #f3f4f6; border-color: var(--muted-2); }
.cal-key.off::before { background: repeating-linear-gradient(135deg, #eef0f2 0 4px, #f8f9fa 4px 8px); }

.cal-card { padding: 0; overflow: hidden; }
.cal-scroll { overflow: auto; max-height: calc(100vh - 230px); min-height: 360px; }
.cal { display: grid; grid-template-columns: 64px repeat(var(--cols, 1), minmax(var(--colmin, 150px), 1fr)); min-width: max-content; }
.cal > .empty { grid-column: 1 / -1; padding: 32px; }
.cal-corner, .cal-head { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--border); }
.cal-corner { left: 0; z-index: 4; }
.cal-head { padding: 10px 12px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-head strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-head.today strong { color: var(--brand-dark); }
.cal-head.today { box-shadow: inset 0 -2px 0 var(--brand); }
.cal-col.past { background-color: rgb(249 250 251); }
.cal-gutter { position: sticky; left: 0; z-index: 2; background: var(--surface); }
.cal-hour { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.cal-hour:first-child { transform: none; }
.cal-col {
  position: relative; border-left: 1px solid var(--border);
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(#f3f4f6 1px, transparent 1px);
  background-size: 100% var(--hour), 100% var(--step);   /* hours, and the business's start-time grid */
}
.cal-closed { position: absolute; left: 0; right: 0; background: rgb(243 244 246 / .75); }
.cal-off { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(135deg, rgb(229 231 235 / .8) 0 6px, rgb(249 250 251 / .8) 6px 12px); }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 1; }
.cal-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.cal-appt {
  position: absolute; left: 4px; right: 4px; z-index: 2; overflow: hidden;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 4px 8px; text-align: left; font: inherit; font-size: 12px; line-height: 1.3; cursor: pointer;
  color: var(--text); background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 35%, #fff);
  border-left: 3px solid var(--brand); border-radius: var(--radius-sm);
}
.cal-appt:hover, .cal-appt:focus-visible { box-shadow: var(--shadow-pop); z-index: 3; }
.cal-appt:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.cal-appt.completed { background: var(--ok-soft); border-color: var(--ok-line); border-left-color: var(--ok); }
.cal-appt.no_show { background: #f3f4f6; border-color: var(--border-strong); border-left-color: var(--muted-2); color: var(--muted); }
.cal-appt.no_show .cal-appt-who { text-decoration: line-through; }
.cal-appt-who { font-weight: 600; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-appt-what { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; color: var(--text-2); }
.cal-appt.short { flex-direction: row; align-items: center; gap: 6px; padding-block: 1px; }
.cal-details { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; margin: 0; }
.cal-details dt { color: var(--muted); }
.cal-details dd { margin: 0; }
@media (max-width: 640px) {
  .cal-legend { margin-left: 0; }
  .cal-scroll { max-height: calc(100vh - 290px); }
  .cal { grid-template-columns: 56px repeat(var(--cols, 1), minmax(min(var(--colmin, 150px), 130px), 1fr)); }
}
/* Dragging a booking (calendar.php): the original fades, a copy follows the pointer. */
.cal-appt.movable { cursor: grab; touch-action: manipulation; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.cal-appt.dragging { opacity: .35; }
.cal-ghost { pointer-events: none; z-index: 6; cursor: grabbing; box-shadow: var(--shadow-lg); border-left-width: 4px; }
.cal-ghost.invalid { background: var(--danger-soft); border-color: var(--danger-line); border-left-color: var(--danger); }
.cal-ghost.invalid .cal-appt-what { color: var(--danger); }
.cal-col.no-drop::after { content: ""; position: absolute; inset: 0; z-index: 1; background: rgb(229 231 235 / .55); pointer-events: none; }
/* Hovering an empty time in the calendar: where a click would book. */
.cal-slot-hint {
  position: absolute; left: 4px; right: 4px; z-index: 1; pointer-events: none;
  display: flex; align-items: center; padding: 0 8px; font-size: 11.5px; font-weight: 600;
  color: var(--brand-dark); background: color-mix(in srgb, var(--brand) 8%, transparent);
  border: 1px dashed color-mix(in srgb, var(--brand) 55%, transparent); border-radius: var(--radius-sm);
}
.cal-col:has(> .cal-slot-hint) { cursor: pointer; }
/* Settings: the logo field. A checkerboard behind the preview shows what is transparent. */
.logo-field { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-preview {
  display: flex; align-items: center; justify-content: center; width: 240px; height: 72px; padding: 8px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: conic-gradient(#f3f4f6 25%, #fff 0 50%, #f3f4f6 0 75%, #fff 0) 0 0 / 16px 16px;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-actions { display: flex; gap: 8px; }
.logo-actions .btn.disabled { opacity: .6; pointer-events: none; }
/* Hidden from sight but still there for keyboards and screen readers. */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.logo-actions:has(#blogoFile:focus-visible) #logoPick { outline: 2px solid var(--brand); outline-offset: 2px; }
/* Figures in tables (Reports): right-aligned, digits of equal width so columns line up. */
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.notice > div + div { margin-top: 4px; }
/* The message log of a booking (views/admin/_messages.php). */
.msg-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.msg-list > .empty { padding: 16px 0; color: var(--muted); }
.msg { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); }
.msg-head { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.msg details, .msg > .cell-sub { grid-column: 1 / -1; }
.msg summary { cursor: pointer; font-size: 13px; color: var(--brand-dark); }
.msg-subject { margin: 8px 0 0; font-weight: 600; font-size: 13px; }
.msg-text { margin: 6px 0 0; padding: 10px 12px; white-space: pre-wrap; word-break: break-word; font: inherit; font-size: 13px; line-height: 1.5; background: var(--surface-2); border-radius: var(--radius-sm); }
.msg-error { color: var(--danger); }
.msg .pill { justify-self: start; }
@media (max-width: 520px) { .msg { grid-template-columns: 1fr; } }
.btn.btn-sm { padding: 3px 8px; min-height: 0; font-size: 12.5px; }
/* My profile (views/profile.php) and the top-bar circle when it holds a picture. */
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.profile-photo { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.profile-avatar { width: 96px; height: 96px; font-size: 32px; overflow: hidden; }
.profile-photo-actions .hint { margin-top: 8px; }
.profile-photo-actions:has(#avatarFile:focus-visible) label.btn { outline: 2px solid var(--brand); outline-offset: 2px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.card-body .modal-footer { padding: 12px 0 0; }   /* the two-factor states, drawn into a card instead of the window */

/* The checkout window (views/_checkout.php) and the Payments page (views/admin/payments.php), docs/GUIDE.md §7.9. */
.checkout-card { max-width: 560px; }
.checkout-card .modal-footer { position: sticky; bottom: 0; padding-top: 14px; border-top: 1px solid var(--border); background: var(--surface); } /* Take payment stays in view while the form scrolls */
.co-who { margin-bottom: 14px; color: var(--text-2); font-weight: 500; }
.co-visit { display: flex; align-items: center; gap: 12px; margin: 0 0 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-weight: 400; cursor: pointer; }
.co-visit:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.co-visit input { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--brand); }
.co-visit-main { flex: 1; min-width: 0; }
.co-visit-price { font-weight: 600; white-space: nowrap; }
.co-discount, .co-tip, .co-pay { display: flex; align-items: center; gap: 8px; }
.co-discount input, .co-pay input { flex: 1; min-width: 0; }
.co-tip, .co-pay { margin-bottom: 8px; }
.co-tip label { flex: 1; min-width: 0; margin: 0; }
.co-tip input { flex: 0 0 130px; width: 130px; }
.co-pay select { flex: 0 0 140px; width: 140px; }
.co-sum { margin: 4px 0 18px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); transition: opacity .15s; }
.co-sum.stale { opacity: .5; }   /* a new quote is on its way */
.co-row { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.co-row > :last-child { white-space: nowrap; text-align: end; font-variant-numeric: tabular-nums; }
.co-sub { color: var(--muted); font-size: 12.5px; }
.co-topay { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 17px; font-weight: 700; }
.co-done { padding: 8px 0 4px; text-align: center; }
.co-done-icon { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); }
.co-done h3 { font-size: 18px; }
.co-done-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
@media (max-width: 560px) {
  .checkout-card .modal-header { padding-inline: 16px; }
  .checkout-card .modal-body, .checkout-card .modal-footer { padding-inline: 16px; }
  .co-pay select { flex-basis: 132px; width: 132px; }
}

.mini-stats.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1400px) { .mini-stats.six { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .mini-stats.six { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mini-stats.six strong { font-size: 17px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.pay-hint { margin: -4px 0 16px; }
.not-paid { margin-top: 14px; }
.bill-h { margin: 18px 0 8px; font-size: 14px; font-weight: 600; }
.bill-lines { margin: 14px 0 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.bill-sums { max-width: 360px; margin-inline-start: auto; }
.refund-form { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--border); }
.refund-line { margin-bottom: 12px; }
.refund-line .inline-field input { max-width: 160px; }
