/* ============================================================
   SCHEDMATE — GLOBAL DARK MODE OVERRIDES
   Covers ALL modules safely
============================================================ */

html.dark,
body.dark ,
html.dark body {
  --sm-bg-deep: #0b0f19;
  --sm-bg: #0e1324;

  --sm-text: rgba(248,250,252,.95);
  --sm-muted: rgba(248,250,252,.65);
  --sm-dim: rgba(248,250,252,.72);

  --sm-border: rgba(148,163,184,.18);

  --sm-card: rgba(20,26,45,.85);
  --sm-card2: rgba(255,255,255,.05);

  --sm-primary: #7c7cff;
  --sm-primary2: #38bdf8;

  --sm-good: #22c55e;
  --sm-warn: #fbbf24;

  --sm-shadow: 0 20px 60px rgba(0,0,0,.45);
  --sm-shadow2: 0 12px 32px rgba(0,0,0,.35);
}

/* ========== GLOBAL TEXT SAFETY ==========
   Do not force one color on every descendant. Component-level tokens
   preserve contrast for badges, buttons, hero panels, icons, and charts.
============================================================ */
body.dark,
html.dark body {
  color: var(--sm-text);
}

body.dark :where(.sm-muted, .help, .desc),
html.dark body :where(.sm-muted, .help, .desc) {
  color: var(--sm-muted);
}

/* ========== BACKGROUNDS ========== */
body.dark.sm-body ,
html.dark body.sm-body {
  background:
    radial-gradient(1200px 700px at 10% 0%, rgba(124,124,255,.18), transparent 60%),
    radial-gradient(1200px 700px at 100% 10%, rgba(56,189,248,.14), transparent 60%),
    linear-gradient(180deg, var(--sm-bg-deep), var(--sm-bg));
}

/* ========== SIDEBAR + TOPBAR ========== */
body.dark .sm-sidebar,
html.dark body .sm-sidebar,
body.dark .sm-topbar ,
html.dark body .sm-topbar {
  background: rgba(15,23,42,.82);
  border-color: var(--sm-border);
}

/* ========== CARDS / PANELS / WRAPPERS ========== */
body.dark .sm-card,
html.dark body .sm-card,
body.dark .sm-panel,
html.dark body .sm-panel,
body.dark .sm-view,
html.dark body .sm-view,
body.dark .sm-empty,
html.dark body .sm-empty,
body.dark .sm-box,
html.dark body .sm-box,
body.dark .sm-wrapper ,
html.dark body .sm-wrapper {
  background: var(--sm-card) !important;
  border-color: var(--sm-border) !important;
}

/* ========== TABLES (CLIENTS, BOOKINGS, INVOICES, REPORTS) ========== */
body.dark table,
html.dark body table,
body.dark thead,
html.dark body thead,
body.dark tbody,
html.dark body tbody,
body.dark tr,
html.dark body tr,
body.dark th,
html.dark body th,
body.dark td ,
html.dark body td {
  background: transparent !important;
  color: var(--sm-text) !important;
}

body.dark thead th ,
html.dark body thead th {
  background: rgba(255,255,255,.06) !important;
  color: var(--sm-muted) !important;
}

body.dark tbody td ,
html.dark body tbody td {
  border-bottom: 1px solid rgba(255,255,255,.06);
}

body.dark tbody tr:hover td ,
html.dark body tbody tr:hover td {
  background: rgba(124,124,255,.14) !important;
}

/* ========== INPUTS / SELECTS ========== */
body.dark input,
html.dark body input,
body.dark select,
html.dark body select,
body.dark textarea ,
html.dark body textarea {
  background: rgba(255,255,255,.06) !important;
  color: var(--sm-text) !important;
  border-color: rgba(255,255,255,.18) !important;
}

/* placeholders */
body.dark input::placeholder ,
html.dark body input::placeholder {
  color: rgba(248,250,252,.45);
}

/* ========== STATUS PILLS / BADGES ========== */
body.dark .sm-chip,
html.dark body .sm-chip,
body.dark .badge,
html.dark body .badge,
body.dark .pill ,
html.dark body .pill {
  background: rgba(255,255,255,.08) !important;
  border-color: rgba(255,255,255,.18) !important;
  color: var(--sm-text) !important;
}

/* ========== MODALS ========== */
body.dark .sm-modal-card ,
html.dark body .sm-modal-card {
  background: rgba(18,24,40,.95) !important;
  border-color: rgba(255,255,255,.18) !important;
}

body.dark .sm-modal-head,
html.dark body .sm-modal-head,
body.dark .sm-modal-actions ,
html.dark body .sm-modal-actions {
  background: rgba(255,255,255,.04) !important;
}

/* ========== BUTTONS ========== */
body.dark button,
html.dark body button,
body.dark .sm-btn ,
html.dark body .sm-btn {
  color: var(--sm-text);
}

body.dark .sm-btn-ghost ,
html.dark body .sm-btn-ghost {
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.18);
}

/* ========== LINKS ========== */
body.dark a ,
html.dark body a {
  color: #8ab4ff;
}

/* ========== THEME TOGGLE SAFETY ========== */
.theme-toggle {
  z-index: 50;
  pointer-events: auto;
}
/* ============================================================
   DARK MODE — CONTRAST & READABILITY FIX (SURGICAL)
============================================================ */

/* ---------- BASE CONTRAST BOOST ---------- */
html.dark {
  --dm-bg-1: #0b1020;
  --dm-bg-2: #0f172a;
  --dm-card: rgba(255,255,255,0.06);
  --dm-border: rgba(255,255,255,0.12);
  --dm-text-main: #f8fafc;
  --dm-text-muted: #94a3b8;
}

/* ---------- CALENDAR GRID ---------- */
html.dark .calendar-day {
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.10),
    rgba(255,255,255,0.05)
  );
  border: 1px solid var(--dm-border);
  color: var(--dm-text-main);
}

html.dark .calendar-day.today {
  outline: 2px solid #60a5fa;
  outline-offset: -2px;
}

html.dark .calendar-day:hover {
  background: rgba(255,255,255,0.12);
}

/* Booking chips */
html.dark .calendar-booking {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border-radius: 999px;
}

/* ---------- CALENDAR DAY MODAL ---------- */
html.dark .day-modal {
  background: linear-gradient(
    180deg,
    #0f172a,
    #0b1020
  );
  border: 1px solid var(--dm-border);
}

html.dark .day-modal-header {
  border-bottom: 1px solid var(--dm-border);
}

html.dark .day-modal-row {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--dm-border);
}

html.dark .day-modal-row:hover {
  background: rgba(255,255,255,0.12);
}

/* ---------- STATUS PILLS ---------- */
html.dark .status.pending {
  background: rgba(251,191,36,0.25);
  color: #fde68a;
}

html.dark .status.completed {
  background: rgba(34,197,94,0.25);
  color: #86efac;
}

/* ---------- OVERVIEW: RECENT ACTIVITY ---------- */
html.dark .activity-row {
  background: rgba(255,255,255,0.06);
  border-bottom: 1px solid var(--dm-border);
}

html.dark .activity-row:hover {
  background: rgba(255,255,255,0.10);
}

html.dark .activity-row .what {
  color: var(--dm-text-main);
}

/* ---------- BOOKINGS TABLE ---------- */
html.dark table tr {
  background: rgba(255,255,255,0.05);
}

html.dark table tr:hover {
  background: rgba(255,255,255,0.10);
}

html.dark select,
html.dark input {
  background: rgba(255,255,255,0.10);
  color: #fff;
  border: 1px solid var(--dm-border);
}

/* Archive button soften */
html.dark .btn-archive {
  background: rgba(239,68,68,0.15);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.35);
}
/* ============================================================
   THEME TOGGLE — MINI ANIMATED (DARK / LIGHT)
============================================================ */

.sm-theme-toggle {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.toggle-track {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(180deg, #e5e7eb, #d1d5db);
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
  transition: background .3s ease;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  display: grid;
  place-items: center;
  font-size: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  transition: transform .35s cubic-bezier(.4,0,.2,1);
}

/* Icons */
.toggle-thumb .icon {
  position: absolute;
  transition: opacity .25s ease, transform .35s ease;
}

.toggle-thumb .moon {
  opacity: 0;
  transform: scale(.6) rotate(-30deg);
}

/* ---------- DARK MODE ---------- */
html.dark .toggle-track {
  background: linear-gradient(180deg, #0f172a, #020617);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}

html.dark .toggle-thumb {
  transform: translateX(20px);
  background: #020617;
}

html.dark .toggle-thumb .sun {
  opacity: 0;
  transform: scale(.6) rotate(30deg);
}

html.dark .toggle-thumb .moon {
  opacity: 1;
  transform: scale(1) rotate(0);
}
/* ============================================================
   THEME TOGGLE — POLISH v2 (GLASS + GLOW + TACTILE)
============================================================ */

.sm-theme-toggle {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- TRACK ---------- */
.toggle-track {
  width: 46px;
  height: 24px;
  border-radius: 999px;
  position: relative;

  background:
    linear-gradient(180deg,
      rgba(255,255,255,.85),
      rgba(255,255,255,.65)
    );

  backdrop-filter: blur(10px);
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,.08),
    0 6px 16px rgba(0,0,0,.12);

  transition:
    background .35s ease,
    box-shadow .35s ease,
    transform .15s ease;
}

/* Hover lift (desktop only) */
@media (hover:hover) {
  .sm-theme-toggle:hover .toggle-track {
    transform: translateY(-1px);
    box-shadow:
      inset 0 0 0 1px rgba(0,0,0,.10),
      0 10px 22px rgba(0,0,0,.18);
  }
}

/* ---------- THUMB ---------- */
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;

  display: grid;
  place-items: center;
  font-size: 12px;

  background:
    radial-gradient(circle at 30% 30%,
      #ffffff,
      #e5e7eb
    );

  box-shadow:
    0 4px 10px rgba(0,0,0,.25),
    inset 0 0 0 1px rgba(0,0,0,.08);

  transition:
    transform .4s cubic-bezier(.4,0,.2,1),
    box-shadow .2s ease,
    background .3s ease;
}

/* Press feedback */
.sm-theme-toggle:active .toggle-thumb {
  transform: scale(.94);
  box-shadow:
    0 2px 6px rgba(0,0,0,.25);
}

/* ---------- ICONS ---------- */
.toggle-thumb .icon {
  position: absolute;
  transition:
    opacity .25s ease,
    transform .4s cubic-bezier(.4,0,.2,1);
}

.toggle-thumb .moon {
  opacity: 0;
  transform: scale(.6) rotate(-30deg);
}

/* ---------- DARK MODE ---------- */
html.dark .toggle-track {
  background:
    linear-gradient(180deg,
      rgba(15,23,42,.95),
      rgba(2,6,23,.95)
    );

  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.14),
    0 8px 20px rgba(0,0,0,.55);
}

html.dark .toggle-thumb {
  transform: translateX(22px);

  background:
    radial-gradient(circle at 30% 30%,
      #1f2933,
      #020617
    );

  box-shadow:
    0 6px 14px rgba(0,0,0,.6),
    inset 0 0 0 1px rgba(255,255,255,.12);
}

/* Icon swap */
html.dark .toggle-thumb .sun {
  opacity: 0;
  transform: scale(.6) rotate(30deg);
}

html.dark .toggle-thumb .moon {
  opacity: 1;
  transform: scale(1) rotate(0);
}

/* ---------- ACCENT GLOW ---------- */
html.dark .toggle-track::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  background:
    radial-gradient(circle,
      rgba(91,92,255,.35),
      transparent 60%);
  opacity: .6;
  pointer-events: none;
}

@media (hover:hover) {
  html.dark .sm-theme-toggle:hover .toggle-track::after {
    opacity: .85;
  }
}

/* ============================================================
   DESIGN SYSTEM v1 — Consistency Layer (LIGHT + DARK)
   Goal: make modules look the same across themes (buttons, tables,
   pills, calendar cells, modals).
   Loaded last via /css/theme.css so this safely overrides modules.
============================================================ */

/* --------- Semantic Tokens (LIGHT) --------- */
:root{
  --sm-surface: rgba(255,255,255,.88);
  --sm-surface-2: rgba(255,255,255,.72);
  --sm-surface-3: rgba(15,23,42,.04);

  --sm-control: rgba(15,23,42,.04);
  --sm-control-hover: rgba(15,23,42,.06);

  --sm-table-head: rgba(91,92,255,.06);
  --sm-table-row: rgba(255,255,255,.72);
  --sm-row-hover: rgba(91,92,255,.07);

  --sm-pill-bg: rgba(15,23,42,.05);
  --sm-pill-bd: rgba(15,23,42,.10);

  --sm-soft-border: rgba(15,23,42,.10);
}

/* --------- Semantic Tokens (DARK) --------- */
html.dark, body.dark{
  --sm-surface: rgba(17,24,39,.70);
  --sm-surface-2: rgba(17,24,39,.55);
  --sm-surface-3: rgba(148,163,184,.10);

  --sm-control: rgba(148,163,184,.12);
  --sm-control-hover: rgba(148,163,184,.16);

  --sm-table-head: rgba(148,163,184,.10);
  --sm-table-row: rgba(2,6,23,.40);
  --sm-row-hover: rgba(91,92,255,.16);

  --sm-pill-bg: rgba(148,163,184,.14);
  --sm-pill-bd: rgba(148,163,184,.20);

  --sm-soft-border: rgba(148,163,184,.18);
}

/* --------- Core Surfaces --------- */
.sm-card, .sm-panel{
  background: var(--sm-surface) !important;
  border-color: var(--sm-soft-border) !important;
}
.sm-side-search, .sm-user, .sm-collapse-btn, .sm-hamburger{
  background: var(--sm-surface-2) !important;
  border-color: var(--sm-soft-border) !important;
}

/* --------- Inputs / Selects --------- */
.sm-input,
input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="date"], input[type="datetime-local"], select, textarea{
  background: var(--sm-surface-2);
  border-color: var(--sm-soft-border);
  color: var(--sm-text);
}
html.dark input::placeholder, body.dark input::placeholder,
html.dark textarea::placeholder, body.dark textarea::placeholder{
  color: rgba(226,232,240,.55);
}

/* --------- Buttons (global) --------- */
.sm-btn,
#view-bookings button,
#view-clients button,
#view-invoices button,
#view-payments button,
#view-reports button{
  border-radius: 14px;
}
.sm-btn-ghost{
  background: var(--sm-control) !important;
  border-color: var(--sm-soft-border) !important;
}
.sm-btn-ghost:hover{ background: var(--sm-control-hover) !important; }

/* Module buttons frequently drift — normalize */
.sm-icon-btn, .sm-btn-archive, .sm-btn-danger, .sm-btn-secondary{
  border-radius: 12px !important;
  border-color: var(--sm-soft-border) !important;
  background: var(--sm-control) !important;
  color: var(--sm-text) !important;
}
.sm-btn-archive{
  border-color: rgba(239,68,68,.40) !important;
  background: rgba(239,68,68,.10) !important;
  color: rgba(239,68,68,.95) !important;
}
html.dark .sm-btn-archive{
  background: rgba(239,68,68,.14) !important;
}

/* --------- Tables (all modules) --------- */
.sm-table thead th{
  background: var(--sm-table-head) !important;
  border-bottom-color: var(--sm-soft-border) !important;
}
.sm-table tbody td{
  background: var(--sm-table-row) !important;
  border-bottom-color: rgba(148,163,184,.18) !important;
}
.sm-table tbody tr:hover td{
  background: var(--sm-row-hover) !important;
}

/* --------- Pills / Chips --------- */
.sm-pill{
  background: var(--sm-pill-bg) !important;
  border-color: var(--sm-pill-bd) !important;
  color: var(--sm-text) !important;
}

/* --------- Calendar Readability (DARK) --------- */
html.dark #view-calendar .sm-cal-cell,
body.dark #view-calendar .sm-cal-cell{
  background: rgba(2,6,23,.35) !important;
  border-color: rgba(148,163,184,.18) !important;
}
html.dark #view-calendar .sm-cal-cell:hover,
body.dark #view-calendar .sm-cal-cell:hover{
  background: rgba(2,6,23,.46) !important;
}
html.dark #view-calendar .sm-cal-daynum,
body.dark #view-calendar .sm-cal-daynum{
  color: rgba(226,232,240,.88) !important;
}
html.dark #view-calendar .sm-cal-chip,
body.dark #view-calendar .sm-cal-chip{
  background: rgba(148,163,184,.14) !important;
  border-color: rgba(148,163,184,.20) !important;
  color: rgba(226,232,240,.92) !important;
}

/* --------- Modal polish (DARK) --------- */
html.dark .sm-modal,
body.dark .sm-modal{
  background: rgba(2,6,23,.78) !important;
  border-color: rgba(148,163,184,.18) !important;
}
html.dark .sm-modal .sm-table thead th,
body.dark .sm-modal .sm-table thead th{
  background: rgba(148,163,184,.10) !important;
}

/* --------- Theme Toggle (Polish v2) --------- */
.theme-toggle{
  width: 44px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--sm-soft-border);
  background: var(--sm-surface-2);
  box-shadow: var(--sm-shadow2);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  color: transparent; /* hide emoji */
}
.theme-toggle::before{
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(91,92,255,.18), rgba(34,211,238,.14));
  opacity: .9;
}
.theme-toggle::after{
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(135deg, rgba(255,255,255,.95), rgba(255,255,255,.80));
  box-shadow: 0 10px 22px rgba(15,23,42,.18);
  transition: transform .22s ease, left .22s ease, background .22s ease;
}
html.dark .theme-toggle::after,
body.dark .theme-toggle::after{
  left: 14px;
  background: linear-gradient(135deg, rgba(15,23,42,.92), rgba(2,6,23,.88));
  box-shadow: 0 10px 22px rgba(0,0,0,.35);
}
.theme-toggle:focus-visible{
  outline: 2px solid rgba(91,92,255,.55);
  outline-offset: 2px;
}

/* ============================================================
   DESIGN SYSTEM v2 — TOKENS + COMPONENT CONTRACTS
   - Single source of truth for Light/Dark
   - Buttons / Tables / Inputs / Pills unified
   - Module CSS should avoid hard-coded colors; use tokens below
============================================================ */

/* ---------- Core Tokens (Light) ---------- */
:root{
  --sm-bg: #f4f6fb;
  --sm-bg-deep: #ffffff;

  --sm-surface: rgba(255,255,255,.88);
  --sm-surface-2: rgba(15,23,42,.04);
  --sm-surface-3: rgba(15,23,42,.06);

  --sm-control: rgba(255,255,255,.80);
  --sm-control-hover: rgba(255,255,255,.92);

  --sm-text: rgba(15,23,42,.92);
  --sm-muted: rgba(15,23,42,.62);
  --sm-dim: rgba(15,23,42,.70);
  /* light counterpart of the dark --sm-card above; previously only
     dashboard.css defined this, so the "shared" card token was owned by a
     module stylesheet instead of the theme. */
  --sm-card: rgba(255,255,255,.88);
  --sm-card2: rgba(15,23,42,.04);

  --sm-border: rgba(15,23,42,.10);
  --sm-border-strong: rgba(15,23,42,.16);

  --sm-primary: #5b5cff;
  --sm-primary2:#22d3ee;
  --sm-good: #16a34a;
  --sm-warn: #f59e0b;

  --sm-row-hover: rgba(91,92,255,.06);
  --sm-table-head: rgba(15,23,42,.04);
  --sm-table-row: rgba(255,255,255,.55);

  --sm-success: #16a34a;
  --sm-warning: #f59e0b;
  --sm-danger:  #ef4444;
  --sm-neutral: #475569;

  --sm-success-bg: rgba(34,197,94,.12);
  --sm-success-bd: rgba(34,197,94,.22);

  --sm-warning-bg: rgba(245,158,11,.14);
  --sm-warning-bd: rgba(245,158,11,.26);

  --sm-danger-bg: rgba(239,68,68,.10);
  --sm-danger-bd: rgba(239,68,68,.25);

  --sm-neutral-bg: rgba(15,23,42,.04);
  --sm-neutral-bd: rgba(15,23,42,.08);

  --sm-radius-sm: 12px;
  --sm-radius-md: 14px;
  --sm-radius-lg: 18px;

  --sm-shadow-sm: 0 10px 28px rgba(15,23,42,.08);
  --sm-shadow-md: 0 14px 40px rgba(15,23,42,.10);
  --sm-shadow: var(--sm-shadow-md);
  --sm-shadow2: var(--sm-shadow-sm);

  /* Semantic aliases used by shared controls such as the archive Undo,
     read-only banner, and theme button. Keeping these mapped to the
     canonical SchedMate tokens prevents light/dark drift. */
  --color-surface: var(--sm-control);
  --color-surface-raised: var(--sm-card);
  --color-text: var(--sm-text);
  --color-text-muted: var(--sm-muted);
  --color-border: var(--sm-border);
  --color-primary: var(--sm-primary);
  --color-focus: var(--sm-primary);
}

/* ---------- Core Tokens (Dark) ---------- */
html.dark{
  --sm-bg: #0b0f19;
  --sm-bg-deep: #0e1324;

  --sm-surface: rgba(255,255,255,.06);
  --sm-surface-2: rgba(255,255,255,.04);
  --sm-surface-3: rgba(255,255,255,.07);

  --sm-control: rgba(255,255,255,.09);
  --sm-control-hover: rgba(255,255,255,.12);

  --sm-text: rgba(248,250,252,.92);
  --sm-muted: rgba(148,163,184,.90);
  --sm-dim: rgba(148,163,184,.70);
  --sm-card2: rgba(255,255,255,.05);
  --sm-good: #22c55e;
  --sm-warn: #fbbf24;

  --sm-border: rgba(255,255,255,.12);
  --sm-border-strong: rgba(255,255,255,.18);

  --sm-row-hover: rgba(255,255,255,.07);
  --sm-table-head: rgba(255,255,255,.06);
  --sm-table-row: rgba(255,255,255,.03);

  --sm-success: #22c55e;
  --sm-warning: #fbbf24;
  --sm-danger:  #fb7185;
  --sm-neutral: rgba(148,163,184,.95);

  --sm-success-bg: rgba(34,197,94,.14);
  --sm-success-bd: rgba(34,197,94,.26);

  --sm-warning-bg: rgba(245,158,11,.16);
  --sm-warning-bd: rgba(245,158,11,.28);

  --sm-danger-bg: rgba(239,68,68,.14);
  --sm-danger-bd: rgba(239,68,68,.28);
}

/* ---------- Base surfaces (theme-consistent) ---------- */
body.sm-body{
  color: var(--sm-text);
}
.sm-card, .sm-panel{
  background: var(--sm-surface) !important;
  border: 1px solid var(--sm-border) !important;
  border-radius: var(--sm-radius-lg);
  box-shadow: var(--sm-shadow-sm);
}
.sm-muted{ color: var(--sm-muted) !important; }

/* ---------- Inputs / selects ---------- */
.sm-input, .sm-table select[data-status], select.sm-input{
  background: var(--sm-control) !important;
  border: 1px solid var(--sm-border) !important;
  color: var(--sm-text) !important;
}
.sm-input::placeholder{ color: var(--sm-dim) !important; }
.sm-input:focus, .sm-table select[data-status]:focus{
  outline: none;
  box-shadow: 0 0 0 3px rgba(91,92,255,.18);
  border-color: rgba(91,92,255,.35) !important;
}

/* ---------- Buttons (single contract) ---------- */
.sm-btn, .sm-icon-btn, button.sm-btn-archive{
  border-radius: var(--sm-radius-md) !important;
  font-weight: 1000;
}

.sm-btn-primary{
  color: #fff !important;
  background: linear-gradient(135deg, var(--sm-primary), rgba(34,211,238,.88)) !important;
  border: 1px solid rgba(91,92,255,.22) !important;
  box-shadow: 0 18px 40px rgba(91,92,255,.18);
}

.sm-btn-ghost, .sm-btn-secondary{
  background: var(--sm-surface-2) !important;
  border: 1px solid var(--sm-border) !important;
  color: var(--sm-text) !important;
}

.sm-btn-danger, .sm-btn-archive{
  background: var(--sm-danger-bg) !important;
  border: 1px solid var(--sm-danger-bd) !important;
  color: var(--sm-danger) !important;
}

/* ---------- Tables (shared) ---------- */
.sm-table thead th{
  background: var(--sm-table-head) !important;
  color: var(--sm-muted) !important;
  border-bottom: 1px solid var(--sm-border) !important;
}
.sm-table tbody td{
  background: var(--sm-table-row) !important;
  border-bottom: 1px solid rgba(15,23,42,.06);
  color: var(--sm-text) !important;
}
html.dark .sm-table tbody td{
  border-bottom-color: rgba(255,255,255,.07);
}
.sm-table tbody tr:hover td{
  background: var(--sm-row-hover) !important;
}

/* ---------- Status pills (unified) ---------- */
.sm-pill{
  background: var(--sm-neutral-bg) !important;
  border: 1px solid var(--sm-neutral-bd) !important;
  color: var(--sm-muted) !important;
}
.sm-pill-good{ background: var(--sm-success-bg) !important; border-color: var(--sm-success-bd) !important; color: var(--sm-success) !important; }
.sm-pill-warn{ background: var(--sm-warning-bg) !important; border-color: var(--sm-warning-bd) !important; color: var(--sm-warning) !important; }
.sm-pill-danger{ background: var(--sm-danger-bg) !important; border-color: var(--sm-danger-bd) !important; color: var(--sm-danger) !important; }

/* ---------- Calendar contrast guardrails ---------- */
html.dark #view-calendar .sm-cal,
html.dark #view-calendar .sm-cal *{
  color: var(--sm-text);
}
html.dark #view-calendar .sm-cal-day{
  background: var(--sm-surface-2);
  border-color: var(--sm-border);
}
html.dark #view-calendar .sm-cal-day:hover{
  background: var(--sm-surface-3);
}

/* =========================================================
   DESIGN SYSTEM v2.3 — CALENDAR ELEVATION TOKENS (SAFE)
========================================================= */

:root{
  --sm-surface: rgba(255,255,255,.88);
  --sm-surface-2: rgba(15,23,42,.04);
  --sm-control: rgba(255,255,255,.78);
}

/* Dark surfaces tuned for readability (calendar + modals) */
html.dark,
body.dark,
html.dark body{
  --sm-surface: rgba(15,23,42,.72);
  --sm-surface-2: rgba(148,163,184,.10);
  --sm-control: rgba(15,23,42,.62);
}


/* ================================
   SCHEDMATE — HELP TOOLTIP UI
   (Late-loaded override; used by ? icons)
================================ */
.sm-help-icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:18px;
  height:18px;
  margin-left:8px;
  border-radius:999px;
  font-size:12px;
  font-weight:800;
  cursor:help;
  user-select:none;
  vertical-align:middle;
  border:1px solid rgba(120,130,150,0.35);
  background:rgba(255,255,255,0.06);
  color:rgba(230,235,245,0.95);
}
.sm-help-icon:focus{ outline:2px solid rgba(120,160,255,0.55); outline-offset:2px; }

html[data-theme="light"] .sm-help-icon{
  border-color: rgba(15,23,42,0.22);
  background: rgba(15,23,42,0.06);
  color: rgba(15,23,42,0.78);
}
html[data-theme="light"] .sm-help-icon:hover{
  background: rgba(15,23,42,0.10);
  border-color: rgba(15,23,42,0.28);
}



html:not(.dark) .sm-help-icon{
  border-color: rgba(15,23,42,0.22);
  background: rgba(15,23,42,0.06);
  color: rgba(15,23,42,0.78);
}
html:not(.dark) .sm-help-icon:hover{
  background: rgba(15,23,42,0.10);
  border-color: rgba(15,23,42,0.28);
}
#global-tooltip{
  position:fixed;
  z-index:99999;
  max-width:280px;
  padding:10px 12px;
  border-radius:12px;
  background:rgba(18,20,26,0.92);
  color:rgba(245,246,250,0.96);
  font-size:12px;
  line-height:1.35;
  letter-spacing:0.1px;
  border:1px solid rgba(255,255,255,0.10);
  box-shadow:0 16px 40px rgba(0,0,0,0.35);
  opacity:0;
  transform:translateY(4px);
  pointer-events:none;
  transition:opacity .12s ease, transform .12s ease;
}
#global-tooltip.visible{ opacity:1; transform:translateY(0); }


/* Settings: Payment methods card actions */
.sm-settings-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:6px;}
.sm-note{padding:10px 12px;border-radius:12px;background:rgba(255,255,255,0.04);border:1px solid rgba(255,255,255,0.08);}
html[data-theme="light"] .sm-note{background:rgba(0,0,0,0.03);border-color:rgba(0,0,0,0.08);}


/* ============================================================
   SchedMate — Scenic Theme Toggle (Dashboard only)
   - Small pill (clouds/day + stars/night)
   - Works with html.dark class
============================================================ */
/* =====================================================================
   The decorative scenic theme switch (60x30 pill with clouds, stars and a
   sliding thumb) was removed in v111.1 per audit 3.8. Its markup no longer
   exists on any page; the canonical control is .sm-theme-toggle.sm-theme-icon
   defined at the end of this file.
===================================================================== */


/* =====================================================================
   THEME TOGGLE — single accessible icon button (audit 3.8)

   Replaces the decorative scenic switch (clouds, stars, sliding thumb).
   A 40-44px hit target, a visible focus ring, and an icon that describes
   the action rather than decorating the bar.
===================================================================== */
.sm-theme-toggle.sm-theme-icon {
  inline-size: 42px;
  block-size: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 12px;
  background: var(--color-surface, transparent);
  border: 1px solid var(--color-border, rgba(128, 138, 160, 0.28));
  color: var(--color-text, inherit);
  cursor: pointer;
  /* Reset the scenic switch's positioning context and sizing. */
  position: relative;
  overflow: visible;
  box-shadow: none;
}

.sm-theme-toggle.sm-theme-icon:hover {
  background: var(--color-surface-raised, rgba(128, 138, 160, 0.12));
}

.sm-theme-toggle.sm-theme-icon:focus-visible {
  outline: 2px solid var(--color-focus, #4c8dff);
  outline-offset: 2px;
}

.sm-theme-toggle.sm-theme-icon .sm-theme-icon-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 20px;
  block-size: 20px;
}

@media (prefers-reduced-motion: no-preference) {
  .sm-theme-toggle.sm-theme-icon { transition: background-color .15s ease, border-color .15s ease; }
}

/* The scenic switch internals are gone from the markup; neutralise any
   leftover rules that would otherwise size or decorate the new button. */
.sm-theme-toggle.sm-theme-icon .sm-theme-track,
.sm-theme-toggle.sm-theme-icon .sm-theme-thumb { display: none; }
