/* ==========================================================================
   appointment-mgt · sistema de diseño (CSS propio, sin frameworks)
   Tokens en :root · contraste WCAG AA · sidebar en escritorio, barra en móvil
   ========================================================================== */

:root {
  /* Color */
  --c-bg: #f4f6f8;
  --c-surface: #ffffff;
  --c-surface-2: #f8fafb;
  --c-border: #dde3e8;
  --c-border-strong: #b9c3cc;
  --c-text: #17212b;
  --c-text-2: #4a5866;      /* 7.0:1 sobre blanco */
  --c-text-3: #5f6d7a;      /* 5.3:1 sobre blanco */
  --c-primary: #0d6e6a;     /* 5.8:1 sobre blanco */
  --c-primary-hover: #0a5753;
  --c-primary-soft: #e3f3f1;
  --c-on-primary: #ffffff;
  --c-danger: #b42318;
  --c-danger-soft: #fdecea;
  --c-success: #17663a;
  --c-success-soft: #e6f4ea;
  --c-warning: #8a4b00;
  --c-warning-soft: #fff4e0;
  --c-info: #1d4f91;
  --c-info-soft: #e8f0fb;
  --c-nav-bg: #12232c;
  --c-nav-text: #c9d6dd;
  --c-nav-active: #ffffff;
  --c-nav-active-bg: #1f3a46;
  --c-focus: #f0a500;

  /* Tipografía */
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: .75rem;
  --fs-sm: .8125rem;
  --fs-md: .9375rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 1.875rem;

  /* Espacio, radios, sombras */
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem; --sp-5: 1.5rem; --sp-6: 2rem;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(16, 33, 43, .06), 0 1px 3px rgba(16, 33, 43, .08);
  --shadow-2: 0 4px 16px rgba(16, 33, 43, .10);
  --sidebar-w: 248px;
  --hour-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: var(--fs-md); line-height: 1.5;
  color: var(--c-text); background: var(--c-bg);
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 var(--sp-3); font-weight: 650; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0 0 var(--sp-3); }
a { color: var(--c-primary); }
a:hover { color: var(--c-primary-hover); }
small, .muted { color: var(--c-text-3); }
.muted { font-size: var(--fs-sm); }
:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--c-surface); padding: var(--sp-2) var(--sp-3); z-index: 100; }
.skip-link:focus { left: var(--sp-2); }
hr { border: 0; border-top: 1px solid var(--c-border); margin: var(--sp-4) 0; }

/* ---------- Layout de la aplicación ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--c-nav-bg); color: var(--c-nav-text);
  display: flex; flex-direction: column; padding: var(--sp-4) var(--sp-3); overflow-y: auto; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; text-decoration: none; padding: var(--sp-1) var(--sp-2) var(--sp-2); }
.brand-logo { height: 32px; width: auto; flex: none; display: block; }
.brand-name { color: #FFFFFF; font-weight: 700; font-size: 1.2rem; letter-spacing: .01em; line-height: 1; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: #27a59e; color: #06221f; display: grid; place-items: center; font-weight: 800; }
.brand:hover { color: #fff; }
.biz-switch { margin: 0 var(--sp-2) var(--sp-4); }
.biz-switch label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: #9fb2bc; display: block; margin-bottom: var(--sp-1); }
.biz-switch select { width: 100%; background: #1b313c; color: #fff; border: 1px solid #2f4b58; border-radius: var(--r-sm); padding: .45rem .5rem; font: inherit; font-size: var(--fs-sm); }
.biz-name { color: #fff; font-weight: 600; font-size: var(--fs-sm); padding: 0 var(--sp-2) var(--sp-4); overflow-wrap: anywhere; }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-section { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: #8ea3ad; padding: var(--sp-4) var(--sp-3) var(--sp-1); }
.nav a {
  display: flex; align-items: center; gap: var(--sp-3); padding: .55rem var(--sp-3); border-radius: var(--r-sm);
  color: var(--c-nav-text); text-decoration: none; font-size: var(--fs-md);
}
.nav a:hover { background: #1a303b; color: #fff; }
.nav a[aria-current="page"] { background: var(--c-nav-active-bg); color: var(--c-nav-active); font-weight: 600; box-shadow: inset 3px 0 0 #3cc2b9; }
.nav svg, .ico { width: 18px; height: 18px; flex: none; }
.sidebar-foot { margin-top: auto; padding: var(--sp-4) var(--sp-2) 0; border-top: 1px solid #243d49; font-size: var(--fs-sm); }
.sidebar-foot .who { color: #fff; font-weight: 600; }
.sidebar-foot .role { color: #9fb2bc; font-size: var(--fs-xs); }
.sidebar-foot form { margin-top: var(--sp-2); }
.btn-logout { background: transparent; border: 1px solid #36525f; color: var(--c-nav-text); border-radius: var(--r-sm); padding: .35rem .7rem; font: inherit; font-size: var(--fs-sm); cursor: pointer; }
.btn-logout:hover { background: #1a303b; color: #fff; }

.topbar { display: none; }
.content { margin-left: var(--sidebar-w); padding: var(--sp-5) var(--sp-6) var(--sp-6); max-width: 1320px; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--c-text-3); font-size: var(--fs-sm); margin: 2px 0 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.breadcrumb { font-size: var(--fs-sm); margin-bottom: var(--sp-2); }
.breadcrumb a { text-decoration: none; }

@media (max-width: 899px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; width: min(84vw, 300px); box-shadow: var(--shadow-2); }
  .app.nav-open .sidebar { transform: none; }
  .nav-backdrop { display: none; }
  .app.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(10, 20, 26, .45); z-index: 30; }
  .topbar {
    display: flex; align-items: center; gap: var(--sp-3); position: sticky; top: 0; z-index: 20;
    background: var(--c-nav-bg); color: #fff; padding: var(--sp-2) var(--sp-4); min-height: 52px;
  }
  .topbar .title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .menu-btn { background: transparent; border: 1px solid #36525f; color: #fff; border-radius: var(--r-sm); width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer; }
  .topbar .btn { padding: .4rem .7rem; }
  .content { margin-left: 0; padding: var(--sp-4); }
  .page-head { margin-bottom: var(--sp-4); }
}

/* ---------- Componentes ---------- */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); padding: var(--sp-5); box-shadow: var(--shadow-1); margin-bottom: var(--sp-4); }
.card > h2:first-child, .card-head h2 { margin-bottom: var(--sp-3); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-3); flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-tight { padding: var(--sp-4); }
@media (max-width: 599px) { .card { padding: var(--sp-4); } }

.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.split { display: grid; gap: var(--sp-4); grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
@media (max-width: 1099px) { .split { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: var(--sp-3); }
.row { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.row-between { justify-content: space-between; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: .55rem 1rem; border-radius: var(--r-sm); border: 1px solid transparent; font: inherit; font-weight: 600;
  font-size: var(--fs-md); line-height: 1.2; text-decoration: none; cursor: pointer; min-height: 40px; white-space: nowrap;
}
.btn-primary { background: var(--c-primary); color: var(--c-on-primary); }
.btn-primary:hover { background: var(--c-primary-hover); color: #fff; }
.btn-secondary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border-strong); }
.btn-secondary:hover { background: var(--c-surface-2); color: var(--c-text); border-color: var(--c-text-3); }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger:hover { background: #8f1c13; color: #fff; }
.btn-ghost { background: transparent; color: var(--c-primary); }
.btn-ghost:hover { background: var(--c-primary-soft); }
.btn-sm { padding: .3rem .65rem; min-height: 32px; font-size: var(--fs-sm); }
.btn-lg { padding: .8rem 1.25rem; min-height: 48px; font-size: var(--fs-lg); }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); font-weight: 600; font-size: var(--fs-sm); color: var(--c-text); }
.field .hint { font-weight: 400; color: var(--c-text-3); font-size: var(--fs-xs); }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea, .input {
  font: inherit; font-weight: 400; font-size: var(--fs-md); color: var(--c-text); background: var(--c-surface);
  border: 1px solid var(--c-border-strong); border-radius: var(--r-sm); padding: .55rem .7rem; min-height: 42px; width: 100%;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: 2px solid var(--c-primary); outline-offset: 0; border-color: var(--c-primary); }
.field-error, .field .field-error { color: var(--c-danger); font-weight: 500; font-size: var(--fs-xs); }
.input-validation-error { border-color: var(--c-danger) !important; }
.fields { display: grid; gap: 0 var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.check { display: flex; gap: var(--sp-2); align-items: flex-start; font-weight: 500; font-size: var(--fs-md); margin-bottom: var(--sp-3); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--c-primary); flex: none; }
.check small { display: block; font-weight: 400; }
fieldset { border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-4); margin: 0 0 var(--sp-4); }
legend { font-weight: 650; padding: 0 var(--sp-2); font-size: var(--fs-md); }
.filters { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 150px; flex: 1 1 150px; }
.filters .btn { flex: none; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); }
.segmented { display: inline-flex; border: 1px solid var(--c-border-strong); border-radius: var(--r-sm); overflow: hidden; background: var(--c-surface); }
.segmented a, .segmented button { padding: .45rem .85rem; text-decoration: none; color: var(--c-text); border: 0; background: none; font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
.segmented a + a { border-left: 1px solid var(--c-border-strong); }
.segmented [aria-current="true"], .segmented .on { background: var(--c-primary); color: #fff; }

/* Alertas */
.alert { border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4); border: 1px solid; display: flex; gap: var(--sp-3); align-items: flex-start; }
.alert::before { font-weight: 800; flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; color: #fff; margin-top: 1px; }
.alert > div, .alert > p { flex: 1; margin: 0; }
.alert-error { background: var(--c-danger-soft); border-color: #f3b8b2; color: #7a1710; }
.alert-error::before { content: "!"; background: var(--c-danger); }
.alert-success { background: var(--c-success-soft); border-color: #b5dcc1; color: #114d2b; }
.alert-success::before { content: "✓"; background: var(--c-success); }
.alert-info { background: var(--c-info-soft); border-color: #bcd0ee; color: #173f74; }
.alert-info::before { content: "i"; background: var(--c-info); }
.alert-warning { background: var(--c-warning-soft); border-color: #f0cf96; color: #6b3a00; }
.alert-warning::before { content: "!"; background: var(--c-warning); }
.alert strong { display: block; }

/* Badges de estado: texto + icono/forma */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 650; border: 1px solid; white-space: nowrap; line-height: 1.6; }
.badge::before { font-size: 11px; line-height: 1; }
.badge-pending   { background: #fff4e0; color: #7a4200; border-color: #f0cf96; }
.badge-pending::before { content: "◔"; }
.badge-confirmed { background: #e3f3f1; color: #0a5753; border-color: #a9d9d4; }
.badge-confirmed::before { content: "●"; }
.badge-completed { background: #e6f4ea; color: #114d2b; border-color: #b5dcc1; }
.badge-completed::before { content: "✓"; }
.badge-cancelled { background: #f1f3f5; color: #4a5866; border-color: #ccd3da; text-decoration: line-through; text-decoration-thickness: 1px; }
.badge-cancelled::before { content: "✕"; text-decoration: none; display: inline-block; }
.badge-noshow    { background: #fdecea; color: #7a1710; border-color: #f3b8b2; }
.badge-noshow::before { content: "⊘"; }
.badge-neutral   { background: #f1f3f5; color: #3b4753; border-color: #ccd3da; }
.badge-warn      { background: #fff4e0; color: #7a4200; border-color: #f0cf96; }
.badge-warn::before { content: "$"; font-weight: 800; }
.badge-ok        { background: #e6f4ea; color: #114d2b; border-color: #b5dcc1; }
.badge-ok::before { content: "✓"; }

.prio { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 650; padding: 1px 7px; border-radius: var(--r-sm); }
.prio-high   { color: #7a1710; background: #fdecea; }
.prio-high::before { content: "▲"; font-size: 9px; }
.prio-normal { color: #3b4753; background: #f1f3f5; }
.prio-normal::before { content: "■"; font-size: 8px; }
.prio-low    { color: #1d4f91; background: #e8f0fb; }
.prio-low::before { content: "▼"; font-size: 9px; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* Tablas */
.table-wrap { overflow-x: auto; border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.table th, .table td { padding: .65rem .8rem; text-align: left; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--c-text-2); background: var(--c-surface-2); font-weight: 650; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f6fafa; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table a.rowlink { font-weight: 600; text-decoration: none; color: var(--c-text); }
.table a.rowlink:hover { color: var(--c-primary); text-decoration: underline; }
@media (max-width: 699px) {
  .table-stack thead { display: none; }
  .table-stack tr { display: block; border-bottom: 1px solid var(--c-border); padding: var(--sp-2) 0; }
  .table-stack td { display: flex; justify-content: space-between; gap: var(--sp-3); border: 0; padding: .3rem .8rem; }
  .table-stack td::before { content: attr(data-label); font-size: var(--fs-xs); color: var(--c-text-3); font-weight: 600; text-transform: uppercase; }
  .table-stack td.num { text-align: right; }
}

/* Listas definidas */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-2) var(--sp-4); margin: 0; }
.dl dt { color: var(--c-text-3); font-size: var(--fs-sm); }
.dl dd { margin: 0; font-weight: 500; }
@media (max-width: 499px) { .dl { grid-template-columns: 1fr; gap: 0; } .dl dd { margin-bottom: var(--sp-2); } }

/* Métricas */
.metrics { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: var(--sp-4); }
.metric { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-4); box-shadow: var(--shadow-1); text-decoration: none; color: inherit; display: block; }
a.metric:hover { border-color: var(--c-primary); }
.metric .label { font-size: var(--fs-sm); color: var(--c-text-2); font-weight: 600; }
.metric .value { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.metric .foot { font-size: var(--fs-xs); color: var(--c-text-3); }
.metric-warn { border-left: 4px solid #d98a00; }
.metric-danger { border-left: 4px solid var(--c-danger); }
.metric-ok { border-left: 4px solid var(--c-success); }

/* Listas de citas */
.appt-list { list-style: none; margin: 0; padding: 0; }
.appt-item { display: grid; grid-template-columns: 76px 1fr auto; gap: var(--sp-3); align-items: center; padding: var(--sp-3) 0; border-bottom: 1px solid var(--c-border); }
.appt-item:last-child { border-bottom: 0; }
.appt-item .when { font-variant-numeric: tabular-nums; }
.appt-item .when b { display: block; font-size: var(--fs-md); }
.appt-item .when span { font-size: var(--fs-xs); color: var(--c-text-3); }
.appt-item .who a { font-weight: 600; text-decoration: none; color: var(--c-text); }
.appt-item .who a:hover { color: var(--c-primary); }
.appt-item .meta { font-size: var(--fs-sm); color: var(--c-text-3); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.appt-item .tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 599px) { .appt-item { grid-template-columns: 64px 1fr; } .appt-item .tags { grid-column: 2; justify-content: flex-start; } }

/* Estado vacío */
.empty-state { text-align: center; padding: var(--sp-6) var(--sp-4); color: var(--c-text-2); border: 1px dashed var(--c-border-strong); border-radius: var(--r-md); background: var(--c-surface-2); }
.empty-state .ico-big { font-size: 28px; line-height: 1; margin-bottom: var(--sp-2); color: var(--c-text-3); }
.empty-state h3 { margin-bottom: var(--sp-1); color: var(--c-text); }
.empty-state p { margin-bottom: var(--sp-3); }

/* Horarios (slots) */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--sp-2); }
.slot { position: relative; }
.slot input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.slot span { display: block; text-align: center; padding: .55rem .4rem; border: 1px solid var(--c-border-strong); border-radius: var(--r-sm); background: var(--c-surface); font-weight: 600; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.slot input:hover + span { border-color: var(--c-primary); }
.slot input:checked + span { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.slot input:checked + span::before { content: "✓ "; }
.slot input:focus-visible + span { outline: 3px solid var(--c-focus); outline-offset: 2px; }
.slots-loading { color: var(--c-text-3); font-size: var(--fs-sm); }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

/* Choices (tarjetas seleccionables) */
.choices { display: grid; gap: var(--sp-2); }
.choice { position: relative; display: block; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice .box { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--c-border-strong); border-radius: var(--r-md); background: var(--c-surface); }
.choice .box b { display: block; }
.choice .box small { color: var(--c-text-3); }
.choice input:checked + .box { border-color: var(--c-primary); box-shadow: 0 0 0 2px var(--c-primary) inset; background: var(--c-primary-soft); }
.choice input:focus-visible + .box { outline: 3px solid var(--c-focus); outline-offset: 2px; }

/* Búsqueda de clientes */
.search-results { border: 1px solid var(--c-border); border-radius: var(--r-md); max-height: 260px; overflow: auto; background: var(--c-surface); }
.search-results:empty { display: none; }
.search-results .choice .box { border: 0; border-bottom: 1px solid var(--c-border); border-radius: 0; }

/* Tabs simples */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--c-border); margin-bottom: var(--sp-4); overflow-x: auto; }
.tabs a { padding: .6rem .9rem; text-decoration: none; color: var(--c-text-2); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--c-primary); border-color: var(--c-primary); }

/* Detalles / acordeón */
details.disclosure { border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface); margin-bottom: var(--sp-3); }
details.disclosure > summary { cursor: pointer; padding: var(--sp-3) var(--sp-4); font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
details.disclosure > summary::after { content: "▾"; color: var(--c-text-3); }
details.disclosure[open] > summary::after { content: "▴"; }
details.disclosure > .body { padding: 0 var(--sp-4) var(--sp-4); }

/* Resumen de pagos */
.money-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--sp-2); }
.money-grid > div { background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--r-sm); padding: var(--sp-2) var(--sp-3); }
.money-grid .k { font-size: var(--fs-xs); color: var(--c-text-3); font-weight: 600; }
.money-grid .v { font-weight: 700; font-variant-numeric: tabular-nums; font-size: var(--fs-lg); }
.money-grid .due { background: var(--c-warning-soft); border-color: #f0cf96; }
.money-grid .due .v { color: #7a4200; }
.money-grid .paid { background: var(--c-success-soft); border-color: #b5dcc1; }

/* ---------- Calendario ---------- */
.cal-toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.cal-toolbar .range { font-weight: 650; font-size: var(--fs-lg); text-transform: capitalize; }
.cal-legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); font-size: var(--fs-sm); color: var(--c-text-2); margin-bottom: var(--sp-3); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal { --cols: 7; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); overflow: auto; }
.cal-head, .cal-body { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(110px, 1fr)); min-width: calc(56px + var(--cols) * 110px); }
.cal-head { position: sticky; top: 0; background: var(--c-surface-2); border-bottom: 1px solid var(--c-border); z-index: 2; }
.cal-head div { padding: var(--sp-2); font-size: var(--fs-sm); font-weight: 650; text-align: center; border-left: 1px solid var(--c-border); text-transform: capitalize; }
.cal-head div:first-child { border-left: 0; }
.cal-head .today { color: var(--c-primary); box-shadow: inset 0 -3px 0 var(--c-primary); }
.cal-hours div { height: var(--hour-h); font-size: var(--fs-xs); color: var(--c-text-3); text-align: right; padding: 2px 6px 0 0; font-variant-numeric: tabular-nums; }
.cal-col { position: relative; border-left: 1px solid var(--c-border); background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hour-h) - 1px), var(--c-border) calc(var(--hour-h) - 1px), var(--c-border) var(--hour-h)); }
.cal-col.today { background-color: #f3faf9; }
.cal-ev {
  position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 3px 6px; font-size: var(--fs-xs); line-height: 1.3;
  color: #fff; background: var(--ev, #0d6e6a); overflow: hidden; text-decoration: none; border: 1px solid rgba(0,0,0,.15);
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.cal-ev:hover { color: #fff; filter: brightness(1.08); z-index: 3; }
.cal-ev b { display: block; font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev .t { opacity: .95; font-variant-numeric: tabular-nums; }
.cal-ev.st-cancelled { background: repeating-linear-gradient(135deg, #e9edf0 0 6px, #f6f7f8 6px 12px); color: #4a5866; text-decoration: line-through; }
.cal-ev.st-noshow { background: #fdecea; color: #7a1710; border-color: #f3b8b2; }
.cal-ev.st-completed { opacity: .8; }
.cal-ev.st-completed b::after { content: " ✓"; }
.cal-ev.st-pending { border: 2px dashed rgba(255,255,255,.85); }
.cal-block { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(45deg, #eef1f3 0 6px, #e1e6ea 6px 12px); color: #3b4753; font-size: var(--fs-xs); padding: 2px 6px; border-top: 2px solid #9aa7b2; overflow: hidden; }
.cal-off { position: absolute; left: 0; right: 0; background: rgba(23, 33, 43, .035); pointer-events: none; }

.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); overflow: hidden; }
.cal-month .dow { background: var(--c-surface-2); font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; padding: var(--sp-2); text-align: center; color: var(--c-text-2); border-bottom: 1px solid var(--c-border); }
.cal-month .day { min-height: 108px; border-right: 1px solid var(--c-border); border-bottom: 1px solid var(--c-border); padding: 4px 6px; font-size: var(--fs-xs); }
.cal-month .day:nth-child(7n) { border-right: 0; }
.cal-month .day.out { background: var(--c-surface-2); color: var(--c-text-3); }
.cal-month .day.today .num { background: var(--c-primary); color: #fff; border-radius: 50%; }
.cal-month .num { display: inline-grid; place-items: center; width: 24px; height: 24px; font-weight: 650; text-decoration: none; color: inherit; }
.cal-month .count { float: right; font-weight: 650; color: var(--c-text-2); }
.cal-month ul { list-style: none; margin: 4px 0 0; padding: 0; }
.cal-month li a { display: flex; gap: 4px; align-items: center; text-decoration: none; color: var(--c-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 1px 0; }
.cal-month li a.st-cancelled { text-decoration: line-through; color: var(--c-text-3); }

.agenda { display: none; }
@media (max-width: 767px) {
  .cal-desktop { display: none; }
  .agenda { display: block; }
  .cal-month .day { min-height: 64px; }
  .cal-month ul { display: none; }
  .cal-month .count { float: none; display: block; text-align: center; background: var(--c-primary-soft); color: var(--c-primary); border-radius: var(--r-sm); margin-top: 2px; }
}
.agenda-day { margin-bottom: var(--sp-4); }
.agenda-day h3 { font-size: var(--fs-md); padding: var(--sp-2) 0; border-bottom: 2px solid var(--c-border); }
.agenda-day h3.today { color: var(--c-primary); border-color: var(--c-primary); }
.agenda-item { display: grid; grid-template-columns: 72px 1fr; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px solid var(--c-border); text-decoration: none; color: inherit; }
.agenda-item .time { font-weight: 650; font-variant-numeric: tabular-nums; }
.agenda-item .time small { display: block; font-weight: 400; }
.agenda-item .body { border-left: 4px solid var(--ev, var(--c-primary)); padding-left: var(--sp-3); }
.agenda-item.block .body { border-left-color: #9aa7b2; color: var(--c-text-2); }

/* ---------- Página pública (reserva) ---------- */
.public-body { background: #eef3f3; }
.public-header { background: var(--c-surface); border-bottom: 1px solid var(--c-border); }
.public-header .inner { max-width: 640px; margin: 0 auto; padding: var(--sp-4); display: flex; gap: var(--sp-3); align-items: center; }
.public-logo { width: 44px; height: 44px; border-radius: 12px; background: var(--c-primary); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none; }
.public-header h1 { font-size: var(--fs-lg); margin: 0; }
.public-header p { margin: 0; font-size: var(--fs-sm); color: var(--c-text-3); }
.public-main { max-width: 640px; margin: 0 auto; padding: var(--sp-4) var(--sp-4) var(--sp-6); }
.public-footer { max-width: 640px; margin: 0 auto; padding: 0 var(--sp-4) var(--sp-6); font-size: var(--fs-xs); color: var(--c-text-3); text-align: center; }
.steps { list-style: none; display: flex; gap: 4px; margin: 0 0 var(--sp-4); padding: 0; counter-reset: st; }
.steps li { flex: 1; font-size: 11px; color: var(--c-text-3); text-align: center; counter-increment: st; }
.steps li::before { content: counter(st); display: grid; place-items: center; width: 26px; height: 26px; margin: 0 auto 2px; border-radius: 50%; border: 2px solid var(--c-border-strong); background: var(--c-surface); font-weight: 700; font-size: 12px; }
.steps li.done::before { content: "✓"; background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.steps li.current { color: var(--c-text); font-weight: 650; }
.steps li.current::before { border-color: var(--c-primary); color: var(--c-primary); }
.step-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); padding: var(--sp-4); margin-bottom: var(--sp-3); box-shadow: var(--shadow-1); }
.step-card h2 { font-size: var(--fs-md); display: flex; gap: var(--sp-2); align-items: center; }
.step-card h2 .n { width: 24px; height: 24px; border-radius: 50%; background: var(--c-primary); color: #fff; display: grid; place-items: center; font-size: 12px; flex: none; }
.sticky-cta { position: sticky; bottom: 0; background: linear-gradient(to top, #eef3f3 70%, rgba(238,243,243,0)); padding: var(--sp-4) 0 var(--sp-2); }
.success-hero { text-align: center; padding: var(--sp-5) var(--sp-4) var(--sp-4); }
.success-hero .tick { width: 64px; height: 64px; border-radius: 50%; background: var(--c-success); color: #fff; display: grid; place-items: center; font-size: 32px; margin: 0 auto var(--sp-3); }
.ticket { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-1); }
.ticket .top { background: var(--c-primary); color: #fff; padding: var(--sp-4); }
.ticket .top .big { font-size: var(--fs-xl); font-weight: 700; }
.ticket .rows { padding: var(--sp-2) var(--sp-4); }
.ticket .rows > div { display: flex; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) 0; border-bottom: 1px dashed var(--c-border); }
.ticket .rows > div:last-child { border-bottom: 0; }
.ticket .rows span:first-child { color: var(--c-text-3); font-size: var(--fs-sm); }
.ticket .rows span:last-child { font-weight: 600; text-align: right; }

/* ---------- Autenticación ---------- */
.auth-body { background: linear-gradient(160deg, #12232c 0%, #16413f 100%); min-height: 100vh; }
/* Arriba, no centrado vertical: ~40 px desde el borde superior; centrado horizontal. */
.auth-main { min-height: 100vh; display: flex; justify-content: center; align-items: flex-start; padding: 40px var(--sp-4) var(--sp-6); }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-brand { display: flex; align-items: center; gap: var(--sp-2); color: #fff; font-weight: 700; font-size: var(--fs-lg); }
.auth-card { width: 100%; max-width: 420px; background: var(--c-surface); border-radius: var(--r-lg); padding: var(--sp-6) var(--sp-5); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-card h1 { margin-bottom: var(--sp-1); }
.auth-card .sub { color: var(--c-text-3); margin-bottom: var(--sp-5); font-size: var(--fs-sm); }

/* Utilidades */
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } .mb-3 { margin-bottom: var(--sp-3); }
.text-right { text-align: right; } .nowrap { white-space: nowrap; } .num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 650; }
.hidden { display: none !important; }
.inline-form { display: inline; }
.color-input { width: 56px !important; padding: 2px !important; height: 42px; }
.kbd-copy { font-family: ui-monospace, Consolas, monospace; font-size: var(--fs-sm); background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--r-sm); padding: .4rem .6rem; word-break: break-all; }

.agenda-day h3::first-letter, .ticket .top .big::first-letter { text-transform: uppercase; }

/* Selector de idioma */
.lang-switch { display: inline-flex; align-items: center; gap: .35rem; font-size: var(--fs-sm, .875rem); }
.lang-switch button { background: none; border: 1px solid transparent; border-radius: 6px; padding: .2rem .5rem; cursor: pointer; color: inherit; font: inherit; min-height: 32px; }
.lang-switch button.on { font-weight: 700; border-color: currentColor; }
.lang-switch button:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.sidebar-foot .lang-switch { color: #e5edf2; margin-bottom: .75rem; }
.topbar .lang-switch { color: #fff; margin-left: auto; margin-right: .5rem; }
.public-header .inner { position: relative; }
.public-header .lang-switch { margin-left: auto; }

/* El atributo hidden debe ocultar siempre (también tarjetas con display propio). */
[hidden] { display: none !important; }


/* ---- Marca CitaLoop en la barra superior (móvil): icono + nombre y, debajo, el negocio activo ---- */
.topbar-brand { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; color: #fff; text-decoration: none; }
.topbar-brand .brand-line { display: flex; align-items: center; gap: 10px; }
.topbar-brand .brand-logo { height: 30px; width: auto; }
.topbar-brand .brand-name { font-size: 1.1rem; }
.topbar-brand .brand-biz { font-size: var(--fs-xs, .75rem); color: #d6e4ea; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-brand .brand-logo { height: 40px; width: auto; }
.auth-brand { gap: 10px; }

/* ---- Filtros de la Cola de mensajes y la Bandeja ----
   Seleccionado: texto blanco #FFFFFF sobre verde oscuro #0F6B6D. Inactivo: texto oscuro con borde visible.
   (Antes se reutilizaban .btn dentro de .tabs y la regla .tabs a pintaba de gris el texto del seleccionado.) */
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.filter-row:last-of-type { margin-bottom: 16px; }
.filter-chip { display: inline-flex; align-items: center; min-height: 38px; padding: .4rem .9rem; border-radius: 999px; border: 1px solid #5b6b76; background: #FFFFFF; color: #1b2a33; font-weight: 600; font-size: var(--fs-sm, .875rem); text-decoration: none; line-height: 1.2; }
.filter-chip:hover { background: #E3F1F1; border-color: #0F6B6D; color: #0b2f31; }
.filter-chip.is-active { background: #0F6B6D; border-color: #0F6B6D; color: #FFFFFF; }
.filter-chip.is-active:hover { background: #0B5557; border-color: #0B5557; color: #FFFFFF; }
.filter-chip:focus-visible { outline: 3px solid #0F6B6D; outline-offset: 2px; box-shadow: 0 0 0 2px #FFFFFF; }
.filter-chip.is-active:focus-visible { color: #FFFFFF; outline-color: #0B2F31; box-shadow: 0 0 0 2px #FFFFFF, 0 0 0 5px #0F6B6D; }
.page-header .btn, .page-header form { margin-bottom: 0; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.table-wrap { overflow-x: auto; max-width: 100%; }


/* ======================= Dashboard · Actividad de citas ======================= */
:root {
  --st-confirmed: #0F6B6D;   /* verde azulado de marca */
  --st-pending: #C27803;     /* ámbar (3:1 sobre blanco) */
  --st-completed: #3F8F4F;   /* verde */
  --st-noshow: #C0392B;      /* rojo */
}
.chart-card { position: relative; padding-bottom: var(--sp-4); }
.chart-card .card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.chart-total { font-weight: 700; color: var(--c-text-2); font-size: var(--fs-sm, .875rem); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 0 0 var(--sp-2); padding: 0; font-size: var(--fs-sm, .875rem); color: var(--c-text); }
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.swatch.st-confirmed, .seg.st-confirmed { background: var(--st-confirmed); fill: var(--st-confirmed); }
.swatch.st-pending, .seg.st-pending { background: var(--st-pending); fill: var(--st-pending); }
.swatch.st-completed, .seg.st-completed { background: var(--st-completed); fill: var(--st-completed); }
.swatch.st-noshow, .seg.st-noshow { background: var(--st-noshow); fill: var(--st-noshow); }
.seg { stroke: #FFFFFF; stroke-width: 1; }
.chart-body { min-height: 120px; max-width: 100%; overflow: hidden; }
.chart-svg { display: block; max-width: 100%; height: auto; }
.chart-svg .grid { stroke: #E3E8EC; stroke-width: 1; }
.chart-svg .grid.axis { stroke: #B9C3CC; }
.chart-svg .ytick, .chart-svg .xtick { fill: #4A5866; font-size: 11px; font-family: inherit; }
.chart-svg .bar { cursor: pointer; outline: none; }
.chart-svg .bar-hit { fill: transparent; }
.chart-svg .bar-ring { fill: none; stroke: transparent; stroke-width: 2.5; }
.chart-svg .bar:hover .bar-ring { stroke: #9FC9CA; }
.chart-svg .bar:focus-visible .bar-ring { stroke: #0B2F31; stroke-width: 3; }
.chart-svg .bar.is-selected .bar-ring { stroke: #0F6B6D; stroke-width: 3; }
.chart-svg .bar.is-dim .seg { opacity: .45; }
.chart-skeleton { height: 160px; border-radius: 10px; background: linear-gradient(90deg, #eef2f4 25%, #e2e8ec 37%, #eef2f4 63%); background-size: 400% 100%; animation: chart-shimmer 1.4s ease infinite; }
@keyframes chart-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .chart-skeleton { animation: none; } }
.chart-empty, .chart-error { display: grid; place-items: center; text-align: center; min-height: 120px; color: var(--c-text-2); gap: 8px; border: 1px dashed var(--c-border-strong); border-radius: 10px; padding: var(--sp-4); }
.chart-empty p, .chart-error p { margin: 0; font-weight: 600; }
.chart-tip { position: absolute; z-index: 20; pointer-events: none; background: #12232C; color: #FFFFFF; border-radius: 8px; padding: 8px 10px; font-size: var(--fs-sm, .875rem); box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 240px; }
.chart-tip[hidden] { display: none; }
.chart-tip strong { display: block; margin-bottom: 2px; }
.chart-tip .tip-total { font-weight: 600; margin-bottom: 4px; }
.chart-tip ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.chart-tip li { display: flex; align-items: center; gap: 6px; }
.range-selection { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: var(--sp-3); padding: 8px 10px; background: var(--c-primary-soft); border-radius: 8px; }
.range-selection[hidden] { display: none; }
@media (max-width: 640px) {
  .chart-card { padding-left: var(--sp-3); padding-right: var(--sp-3); }
  .chart-tip { max-width: 200px; }
}


/* ======================= Dashboard · distribución a todo el ancho =======================
   .content limita el ancho a 1320 px (lectura cómoda en el resto de pantallas). El Dashboard usa .content-wide:
   todo el ancho disponible después del sidebar con márgenes laterales de 28 px. */
.content.content-wide { max-width: none; padding-left: 28px; padding-right: 28px; }

.content-wide .filters .field { flex: 1 1 170px; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: var(--sp-4); align-items: start; }
.dash-main { min-width: 0; display: grid; gap: var(--sp-4); }
.dash-main > .card, .dash-grid > .card { margin-bottom: 0; }
/* Cuando las dos columnas ya no caben con comodidad: gráfico → Citas del rango → Próximas citas, en una columna. */
@media (max-width: 1199px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 899px) { .content.content-wide { padding-left: var(--sp-4); padding-right: var(--sp-4); } }

/* Tarjeta del gráfico: título, leyenda y total en una sola fila (se reparte en varias si no cabe). */
.chart-card .card-head { flex-wrap: wrap; row-gap: 6px; margin-bottom: var(--sp-2); }
.chart-card .card-head h2 { margin: 0; }
.chart-card .chart-legend { margin: 0 0 0 auto; }
.chart-card .chart-total { margin-left: 0; }
@media (max-width: 899px) { .chart-card .chart-legend { margin-left: 0; flex-basis: 100%; order: 3; } }

/* ---- Dashboard: filtros, métricas, gráfico y Citas del rango en la columna izquierda; Próximas citas a la derecha ---- */
.dash-main { container-type: inline-size; container-name: dash; }
.dash-main > .metrics { margin-bottom: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }          /* dos filas de dos tarjetas si el ancho se reduce */
@container dash (min-width: 860px) { .dash-main > .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); } }   /* una fila cuando se leen cómodas */
.dash-main > .filters { margin-bottom: 0; }
.filters .filters-error { flex: 1 0 100%; margin: 0; }
.dash-main .filters .field { flex: 1 1 170px; min-width: 170px; }         /* los campos no se comprimen: pasan a otra línea */
.dash-main .filters .btn { flex: none; white-space: nowrap; }
.dash-grid > aside.card { align-self: start; }                             /* la tarjeta toma la altura de su contenido */
@media (max-width: 599px) { .dash-main > .metrics { gap: var(--sp-2); } }

/* ---- Correo electrónico (negocio) y Correo de plataforma ---- */
.radio-card { display: flex; gap: var(--sp-2); align-items: flex-start; padding: var(--sp-3); border: 1px solid var(--c-border, #d5dde3); border-radius: 12px; background: #fff; cursor: pointer; flex: 1 1 240px; }
.radio-card input { margin-top: 3px; accent-color: var(--c-primary); flex: none; }
.radio-card:has(input:checked) { border-color: var(--c-primary); box-shadow: 0 0 0 2px rgba(15, 107, 109, .18); }
.radio-card:focus-within { outline: 3px solid rgba(15, 107, 109, .4); outline-offset: 2px; }
.kv { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: var(--sp-2) var(--sp-4); margin: 0 0 var(--sp-3); }
.kv dt { font-weight: 600; color: var(--c-text-2, #3b4b57); }
.kv dd { margin: 0; display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; min-width: 0; overflow-wrap: anywhere; }
.checklist { list-style: none; margin: 0 0 var(--sp-3); padding: 0; display: grid; gap: 6px; }
.token-status { margin: 0; }
/* Estado, ayuda y avisos del campo: siempre debajo del control (tercera fila de la rejilla), nunca entre la etiqueta y el campo. */
.field-notes { display: flex; flex-direction: column; gap: 6px; align-self: start; }
[data-panel][hidden], [data-ses-keys][hidden], [data-ses-role][hidden], [data-pe-keys][hidden] { display: none !important; }
@media (max-width: 599px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: var(--sp-2); } .radio-card { flex-basis: 100%; } }

/* ---- Avisos temporales con × (cierre por teclado/ratón; la confirmación se oculta sola a los 8 s) ---- */
.alert[data-notice] { align-items: flex-start; }
.notice-close { flex: none; margin-left: auto; width: 32px; height: 32px; min-width: 32px; border: 0; border-radius: 8px; background: transparent; color: inherit; font-size: 22px; line-height: 1; cursor: pointer; display: grid; place-items: center; margin-top: -4px; margin-right: -8px; }
.notice-close:hover { background: rgba(0, 0, 0, .08); }
.notice-close:focus-visible { outline: 3px solid rgba(15, 107, 109, .6); outline-offset: 1px; }
.alert[data-notice][hidden] { display: none !important; }

/* ---- Cola de mensajes: tabla compacta, una línea por mensaje ---- */
.queue-wrap { max-width: 100%; }
.queue-table { font-size: 13px; }
.queue-table th, .queue-table td { padding: .4rem .5rem; white-space: nowrap; }
.queue-table th { font-size: 11px; }
.queue-table td.num, .queue-table th.num { text-align: right; }
.queue-table .nowrap { white-space: nowrap; }
.queue-table .secondary, .queue-table small { font-size: 12px; color: var(--c-text-2); }
.queue-table .cell-ellipsis { overflow: hidden; text-overflow: ellipsis; max-width: 14rem; }
.queue-table td:nth-child(5) { min-width: 8rem; }
.queue-table .badge { font-size: 11px; padding: 1px 7px; }
.queue-table .btn-sm { padding: .2rem .55rem; min-height: 28px; font-size: 12px; }
.prov-cell { display: flex; gap: .5rem; align-items: baseline; min-width: 0; max-width: 24rem; border-bottom: 0; }
.queue-table td.prov-cell { display: table-cell; }
.prov-cell .prov-name { display: inline-block; max-width: 10rem; vertical-align: bottom; }
.prov-cell .prov-mode { margin-left: .35rem; }
.prov-cell .id-short { display: none; margin-left: .35rem; font-family: ui-monospace, Consolas, monospace; }
@media (min-width: 1500px) { .prov-cell .id-short { display: inline; } .queue-table .cell-ellipsis { max-width: 18rem; } }
.queue-table .sticky-end { position: sticky; right: 0; background: var(--c-surface); box-shadow: -8px 0 8px -8px rgba(0, 0, 0, .18); }
.queue-table thead .sticky-end { background: var(--c-surface-2); }
.queue-table tbody tr:hover .sticky-end { background: #f6fafa; }
.msg-detail td { background: var(--c-surface-2); white-space: normal; }
.js .msg-detail:not(.open) { display: none; }
.detail-grid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .35rem 1rem; margin: 0; }
.detail-grid dt { font-weight: 600; color: var(--c-text-2); }
.detail-grid dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.detail-grid .msg-id { font-family: ui-monospace, Consolas, monospace; font-size: 12px; margin-right: .5rem; overflow-wrap: anywhere; }
.detail-grid .detail-error { color: #7a1710; white-space: pre-wrap; }
.queue-review td.cell-ellipsis.secondary { max-width: 22rem; }
/* ajuste fino de anchos (1280 px cabe sin desplazamiento) */
.queue-table th, .queue-table td { padding: .35rem .4rem; }
.queue-table th { font-size: 10.5px; letter-spacing: .02em; }
.queue-table .badge { font-size: 11px; padding: 1px 6px; }
.queue-table .cell-ellipsis { max-width: 10.5rem; }
.queue-table td:nth-child(3) { max-width: 10.5rem; }
.queue-table td:nth-child(5) { min-width: 6rem; max-width: 9rem; }
.prov-cell .prov-name { max-width: 8.5rem; }
.queue-table .btn-sm { padding: .15rem .45rem; }
@media (min-width: 1500px) { .queue-table .cell-ellipsis { max-width: 18rem; } .queue-table td:nth-child(5) { max-width: 14rem; } .prov-cell .prov-name { max-width: 12rem; } }

/* tabla de la cola: columnas fijas para las cortas; Tipo, Cliente y Proveedor reparten el resto y cortan con puntos suspensivos */
#cola-mensajes { table-layout: fixed; width: 100%; min-width: 900px; }
#cola-mensajes th:nth-child(1) { width: 176px; } #cola-mensajes th:nth-child(2) { width: 68px; } #cola-mensajes th:nth-child(4) { width: 54px; }
#cola-mensajes th:nth-child(6) { width: 110px; } #cola-mensajes th:nth-child(7) { width: 62px; } #cola-mensajes th:nth-child(9) { width: 94px; }
#cola-mensajes td, #cola-mensajes th { overflow: hidden; text-overflow: ellipsis; }
#cola-mensajes td.sticky-end { overflow: visible; }
#cola-mensajes td:nth-child(3), #cola-mensajes td:nth-child(5) { max-width: none; min-width: 0; }
.prov-inner { display: flex; align-items: baseline; gap: .4rem; min-width: 0; }
.prov-inner .prov-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: none; }
.prov-inner .prov-mode, .prov-inner .id-short { flex: none; margin: 0; }
@media (max-width: 999px) { .prov-inner .prov-name { min-width: 7rem; } }
#cola-mensajes th:nth-child(1) { width: 160px; } #cola-mensajes th:nth-child(2) { width: 78px; } #cola-mensajes th:nth-child(3) { width: 124px; }
#cola-mensajes th:nth-child(5) { width: 118px; } #cola-mensajes th:nth-child(6) { width: 100px; } #cola-mensajes th:nth-child(7) { width: 54px; } #cola-mensajes th:nth-child(9) { width: 90px; }
@media (min-width: 1500px) { #cola-mensajes th:nth-child(3), #cola-mensajes th:nth-child(5) { width: auto; } }
#cola-mensajes th:nth-child(2) { width: 70px; } #cola-mensajes th:nth-child(3) { width: 150px; } #cola-mensajes th:nth-child(5) { width: 112px; }
#cola-mensajes th:nth-child(6) { width: 122px; } #cola-mensajes th:nth-child(7) { width: 66px; }
@media (min-width: 1500px) { #cola-mensajes th:nth-child(3), #cola-mensajes th:nth-child(5) { width: auto; } }
/* en pantallas estrechas la tabla se desplaza dentro de su contenedor y la columna de acciones no se queda fija encima del contenido */
@media (max-width: 999px) { .queue-table .sticky-end { position: static; box-shadow: none; } }
#cola-mensajes th:nth-child(1) { width: 184px; } #cola-mensajes th:nth-child(3) { width: 138px; } #cola-mensajes th:nth-child(4) { width: 58px; }
#cola-mensajes th:nth-child(5) { width: 106px; } #cola-mensajes th:nth-child(6) { width: 114px; } #cola-mensajes th:nth-child(7) { width: 76px; } #cola-mensajes th:nth-child(9) { width: 88px; }
@media (min-width: 1500px) { #cola-mensajes th:nth-child(3), #cola-mensajes th:nth-child(5) { width: auto; } }
.detail-grid { position: sticky; left: .5rem; max-width: calc(100vw - 4.5rem); }
@media (min-width: 1000px) { .detail-grid { position: static; max-width: none; } }

/* separación de 24 px (--sp-5) entre la cola de mensajes y la tarjeta de plantillas de WhatsApp, también cuando la tabla se desplaza */
.queue-block { margin-bottom: var(--sp-5); }
.queue-block .queue-wrap { margin-bottom: 0; }
.queue-block .queue-note { margin: var(--sp-2) 0 0; }
.queue-block + .card { margin-top: 0; }


/* ===== Patrones compartidos de formularios y filas de tabla (Mi perfil, Usuarios, Invitaciones) ===== */

/* Cuenta en el pie del menú: nombre y rol, «Mi perfil» como fila de navegación y «Salir» aparte. */
.sidebar-foot { padding-left: 0; padding-right: 0; }
.sidebar-foot .who, .sidebar-foot .role { padding: 0 var(--sp-3); }
.nav-account { margin-top: var(--sp-3); }
.nav-account .nav-sep { height: 1px; background: #243d49; margin: var(--sp-2) var(--sp-3); }
.nav-account form { margin: 0; padding: 0; border: 0; }
.nav .nav-btn { display: flex; align-items: center; gap: var(--sp-3); width: 100%; padding: .55rem var(--sp-3); border-radius: var(--r-sm);
  background: none; border: 0; font: inherit; font-size: var(--fs-md); color: var(--c-nav-text); text-align: left; cursor: pointer; }
.nav .nav-btn:hover { background: #1a303b; color: #fff; }
.nav a:focus-visible, .nav .nav-btn:focus-visible { outline: 2px solid #3cc2b9; outline-offset: -2px; }

/* Campo con su acción en la misma línea: etiqueta arriba, control y botón alineados, ayuda/errores en una fila aparte. */
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'label label' 'control action' 'help .';
  column-gap: var(--sp-3); row-gap: 6px; align-items: center; margin-bottom: 0; }
.field-row > label { grid-area: label; font-weight: 600; font-size: var(--fs-sm); }
.field-row > .input, .field-row > input, .field-row > select { grid-area: control; }
.field-row > .btn { grid-area: action; min-height: 42px; }
.field-row > .hint, .field-row > .field-error { grid-area: help; font-size: var(--fs-xs); }
.field-row > .hint { color: var(--c-text-3); }

/* Rejilla de campos alineados por sus controles: cada .field ocupa tres filas (etiqueta, control, ayuda) compartidas con sus vecinos,
   así una etiqueta larga o una ayuda no desplaza los controles ni los botones. */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); column-gap: var(--sp-4); row-gap: var(--sp-3); align-items: start; }
.form-grid > .field { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 6px; margin-bottom: 0; align-items: start; }
.form-grid > .field > label { align-self: end; }
.form-grid > .field > .hint, .form-grid > .field > .field-error { align-self: start; }
.form-grid > .field-action > .btn { grid-row: 2; min-height: 42px; }
/* Selectores + botón en una sola fila: columnas fijas para que un nombre largo no mueva el botón. */
.form-grid--action { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; }
.form-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 1100px) { .form-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.filters .btn { min-height: 42px; }
.measure { max-width: 75ch; }
.nowrap { white-space: nowrap; }
.cell-wrap { overflow-wrap: anywhere; }
.btn-ghost-danger { color: var(--c-danger); }
.btn-ghost-danger:hover { background: #fdecea; color: var(--c-danger); }
/* Acción del formulario: a la derecha, debajo de los campos, con el mismo margen en todas las tarjetas. */
.form-actions-end { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: var(--sp-3); margin-top: var(--sp-4); }
.form-actions-end .note { margin: 0 auto 0 0; color: var(--c-text-3); font-size: var(--fs-sm); }

/* Filas de tabla con controles: centrados en la fila, a una sola altura, y acciones juntas a la derecha. */
.table .input-compact { min-height: 36px; padding: .35rem .6rem; width: 100%; min-width: 9rem; }
.table .cell-control { width: 13rem; }
.table .cell-actions { width: 1%; white-space: nowrap; text-align: right; }
.row-actions { display: flex; flex-wrap: nowrap; justify-content: flex-end; align-items: center; gap: var(--sp-2); }
.row-actions form { margin: 0; }
.row-actions .btn { min-height: 36px; }
.cell-inline { display: flex; align-items: center; gap: var(--sp-2); }
.cell-inline .input-compact { flex: 1 1 auto; }

@media (max-width: 699px) {
  .field-row { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'label' 'control' 'help' 'action'; }
  .field-row > .btn { justify-self: stretch; min-height: 44px; }
  .form-grid, .form-grid--action { grid-template-columns: minmax(0, 1fr); }
  .form-grid > .field-action > .btn { width: 100%; min-height: 44px; }
  .form-actions-end { flex-direction: column; align-items: stretch; }
  .form-actions-end .btn { min-height: 44px; width: 100%; }
  .form-actions-end .note { margin: 0; }
  .table-stack td.cell-control, .table-stack td.cell-actions { width: auto; }
  .table-stack td.cell-actions { justify-content: flex-end; padding-top: var(--sp-2); }
  .table-stack td.cell-actions::before { content: none; }
  .row-actions { flex-wrap: wrap; }
  .row-actions .btn, .cell-inline .btn { min-height: 44px; }
  .table .input-compact { min-height: 44px; }
}
.table td.cell-name { white-space: nowrap; }
@media (max-width: 699px) { .table td.cell-name { white-space: normal; } }

/* Tablas con controles (.table-cells): se apilan según el ANCHO DISPONIBLE (container query), no el de la ventana,
   para que una tabla de muchas columnas no se corte ni parta correos letra a letra en pantallas medianas. */
.table-wrap:has(> .table-cells) { container-type: inline-size; }
.table td.cell-wrap { min-width: 12rem; overflow-wrap: break-word; }
.table td.cell-business { min-width: 11rem; }
@container (max-width: 900px) {
  .table-wrap .table-cells:not(.table-cells-narrow) thead { display: none; }
  .table-wrap .table-cells:not(.table-cells-narrow), .table-wrap .table-cells:not(.table-cells-narrow) tbody, .table-wrap .table-cells:not(.table-cells-narrow) tr { display: block; }
  .table-wrap .table-cells:not(.table-cells-narrow) tr { border-bottom: 1px solid var(--c-border); padding: var(--sp-2) 0; }
  .table-wrap .table-cells:not(.table-cells-narrow) tr:last-child { border-bottom: 0; }
  .table-wrap .table-cells:not(.table-cells-narrow) td { display: grid; grid-template-columns: 9rem minmax(0, 1fr); align-items: center; gap: var(--sp-3); border: 0; padding: .35rem .8rem;
    width: auto; min-width: 0; white-space: normal; overflow-wrap: anywhere; text-align: left; }
  .table-wrap .table-cells:not(.table-cells-narrow) td::before { content: attr(data-label); font-size: var(--fs-xs); color: var(--c-text-3); font-weight: 600; text-transform: uppercase; overflow-wrap: normal; }
  .table-wrap .table-cells:not(.table-cells-narrow) td > .cell { min-width: 0; }
  .table-wrap .table-cells:not(.table-cells-narrow) td.cell-control .input-compact { max-width: 18rem; }
  .table-wrap .table-cells:not(.table-cells-narrow) td.cell-actions { grid-template-columns: minmax(0, 1fr); padding-top: var(--sp-2); }
  .table-wrap .table-cells:not(.table-cells-narrow) td.cell-actions::before { content: none; }
  .table-wrap .table-cells:not(.table-cells-narrow) .row-actions { justify-content: flex-start; flex-wrap: wrap; }
}
@container (max-width: 560px) {
  .table-wrap .table-cells thead { display: none; }
  .table-wrap .table-cells, .table-wrap .table-cells tbody, .table-wrap .table-cells tr { display: block; }
  .table-wrap .table-cells tr { border-bottom: 1px solid var(--c-border); padding: var(--sp-2) 0; }
  .table-wrap .table-cells tr:last-child { border-bottom: 0; }
  .table-wrap .table-cells td { display: grid; grid-template-columns: 9rem minmax(0, 1fr); align-items: center; gap: var(--sp-3); border: 0; padding: .35rem .8rem;
    width: auto; min-width: 0; white-space: normal; overflow-wrap: anywhere; text-align: left; }
  .table-wrap .table-cells td::before { content: attr(data-label); font-size: var(--fs-xs); color: var(--c-text-3); font-weight: 600; text-transform: uppercase; overflow-wrap: normal; }
  .table-wrap .table-cells td > .cell { min-width: 0; }
  .table-wrap .table-cells td.cell-control .input-compact { max-width: 18rem; }
  .table-wrap .table-cells td.cell-actions { grid-template-columns: minmax(0, 1fr); padding-top: var(--sp-2); }
  .table-wrap .table-cells td.cell-actions::before { content: none; }
  .table-wrap .table-cells .row-actions { justify-content: flex-start; flex-wrap: wrap; }
}
.table-cells .cell .badge { max-width: 100%; white-space: normal; text-align: left; }
@container (max-width: 560px) {
  .table-wrap .table-cells .cell-inline { flex-wrap: wrap; }
  .table-wrap .table-cells .input-compact { min-width: 0; }
  .table-wrap .table-cells .cell-inline .input-compact { flex: 1 1 100%; max-width: none; }
}
/* Tarjetas apiladas estrechas: etiqueta encima del valor, todo alineado arriba; los correos se parten en @ y puntos (<wbr>). */
@container (max-width: 560px) {
  .table-wrap.table-wrap .table-cells.table-cells td { grid-template-columns: minmax(0, 1fr); row-gap: 2px; align-items: start; overflow-wrap: break-word; }
  .table-wrap .table-cells .nowrap { white-space: normal; }
}
.form-grid + fieldset, .form-grid + .check { margin-top: var(--sp-4); }
@media (min-width: 1100px) { .form-grid--lead { grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); } }
@container (max-width: 560px) {
  .table-wrap.table-wrap .table-cells.table-cells td.cell-control .input-compact { max-width: none; }
}

/* ---------- Varios servicios por cita ---------- */
.choice.multi .box { justify-content: flex-start; }
.choice.multi .grow { flex: 1; min-width: 0; }
.choice.multi .grow b { overflow-wrap: anywhere; }
.choice.multi .mark { flex: none; width: 20px; height: 20px; border: 2px solid var(--c-border-strong); border-radius: 5px; background: var(--c-surface); display: grid; place-items: center; }
.choice.multi input:checked + .box .mark { background: var(--c-primary); border-color: var(--c-primary); }
.choice.multi input:checked + .box .mark::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.svc-summary { margin-top: var(--sp-4); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); background: var(--c-surface); }
.svc-summary-title { font-size: var(--fs-sm); margin: 0 0 var(--sp-2); color: var(--c-text-2); }
.svc-lines { list-style: none; margin: 0; padding: 0; }
.svc-lines li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: var(--sp-3); align-items: center; padding: 6px 0; border-bottom: 1px solid var(--c-border); }
.svc-lines.compact li { grid-template-columns: minmax(0, 1fr) auto auto; padding: 2px 0; }
.svc-lines .name { overflow-wrap: anywhere; }
.svc-lines .mins, .svc-total .mins { color: var(--c-text-3); font-size: var(--fs-sm); white-space: nowrap; }
.svc-lines .price, .svc-total .price { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.svc-total { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: var(--sp-3); align-items: baseline; padding-top: var(--sp-2); font-weight: 700; }
.svc-summary .svc-total { grid-template-columns: minmax(0, 1fr) auto auto 0; }
.final-summary h3 { font-size: var(--fs-md); margin: 0 0 var(--sp-3); }
.final-summary { border-left: 4px solid var(--c-primary); background: var(--c-primary-soft); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); margin-top: var(--sp-3); }
.picker-grid { display: grid; gap: var(--sp-4); }
.picker-grid .svc-summary { margin-top: 0; }
.label-like { display: block; font-weight: 600; font-size: var(--fs-sm); margin-bottom: 6px; }
.label-like .hint { font-weight: 400; color: var(--c-text-3); font-size: var(--fs-xs); }
@media (min-width: 900px) { .picker-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; } .picker-grid .svc-summary { margin-top: 22px; } }
@media (max-width: 420px) {
  .svc-lines li { grid-template-columns: minmax(0, 1fr) auto; row-gap: 0; }
  .svc-lines li .mins { grid-column: 1; grid-row: 2; }
  .svc-lines li .price { grid-column: 2; grid-row: 1; }
  .svc-lines li .btn { grid-column: 2; grid-row: 2; justify-self: end; }
}
.mt-2 { margin-top: var(--sp-2); } .mb-2 { margin-bottom: var(--sp-2); }

/* ---------- Cantidad por servicio ---------- */
.svc-lines.qty li { grid-template-columns: minmax(0, 1fr) auto minmax(96px, auto) auto; row-gap: 4px; }
.svc-lines.qty .name small.unit { display: block; color: var(--c-text-3); font-size: var(--fs-xs); }
.svc-lines.qty .sub { display: flex; flex-direction: column; align-items: flex-end; }
.svc-lines.qty .field-error { grid-column: 1 / -1; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper .btn { min-width: 36px; min-height: 36px; padding: 0; font-size: 1.1rem; line-height: 1; }
.qty-input { width: 4.25rem; text-align: center; padding-left: 4px; padding-right: 4px; -moz-appearance: textfield; }
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.has-error .qty-input { border-color: var(--c-danger); box-shadow: 0 0 0 1px var(--c-danger) inset; }
.field-error { color: var(--c-danger); font-size: var(--fs-sm); font-weight: 600; }
@media (max-width: 520px) {
  .svc-lines.qty li { grid-template-columns: auto minmax(0, 1fr) auto; }
  .svc-lines.qty li .name { grid-column: 1 / -1; grid-row: auto; }
  .svc-lines.qty li .qty-field { grid-column: 1; grid-row: auto; }
  .svc-lines.qty li .sub { grid-column: 2; grid-row: auto; }
  .svc-lines.qty li .remove { grid-column: 3; grid-row: auto; justify-self: end; }
}
.qty-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); margin: -2px 0 var(--sp-2) 46px; font-size: var(--fs-sm); }
.qty-row > label { font-weight: 600; }
.qty-row .sub { color: var(--c-text-2); }
.qty-row .field-error { flex-basis: 100%; }
@media (max-width: 520px) { .qty-row { margin-left: 12px; } }
@media (max-width: 520px) {
  .svc-lines.qty li { grid-template-columns: auto minmax(0, 1fr) auto; column-gap: var(--sp-2); }
  .svc-lines.qty .stepper .btn { min-width: 34px; min-height: 34px; }
  .svc-lines.qty .qty-input { width: 3.25rem; }
  .svc-lines.qty .sub { font-size: var(--fs-sm); white-space: nowrap; }
}

/* ---------- Precio por servicio (panel) ---------- */
.svc-lines.qty.panel li { grid-template-columns: minmax(140px, 1fr) auto; align-items: end; padding: var(--sp-3) 0; }
.svc-lines.qty.panel .name { align-self: center; }
.line-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-2) var(--sp-4); justify-content: flex-end; }
.line-fields .lf { display: flex; flex-direction: column; gap: 4px; }
.line-fields .lf > label, .line-fields .lf-label { font-size: var(--fs-xs); font-weight: 600; color: var(--c-text-2); }
.line-fields .lf-value { min-height: 36px; display: flex; align-items: center; font-variant-numeric: tabular-nums; }
.line-fields .lf.sub { min-width: 104px; align-items: flex-end; text-align: right; }
.line-fields .lf.sub .lf-value { min-height: 0; }
.line-fields .lf.sub .mins { color: var(--c-text-3); font-size: var(--fs-xs); }
.line-fields .remove { align-self: center; }
.money-input { display: inline-flex; align-items: center; border: 1px solid var(--c-border-strong); border-radius: var(--r-sm); background: var(--c-surface); }
.money-input .affix { padding: 0 6px 0 10px; color: var(--c-text-3); font-size: var(--fs-sm); }
.money-input .affix:last-child { padding: 0 10px 0 6px; }
.money-input .price-input { border: 0; width: 6.5rem; min-height: 36px; padding-left: 2px; text-align: right; font-variant-numeric: tabular-nums; box-shadow: none; }
.money-input:focus-within { outline: 3px solid var(--c-focus); outline-offset: 1px; }
.lf.has-error .money-input, .lf.has-error .qty-input { border-color: var(--c-danger); box-shadow: 0 0 0 1px var(--c-danger) inset; }
@media (max-width: 899px) {
  .svc-lines.qty.panel li { grid-template-columns: 1fr; }
  .line-fields { justify-content: flex-start; }
  .line-fields .lf.sub { align-items: flex-start; text-align: left; margin-left: auto; }
}
@media (max-width: 520px) {
  .svc-lines.qty.panel li .name, .svc-lines.qty.panel li .line-fields { grid-column: 1; }
  .line-fields { gap: var(--sp-2) var(--sp-3); }
  .line-fields .lf.sub { margin-left: 0; }
}
.qty-row.line-fields { justify-content: flex-start; margin: 2px 0 var(--sp-3) 46px; }
.qty-row.line-fields .lf.sub { margin-left: auto; }
@media (max-width: 520px) { .qty-row.line-fields { margin-left: 8px; } .qty-row.line-fields .lf.sub { margin-left: 0; } }
/* Nueva cita: el resumen editable (cantidad, precio, subtotal) va a todo el ancho bajo los servicios para alinear los controles en una fila. */
@media (min-width: 900px) { .picker-grid { grid-template-columns: 1fr; } .picker-grid .svc-summary { margin-top: 0; } }
.svc-lines.qty.panel .line-fields { flex-wrap: nowrap; }
@media (max-width: 899px) { .svc-lines.qty.panel .line-fields { flex-wrap: wrap; } }
.btn-danger-ghost { color: var(--c-danger); }
.btn-danger-ghost:hover { background: var(--c-danger-soft); color: var(--c-danger); }
.table .cell-actions { text-align: right; white-space: nowrap; }
/* Depósito requerido editable */
.deposit-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px dashed var(--c-border); }
.deposit-row > label { font-weight: 600; font-size: var(--fs-sm); }
.deposit-row .hint { color: var(--c-text-3); font-size: var(--fs-xs); flex: 1 1 200px; }
.deposit-row .field-error { flex-basis: 100%; }
.deposit-row.has-error .money-input { border-color: var(--c-danger); box-shadow: 0 0 0 1px var(--c-danger) inset; }

/* ---------- Botón de icono (papelera) y diálogo de confirmación ---------- */
.btn-icon { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: var(--r-md); background: transparent; color: var(--c-text-2); cursor: pointer; transition: background-color .12s ease, color .12s ease; }
.btn-icon svg { width: 20px; height: 20px; }
.btn-icon:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; }
.btn-icon-danger { color: var(--c-danger); }
.btn-icon-danger:hover, .btn-icon-danger:focus-visible { background: var(--c-danger-soft); color: var(--c-danger); }
@media (pointer: coarse), (max-width: 760px) { .btn-icon { width: 44px; height: 44px; } }
/* Tooltip al pasar el cursor o con el foco del teclado (el nombre accesible lo lleva aria-label). */
[data-tooltip]::after { content: attr(data-tooltip); position: absolute; right: 50%; bottom: calc(100% + 6px); transform: translateX(50%); padding: 4px 8px; border-radius: var(--r-sm); background: #0b2f31; color: #fff; font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s ease .15s; z-index: 5; }
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after { opacity: 1; }
/* Última columna del listado: acciones centradas y de ancho fijo para que todas las filas queden alineadas. */
.table th.col-actions, .table td.cell-actions { width: 64px; text-align: center; vertical-align: middle; }
.table td.cell-actions .inline-form { display: inline-flex; margin: 0; }
@media (max-width: 699px) {
  .table-stack td.cell-actions { width: auto; justify-content: flex-end; }
  .table-stack td.cell-actions.is-empty { display: none; }
}
.confirm-dialog { border: 0; border-radius: var(--r-lg); padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(11, 47, 49, .25); color: var(--c-text); }
.confirm-dialog::backdrop { background: rgba(11, 47, 49, .45); }
.confirm-dialog form { padding: var(--sp-5); margin: 0; }
.confirm-dialog h2 { margin: 0 0 var(--sp-2); font-size: var(--fs-lg, 1.15rem); }
.confirm-dialog p { margin: 0 0 var(--sp-5); color: var(--c-text-2); }
.confirm-actions { display: flex; justify-content: flex-end; gap: var(--sp-3); flex-wrap: wrap; }
@media (max-width: 420px) { .confirm-actions { flex-direction: column-reverse; } .confirm-actions .btn { width: 100%; min-height: 44px; } }
/* En la última columna el tooltip se abre a la izquierda del botón para no salirse de la tabla. */
.cell-actions [data-tooltip]::after { right: calc(100% + 6px); bottom: auto; top: 50%; transform: translateY(-50%); }
/* «Editar servicios» en el desglose: lleva al editor de la cita y lo resalta. */
#servicios-cita { scroll-margin-top: 80px; }
.edit-services-link { display: inline-flex; }
section:has(> #servicios-cita:target) { box-shadow: 0 0 0 2px var(--c-primary); }
/* «Mantener la hora actual» en el editor de servicios (cuando la hora no figura entre los horarios libres). */
.slots.slots-current { grid-template-columns: minmax(0, 1fr); margin-bottom: var(--sp-3); }
.slot.slot-wide span { justify-content: flex-start; padding-left: var(--sp-3); padding-right: var(--sp-3); }
/* «Ajustar cobro» */
#ajustar-cobro { scroll-margin-top: 80px; }
section:has(> #ajustar-cobro:target) { box-shadow: 0 0 0 2px var(--c-primary); }
.breakdown-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.charge-note { display: block; color: var(--c-warning, #8a5300); font-size: var(--fs-xs); font-weight: 600; }
.charge-lines .qty-input { width: 4.5rem; }
.charge-history { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.charge-history li { border-left: 3px solid var(--c-border-strong); padding-left: var(--sp-3); font-size: var(--fs-sm); }

/* Encabezado del acceso (login y demás páginas sin sesión): logo a la izquierda, idioma a la derecha, mismo ancho que la tarjeta. */
.auth-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 14px; }
.auth-head .lang-switch { color: #e6eef0; gap: .25rem; }
.auth-head .lang-switch > span { color: rgba(230,238,240,.55); }
.auth-head .lang-switch button { color: #e6eef0; border-color: rgba(255,255,255,.22); padding: .25rem .65rem; min-height: 36px; font-weight: 500; }
.auth-head .lang-switch button:hover { background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.45); color: #fff; }
.auth-head .lang-switch button.on { background: rgba(255,255,255,.18); border-color: #fff; color: #fff; font-weight: 700; }
.auth-head .lang-switch button:focus-visible { outline: 2px solid #9ee6df; outline-offset: 2px; }
@media (max-width: 360px) { .auth-head { flex-direction: column; align-items: flex-start; } }
