/* ==========================================================================
   BookMaster — design system
   RTL-first. Mobile-first: every layout starts as a single column and only
   becomes a grid once there is room, so nothing needs a horizontal scrollbar
   on a phone except the calendars, which scroll inside their own container.
   ========================================================================== */

:root {
  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;

  --text:          #0f172a;
  --text-2:        #475569;
  --text-3:        #94a3b8;

  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-soft:  #eff6ff;

  --success:       #16a34a;
  --success-soft:  #f0fdf4;
  --warning:       #d97706;
  --warning-soft:  #fffbeb;
  --danger:        #dc2626;
  --danger-soft:   #fef2f2;
  --info:          #0891b2;
  --purple:        #7c3aed;

  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     18px;
  --shadow:        0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md:     0 4px 14px rgba(15,23,42,.10);
  --shadow-lg:     0 12px 40px rgba(15,23,42,.18);

  --header-h:      60px;
  --sidebar-w:     236px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Heebo', 'Segoe UI', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  direction: rtl;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 700; line-height: 1.25; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.1rem; }

.hidden { display: none !important; }
.muted  { color: var(--text-2); }
.small  { font-size: .84rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.grow   { flex: 1; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: .6rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1.05rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--primary); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover  { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger  { background: var(--danger); } .btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); } .btn-success:hover { background: #15803d; }
.btn-ghost   { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: .32rem .7rem; font-size: .84rem; }
.btn-block { width: 100%; }
.btn-icon { padding: .4rem .55rem; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.field { margin-bottom: .9rem; }
.field label { display: block; margin-bottom: .3rem; font-weight: 600; font-size: .88rem; color: var(--text-2); }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], input[type=date], input[type=time], input[type=datetime-local],
input[type=color], select, textarea {
  width: 100%; padding: .55rem .75rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; direction: rtl;
  transition: border-color .15s, box-shadow .15s;
}
input[type=color] { padding: .2rem; height: 40px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.14);
}
input:disabled, select:disabled { background: var(--surface-2); color: var(--text-3); }
textarea { min-height: 84px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr; gap: 0 .9rem; }
.checkbox { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 500; }
.checkbox input { width: auto; margin: 0; }

/* ── Cards & layout ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem;
}
.card + .card { margin-top: 1rem; }
.card-title { display: flex; align-items: center; justify-content: space-between;
              gap: .6rem; margin-bottom: .9rem; flex-wrap: wrap; }
.card-title h2, .card-title h3 { margin: 0; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: .16rem .6rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; white-space: nowrap;
}
.badge-pending    { background: var(--warning-soft); color: var(--warning); }
.badge-confirmed  { background: var(--primary-soft); color: var(--primary-dark); }
.badge-checked_in { background: var(--success-soft); color: var(--success); }
.badge-completed  { background: #f1f5f9; color: var(--text-2); }
.badge-cancelled  { background: var(--danger-soft); color: var(--danger); }
.badge-no_show    { background: #f5f3ff; color: var(--purple); }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td {
  padding: .55rem .6rem; text-align: right; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data th {
  background: var(--surface-2); font-weight: 700; font-size: .82rem;
  color: var(--text-2); position: sticky; top: 0; z-index: 1;
}
table.data tbody tr:hover { background: var(--primary-soft); }
table.data tbody tr.clickable { cursor: pointer; }
table.data td.actions { white-space: nowrap; width: 1%; }

/* ── App shell ───────────────────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: .8rem; padding: 0 .9rem;
  background: #0f172a; color: #fff; box-shadow: var(--shadow-md);
}
.app-header .brand { font-weight: 800; font-size: 1.15rem; letter-spacing: .5px; }
.app-header .brand span { color: #60a5fa; }
.app-header select {
  background: rgba(255,255,255,.10); color: #fff;
  border-color: rgba(255,255,255,.22); max-width: 210px; padding: .35rem .6rem;
}
.app-header select option { color: #0f172a; }
.header-user { display: flex; align-items: center; gap: .5rem; font-size: .88rem; }
.burger { display: flex; background: transparent; border: 0; color: #fff;
          font-size: 1.5rem; cursor: pointer; padding: .2rem .4rem; line-height: 1; }

.app-body { display: flex; min-height: calc(100vh - var(--header-h)); }

.sidebar {
  position: fixed; inset-block: var(--header-h) 0; inset-inline-start: 0;
  width: var(--sidebar-w); z-index: 35;
  background: var(--surface); border-inline-end: 1px solid var(--border);
  padding: .8rem .6rem; overflow-y: auto;
  transform: translateX(100%); transition: transform .22s ease;
}
.sidebar.open { transform: translateX(0); }
.nav-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .7rem; margin-bottom: .15rem;
  border-radius: var(--radius-sm); color: var(--text-2);
  font-weight: 600; cursor: pointer; user-select: none;
}
.nav-item:hover  { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-dark); }
.nav-item .ico { font-size: 1.05rem; width: 1.4rem; text-align: center; }
.nav-sep { margin: .7rem .7rem .35rem; font-size: .72rem; font-weight: 700;
           color: var(--text-3); letter-spacing: .04em; }

.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 34;
}

.main { flex: 1; padding: 1rem .9rem 3rem; min-width: 0; }
.screen { display: none; }
.screen.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: center; justify-content: space-between;
             gap: .7rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.35rem; }

/* ── KPI tiles ───────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .7rem; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem; box-shadow: var(--shadow);
}
.kpi .kpi-label { font-size: .8rem; color: var(--text-2); font-weight: 600; }
.kpi .kpi-value { font-size: 1.55rem; font-weight: 800; margin-top: .15rem; }
.kpi .kpi-sub   { font-size: .76rem; color: var(--text-3); }
.kpi.accent-blue   { border-inline-start: 4px solid var(--primary); }
.kpi.accent-green  { border-inline-start: 4px solid var(--success); }
.kpi.accent-orange { border-inline-start: 4px solid var(--warning); }
.kpi.accent-purple { border-inline-start: 4px solid var(--purple); }

/* ── Calendar: shared ────────────────────────────────────────────────────── */
.cal-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; margin-bottom: .8rem; flex-wrap: wrap;
}
.cal-title { font-weight: 800; font-size: 1.05rem; min-width: 9rem; text-align: center; }
.view-switch { display: inline-flex; border: 1px solid var(--border-strong);
               border-radius: var(--radius-sm); overflow: hidden; }
.view-switch button {
  padding: .4rem .85rem; border: 0; background: var(--surface);
  font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer;
}
.view-switch button + button { border-inline-start: 1px solid var(--border); }
.view-switch button.active { background: var(--primary); color: #fff; }

.legend { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .8rem; color: var(--text-2); }
.legend i { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px;
            margin-inline-end: .3rem; vertical-align: -1px; }
.lg-free    { background: var(--surface); border: 1px solid var(--border-strong); }
.lg-busy    { background: #bfdbfe; }
.lg-blocked { background: #e2e8f0; }
.lg-pending { background: #fde68a; }

/* ── Calendar: month ─────────────────────────────────────────────────────── */
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0,1fr));
             gap: 1px; background: var(--border); border: 1px solid var(--border);
             border-radius: var(--radius); overflow: hidden; }
.cal-month .dow { background: var(--surface-2); padding: .45rem .2rem; text-align: center;
                  font-weight: 700; font-size: .78rem; color: var(--text-2); }
.cal-day { background: var(--surface); min-height: 92px; padding: .3rem; cursor: pointer;
           position: relative; transition: background .12s; }
.cal-day:hover { background: var(--primary-soft); }
.cal-day.other-month { background: var(--surface-2); color: var(--text-3); }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-day .dnum { font-weight: 700; font-size: .85rem; }
.cal-day .dnum .free-count { float: left; font-size: .7rem; font-weight: 600; color: var(--text-3); }
.cal-chip {
  display: block; margin-top: .18rem; padding: .1rem .35rem;
  border-radius: 4px; font-size: .72rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: #dbeafe; color: #1e3a8a; border-inline-start: 3px solid var(--primary);
}
.cal-chip.st-pending   { background: #fef3c7; color: #92400e; border-color: var(--warning); }
.cal-chip.st-blocked   { background: #e2e8f0; color: var(--text-2); border-color: var(--border-strong); }
.cal-chip.more { background: transparent; color: var(--text-3); border: 0; font-size: .68rem; }

/* ── Calendar: week (resource rows × 7 days) ─────────────────────────────── */
.cal-week-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch;
                 border: 1px solid var(--border); border-radius: var(--radius);
                 background: var(--surface); }
.cal-week { min-width: 720px; }
/* ── Drag to select a range ──────────────────────────────────────────────
   `touch-action: none` is what makes this work on a phone: without it the
   browser claims the gesture for scrolling and no pointermove ever arrives.
   It is scoped to the draggable cells so the page still scrolls normally. */
.cal-month .cal-day, .cal-week .wk-half, .cal-daygrid .dg-slot { touch-action: none; }
.is-dragging { user-select: none; -webkit-user-select: none; cursor: crosshair; }
.drag-sel { background: var(--primary-soft) !important;
            box-shadow: inset 0 0 0 1px var(--primary); }
.dg-ghost {
  position: absolute; z-index: 5; pointer-events: none;
  border-radius: 6px; background: var(--primary-soft);
  border: 1px dashed var(--primary); color: var(--primary);
  font-size: .72rem; font-weight: 700; padding: .1rem .3rem;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
/* The chosen time already belongs to someone. Shown while choosing, so the
   answer arrives before the save is attempted rather than as a rejection. */
.dg-ghost.is-clash {
  background: repeating-linear-gradient(45deg,
    rgba(148,163,184,.25), rgba(148,163,184,.25) 5px,
    rgba(148,163,184,.45) 5px, rgba(148,163,184,.45) 10px);
  border-color: var(--text-3); color: var(--text-2);
}

/* Week, guesthouses — a continuous bar per stay over half-day columns.
   The header and the rows both split "130px + 1fr", and each puts its own grid
   INSIDE that 1fr (7 days above, 14 halves below), so the two always line up no
   matter how the week is sized. */
.cal-week .wk-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-week .wk-halves { display: grid; position: relative; align-items: center;
                       min-height: 54px; }
.cal-week .wk-half { grid-row: 1; min-height: 54px; cursor: pointer; }
.cal-week .wk-half.daystart { border-inline-start: 1px solid var(--border); }
.cal-week .wk-half:hover { background: var(--primary-soft); }
.cal-week .wk-half.is-blocked { background: repeating-linear-gradient(
    45deg, #f1f5f9, #f1f5f9 5px, #e2e8f0 5px, #e2e8f0 10px); cursor: not-allowed; }
.cal-week .wk-stay {
  grid-row: 1; z-index: 2; height: 38px; align-self: center;
  display: flex; align-items: center; justify-content: space-between; gap: .4rem;
  padding: 0 .5rem; border-radius: 7px; overflow: hidden; cursor: pointer;
  background: #dbeafe; color: #1e3a8a; border: 1px solid #bfdbfe;
  box-shadow: var(--shadow);
}
.cal-week .wk-stay.is-pending { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.cal-week .wk-stay .who { font-size: .78rem; font-weight: 700; white-space: nowrap;
                          overflow: hidden; text-overflow: ellipsis; }
.cal-week .wk-stay .n { font-size: .7rem; opacity: .8; white-space: nowrap; }
.cal-week .wk-dayhead.is-today { color: var(--primary); }

.cal-week .wk-row { display: grid; grid-template-columns: 130px 1fr;
                    border-bottom: 1px solid var(--border); }
.cal-week .wk-row:last-child { border-bottom: 0; }
.cal-week .wk-head { background: var(--surface-2); font-weight: 700; font-size: .8rem;
                     position: sticky; top: 0; z-index: 2; }
.cal-week .wk-cell { padding: .35rem .3rem; border-inline-start: 1px solid var(--border);
                     min-height: 54px; text-align: center; cursor: pointer; }
.cal-week .wk-cell:hover { background: var(--primary-soft); }
.cal-week .wk-res { padding: .55rem .6rem; font-weight: 700; font-size: .88rem;
                    display: flex; align-items: center; gap: .4rem; background: var(--surface-2); }
.cal-week .wk-res .dot { width: .7rem; height: .7rem; border-radius: 50%; flex: none; }
.cal-week .wk-cell.is-busy    { background: #dbeafe; }
.cal-week .wk-cell.is-pending { background: #fef3c7; }
.cal-week .wk-cell.is-blocked { background: #e2e8f0; color: var(--text-3); }
.cal-week .wk-cell.is-checkout{ background: linear-gradient(135deg,#dbeafe 0 48%, var(--surface) 52% 100%); }
.cal-week .wk-cell.is-today   { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-week .wk-cell .g-name { font-size: .74rem; font-weight: 600; display: block;
                             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-week .wk-dayhead { padding: .4rem .2rem; text-align: center; font-size: .78rem;
                        border-inline-start: 1px solid var(--border); }
.cal-week .wk-dayhead b { display: block; font-size: .95rem; }

/* ── Calendar: day (time rows × resource columns) ─────────────────────────── */
.cal-day-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch;
                border: 1px solid var(--border); border-radius: var(--radius);
                background: var(--surface); }
.cal-daygrid { position: relative; min-width: 520px; }
.cal-daygrid .dg-head { display: grid; background: var(--surface-2);
                        border-bottom: 1px solid var(--border);
                        position: sticky; top: 0; z-index: 3; }
.cal-daygrid .dg-head > div { padding: .5rem .3rem; text-align: center;
                              font-weight: 700; font-size: .84rem;
                              border-inline-start: 1px solid var(--border); }
.cal-daygrid .dg-body { position: relative; display: grid; }
.cal-daygrid .dg-hour { display: grid; border-bottom: 1px solid var(--border); }
.cal-daygrid .dg-hour > div { border-inline-start: 1px solid var(--border); }
/* Each hour holds its bookable slots stacked — 3 at the default 20-minute
   rhythm. The inner dividers are dashed so the solid line still reads as the
   hour boundary. */
.cal-daygrid .dg-col { display: flex; flex-direction: column; }
.cal-daygrid .dg-col .dg-slot + .dg-slot { border-top: 1px dashed var(--border); }
.cal-daygrid .dg-time { font-size: .74rem; color: var(--text-3); padding: .15rem .35rem;
                        border-inline-start: 0 !important; text-align: center; }
.cal-daygrid .dg-slot { cursor: pointer; }
.cal-daygrid .dg-slot:hover { background: var(--primary-soft); }
.cal-daygrid .dg-slot.closed { background: repeating-linear-gradient(
    45deg, #f8fafc, #f8fafc 6px, #eef2f7 6px, #eef2f7 12px); cursor: not-allowed; }
.dg-event {
  position: absolute; inset-inline-start: 2px; inset-inline-end: 2px;
  border-radius: 6px; padding: .2rem .4rem; font-size: .75rem; font-weight: 600;
  background: #dbeafe; color: #1e3a8a; border-inline-start: 3px solid var(--primary);
  overflow: hidden; cursor: pointer; box-shadow: var(--shadow);
}
.dg-event.st-pending { background: #fef3c7; color: #92400e; border-color: var(--warning); }
.dg-event.st-blocked { background: #e2e8f0; color: var(--text-2); border-color: var(--border-strong); }
.dg-event .ev-time { font-weight: 700; font-size: .7rem; opacity: .85; display: block; }
.dg-event .ev-name { display: block; overflow: hidden; text-overflow: ellipsis;
                     white-space: nowrap; }
/* A short appointment has no room for two stacked lines — the name used to be
   pushed out of the box and clipped. Side by side, both still fit. */
.dg-event.is-compact { display: flex; align-items: center; gap: .3rem;
                       padding-top: 0; padding-bottom: 0; line-height: 1.1; }
.dg-event.is-compact .ev-time { display: inline; flex: none; font-size: .66rem; }
.dg-event.is-compact .ev-name { display: inline; font-size: .72rem; min-width: 0; }

/* Week timetable — hour rows × day columns, for service providers.
   Closed time is an absolutely-positioned overlay rather than a per-cell class,
   so a shop opening at 08:30 gets exactly half of the 08:00 row shaded instead
   of the whole hour rounded off. It must not swallow clicks aimed at the row
   underneath, hence pointer-events: none. */
.cal-week .cal-daygrid { min-width: 660px; }
.cal-week .cal-daygrid .dg-head > div.is-today { color: var(--primary); }
.cal-week .cal-daygrid .dg-head > div b { display: block; font-size: .95rem; }
.wt-closed {
  position: absolute; pointer-events: none; z-index: 1;
  background: repeating-linear-gradient(
    45deg, #f8fafc, #f8fafc 6px, #eef2f7 6px, #eef2f7 12px);
}
.cal-week .cal-daygrid .dg-event { z-index: 2; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
  overflow-y: auto;
}
.modal {
  background: var(--surface); width: 100%; max-width: 620px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg); max-height: 94vh;
  display: flex; flex-direction: column; animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal.modal-lg { max-width: 900px; }
.modal-head { display: flex; align-items: center; justify-content: space-between;
              gap: .6rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-close { background: transparent; border: 0; font-size: 1.5rem; line-height: 1;
               cursor: pointer; color: var(--text-3); padding: 0 .3rem; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 1.1rem; overflow-y: auto; }
.modal-foot { display: flex; gap: .55rem; justify-content: flex-start; flex-wrap: wrap;
              padding: .85rem 1.1rem; border-top: 1px solid var(--border); background: var(--surface-2); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toasts { position: fixed; bottom: 1rem; inset-inline-start: 1rem; z-index: 90;
          display: flex; flex-direction: column; gap: .5rem; max-width: min(92vw, 380px); }
.toast {
  padding: .7rem .95rem; border-radius: var(--radius-sm); color: #fff;
  background: #0f172a; box-shadow: var(--shadow-lg); font-weight: 600; font-size: .9rem;
  animation: fade .2s ease;
}
.toast.ok    { background: var(--success); }
.toast.err   { background: var(--danger); }
.toast.warn  { background: var(--warning); }

/* ── Auth screens ────────────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
             padding: 1.2rem; background: linear-gradient(160deg,#0f172a 0%,#1e3a8a 100%); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface);
             border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 1.6rem; }
.auth-card .brand { text-align: center; font-size: 1.7rem; font-weight: 800; margin-bottom: .2rem; }
.auth-card .brand span { color: var(--primary); }
.auth-card .tagline { text-align: center; color: var(--text-2); margin-bottom: 1.3rem; font-size: .9rem; }
.auth-links { margin-top: 1rem; display: flex; justify-content: space-between;
              font-size: .86rem; flex-wrap: wrap; gap: .5rem; }

.alert { padding: .6rem .8rem; border-radius: var(--radius-sm); font-size: .88rem;
         font-weight: 600; margin-bottom: .8rem; }
.alert-err  { background: var(--danger-soft);  color: var(--danger);  border: 1px solid #fecaca; }
.alert-ok   { background: var(--success-soft); color: var(--success); border: 1px solid #bbf7d0; }
.alert-info { background: var(--primary-soft); color: var(--primary-dark); border: 1px solid #bfdbfe; }
.alert-warn { background: var(--warning-soft); color: var(--warning); border: 1px solid #fde68a; }

.code-input { letter-spacing: .6rem; text-align: center; font-size: 1.6rem;
              font-weight: 700; direction: ltr; }

.empty { text-align: center; padding: 2.2rem 1rem; color: var(--text-3); }
.empty .ico { font-size: 2.4rem; display: block; margin-bottom: .4rem; }

.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.35);
           border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
           display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Price breakdown ─────────────────────────────────────────────────────── */
.price-box { background: var(--surface-2); border: 1px solid var(--border);
             border-radius: var(--radius-sm); padding: .7rem .85rem; }
.price-box .pl { display: flex; justify-content: space-between; font-size: .85rem;
                 padding: .18rem 0; color: var(--text-2); }
.price-box .pl.total { border-top: 1px solid var(--border-strong); margin-top: .35rem;
                       padding-top: .45rem; font-weight: 800; font-size: 1rem; color: var(--text); }

/* ── Slot picker ─────────────────────────────────────────────────────────── */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px,1fr)); gap: .45rem; }
.slot {
  padding: .5rem .3rem; text-align: center; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
  font-weight: 600; font-size: .9rem; direction: ltr;
}
.slot:hover { border-color: var(--primary); background: var(--primary-soft); }
.slot.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Week editor (availability) ──────────────────────────────────────────── */
.week-editor { display: grid; gap: .5rem; }
.week-row { display: grid; grid-template-columns: 5.5rem 1fr; gap: .5rem; align-items: center; }
.week-row .times { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.week-row .times input { width: 7rem; }

/* ── Accessibility widget (SKILL: NEGISHUT) ──────────────────────────────── */
#a11yBtn {
  position: fixed; bottom: 18px; inset-inline-end: 18px; z-index: 99999;
  width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: var(--primary); color: #fff; font-size: 1.5rem; cursor: pointer;
  box-shadow: var(--shadow-lg);
}
#a11yPanel {
  position: fixed; bottom: 76px; inset-inline-end: 18px; z-index: 99999;
  width: 250px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .9rem;
}
#a11yPanel h4 { margin: 0 0 .6rem; font-size: .95rem; }
#a11yPanel .a11y-row { display: flex; justify-content: space-between; align-items: center;
                       gap: .5rem; padding: .3rem 0; font-size: .87rem; }

body.a11y-high-contrast { --bg:#000; --surface:#000; --surface-2:#111; --text:#fff;
                          --text-2:#eee; --text-3:#ccc; --border:#fff; --border-strong:#fff;
                          --primary:#ff0; --primary-dark:#ff0; --primary-soft:#333; }
body.a11y-high-contrast .btn { background:#ff0; color:#000; border-color:#fff; }
body.a11y-high-contrast .app-header { background:#000; border-bottom:2px solid #fff; }
body.a11y-no-motion *, body.a11y-no-motion *::before, body.a11y-no-motion *::after {
  animation: none !important; transition: none !important; }
body.a11y-highlight-links a, body.a11y-highlight-links .nav-item {
  text-decoration: underline !important; outline: 1px dashed currentColor; }

/* ══ Tablet ═══════════════════════════════════════════════════════════════ */
@media (min-width: 641px) {
  .field-row { grid-template-columns: 1fr 1fr; }
  .kpi-grid  { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .modal-backdrop { align-items: center; padding: 1.2rem; }
  .modal { border-radius: var(--radius-lg); }
  .cal-day { min-height: 104px; }
}

/* ══ Desktop ══════════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
  .burger { display: none; }
  .sidebar { transform: none; position: sticky; top: var(--header-h);
             height: calc(100vh - var(--header-h)); inset-block: auto; }
  .sidebar-backdrop { display: none !important; }
  .app-body { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }
  .main { padding: 1.3rem 1.5rem 3rem; }
  .kpi-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .field-row-3 { grid-template-columns: repeat(3, 1fr); }
  .cal-week { min-width: 0; }
  .cal-daygrid { min-width: 0; }
}

/* ══ Phone tweaks ═════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .app-header .brand { font-size: 1rem; }
  .app-header select { max-width: 120px; font-size: .82rem; }
  .header-user .uname { display: none; }
  .page-head h1 { font-size: 1.15rem; }
  .cal-day { min-height: 64px; padding: .2rem; }
  .cal-day .dnum { font-size: .78rem; }
  .cal-chip { font-size: .66rem; padding: .05rem .25rem; }
  .cal-month .dow { font-size: .68rem; padding: .3rem .1rem; }
  table.data { font-size: .84rem; }
  table.data th, table.data td { padding: .45rem .4rem; }
  /* Columns marked collapse-mobile are hidden on a phone rather than squeezed. */
  table.data .collapse-mobile { display: none; }
  .modal-foot .btn { flex: 1 1 auto; }
}

@media print {
  .app-header, .sidebar, .modal-backdrop, #a11yBtn, #a11yPanel, .btn { display: none !important; }
  .main { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
