/* ==========================================================================
   agendate.py - Sistema de Diseño y Tokens de Marca Oficiales
   Basado en la identidad visual: Amigable, moderna, cercana y profesional
   ========================================================================== */

:root {
  /* Sigue automáticamente la preferencia del sistema; JS o <meta> fijan claro/oscuro */
  color-scheme: light dark;

  &:has(> head > meta[name="color-scheme"][content="dark"]),
  &[data-theme="dark"],
  &.dark {
    color-scheme: dark;
  }

  &:has(> head > meta[name="color-scheme"][content="light"]),
  &[data-theme="light"],
  &.light {
    color-scheme: light;
  }

  /* --- Stitch & Brand Official Tokens (Modo Claro predeterminado) --- */
  --brand-primary: #22C55E;
  --brand-primary-hover: #16A34A;
  --brand-dark: #0B1F17;
  --brand-soft: #D1FAE5;
  --brand-soft-border: #A7F3D0;

  /* --- Superficies y Fondos Stitch --- */
  --background: #f7f9fd;
  --surface: #ffffff;
  --surface-subtle: #f2f4f8;
  --border: #E5E7EB;
  --border-focus: #22C55E;

  /* --- Tipografía y Textos --- */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --text-primary: #191c1f;
  --text-secondary: #3d4a3d;
  --text-muted: #64748B;

  /* --- Radios de Borde (Stitch Geometry) --- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* --- Sombras Stitch --- */
  --shadow-sm: 0 1px 2px 0 rgba(11, 31, 23, 0.04);
  --shadow-card: 0 1px 3px 0 rgba(11, 31, 23, 0.04), 0 1px 2px -1px rgba(11, 31, 23, 0.03);
  --shadow-hover: 0 10px 20px -5px rgba(11, 31, 23, 0.07), 0 4px 6px -4px rgba(11, 31, 23, 0.03);
  --shadow-brand: 0 4px 14px 0 rgba(34, 197, 94, 0.28);

  /* --- Canales RGB para Tailwind CDN (habilita modificadores de opacidad /10../95) --- */
  --rgb-surface: 247 249 253;
  --rgb-surface-dim: 216 218 222;
  --rgb-surface-container-lowest: 255 255 255;
  --rgb-surface-container-low: 242 244 248;
  --rgb-surface-container: 236 238 242;
  --rgb-surface-container-high: 230 232 236;
  --rgb-surface-container-highest: 224 226 230;
  --rgb-surface-mint: 209 250 229;
  --rgb-mint-border: 167 243 208;
  --rgb-on-surface: 25 28 31;
  --rgb-on-surface-variant: 61 74 61;
  --rgb-text-muted: 100 116 139;
  --rgb-border-subtle: 229 231 235;
  --rgb-outline: 109 123 108;
  --rgb-outline-variant: 188 203 185;

  --rgb-primary: 0 110 47;
  --rgb-primary-hover: 0 110 47;
  --rgb-primary-container: 34 197 94;
  --rgb-on-primary: 255 255 255;
  --rgb-on-primary-container: 0 75 30;
  --rgb-secondary: 78 99 89;
  --rgb-secondary-container: 206 229 216;
  --rgb-on-secondary: 255 255 255;
  --rgb-on-secondary-container: 82 103 93;
  --rgb-on-secondary-fixed: 11 31 23;
  --rgb-tertiary: 59 102 90;
  --rgb-tertiary-container: 136 181 166;
  --rgb-on-tertiary: 255 255 255;
  --rgb-on-tertiary-container: 27 71 60;
  --rgb-inverse-surface: 45 49 52;
  --rgb-inverse-on-surface: 239 241 245;
  --rgb-inverse-primary: 74 225 118;
  --rgb-error: 186 26 26;
  --rgb-error-container: 255 218 214;
  --rgb-on-error-container: 147 0 10;

  /* --- Integración Nativa del Navegador (Modern UI Hooks) --- */
  --scrollbar-track: #F2F4F8;
  --scrollbar-thumb: #CBD5E1;
  --ui-accent: #16A34A;
  accent-color: var(--ui-accent);
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* Fallback WebKit para navegadores que aún no soportan scrollbar-color */
@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }

  ::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
  }

  ::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 9999px;
    border: 2px solid var(--scrollbar-track);
  }
}


/* ==========================================================================
   Modo Oscuro Stitch Oficial (Deep Pine Theme: #07130F & #0B1F17)
   ========================================================================== */
:root[data-theme="dark"],
:root.dark,
:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  --brand-primary: #22C55E;
  --brand-primary-hover: #4ADE80;
  --brand-dark: #07130F;
  --brand-soft: #133A2A;
  --brand-soft-border: #2D7757;
  --background: #07130F;
  --surface: #0B1F17;
  --surface-subtle: #102B20;
  --border: #234C3B;
  --border-focus: #34D399;
  --text-primary: #EFF1F5;
  --text-secondary: #C7D6CB;
  --text-muted: #9BB0A3;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.45), 0 1px 2px -1px rgba(0, 0, 0, 0.32);
  --shadow-hover: 0 12px 24px -8px rgba(0, 0, 0, 0.65);

  --rgb-surface: 7 19 15;
  --rgb-surface-dim: 4 12 9;
  --rgb-surface-container-lowest: 11 31 23;
  --rgb-surface-container-low: 16 43 32;
  --rgb-surface-container: 20 54 40;
  --rgb-surface-container-high: 27 69 52;
  --rgb-surface-container-highest: 36 87 66;
  --rgb-surface-mint: 19 58 42;
  --rgb-mint-border: 45 119 87;
  --rgb-on-surface: 239 241 245;
  --rgb-on-surface-variant: 199 214 203;
  --rgb-text-muted: 155 176 163;
  --rgb-border-subtle: 35 76 59;
  --rgb-outline: 110 148 128;
  --rgb-outline-variant: 47 96 76;

  --rgb-primary: 52 211 153;
  --rgb-primary-hover: 74 222 128;
  --rgb-primary-container: 34 197 94;
  --rgb-on-primary: 4 36 20;
  --rgb-on-primary-container: 209 250 229;
  --rgb-secondary: 167 203 180;
  --rgb-secondary-container: 23 64 47;
  --rgb-on-secondary: 4 36 20;
  --rgb-on-secondary-container: 209 250 229;
  --rgb-on-secondary-fixed: 11 31 23;
  --rgb-tertiary: 136 181 166;
  --rgb-tertiary-container: 27 71 60;
  --rgb-on-tertiary: 7 19 15;
  --rgb-on-tertiary-container: 209 250 229;
  --rgb-inverse-surface: 239 241 245;
  --rgb-inverse-on-surface: 11 31 23;
  --rgb-inverse-primary: 0 110 47;
  --rgb-error: 251 113 133;
  --rgb-error-container: 76 17 29;
  --rgb-on-error-container: 254 205 211;

  --scrollbar-track: #07130F;
  --scrollbar-thumb: #2D7757;
  --ui-accent: #22C55E;
}

/* Fallback sin JS o en modo 'system' ('light dark') */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not(.light):not(:has(> head > meta[name="color-scheme"][content="light"])) {
    --brand-primary: #22C55E;
    --brand-primary-hover: #4ADE80;
    --brand-dark: #07130F;
    --brand-soft: #133A2A;
    --brand-soft-border: #2D7757;
    --background: #07130F;
    --surface: #0B1F17;
    --surface-subtle: #102B20;
    --border: #234C3B;
    --border-focus: #34D399;
    --text-primary: #EFF1F5;
    --text-secondary: #C7D6CB;
    --text-muted: #9BB0A3;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
    --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.45), 0 1px 2px -1px rgba(0, 0, 0, 0.32);
    --shadow-hover: 0 12px 24px -8px rgba(0, 0, 0, 0.65);

    --rgb-surface: 7 19 15;
    --rgb-surface-dim: 4 12 9;
    --rgb-surface-container-lowest: 11 31 23;
    --rgb-surface-container-low: 16 43 32;
    --rgb-surface-container: 20 54 40;
    --rgb-surface-container-high: 27 69 52;
    --rgb-surface-container-highest: 36 87 66;
    --rgb-surface-mint: 19 58 42;
    --rgb-mint-border: 45 119 87;
    --rgb-on-surface: 239 241 245;
    --rgb-on-surface-variant: 199 214 203;
    --rgb-text-muted: 155 176 163;
    --rgb-border-subtle: 35 76 59;
    --rgb-outline: 110 148 128;
    --rgb-outline-variant: 47 96 76;

    --rgb-primary: 52 211 153;
    --rgb-primary-hover: 74 222 128;
    --rgb-primary-container: 34 197 94;
    --rgb-on-primary: 4 36 20;
    --rgb-on-primary-container: 209 250 229;
    --rgb-secondary: 167 203 180;
    --rgb-secondary-container: 23 64 47;
    --rgb-on-secondary: 4 36 20;
    --rgb-on-secondary-container: 209 250 229;
    --rgb-on-secondary-fixed: 11 31 23;
    --rgb-tertiary: 136 181 166;
    --rgb-tertiary-container: 27 71 60;
    --rgb-on-tertiary: 7 19 15;
    --rgb-on-tertiary-container: 209 250 229;
    --rgb-inverse-surface: 239 241 245;
    --rgb-inverse-on-surface: 11 31 23;
    --rgb-inverse-primary: 0 110 47;
    --rgb-error: 251 113 133;
    --rgb-error-container: 76 17 29;
    --rgb-on-error-container: 254 205 211;

    --scrollbar-track: #07130F;
    --scrollbar-thumb: #2D7757;
    --ui-accent: #22C55E;
  }
}

/* Selección de texto legible en ambos temas */
::selection {
  background-color: #D1FAE5;
  color: #0B1F17;
}

:is(:root[data-theme="dark"], :root.dark, :root:has(> head > meta[name="color-scheme"][content="dark"])) ::selection {
  background-color: #1B5E41;
  color: #ECFDF5;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not(.light):not(:has(> head > meta[name="color-scheme"][content="light"])) ::selection {
    background-color: #1B5E41;
    color: #ECFDF5;
  }
}

/* Base semántica mínima sin bloquear utilidades de Tailwind */
html,
body {
  background-color: var(--background);
  color: var(--text-primary);
}

/* Texto mint legible sobre superficies oscuras */
:is(:root[data-theme="dark"], .dark, :root:has(> head > meta[name="color-scheme"][content="dark"])) :where(.text-on-secondary-fixed) {
  color: #D1FAE5;
}

:is(:root[data-theme="dark"], .dark, :root:has(> head > meta[name="color-scheme"][content="dark"])) :where(.hover\:text-on-secondary-fixed:hover) {
  color: #ECFDF5;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not(.light):not(:has(> head > meta[name="color-scheme"][content="light"])) :where(.text-on-secondary-fixed) {
    color: #D1FAE5;
  }
  :root:not([data-theme="light"]):not(.light):not(:has(> head > meta[name="color-scheme"][content="light"])) :where(.hover\:text-on-secondary-fixed:hover) {
    color: #ECFDF5;
  }
}

/* Controles de formulario nativos: dropdowns <option> legibles en Windows/Linux oscuro */
:is(:root[data-theme="dark"], .dark, :root:has(> head > meta[name="color-scheme"][content="dark"])) select option {
  background-color: #0B1F17;
  color: #EFF1F5;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not(.light):not(:has(> head > meta[name="color-scheme"][content="light"])) select option {
    background-color: #0B1F17;
    color: #EFF1F5;
  }
}

.admin-layout {
  display: grid;
  grid-template-columns: 235px minmax(0, 1fr);
  gap: 1.5rem;
  width: min(100%, 1560px);
  margin-inline: auto;
  align-items: start;
}

.admin-sidebar {
  position: sticky;
  top: 5.5rem;
  display: flex;
  min-height: min(720px, calc(100vh - 7rem));
  flex-direction: column;
  padding: 1rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.sidebar-business { display: flex; align-items: center; gap: 0.7rem; padding: 0.35rem 0.35rem 1.1rem; border-bottom: 1px solid var(--border); }
.sidebar-business strong, .sidebar-business span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-business strong { color: var(--text-primary); font-size: 0.8rem; }
.sidebar-business span { margin-top: 0.2rem; color: var(--text-muted); font-size: 0.68rem; }
.sidebar-avatar { display: grid; width: 2.5rem; height: 2.5rem; flex: 0 0 auto; place-items: center; border-radius: 0.8rem; background: #0B1F17; color: #34D399; font-weight: 800; }
.sidebar-avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.sidebar-label { padding: 1.1rem 0.55rem 0.45rem; color: var(--text-muted); font-size: 0.62rem; font-weight: 800; letter-spacing: 0.12em; }
.sidebar-nav { display: grid; gap: 0.25rem; }
.sidebar-nav button {
  display: flex;
  min-height: 2.65rem;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.65rem;
  border: 0;
  border-radius: 0.7rem;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  font-size: 0.76rem;
  font-weight: 600;
  transition: 0.15s ease;
  @media (prefers-reduced-motion: reduce) {
    transition: none;
  }
}
.sidebar-nav button > span:first-child { display: grid; width: 1.25rem; place-items: center; color: var(--text-muted); font-size: 1rem; }
.sidebar-nav button:hover { background: var(--surface-subtle); color: var(--text-primary); }
.sidebar-nav button.selected { background: var(--brand-soft); color: #087443; }
.sidebar-nav button.selected > span:first-child { color: #0F9F61; }
.sidebar-count { margin-left: auto; padding: 0.1rem 0.4rem; border-radius: 999px; background: var(--surface-subtle); color: var(--text-secondary); font-size: 0.65rem; }
.sidebar-settings-label { margin-top: 0.25rem; border-top: 1px solid var(--border); }
.sidebar-spacer { flex: 1; min-height: 1.5rem; }
.sidebar-public-link { padding: 0.8rem 0.55rem 0.2rem; border-top: 1px solid var(--border); color: var(--text-secondary); font-size: 0.72rem; font-weight: 600; }
.sidebar-public-link:hover { color: #0F9F61; }
.sidebar-logout { margin-top: 0.45rem; border-top: 1px solid var(--border); }
.sidebar-logout button { width: 100%; padding: 0.7rem 0.55rem 0.2rem; border: 0; background: transparent; color: var(--text-muted); text-align: left; font-size: 0.7rem; font-weight: 600; }
.sidebar-logout button:hover { color: #DC2626; }
.admin-main { min-width: 0; display: grid; gap: 1.5rem; }
.admin-main > [x-show] { min-width: 0; }
.module-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.module-heading h2 { margin: 0.15rem 0; color: var(--text-primary); font-size: clamp(1.25rem, 2vw, 1.65rem); font-weight: 800; letter-spacing: -0.035em; }
.module-heading p:not(.eyebrow) { margin: 0; color: var(--text-secondary); font-size: 0.78rem; }
.eyebrow { margin: 0; color: #0F9F61; font-size: 0.62rem; font-weight: 800; letter-spacing: 0.13em; }
.overview-lower-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr); gap: 1rem; }
.overview-panel { min-width: 0; padding: 1.2rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.65rem; }
.panel-heading h3 { margin: 0; color: var(--text-primary); font-size: 0.9rem; font-weight: 750; }
.panel-heading p { margin: 0.2rem 0 0; color: var(--text-muted); font-size: 0.68rem; }
.upcoming-row, .income-row { display: grid; width: 100%; grid-template-columns: minmax(105px, 0.65fr) minmax(0, 1.2fr) auto; align-items: center; gap: 0.75rem; padding: 0.75rem 0; border: 0; border-top: 1px solid var(--border); background: transparent; color: var(--text-primary); text-align: left; }
.upcoming-row:hover { background: var(--surface-subtle); }
.upcoming-date { color: #0F9F61; font-size: 0.7rem; font-weight: 700; }
.upcoming-row strong, .upcoming-row small, .income-row strong, .income-row small { display: block; }
.upcoming-row strong, .income-row strong { color: var(--text-primary); font-size: 0.76rem; }
.upcoming-row small, .income-row small { margin-top: 0.2rem; color: var(--text-muted); font-size: 0.67rem; }
.upcoming-arrow { color: var(--text-muted); font-size: 1.1rem; }
.service-summary { display: flex; justify-content: space-between; gap: 1rem; padding: 0.75rem 0; border-top: 1px solid var(--border); color: var(--text-primary); font-size: 0.75rem; }
.service-summary strong { color: #0F9F61; }
.empty-copy { padding: 1.5rem 0; color: var(--text-muted); font-size: 0.75rem; }
.income-highlight { display: grid; gap: 0.3rem; padding: 1.5rem; border: 1px solid #B7E4CC; border-radius: var(--radius-lg); background: linear-gradient(120deg, #EAF8F0, #F6FBF7); }
.income-highlight span { color: #35614B; font-size: 0.75rem; font-weight: 650; }
.income-highlight strong { color: #075B35; font-size: 2rem; font-weight: 850; letter-spacing: -0.04em; }
.income-highlight small { color: #557463; font-size: 0.68rem; }
.income-row { grid-template-columns: 1fr auto; }
.income-row > strong { color: #0F9F61; }
.calendar-controls { display: flex; align-items: center; gap: 0.45rem; color: var(--text-secondary); font-size: 0.72rem; font-weight: 650; }
.calendar-controls button { min-width: 2rem; height: 2rem; border: 1px solid var(--border); border-radius: 0.55rem; background: var(--surface); color: var(--text-primary); }
.calendar-controls .today-button { width: auto; padding-inline: 0.65rem; color: #087443; }
.calendar-week { display: grid; grid-template-columns: repeat(7, minmax(115px, 1fr)); overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.calendar-day { min-height: 250px; border-right: 1px solid var(--border); }
.calendar-day:last-child { border-right: 0; }
.calendar-day-heading { display: grid; justify-items: center; gap: 0.3rem; padding: 0.8rem 0.3rem; border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: 0.65rem; font-weight: 700; text-transform: capitalize; }
.calendar-day-heading strong { display: grid; width: 1.8rem; height: 1.8rem; place-items: center; border-radius: 50%; color: var(--text-primary); font-size: 0.8rem; }
.calendar-day.today .calendar-day-heading strong { background: #16A34A; color: white; }
.calendar-day-events { display: grid; align-content: start; gap: 0.4rem; padding: 0.45rem; }
.calendar-event { display: grid; gap: 0.25rem; width: 100%; padding: 0.55rem; border: 1px solid #B9E8CC; border-left: 3px solid #22C55E; border-radius: 0.5rem; background: #EFFAF3; color: #184A30; text-align: left; }
.calendar-event strong { font-size: 0.62rem; line-height: 1.35; }
.calendar-event span { color: #52725E; font-size: 0.58rem; }
.calendar-event:hover { border-color: #22C55E; background: #E2F6E9; }
.calendar-event.cancelled { opacity: 0.55; }
.calendar-empty { padding: 0.7rem 0.1rem; color: var(--text-muted); font-size: 0.62rem; text-align: center; }
.booking-detail { position: relative; padding: 1.25rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card); }
.booking-detail h3 { margin: 0.3rem 0 1rem; color: var(--text-primary); font-size: 1.1rem; }
.detail-close { position: absolute; top: 0.8rem; right: 0.9rem; border: 0; background: transparent; color: var(--text-muted); font-size: 1.3rem; }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.8rem; }
.detail-grid span { color: var(--text-muted); font-size: 0.65rem; }
.detail-grid strong { display: block; margin-top: 0.25rem; color: var(--text-primary); font-size: 0.75rem; }
.detail-notes { color: var(--text-secondary); font-size: 0.75rem; }
.message-help { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; color: var(--text-secondary); font-size: 0.7rem; }
.message-help strong { margin-right: 0.5rem; color: var(--text-primary); }
.message-help code { padding: 0.3rem 0.45rem; border-radius: 0.35rem; background: var(--surface-subtle); color: #087443; font-size: 0.65rem; }
.message-form, .profile-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.message-form label, .profile-form label { display: grid; gap: 0.4rem; color: var(--text-primary); font-size: 0.72rem; font-weight: 650; }
.message-form textarea, .profile-form input, .profile-form textarea { width: 100%; padding: 0.7rem; border: 1px solid var(--border); border-radius: 0.65rem; background: var(--surface); color: var(--text-primary); font: inherit; font-weight: 400; }
.message-form textarea { resize: vertical; }
.message-form .toggle-setting { display: flex; grid-column: 1 / -1; align-items: center; gap: 0.55rem; }
.toggle-setting input { width: 1rem; accent-color: #16A34A; }
.profile-photo-preview { display: grid; width: 5rem; height: 5rem; grid-column: 1 / -1; place-items: center; overflow: hidden; border-radius: 1rem; background: #0B1F17; color: #34D399; font-size: 1.5rem; font-weight: 800; }
.profile-photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.profile-save { align-self: end; }
.profile-or { color: var(--text-muted); font-size: 0.65rem; font-weight: 500; }
.login-wrap { display: grid; min-height: 60vh; place-items: center; }
.login-card { display: grid; width: min(100%, 390px); gap: 0.8rem; padding: 2rem; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow-hover); }
.login-mark { display: grid; width: 2.8rem; height: 2.8rem; place-items: center; border-radius: 0.9rem; background: #0B1F17; color: #34D399; font-weight: 850; }
.login-card h1 { margin: 0; color: var(--text-primary); font-size: 1.45rem; font-weight: 800; }
.login-card label { color: var(--text-secondary); font-size: 0.75rem; font-weight: 650; }
.login-card input { min-width: 0; padding: 0.7rem; border: 1px solid var(--border); border-radius: 0.65rem; background: var(--surface); color: var(--text-primary); }
.login-card button:disabled { cursor: not-allowed; opacity: 0.5; }
.login-card > a { color: var(--text-secondary); font-size: 0.7rem; text-align: center; }
.login-notice, .login-error { margin: 0; padding: 0.65rem; border-radius: 0.6rem; background: #FEF3C7; color: #854D0E; font-size: 0.72rem; line-height: 1.5; }
.login-error { background: #FFF1F2; color: #9F1239; }

:is(:root[data-theme="dark"], .dark, :root:has(> head > meta[name="color-scheme"][content="dark"])) .sidebar-nav button.selected { color: #D1FAE5; }
:is(:root[data-theme="dark"], .dark, :root:has(> head > meta[name="color-scheme"][content="dark"])) .income-highlight { border-color: #2D7757; background: linear-gradient(120deg, #133A2A, #102B20); }
:is(:root[data-theme="dark"], .dark, :root:has(> head > meta[name="color-scheme"][content="dark"])) .income-highlight span,
:is(:root[data-theme="dark"], .dark, :root:has(> head > meta[name="color-scheme"][content="dark"])) .income-highlight small { color: #C7D6CB; }
:is(:root[data-theme="dark"], .dark, :root:has(> head > meta[name="color-scheme"][content="dark"])) .income-highlight strong { color: #A7F3D0; }
:is(:root[data-theme="dark"], .dark, :root:has(> head > meta[name="color-scheme"][content="dark"])) .calendar-event { border-color: #2D7757; background: #133A2A; color: #D1FAE5; }
:is(:root[data-theme="dark"], .dark, :root:has(> head > meta[name="color-scheme"][content="dark"])) .calendar-event span { color: #A7CBB4; }
:is(:root[data-theme="dark"], .dark, :root:has(> head > meta[name="color-scheme"][content="dark"])) .calendar-event:hover { background: #1B4933; }
:is(:root[data-theme="dark"], .dark, :root:has(> head > meta[name="color-scheme"][content="dark"])) .login-notice { background: #423719; color: #FDE68A; }
:is(:root[data-theme="dark"], .dark, :root:has(> head > meta[name="color-scheme"][content="dark"])) .login-error { background: #42202A; color: #FDA4AF; }

@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; min-height: 0; padding: 0.7rem; }
  .sidebar-business, .sidebar-settings-label, .sidebar-spacer, .sidebar-public-link, .sidebar-logout { display: none; }
  .sidebar-label { padding: 0.2rem 0.4rem 0.45rem; }
  .sidebar-nav { display: flex; overflow-x: auto; gap: 0.35rem; }
  .sidebar-nav button { flex: 0 0 auto; }
  .sidebar-nav button > span:first-child { width: auto; }
  .sidebar-count { margin-left: 0; }
  .overview-lower-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .admin-main { gap: 1rem; }
  .module-heading { align-items: flex-start; }
  .module-heading > .btn-brand-primary { align-self: center; }
  .calendar-controls { flex-wrap: wrap; justify-content: flex-end; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .message-form, .profile-form { grid-template-columns: 1fr; }
  .message-form .toggle-setting, .profile-photo-preview { grid-column: auto; }
}

/* Navegación horizontal del panel de administración */
.dashboard-tabbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 0.4rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  scrollbar-width: thin;
}

.dashboard-tab {
  display: inline-flex;
  min-height: 2.6rem;
  flex: 1 0 auto;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  @media (prefers-reduced-motion: reduce) {
    transition: none;
  }
}

.dashboard-tab.is-active {
  color: var(--brand-dark);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px var(--brand-soft-border);
}

.dashboard-tab.is-idle:hover {
  color: var(--brand-dark);
  background: var(--surface-subtle);
}

:is(:root[data-theme="dark"], .dark) .dashboard-tab.is-active {
  color: #D1FAE5;
}

:is(:root[data-theme="dark"], .dark) .dashboard-tab.is-idle:hover {
  color: #EFF1F5;
}

.dashboard-tab:focus-visible {
  outline: 3px solid rgba(34, 197, 94, 0.35);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .dashboard-tabbar {
    justify-content: flex-start;
  }

  .dashboard-tab {
    flex: 0 0 auto;
    padding-inline: 0.8rem;
    font-size: 0.8rem;
  }
}

/* Reducción automática de animaciones según preferencia de accesibilidad del sistema operativo */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  :root .animate-pulse,
  :root .animate-bounce {
    animation: none;
  }

  :root .animate-spin {
    animation: none;
    opacity: 0.7;
  }
}

/* Soporte para Modo de Alto Contraste de Windows (Forced Colors Mode) */
@media (forced-colors: active) {
  :root {
    --background: Canvas;
    --surface: Canvas;
    --surface-subtle: Canvas;
    --border: CanvasText;
    --text-primary: CanvasText;
    --text-secondary: CanvasText;
    --text-muted: GrayText;
  }

  button,
  a,
  input,
  select,
  textarea {
    border-color: ButtonBorder;
  }
}

/* Botones e indicadores duales de tema sin depender de JS */
.theme-show-in-dark {
  display: none !important;
}

.theme-show-in-light {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

html.dark .theme-show-in-light,
html[data-theme="dark"] .theme-show-in-light,
html:has(> head > meta[name="color-scheme"][content="dark"]) .theme-show-in-light {
  display: none !important;
}

html.dark .theme-show-in-dark,
html[data-theme="dark"] .theme-show-in-dark,
html:has(> head > meta[name="color-scheme"][content="dark"]) .theme-show-in-dark {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not(.light):not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-show-in-light {
    display: none !important;
  }

  html:not([data-theme="light"]):not(.light):not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-show-in-dark {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }
}
