/* ==========================================================================
   CIG Booking — Admin SPA (Fase 4 B①)
   Tokens derivados del sistema visual del widget (Fases 1–3) + manual.
   Pendiente: ajuste fino contra el mockup 7.2 cuando este disponible
   (aprobado 2026-07-08: primera version funcional con estos tokens).
   ========================================================================== */

:root {
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --text: #1F2937;
  --text-2: #6B7280;
  --text-3: #374151;
  --primary: #2563EB;
  --primary-soft: #EFF6FF;
  --accent: #3E7B54;
  --danger: #B91C1C;
  --danger-bg: #FEF2F2;
  --warn: #92400E;
  --warn-bg: #FEF3C7;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  --sidebar-w: 232px;
  --shadow: 0 1px 3px rgba(17, 24, 39, .08), 0 1px 2px rgba(17, 24, 39, .04);
}

* { box-sizing: border-box; }

/* El atributo hidden SIEMPRE gana (display:flex de #app lo pisaria). */
[hidden] { display: none !important; }

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

/* ---- Login ---------------------------------------------------------- */

#login-screen,
#reset-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* F5-C: link secundario (forgot password / back to sign in) */
.link-button {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 6px;
  background: none;
  border: 0;
  font: inherit;
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  text-align: center;
}

.link-button:hover { text-decoration: underline; }

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 380px;
}

.login-brand {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.login-subtitle {
  margin: 4px 0 20px;
  color: var(--text-2);
}

.login-notice {
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 14px;
  font-size: 13px;
}

.login-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 14px;
  font-size: 13px;
}

.field { display: block; margin-bottom: 14px; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: 4px;
}

.field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
}

.field input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}

.btn-primary {
  width: 100%;
  padding: 10px 14px;
  background: var(--primary);
  color: var(--on-primary, #fff);
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: .6; cursor: default; }

/* ---- Settings ------------------------------------------------------- */

.settings-view { max-width: 860px; }
.view-subtitle { margin: -8px 0 22px; color: var(--text-2); }
.settings-form { display: grid; gap: 16px; }
.settings-section { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 20px; }
.settings-section .section-title { margin: 0 0 16px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.settings-field { display: block; min-width: 0; }
.settings-input { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; color: var(--text); background: var(--surface); font: inherit; }
textarea.settings-input { resize: vertical; }
.settings-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.settings-readonly { color: var(--text-2); background: var(--bg); }
.settings-hint { display: block; margin-top: 4px; color: var(--text-2); font-size: 12px; }
.settings-toggle { display: flex; align-items: center; gap: 9px; margin-top: 18px; color: var(--text-3); font-weight: 600; }
.settings-toggle input { width: 16px; height: 16px; }
.settings-actions { display: flex; justify-content: flex-end; }
.settings-save { width: auto; min-width: 132px; }
.settings-notice { margin: 0; padding: 9px 12px; border-radius: 6px; }
.settings-notice-success { background: #ECFDF5; color: #166534; }
.settings-notice-error { background: var(--danger-bg); color: var(--danger); }

/* ---- Branding / F5-E shell refinement -------------------------------- */

.branding-view { max-width: 980px; }
.branding-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, .72fr); gap: 16px; align-items: start; }
.branding-layout > .settings-notice { grid-column: 1 / -1; }
.branding-editor .settings-grid { grid-template-columns: 1fr; }
.branding-preview { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.branding-preview-label { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text-2); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.branding-preview-shell { --preview-primary: var(--primary); --preview-on-primary: var(--on-primary, #fff); padding: 20px; background: #FBFCFE; }
.branding-preview-header { display: flex; align-items: center; gap: 10px; }
.branding-preview-logo, .branding-preview-initials { width: 40px; height: 40px; border-radius: 8px; flex: 0 0 40px; }
.branding-preview-logo { object-fit: cover; }
.branding-preview-initials { display: grid; place-items: center; background: var(--preview-primary); color: var(--preview-on-primary); font-weight: 700; }
.branding-preview-identity { min-width: 0; display: grid; gap: 2px; }
.branding-preview-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.branding-preview-detail { color: var(--text-2); font-size: 12px; }
.branding-preview-copy { min-height: 42px; margin: 18px 0; color: var(--text-3); }
.branding-preview-action { width: 100%; padding: 10px 12px; border: 0; border-radius: 6px; background: var(--preview-primary); color: var(--preview-on-primary); font: inherit; font-weight: 700; }

/* ---- Widget embed / F5-F -------------------------------------------- */

.widget-view { max-width: 860px; }
.widget-form { display: grid; gap: 16px; }
.widget-help { margin: -6px 0 16px; color: var(--text-2); font-size: 13px; }
.widget-add-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.widget-add { width: auto; white-space: nowrap; }
.widget-origin-list { display: grid; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.widget-origin-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 42px; padding: 7px 8px 7px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.widget-origin-value { overflow: hidden; color: var(--text-3); text-overflow: ellipsis; white-space: nowrap; }
.widget-remove, .widget-copy { width: auto; flex: 0 0 auto; }
.widget-origin-empty { padding: 14px; border: 1px dashed var(--border); border-radius: 6px; color: var(--text-2); text-align: center; }
.widget-fallback { margin: 0 0 14px; padding: 9px 12px; border-left: 3px solid var(--warn); border-radius: 4px; background: var(--warn-bg); color: var(--warn); font-size: 13px; }
.widget-snippet { min-height: 114px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.5; }

/* ---- Shell ----------------------------------------------------------- */

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 18px 20px;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
}

.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  margin: 2px 0;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 7px;
  background: none;
  font: inherit;
  color: var(--text-3);
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}

.nav-item:hover { background: var(--bg); }

.nav-item.active {
  background: var(--primary-soft);
  border-left-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.nav-item.disabled {
  color: var(--text-2);
  opacity: .55;
  cursor: not-allowed;
}

.nav-icon { width: 18px; text-align: center; }

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  background: var(--bg);
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}

.sidebar-foot {
  padding: 12px 20px;
  font-size: 11px;
  color: var(--text-2);
  border-top: 1px solid var(--border);
}

/* ---- Topbar ----------------------------------------------------------- */

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-business { display: flex; flex-direction: column; }

.topbar-business-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
}

.topbar-business-name { font-weight: 600; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-3);
}

.btn-ghost {
  padding: 7px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  color: var(--text-3);
  cursor: pointer;
}

.btn-ghost:hover { background: var(--bg); }

/* ---- Views (placeholders B①) ------------------------------------------ */

.view { padding: 24px; }

.view-title { margin: 0 0 16px; font-size: 20px; font-weight: 700; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.placeholder-note { color: var(--text-2); margin: 0; }

.placeholder-block {
  margin-top: 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  color: var(--text-2);
  font-size: 13px;
}

/* ---- Dashboard B② ----------------------------------------------------- */

.dashboard { max-width: 1180px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card,
.dashboard-section,
.dashboard-loading,
.dashboard-error {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi-card { padding: 18px; min-height: 96px; }

.kpi-label {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}

.kpi-value {
  color: var(--text);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: 16px;
}

.dashboard-section { padding: 18px; min-width: 0; }

.dashboard-section-wide { grid-column: 1 / -1; }

.section-title {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.appointment-list,
.client-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.appointment-row,
.client-row {
  display: grid;
  align-items: center;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
}

.appointment-row { grid-template-columns: 72px minmax(0, 1fr) auto; }
.client-row { grid-template-columns: minmax(0, 1fr) auto; }

.appointment-time {
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.appointment-main,
.client-main,
.client-stats {
  min-width: 0;
}

.appointment-title,
.client-name {
  overflow: hidden;
  color: var(--text);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appointment-meta,
.client-contact,
.client-last {
  overflow: hidden;
  color: var(--text-2);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-stats { text-align: right; }

.client-count {
  color: var(--text-3);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge {
  justify-self: end;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: capitalize;
  white-space: nowrap;
}

.status-pending { background: var(--warn-bg); border-color: #FCD34D; color: var(--warn); }
.status-confirmed { background: var(--primary-soft); border-color: #BFDBFE; color: var(--primary); }
.status-completed { background: #ECFDF5; border-color: #A7F3D0; color: #047857; }
.status-cancelled { background: #F9FAFB; border-color: var(--border); color: var(--text-2); }
.status-no_show { background: var(--danger-bg); border-color: #FECACA; color: var(--danger); }

.empty-state,
.dashboard-loading,
.dashboard-error {
  color: var(--text-2);
  font-size: 13px;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
}

.dashboard-loading,
.dashboard-error {
  padding: 24px;
}

.dashboard-error p { margin: 0; }

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

@media (max-width: 760px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .sidebar-nav { display: flex; flex-wrap: wrap; }
  .nav-item { width: auto; }
  .sidebar-foot { display: none; }
}

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .view { padding: 16px; }
  .topbar { align-items: flex-start; gap: 12px; padding: 12px 16px; }
  .topbar-user { flex-wrap: wrap; justify-content: flex-end; }
  .kpi-grid { grid-template-columns: 1fr; }
  .appointment-row { grid-template-columns: 58px minmax(0, 1fr); }
  .appointment-row .status-badge {
    grid-column: 2;
    justify-self: start;
  }
  .client-row { grid-template-columns: 1fr; }
  .client-stats { text-align: left; }
}

/* ---- B③: Bookings + Calendar ------------------------------------------- */

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.view-header .view-title { margin: 0; }

.btn-inline { width: auto; padding: 9px 16px; }

.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.filter-bar .field { margin-bottom: 0; }

.filter-bar input,
.filter-bar select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
}

/* Colores por status (mismos tokens que los badges de B②) */
.status-badge { border-radius: 999px; padding: 2px 10px; font-size: 11px; font-weight: 600; white-space: nowrap; text-transform: capitalize; }
.status-pending   { background: var(--warn-bg);    color: var(--warn); }
.status-confirmed { background: var(--primary-soft); color: var(--primary); }
.status-completed { background: #ECFDF5; color: #047857; }
.status-cancelled { background: var(--bg); color: var(--text-2); }
.status-no_show   { background: var(--danger-bg); color: var(--danger); }

.bookings-list { display: flex; flex-direction: column; gap: 8px; }

.booking-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 12px 16px;
}

.status-border-pending   { border-left-color: var(--warn); }
.status-border-confirmed { border-left-color: var(--primary); }
.status-border-completed { border-left-color: #047857; }
.status-border-cancelled { border-left-color: var(--border); }
.status-border-no_show   { border-left-color: var(--danger); }

.booking-when { min-width: 150px; }
.booking-date { font-weight: 600; }
.booking-until { font-size: 12px; color: var(--text-2); }
.booking-main { flex: 1; min-width: 0; }

.appt-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.btn-action {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  font: inherit;
  font-size: 12px;
  color: var(--text-3);
  cursor: pointer;
}

.btn-action:hover { background: var(--bg); }
.btn-action:disabled { opacity: .5; cursor: default; }
.btn-action-confirm  { border-color: var(--primary); color: var(--primary); }
.btn-action-complete { border-color: #047857; color: #047857; }
.btn-action-cancel   { border-color: var(--danger); color: var(--danger); }
.btn-action-no_show  { border-color: var(--danger); color: var(--danger); }
.btn-action-charge   { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-action-charge:hover { filter: brightness(1.08); background: var(--danger); }

/* Calendar (vista dia) */
.calendar-bar { align-items: center; }
.calendar-day-label { font-weight: 600; margin-left: auto; }
.calendar-host { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; align-items: start; }

.calendar-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.calendar-staff { margin: 0 0 10px; font-size: 14px; font-weight: 700; }

.calendar-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.status-bg-pending   { background: var(--warn-bg); border-color: var(--warn); }
.status-bg-confirmed { background: var(--primary-soft); border-color: var(--primary); }
.status-bg-completed { background: #ECFDF5; border-color: #047857; }
.status-bg-cancelled { background: var(--bg); }
.status-bg-no_show   { background: var(--danger-bg); border-color: var(--danger); }

.calendar-block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.calendar-block-time { font-weight: 600; font-size: 12px; }
.calendar-block .appt-actions { margin-top: 8px; justify-content: flex-start; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(17, 24, 39, .2);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px 24px 24px;
}

.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-title { margin: 0; font-size: 17px; }

.modal-close {
  border: 0;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-2);
  cursor: pointer;
  padding: 2px 6px;
}

.modal-context { margin: 0 0 14px; color: var(--text-2); font-size: 13px; }
.modal-loading { color: var(--text-2); }
.modal-form select { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: var(--surface); color: var(--text); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.modal-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 13px;
}

.modal-error-main { font-weight: 600; }
.modal-error-details { margin: 6px 0 0; padding-left: 18px; }

/* Toasts */
#toast-host {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}

.toast {
  background: var(--text);
  color: #fff;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  box-shadow: var(--shadow);
  max-width: 360px;
}

.toast-err { background: var(--danger); }

/* ---- B④: Clients ------------------------------------------------------- */

.clients-view { max-width: 1180px; }

.clients-search .field { flex: 1; max-width: 420px; }

.clients-search input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
}

.clients-grid {
  display: grid;
  grid-template-columns: minmax(300px, .85fr) minmax(0, 1.15fr);
  gap: 16px;
  align-items: start;
}

.clients-list-panel,
.client-detail-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.clients-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.client-summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 11px 12px;
  text-align: left;
}

.client-summary-row:hover { background: var(--bg); }

.client-summary-row.active {
  background: var(--primary-soft);
  border-color: #BFDBFE;
}

.client-summary-main,
.client-summary-stats {
  min-width: 0;
}

.client-summary-stats { text-align: right; }

.client-detail-head {
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  padding-bottom: 14px;
}

.client-detail-title {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}

.client-detail-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin: 0 0 18px;
}

.client-detail-field {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.client-detail-field dt {
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.client-detail-field dd {
  overflow-wrap: anywhere;
  margin: 0;
  color: var(--text);
}

.client-history-title {
  margin: 0 0 10px;
  font-size: 14px;
}

.client-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.client-history-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 12px;
}

.client-history-when,
.client-history-main {
  min-width: 0;
}

.client-history-start {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.client-history-end {
  color: var(--text-2);
  font-size: 12px;
}

@media (max-width: 900px) {
  .clients-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .clients-search .field { max-width: none; }
  .client-summary-row,
  .client-history-row {
    grid-template-columns: 1fr;
  }
  .client-summary-stats { text-align: left; }
  .client-detail-fields { grid-template-columns: 1fr; }
  .client-history-row .status-badge { justify-self: start; }
}

/* ---- B⑤: Services / Staff / Schedules --------------------------------- */

.catalog-view { max-width: 1200px; }

.catalog-grid {
  display: grid;
  grid-template-columns: minmax(320px, .9fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: start;
}

.catalog-grid-wide { grid-template-columns: minmax(340px, .9fr) minmax(0, 1.25fr); }

.catalog-list-panel,
.catalog-editor {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.catalog-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.catalog-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 12px;
  background: var(--surface);
}

.catalog-row.inactive {
  background: #F9FAFB;
  opacity: .82;
}

.catalog-row.active-selection {
  background: var(--primary-soft);
  border-color: #BFDBFE;
}

.catalog-row-main { min-width: 0; }

.catalog-row-button {
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
}

.catalog-title {
  overflow: hidden;
  color: var(--text);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.catalog-meta,
.catalog-note {
  overflow: hidden;
  color: var(--text-2);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.catalog-note {
  margin: 4px 0 0;
  white-space: normal;
}

.catalog-row-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.catalog-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.catalog-pill.active { background: #ECFDF5; border-color: #A7F3D0; color: #047857; }
.catalog-pill.inactive { background: var(--bg); color: var(--text-2); }

.catalog-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.catalog-form input,
.catalog-form select,
.inline-catalog-form input,
.inline-catalog-form select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
}

.catalog-form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
}

.check-row input {
  width: auto;
  padding: 0;
}

.service-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.catalog-assigned {
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-3);
  margin: 12px 0;
  padding: 10px 12px;
}

.catalog-subsection {
  border-top: 1px solid var(--border);
  margin-top: 18px;
  padding-top: 16px;
}

.inline-catalog-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.time-off-form {
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
}

.inline-catalog-form .field { margin-bottom: 0; }

.mini-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mini-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.mini-main {
  overflow-wrap: anywhere;
  color: var(--text-3);
}

@media (max-width: 1020px) {
  .inline-catalog-form,
  .time-off-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .catalog-grid,
  .catalog-grid-wide {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .catalog-row,
  .mini-row {
    grid-template-columns: 1fr;
  }
  .catalog-row-side {
    justify-content: flex-start;
  }
  .service-check-grid,
  .inline-catalog-form,
  .time-off-form {
    grid-template-columns: 1fr;
  }
}

/* ---- B⑦: Reports ------------------------------------------------------- */

.reports-view { max-width: 960px; }

.reports-filter {
  align-items: end;
}

.reports-filter .field {
  min-width: 180px;
}

.reports-filter input {
  width: 100%;
}

.reports-note {
  color: var(--text-2);
  font-size: 12px;
  margin: -4px 0 14px;
}

.report-validation {
  background: var(--danger-bg);
  border-radius: 8px;
  color: var(--danger);
  font-size: 13px;
  margin: -6px 0 14px;
  padding: 9px 12px;
}

.reports-results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.report-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.report-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 92px;
  padding: 16px;
}

.report-zero {
  margin-top: 14px;
}

@media (max-width: 760px) {
  .report-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .reports-filter .field,
  .reports-filter .btn-inline {
    width: 100%;
  }
  .report-card-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- B⑥: Payments (policy + Stripe) ------------------------------------- */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
  align-items: start;
  max-width: 1100px;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px 24px;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.settings-head .section-title { margin: 0; }

.settings-form .field { margin-bottom: 16px; }
.settings-form textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
}

.field-hint {
  display: block;
  font-size: 11px;
  color: var(--text-2);
  margin-top: 4px;
}

.settings-warning {
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}

/* Switches (toggles iOS-like, tokens del sistema) */
.switch-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  cursor: pointer;
}

.switch-input { position: absolute; opacity: 0; pointer-events: none; }

.switch-slider {
  flex: 0 0 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  transition: background .15s ease;
  margin-top: 1px;
}

.switch-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform .15s ease;
}

.switch-input:checked + .switch-slider { background: var(--primary); }
.switch-input:checked + .switch-slider::after { transform: translateX(18px); }
.switch-input:focus-visible + .switch-slider { outline: 2px solid var(--primary); outline-offset: 2px; }

.switch-text { display: flex; flex-direction: column; }
.switch-label { font-weight: 600; }
.switch-hint { font-size: 12px; color: var(--text-2); }

.subfields {
  margin: 0 0 16px 52px;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--bg);
}

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

.radio-row { display: flex; gap: 18px; padding: 4px 0; }
.radio-option { display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* Estado Stripe */
.stripe-status { margin-bottom: 14px; }
.stripe-status-lines { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.stripe-status-line { font-size: 13px; color: var(--text-3); }

@media (max-width: 640px) {
  .settings-section { padding: 16px; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-actions { justify-content: stretch; }
  .settings-save { width: 100%; }
  .branding-layout { grid-template-columns: 1fr; }
  .widget-add-row { grid-template-columns: 1fr; }
  .widget-add { width: 100%; }
  .widget-origin-item { align-items: flex-start; flex-direction: column; }
  .widget-remove { width: 100%; }
}
