/* DentalSystem v0.11 — Apple/Stripe admin
 * Single-file CSS con cascade layers.
 * Tokens → Layout → Components → Utilities → Responsive.
 */

@layer reset, tokens, fonts, base, layout, components, utilities;

/* === Reset === */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
  body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
  ul, ol { list-style: none; padding: 0; }
  body { min-height: 100vh; line-height: 1.5; }
  a:not([class]) { text-decoration-skip-ink: auto; }
  img, picture, svg { max-width: 100%; display: block; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { cursor: pointer; background: none; border: 0; padding: 0; }
  table { border-collapse: collapse; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
}

/* === Print === */
@layer print {
  @media print {
    /* Ocultar chrome del app */
    .ds-sidebar, .ds-tb, .ds-flash, .no-print, form[action*="logout"] { display: none !important; }
    /* Layout a columna simple para papel */
    .ds-shell { display: block !important; }
    .ds-main { display: block !important; }
    .ds-page { padding: 0 !important; max-width: none !important; }
    .ds-panel { box-shadow: none !important; border: 1px solid #ccc !important; page-break-inside: avoid; margin-bottom: 8mm; }
    .ds-panel__head { background: transparent !important; }
    /* Tipografia optima para papel */
    body { font-size: 11pt; line-height: 1.4; color: #000 !important; background: #fff !important; }
    h1 { font-size: 16pt; }
    h2 { font-size: 13pt; }
    h3 { font-size: 11pt; }
    /* Tablas legibles en B/N */
    .ds-table { font-size: 10pt; }
    .ds-table th { background: #f0f0f0 !important; color: #000 !important; }
    /* Links sin color de fondo */
    a { color: #000 !important; text-decoration: underline; }
    /* Saltos de pagina */
    .page-break-before { page-break-before: always; }
    .page-break-after { page-break-after: always; }
    /* Evitar imagenes muy grandes */
    img { max-height: 80mm; }
    /* Fuentes del sistema para portabilidad */
    .ds-mono { font-family: 'Courier New', 'Courier', monospace !important; }
  }
  @page {
    size: A4;
    margin: 18mm 14mm;
  }
}

/* === Tokens === */
@layer tokens {
  :root {
    --bg: #F5F5F7;
    --surface: #FFFFFF;
    --ink: #1D1D1F;
    --ink-2: #3D3D40;
    --ink-soft: #6E6E73;
    --ink-faint: #AEAEB2;
    --line: #E5E5E7;
    --line-2: #D2D2D7;
    --accent: #3A8A3F;
    --accent-hover: #2E7532;
    --accent-soft: #E8F5E9;
    --success: #00875A;
    --success-soft: #E3FCEF;
    --info: #0B5FFF;
    --info-hover: #0947CC;
    --info-soft: #E8F1FF;
    --warning: #B95000;
    --warning-soft: #FFF7E5;
    --danger: #CC1F1F;
    --danger-soft: #FFEBEB;
    --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
    --shadow-lg: 0 4px 20px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-w: 240px;
    --topbar-h: 52px;
    --font-sans: 'Inter', -apple-system, system-ui, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
    --fs-xs: 11.5px;
    --fs-sm: 12.5px;
    --fs-base: 14px;
    --fs-md: 15px;
    --fs-lg: 18px;
    --fs-xl: 26px;
    /* === Breakpoints (mobile-first) === */
    --bp-mobile-s: 480px;   /* phones (xs) */
    --bp-mobile: 760px;     /* phones large / tablet portrait */
    --bp-tablet: 900px;     /* tablet landscape */
    --bp-desktop: 1100px;   /* desktop */
    --bp-wide: 1400px;      /* wide desktop */
  }
}

/* === Base === */
@layer base {
  html { font-family: var(--font-sans); }
  body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
  }
  h1 { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
  h2 { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.01em; }
  h3 { font-size: var(--fs-md); font-weight: 600; }
  a { color: inherit; text-decoration: none; }
  a:hover { text-decoration: underline; text-underline-offset: 2px; }
  code, kbd, samp, pre, .mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
}

/* === Layout === */
@layer layout {
  .ds-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
  .ds-main { display: flex; flex-direction: column; min-width: 0; }
  .ds-page { padding: 24px 28px 80px; max-width: 1400px; margin: 0 auto; width: 100%; }

  /* Sidebar */
  .ds-sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; overflow-y: auto; }
  /* Bloque marca: altura fija (no apretado), logo y texto más grandes, aire abajo */
  .ds-sb__brand {
    margin: 0;
    padding: 20px 18px 22px;
    min-height: 88px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    color: inherit;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
  }
  .ds-sb__brand:hover { text-decoration: none; background: transparent; }
  .ds-sb__logo { width: 48px; height: 48px; border-radius: 10px; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; flex-shrink: 0; }
  .ds-sb__logo-wrap {
    width: 52px;
    height: 52px;
    min-width: 52px;
    flex: 0 0 52px;
    border: 0;
    border-radius: 0;
    background: transparent;
    display: grid;
    place-items: center;
    overflow: visible;
    padding: 0;
  }
  .ds-sidebar .ds-sb__brand .ds-sb__logo-img {
    width: 52px;
    height: 52px;
    max-width: 52px;
    max-height: 52px;
    object-fit: contain;
    object-position: center;
    display: block;
    border: 0;
    background: transparent;
  }
  .ds-sb__ws {
    font-weight: 650;
    font-size: 15px;
    letter-spacing: -0.015em;
    line-height: 1.25;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }
  .ds-sb__ws small {
    display: block;
    font-size: 12px;
    color: var(--ink-soft);
    font-weight: 400;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* No pegar el menú al logo: más aire antes de PRINCIPAL */
  .ds-sidebar > .ds-sb__group:first-of-type {
    padding-top: 18px;
    margin-top: 4px;
  }
  .ds-sb__search { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; color: var(--ink-soft); }
  .ds-sb__search input { flex: 1; padding: 6px 10px; font-size: 13px; background: var(--bg); border-radius: var(--radius-sm); border: 1px solid transparent; color: var(--ink); }
  .ds-sb__search input:focus { border-color: var(--accent); background: var(--surface); outline: none; }
  .ds-sb__group { padding: 16px 18px 6px; font-size: 11px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }
  .ds-sb__nav { padding: 0 8px; }
  .ds-sb__link { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 13.5px; color: var(--ink-2); border-radius: var(--radius-sm); font-weight: 500; margin-bottom: 2px; min-height: 36px; cursor: pointer; -webkit-tap-highlight-color: rgba(0,0,0,0.05); }
  .ds-sb__link:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
  .ds-sb__link:active { background: var(--line); }
  .ds-sb__link--on { background: var(--ink); color: #fff; font-weight: 600; }
  .ds-sb__link--on svg { color: #fff; }
  .ds-sb__link svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; flex-shrink: 0; }
  /* Accesos directos: más compactos, acento sutil */
  .ds-sb__nav--quick { padding-bottom: 4px; }
  .ds-sb__link--quick {
    padding: 8px 12px;
    min-height: 32px;
    font-size: 13px;
    color: var(--accent, #0E5B5B);
  }
  .ds-sb__link--quick:hover {
    background: rgba(14, 91, 91, 0.07);
    color: var(--accent, #0E5B5B);
  }
  .ds-sb__link--quick.ds-sb__link--on {
    background: var(--accent, #0E5B5B);
    color: #fff;
  }
  .ds-sb__link--quick.ds-sb__link--on svg { color: #fff; }
  .ds-sb__ct { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--ink-soft); background: var(--bg); padding: 1px 7px; border-radius: 10px; min-width: 22px; text-align: center; }
  .ds-sb__link--on .ds-sb__ct { background: rgba(255,255,255,.18); color: #fff; }
  .ds-sb__foot { margin-top: auto; padding: 14px; border-top: 1px solid var(--line); }
  .ds-sb__user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); }
  .ds-sb__logout { display: flex; align-items: center; gap: 8px; padding: 10px 14px; margin-top: 4px; border-radius: var(--radius-sm); color: var(--ink-soft); font-size: 13px; font-weight: 500; transition: all .12s; min-height: 40px; cursor: pointer; -webkit-tap-highlight-color: rgba(0,0,0,0.05); }
  .ds-sb__logout:hover { background: var(--bg); color: var(--danger); text-decoration: none; }
  .ds-sb__logout:active { background: rgba(204,31,31,0.08); }
  .ds-sb__logout svg { stroke: currentColor; }
  .ds-sb__avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg,#5856D6,#AF52DE); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 600; flex-shrink: 0; }
  .ds-sb__uinfo { flex: 1; min-width: 0; }
  .ds-sb__uinfo b { display: block; font-size: 13px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ds-sb__uinfo small { display: block; font-size: 11px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Topbar minimal — solo breadcrumb */
  .ds-tb { height: var(--topbar-h); padding: 0 28px; background: rgba(255,255,255,.85); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 5; }
  .ds-tb__crumbs { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink-soft); flex: 1; min-width: 0; }
  .ds-tb__crumbs a { color: var(--ink-soft); }
  .ds-tb__crumbs a:hover { color: var(--ink); }
  .ds-tb__sep { color: var(--ink-faint); }
  .ds-tb__cur { color: var(--ink); font-weight: 600; }
}

/* === Components === */
@layer components {
  /* Page header */
  .ds-ph { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
  .ds-ph__l { flex: 1; min-width: 0; }
  .ds-ph__crumb { font-size: 12px; color: var(--ink-soft); margin-bottom: 5px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; }
  .ds-ph__title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); line-height: 1.15; overflow-wrap: anywhere; max-width: 100%; }
  .ds-ph__title--dia {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 10px;
    font-size: clamp(22px, 5.4vw, 36px);
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: normal;
    max-width: 100%;
  }
  .ds-ph__dia-line, .ds-ph__mes-line { white-space: nowrap; }
  .ds-ph__year { color: var(--ink-soft); font-weight: 500; font-size: 0.52em; margin-left: 0.15em; }
  .ds-ph__desc { font-size: 14px; color: var(--ink-soft); margin-top: 4px; max-width: 600px; }
  .ds-ph__r { display: flex; gap: 6px; align-items: center; }

  .ds-day-nav {
    display: inline-flex;
    align-items: stretch;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
  }
  .ds-day-nav__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 40px;
    padding: 0 12px;
    color: var(--ink);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    border-right: 1px solid var(--line);
  }
  .ds-day-nav__btn:last-child { border-right: 0; }
  .ds-day-nav__btn:hover { background: #fff; text-decoration: none; }
  .ds-day-nav__btn:active { background: var(--line); }
  .ds-day-nav__hoy { min-width: 56px; }

  /* Stat card */
  .ds-stat { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); position: relative; }
  .ds-stat__trend { position: absolute; top: 14px; right: 14px; font-size: 10px; font-family: var(--font-mono); font-weight: 600; padding: 2px 7px; border-radius: 4px; }
  .ds-stat__trend--up { color: var(--success); background: var(--success-soft); }
  .ds-stat__trend--down { color: var(--danger); background: var(--danger-soft); }
  .ds-stat__lbl { font-size: 11.5px; color: var(--ink-soft); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); }
  .ds-stat__icon svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; }
  .ds-stat__val { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; margin-top: 8px; color: var(--ink); line-height: 1; font-feature-settings: "tnum"; }
  .ds-stat__sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; display: flex; align-items: center; gap: 5px; }
  .ds-stat__sub b { color: var(--ink); font-weight: 600; }
  .ds-stat__sub .up { color: var(--success); font-weight: 600; font-family: var(--font-mono); }
  .ds-stat__sub .down { color: var(--danger); font-weight: 600; font-family: var(--font-mono); }

  /* Configuración: el form también es columna, si no los desplegables de adentro quedan pegados */
  .ds-cfg-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 920px;
    margin: 0 auto;
  }
  .ds-cfg-stack > form {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .ds-cfg-details > summary { list-style: none; cursor: pointer; user-select: none; }
  .ds-cfg-details > summary::-webkit-details-marker { display: none; }
  .ds-cfg-details:not([open]) > summary { border-bottom: none; }
  .ds-cfg-chevron { flex-shrink: 0; color: var(--ink-soft); transition: transform .16s ease; }
  .ds-cfg-details[open] > summary .ds-cfg-chevron { transform: rotate(180deg); }
  .ds-cfg-soporte { padding: 18px 22px 22px; }
  .ds-cfg-soporte__lead {
    margin: 0 0 16px;
    font-size: 13.5px;
    color: var(--ink-soft);
    line-height: 1.5;
  }
  .ds-cfg-soporte__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .ds-cfg-soporte__list li {
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 10px;
    align-items: baseline;
    padding: 10px 12px;
    background: #fafbfc;
    border: 1px solid var(--line);
    border-radius: 10px;
  }
  .ds-cfg-soporte__lbl {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ink-soft);
    font-family: var(--font-mono);
  }
  .ds-cfg-soporte__list a {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    word-break: break-word;
  }
  .ds-cfg-soporte__list a:hover { color: var(--accent); }

  /* Panel */
  .ds-panel { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
  .ds-panel__head { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .ds-panel__title { font-size: 15px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; letter-spacing: -0.01em; }
  .ds-panel__title svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; color: var(--ink-soft); }
  .ds-panel__sub { font-size: 12.5px; color: var(--ink-soft); }
  .ds-panel__tools { display: flex; gap: 6px; align-items: center; }
  .ds-panel__body { padding: 0; }
  .ds-panel__foot { padding: 12px 20px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-soft); background: #FCFCFD; display: flex; justify-content: space-between; align-items: center; font-family: var(--font-mono); }

  /* Tags */
  .ds-tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; font-size: 11.5px; font-weight: 600; border-radius: 20px; letter-spacing: -0.01em; line-height: 1.2; }
  .ds-tag--success { background: var(--success-soft); color: var(--success); }
  .ds-tag--warning { background: var(--warning-soft); color: var(--warning); }
  .ds-tag--danger { background: var(--danger-soft); color: var(--danger); }
  .ds-tag--info { background: var(--accent-soft); color: var(--accent); }
  .ds-tag--neutral { background: var(--bg); color: var(--ink-2); }

  /* Avatar */
  .ds-av { display: inline-grid; place-items: center; font-weight: 600; color: #fff; font-family: var(--font-mono); flex-shrink: 0; }
  .ds-av--sm { width: 22px; height: 22px; font-size: 10px; border-radius: 50%; }
  .ds-av--md { width: 26px; height: 26px; font-size: 11px; border-radius: 50%; }
  .ds-av--lg { width: 36px; height: 36px; font-size: 13px; border-radius: 50%; }
  .ds-av--1 { background: #0B5FFF; }
  .ds-av--2 { background: #00875A; }
  .ds-av--3 { background: #B95000; }
  .ds-av--4 { background: #CC1F1F; }

  /* ── Botones semánticos ─────────────────────────────────────────────
     primary  = Nuevo registro (entidad)   → negro
     add      = añadir en contexto         → verde outline
     submit   = finalizar formulario       → azul
     edit     = editar entidad / sección   → blanco + borde gris
     view     = ver detalle / abrir        → blanco + borde negro
     back     = volver                     → negro
     danger   = eliminar / cancelar acción → rojo outline
     danger-solid = eliminar fuerte        → rojo relleno
     ghost / default = Cancelar suave
  */
  .ds-btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 9px 15px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 7px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    line-height: 1.2;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
    white-space: nowrap;
  }
  .ds-btn:hover { background: var(--bg); }
  .ds-btn:disabled, .ds-btn[disabled] {
    opacity: 0.55; cursor: not-allowed; pointer-events: none;
  }

  /* Acciones principales: todo negro sólido, texto/icono blanco */
  .ds-btn--primary,
  .ds-btn--add,
  .ds-btn--submit,
  .ds-btn--edit,
  .ds-btn--view,
  .ds-btn--back,
  .ds-btn--accent {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
  }
  .ds-btn--primary:hover,
  .ds-btn--add:hover,
  .ds-btn--submit:hover,
  .ds-btn--edit:hover,
  .ds-btn--view:hover,
  .ds-btn--back:hover,
  .ds-btn--accent:hover {
    background: #000;
    border-color: #000;
    color: #fff;
  }
  .ds-btn--primary svg,
  .ds-btn--add svg,
  .ds-btn--submit svg,
  .ds-btn--edit svg,
  .ds-btn--view svg,
  .ds-btn--back svg,
  .ds-btn--accent svg {
    stroke: #fff;
    color: #fff;
  }

  /* Eliminar / cancelar acción destructiva */
  .ds-btn--danger {
    background: #fff; color: var(--danger); border-color: var(--danger); font-weight: 700;
  }
  .ds-btn--danger:hover { background: var(--danger-soft); color: var(--danger); }
  .ds-btn--danger-solid {
    background: var(--danger); color: #fff; border-color: var(--danger); font-weight: 700;
  }
  .ds-btn--danger-solid:hover {
    background: #b51b1b; border-color: #b51b1b; color: #fff;
  }

  .ds-btn--sm { min-height: 36px; padding: 7px 12px; font-size: 13px; border-radius: 6px; }
  .ds-btn--lg { min-height: 48px; padding: 12px 22px; font-size: 15px; border-radius: 8px; }
  .ds-btn--ghost { border-color: transparent; background: transparent; color: var(--ink); }
  .ds-btn--ghost:hover { background: var(--bg); color: var(--ink); }
  /* Volver con ghost: forzar negro sólido (sobreescribe ghost si van juntos: poner --back al final) */
  .ds-btn--ghost.ds-btn--back,
  .ds-btn--back.ds-btn--ghost {
    background: var(--ink); color: #fff; border-color: var(--ink);
  }
  .ds-btn--ghost.ds-btn--back:hover,
  .ds-btn--back.ds-btn--ghost:hover {
    background: var(--ink-2); border-color: var(--ink-2); color: #fff;
  }
  .ds-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }
  .ds-btn--sm svg { width: 13px; height: 13px; }
  .ds-btn--lg svg { width: 16px; height: 16px; }

  /* Table */
  .ds-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
  .ds-table th { text-align: left; padding: 10px 16px; font-size: 11.5px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--line); background: #FCFCFD; }
  .ds-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--ink); vertical-align: middle; }
  .ds-table tr:last-child td { border-bottom: none; }
  .ds-table tr:hover td { background: #FCFCFD; }
  .ds-table td.num { font-variant-numeric: tabular-nums; text-align: right; font-family: var(--font-mono); }
  .ds-table td.muted { color: var(--ink-soft); }

  /* Empty state */
  .ds-empty { padding: 48px 20px; text-align: center; color: var(--ink-soft); }
  .ds-empty svg { width: 40px; height: 40px; stroke: currentColor; fill: none; stroke-width: 1.5; margin: 0 auto 14px; opacity: .5; }
  .ds-empty h3 { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
  .ds-empty p { font-size: 13px; margin-bottom: 16px; }
}

/* Odontograma */
  .ds-odontograma {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 22px 18px 18px;
    background: linear-gradient(180deg, #FAFCFC 0%, #FFFFFF 60%);
    border: 1px solid rgba(14,91,91,0.08);
    border-radius: 10px;
    position: relative;
  }
  .ds-odontograma__arco-label { font-size:11px; font-weight:600; color:var(--ink-soft); text-transform:uppercase; letter-spacing:0.05em; margin-bottom:8px; text-align:center; }
  .ds-odontograma__arco { display:grid; grid-template-columns:repeat(16, 1fr); gap:4px; }
  /* Conector visual entre arcadas: 16 puntos alineados con cada columna de pieza,
     sugiriendo visualmente la mordida (cada pieza superior ↔ su opuesta inferior). */
  .ds-odontograma__arco:first-of-type::after {
    content: '';
    display: block;
    height: 14px;
    margin: 4px 2px 0;
    background-image: radial-gradient(circle, currentColor 1px, transparent 1.6px);
    background-size: calc((100% - 0px) / 16) 8px;
    background-position: left center;
    background-repeat: repeat-x;
    color: var(--line-2);
    opacity: 0.65;
  }
  .ds-pieza {
    position:relative;
    aspect-ratio: 1 / 1.15;
    border:1.5px solid var(--border, var(--line-2));
    background:var(--bg, var(--surface));
    border-radius:6px;
    display:flex; flex-direction:column; align-items:center; justify-content:flex-start;
    padding:3px 1px;
    cursor:pointer;
    transition: transform .18s cubic-bezier(.34,1.56,.64,1), box-shadow .18s ease, background .25s ease, border-color .25s ease;
    font-family: var(--font-mono);
    overflow:hidden;
  }
  .ds-pieza--editable:hover { transform:translateY(-2px) scale(1.05); box-shadow:0 4px 10px rgba(0,0,0,.12); z-index:2; }
  .ds-pieza--editable:active { transform:translateY(0) scale(.97); transition-duration:.08s; }
  .ds-pieza--editable:focus-visible { outline:2px solid var(--accent); outline-offset:2px; z-index:2; }
  .ds-pieza--selected { outline: 2px solid #0E5B5B; outline-offset: 2px; transform: translateY(-2px) scale(1.05); }
  /* Indicadores de descripcion/evolucion: ya no son pseudo-elementos
     circulares (que se veian 'recortados' sobre el border grueso).
     Ahora son stripes diagonales sutiles via background-image. */
  .ds-pieza--has-desc {
    background-image: repeating-linear-gradient(
      45deg, transparent, transparent 6px, rgba(0,0,0,.04) 6px, rgba(0,0,0,.04) 12px
    );
  }
  .ds-pieza--has-evo {
    box-shadow: inset 0 0 0 1.5px rgba(249,168,37,.7);
  }
  .ds-pieza svg,
  .ds-pieza__tooth {
    transition: transform .25s ease;
    margin-top: 2px;
    flex-shrink: 0;
  }
  .ds-pieza--editable:hover svg { transform:scale(1.1); }
  /* Silueta dental más definida a escala chica */
  .ds-pieza__tooth path {
    paint-order: stroke fill;
  }
  .ds-pieza__num { font-size:8.5px; font-weight:700; color:var(--border, var(--ink-2)); margin-top:1px; line-height:1; }
  .ds-pieza__estado { font-size:7px; font-weight:600; color:var(--border, var(--ink-soft)); text-transform:uppercase; letter-spacing:0.02em; line-height:1; margin-top:1px; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  /* Estados especificos con animacion de entrada */
  @keyframes ds-pieza-pulse { 0% { box-shadow:0 0 0 0 var(--border, var(--accent)); } 100% { box-shadow:0 0 0 8px transparent; } }
  /* Estados problemáticos (requieren atención): pulse animation */
  .ds-pieza--cariado    { animation: ds-pieza-pulse 1.5s ease-out; }
  .ds-pieza--endodoncia { animation: ds-pieza-pulse 2.2s ease-out infinite; }
  .ds-pieza--extraccion { animation: ds-pieza-pulse 2.2s ease-out infinite; }
  /* Ausente: rayado diagonal */
  .ds-pieza--ausente {
    background:repeating-linear-gradient(45deg, #F5F5F5 0, #F5F5F5 4px, #E0E0E0 4px, #E0E0E0 8px) !important;
    border-style:dashed;
  }
  .ds-pieza--ausente .ds-pieza__num, .ds-pieza--ausente .ds-pieza__estado { color:#757575; }
  .ds-pieza--extraccion {
    background:repeating-linear-gradient(-45deg, #FFCDD2 0, #FFCDD2 4px, #EF9A9A 4px, #EF9A9A 8px) !important;
  }
  /* Restaurados: aspecto solido con ring exterior */
  .ds-pieza--corona  { box-shadow: inset 0 0 0 2px var(--border, #8E24AA); }
  .ds-pieza--puente  { box-shadow: inset 0 0 0 2px var(--border, #00838F); }
  .ds-pieza--implante{ box-shadow: inset 0 0 0 2px var(--border, #0277BD); }
  .ds-pieza--obturado{ box-shadow: inset 0 0 0 2px var(--border, #2196F3); }
  /* Disabled (no editable): quitar cursor */
  .ds-pieza:disabled { cursor:default; }
  .ds-pieza:disabled:hover { transform:none; box-shadow:none; }
  /* En modo readonly, sin pulso (es ruidoso). */
  .ds-odontograma[data-editable="0"] .ds-pieza { animation: none !important; }

  /* === Odontograma: estilos internos del modal (chips, estados, forms) === */
  /* (El wrapper del popover ya no existe; usamos .ds-modal* del patron comun.) */
  .ds-odon-popover__chip {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 12px;
    color: var(--accent, #0E5B5B);
    background: rgba(14,91,91,.10);
    padding: 2px 7px;
    border-radius: 5px;
  }
  .ds-odon-popover__estado-tag {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 2px 7px;
    border-radius: 5px;
    background: var(--bg, #E8F5E9);
    color: var(--border, #4CAF50);
    border: 1px solid var(--border, #4CAF50);
    transition: background .12s ease, color .12s ease, border-color .12s ease;
  }
  .ds-odon-estados-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px;
  }
  .ds-odon-estados-head label {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--ink-soft); font-weight: 600; margin: 0;
  }
  .ds-odon-estado-add-link {
    border: 0; background: transparent;
    color: var(--accent, #0E5B5B);
    font-size: 11px; font-weight: 700;
    font-family: var(--font-ui);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    line-height: 1.2;
  }
  .ds-odon-estado-add-link:hover { background: rgba(14,91,91,.08); }
  .ds-odon-estado-add-link.is-open {
    background: rgba(14,91,91,.12);
  }
  .ds-odon-modal select,
  .ds-odon-modal input[type="text"],
  .ds-odon-modal input[type="color"],
  .ds-odon-modal textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #FFF;
    font-size: 13px;
    font-family: var(--font-ui);
    color: var(--ink);
  }
  .ds-odon-modal textarea {
    font-size: 12.5px;
    line-height: 1.4;
    resize: vertical;
    min-height: 60px;
    max-height: 140px;
  }
  /* Focus state para inputs dentro del modal de odontograma (heredado del .ds-modal__body focus) */
  .ds-odon-modal select:focus,
  .ds-odon-modal input:focus,
  .ds-odon-modal textarea:focus {
    border-color: var(--accent, #0E5B5B);
    outline: none;
    box-shadow: 0 0 0 3px rgba(14, 91, 91, 0.12);
  }
  .ds-odon-evo-block {
    display: grid;
    gap: 5px;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
  }
  .ds-odon-evo-block > label,
  .ds-odon-evo-block__sublabel {
    font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--ink-soft); font-weight: 600;
  }

  /* Chips densos — 4 columnas, poca altura */
  .ds-odon-estados-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 2px;
  }
  .ds-odon-estado-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 7px;
    border: 1.5px solid var(--line);
    border-radius: 8px;
    background: #FFF;
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 10.5px;
    font-weight: 600;
    color: var(--ink);
    text-align: left;
    transition: border-color .1s ease, background .1s ease, box-shadow .1s ease;
    min-width: 0;
    line-height: 1.2;
  }
  .ds-odon-estado-chip:hover {
    border-color: var(--border, var(--accent));
    background: var(--bg, #FAFAFA);
  }
  .ds-odon-estado-chip.is-active {
    border-color: var(--border, var(--accent));
    background: var(--bg, rgba(14,91,91,.06));
    /* Quitamos el box-shadow inset que duplicaba el border (causaba
       efecto 'recortado' en las esquinas con border-radius alto). */
  }
  .ds-odon-estado-chip__swatch {
    flex-shrink: 0;
    width: 16px; height: 16px;
    border-radius: 4px;
    background: var(--bg, #E8F5E9);
    border: 1.5px solid var(--border, #4CAF50);
    color: var(--border, #4CAF50);
    font-size: 9px;
    font-weight: 700;
    display: grid; place-items: center;
    line-height: 1;
  }
  .ds-odon-estado-chip__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
  .ds-odon-caras-head { margin-top: 4px; }
  .ds-odon-caras-head label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
  }
  .ds-odon-caras {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0 10px;
  }
  .ds-odon-cara-chip {
    padding: 5px 10px;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: #fff;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    line-height: 1.2;
  }
  .ds-odon-cara-chip:hover { border-color: var(--accent); }
  .ds-odon-cara-chip.is-active {
    background: var(--accent-soft, rgba(14,91,91,.1));
    border-color: var(--accent);
    color: var(--accent);
  }
  .ds-odon-resumen__caras {
    margin-top: 4px;
    font-size: 11px;
    color: var(--ink-soft);
    font-weight: 500;
  }

  /* Formulario crear estado: oculto hasta + Nuevo */
  .ds-odon-nuevo-estado[hidden] {
    display: none !important;
  }
  .ds-odon-nuevo-estado {
    padding: 8px;
    border: 1px dashed rgba(14,91,91,.28);
    border-radius: 7px;
    background: rgba(14,91,91,.04);
  }
  .ds-odon-nuevo-estado__row {
    display: flex;
    align-items: center;
    gap: 5px;
  }
  .ds-odon-nuevo-estado__row .ds-odon-popover__input {
    flex: 1;
    min-width: 0;
    padding: 5px 7px;
    font-size: 12px;
  }
  .ds-odon-nuevo-estado__row input[type="color"] {
    width: 28px;
    height: 28px;
    padding: 1px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #FFF;
    cursor: pointer;
    flex-shrink: 0;
  }
  .ds-odon-nuevo-estado__row .ds-btn {
    flex-shrink: 0;
    padding: 4px 8px;
    font-size: 11px;
  }
  .ds-odon-nuevo-estado__err {
    margin-top: 4px;
    font-size: 11px;
    color: #C62828;
    background: #FFEBEE;
    border-radius: 4px;
    padding: 4px 6px;
  }
  .ds-odon-color-preview { display: none; }

  @media (max-width: 360px) {
    .ds-odon-estados-grid { grid-template-columns: repeat(2, 1fr); }
  }

  /* === Resumen clínico del odontograma === */
  .ds-odon-resumen {
    font-family: var(--font-ui);
  }
  .ds-odon-resumen__head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
  }
  .ds-odon-resumen__title {
    font-size: 13px; font-weight: 600; color: var(--ink);
    display: inline-flex; align-items: center;
  }
  .ds-odon-resumen__count {
    font-family: var(--font-mono);
    font-size: 11px; color: var(--ink-soft);
    text-transform: uppercase; letter-spacing: 0.04em;
  }
  .ds-odon-resumen__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
  }
  .ds-odon-resumen__table th {
    text-align: left;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    font-weight: 700;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    background: transparent;
  }
  /* Layout fijo (en lugar de auto) — reparte columnas de manera predecible.
     PIEZA = identificador corto, ESTADO = badge compacto, NOTAS = texto
     medio (muchas vacias), EVOLUCIÓN = columna principal con contenido
     largo + boton + line-clamp. */
  .ds-odon-resumen__table {
    table-layout: fixed;
    width: 100%;
  }
  .ds-odon-resumen__th-pieza { width: 64px; }
  .ds-odon-resumen__th-estado { width: 120px; }
  /* NOTAS CLINICAS: ancho generoso para textos largos (corona, etc.). */
  .ds-odon-resumen__th-notas { width: 30%; min-width: 240px; }
  /* EVOLUCION: toma el resto del ancho (incluye badge + nota + boton). */
  .ds-odon-resumen__th-evo { width: auto; }
  .ds-odon-resumen__table tbody tr:last-child td { border-bottom: 0; }
  .ds-odon-resumen__table tbody tr:hover { background: var(--bg, #FAFAFA); }
  .ds-odon-resumen__td-pieza {
    font-weight: 700; color: var(--accent, #0E5B5B);
    font-size: 14px; white-space: nowrap;
    width: 64px;  /* mismo ancho que th-pieza */
  }
  /* Celdas: igual que thead para consistencia con table-layout: fixed */
  .ds-odon-resumen__table td {
    /* Padding lateral moderado para separar visualmente el contenido de
       celdas adyacentes sin dominar el ancho. */
    padding: 14px 18px 14px 22px;  /* top right bottom left */
    vertical-align: top;
  }
  .ds-odon-resumen__table td:first-child { padding-left: 20px; }
  .ds-odon-resumen__table td:last-child { padding-right: 20px; }
  .ds-odon-resumen__td-notas,
  .ds-odon-resumen__td-evo {
    overflow: hidden;  /* permite que line-clamp funcione */
  }
  .ds-odon-resumen__td-notas { width: 30%; }
  .ds-odon-resumen__td-estado { width: 120px; padding-right: 28px; }

  .ds-odon-resumen__estado,
  .ds-odon-resumen__evo {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 999px;  /* pill shape para mejor lectura */
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border: 1.5px solid;  /* mas definido que 1px */
    line-height: 1.2;
    white-space: nowrap;
    white-space: nowrap;
    flex-shrink: 0;  /* evita que el chip se aplaste en filas angostas */
  }
  .ds-odon-resumen__evo--empty {
    border: 0;
    font-weight: 500;
    color: var(--ink-soft);
    background: transparent;
    padding: 0;
    text-transform: none;
    letter-spacing: 0;
  }
  .ds-odon-resumen__td-notas,
  .ds-odon-resumen__td-evo-nota {
    color: var(--ink);
    word-wrap: break-word;
    max-width: 320px;
  }
  .ds-odon-resumen__th-evo { min-width: 280px; width: auto; }
  .ds-odon-resumen__evo-cell {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
  }
  .ds-odon-resumen__evo-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
    flex: 1 1 200px;  /* deja espacio para que el botón tenga sitio */
  }
  .ds-odon-resumen__evo-preview {
    font-size: 12.5px;
    color: var(--ink);
    line-height: 1.45;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;  /* respeta saltos de linea si los hay */
    display: -webkit-box;
    -webkit-line-clamp: 4;  /* máx 4 lineas, ellipsis automático */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 10px;
    border-left: 3px solid var(--accent, #0E5B5B);  /* mas visible, no recortado */
    margin-top: 2px;
  }
  .ds-odon-resumen__td-evo .ds-odon-resumen__evo-preview { white-space: pre-wrap; }

  /* === Fila clickeable del Resumen clínico (variante B del brainstorming) ===
     Toda la fila es clickeable: hover sobre cualquier celda con
     data-popover-target activa el fondo + borde izquierdo mint. */
  .ds-odon-resumen__row--editable { cursor: default; }
  .ds-odon-resumen__td-clickable { position: relative; }
  /* Fallback sin :has(): hover en la celda individual pinta el highlight local. */
  .ds-odon-resumen__row--editable .ds-odon-resumen__td-clickable:hover {
    background: #fafbfb;
    box-shadow: inset 2px 0 0 #0E5B5B;
    cursor: pointer;
  }
  /* Path moderno (Safari 15.4+, Chrome 105+, FF 121+): toda la fila se resalta
     cuando el cursor esta sobre cualquier celda editable. */
  @supports selector(:has(*)) {
    .ds-odon-resumen__row--editable:has(.ds-odon-resumen__td-clickable:hover) {
      background: #fafbfb;
      box-shadow: inset 2px 0 0 #0E5B5B;
    }
    .ds-odon-resumen__row--editable:has(.ds-odon-resumen__td-clickable:hover)
      .ds-odon-resumen__td-clickable {
      background: transparent;
      box-shadow: none;
    }
  }
  /* Touch devices: feedback en :active */
  @media (hover: none) {
    .ds-odon-resumen__row--editable .ds-odon-resumen__td-clickable:active {
      background: #eef4f4;
    }
  }
  .ds-odon-resumen__evo-open {
    flex-shrink: 0;
    white-space: nowrap;
    align-self: center;
  }
  @media (max-width: 720px) {
    .ds-odon-resumen__table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  }
  .ds-odon-resumen__empty {
    text-align: center;
    padding: 22px;
    color: var(--ink-soft);
    font-size: 13px;
  }
  /* Flash para indicar fila recien modificada (resumen reactivo). */
  .ds-odon-resumen__table tbody tr {
    transition: background .3s ease;
  }
  .ds-odon-resumen__table tbody tr[data-just-flashed="1"] {
    background: rgba(76, 175, 80, 0.18) !important;
    animation: ds-odon-flash 1.5s ease-out;
  }
  @keyframes ds-odon-flash {
    0%   { background: rgba(76, 175, 80, 0.45) !important; }
    100% { background: rgba(76, 175, 80, 0.0)  !important; }
  }
  /* Banner de estado en la edit page */
  .ds-odon-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-radius: 4px;
    background: rgba(76,175,80,0.10);
    color: #2E7D32;
    border: 1px solid rgba(76,175,80,0.25);
  }
  .ds-odon-live-badge::before {
    content: '';
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #2E7D32;
    animation: ds-odon-pulse 1.5s ease-in-out infinite;
  }
  @keyframes ds-odon-pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.85); }
    50%      { opacity: 1;   transform: scale(1.1); }
  }

  /* === Flash alert card (post-crear cita) === */
  .ds-alert-card { display:flex; align-items:flex-start; gap:14px; padding:4px 0; }
  .ds-alert-card__icon { flex-shrink:0; width:42px; height:42px; border-radius:50%; background:var(--success); color:#fff; display:grid; place-items:center; }
  .ds-alert-card__icon svg { stroke:#fff; }
  .ds-alert-card__body { flex:1; min-width:0; }
  .ds-alert-card__title { font-size:15px; font-weight:700; color:var(--ink); letter-spacing:-0.01em; margin-bottom:2px; }
  .ds-alert-card__sub { font-size:13px; color:var(--ink-2); margin-bottom:8px; line-height:1.45; }
  .ds-alert-card__sub b { color:var(--ink); font-weight:600; }
  .ds-alert-card__time { display:inline-block; padding:1px 8px; background:var(--accent-soft); color:var(--accent); border-radius:4px; font-family:var(--font-mono); font-weight:600; font-size:12px; }
  .ds-alert-card__meta { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:12px; }
  .ds-alert-card__chip { display:inline-flex; align-items:center; gap:4px; padding:3px 10px; background:var(--bg); color:var(--ink-2); border-radius:20px; font-size:11px; font-weight:500; }
  .ds-alert-card__chip svg { color:var(--success); }
  .ds-alert-card__actions { display:flex; flex-wrap:wrap; gap:6px; padding-top:10px; border-top:1px solid var(--line); }
  .ds-alert-card__cancel { color:var(--danger) !important; }
  .ds-alert-card__cancel:hover { background:rgba(204,31,31,0.08) !important; }

  /* === Recetas: dropdown selector de paciente (Nueva receta) === */
  .ds-nueva-receta-dd { position: relative; }
  .ds-nueva-receta-dd > summary { list-style: none; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
  .ds-nueva-receta-dd > summary::-webkit-details-marker { display: none; }
  .ds-nueva-receta-dd[open] > summary { background: var(--accent-hover); }
  .ds-nueva-receta-dd__panel { position: absolute; right: 0; top: calc(100% + 6px); width: 360px; max-height: 480px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.15); z-index: 50; padding: 8px; }
  .ds-nueva-receta-dd__title { padding: 10px 12px 8px; font-size: 11px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }
  .ds-nueva-receta-dd__list { display: flex; flex-direction: column; gap: 2px; }
  .ds-nueva-receta-dd__item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; transition: background 0.1s; min-height: 48px; }
  .ds-nueva-receta-dd__item:hover { background: var(--bg); }
  .ds-nueva-receta-dd__more { display: block; text-align: center; padding: 10px; margin-top: 6px; border-top: 1px solid var(--line); color: var(--accent); font-size: 12px; font-weight: 500; text-decoration: none; }
  .ds-nueva-receta-dd__more:hover { background: var(--bg); }
  .ds-avatar-mini { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #4CAF50, #2E7532); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 600; flex-shrink: 0; }

  /* === Utilities === */
@layer utilities {
  .ds-stack { display: flex; flex-direction: column; }
  .ds-stack > * + * { margin-top: 12px; }
  .ds-cluster { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .ds-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .ds-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
  .ds-split-2 { display: grid; grid-template-columns: 1.7fr 1fr; gap: 14px; }
  .ds-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .ds-mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
  .ds-muted { color: var(--ink-soft); }
  .ds-uppercase { text-transform: uppercase; letter-spacing: 0.04em; font-size: 11.5px; font-family: var(--font-mono); color: var(--ink-soft); font-weight: 600; }

  /* Bot status banner (INLINE en el flujo del form, NO fixed) */
  .ds-bot-banner {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius);
    background: var(--surface);
    border-left: 4px solid var(--accent);
    box-shadow: var(--shadow-sm);
    font-size: 13.5px;
    line-height: 1.5;
    margin: 0 0 16px;
  }
  .ds-bot-banner svg { flex-shrink: 0; margin-top: 3px; }
  .ds-bot-banner strong { color: var(--ink); display: inline; font-weight: 600; }
  .ds-bot-banner--success { border-left-color: var(--success); background: rgba(46,125,50,.04); }
  .ds-bot-banner--warning { border-left-color: var(--warning); background: rgba(255,179,0,.06); }
  .ds-bot-banner--info { border-left-color: var(--info, var(--accent)); background: rgba(0,140,180,.04); }

  /* Flash (toasts de un solo mensaje flash()) */
  .ds-flash { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; }
  .ds-flash > div { padding: 12px 16px; border-radius: var(--radius); border-left: 4px solid var(--accent); font-size: 13.5px; background: var(--surface); }
  .ds-flash .ds-flash--success { border-left-color: var(--success); background: rgba(46,125,50,.04); }
  .ds-flash .ds-flash--warning { border-left-color: var(--warning); background: rgba(255,179,0,.06); }
  .ds-flash .ds-flash--danger  { border-left-color: var(--danger);  background: rgba(204,31,31,.04); }
  .ds-flash .ds-flash--info    { border-left-color: var(--accent);  }

  /* Auth pages (no sidebar) */
  .ds-auth { background: var(--bg); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
  .ds-auth__card { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 40px; width: 100%; max-width: 420px; }
  .ds-auth__title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 6px; }
  .ds-auth__sub { font-size: 14px; color: var(--ink-soft); margin-bottom: 28px; }

  /* Form fields */
  .ds-field { margin-bottom: 16px; }
  .ds-field__label { display: block; font-size: 13px; font-weight: 500; color: var(--ink); margin-bottom: 6px; }
  .ds-field__required { color: var(--danger); margin-left: 2px; }
  .ds-field input, .ds-field select, .ds-field textarea { width: 100%; padding: 9px 12px; font-size: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); transition: border-color .12s; color: var(--ink); }
  .ds-field input:focus, .ds-field select:focus, .ds-field textarea:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-soft);  /* halo mas sutil (2px en vez de 3px) */
  }
  /* Inputs de login no deben verse raros al cargar la pagina.
     El autofocus + el focus state produce un highlight muy visible
     al cargar. Para login, no usamos box-shadow en focus (solo
     border mint). */
  .ds-auth__card .ds-field input:focus,
  .ds-auth__card .ds-field select:focus,
  .ds-auth__card .ds-field textarea:focus {
    box-shadow: none;
  }
  /* Asegurar que el input de email/contrasena NO tenga text-transform
     upper. Algunos navegadores (Safari, old Firefox) pueden aplicar
     text-transform del padre. Forzamos none explicitamente. */
  .ds-auth__card .ds-field input,
  .ds-auth__card .ds-field textarea,
  .ds-auth__card .ds-field select {
    text-transform: none;
    -webkit-text-transform: none;
  }
  .ds-field--invalid input, .ds-field--invalid select, .ds-field--invalid textarea { border-color: var(--danger); }
  .ds-field__hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

  /* Límite de caracteres: el valor no se pone rojo al tope (parece error).
     Solo un destello si se intenta escribir de más. */
  .ds-field__limit {
    font-size: 11.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--ink-soft);
    margin-top: 5px;
    text-align: right;
    letter-spacing: .02em;
    transition: color .12s;
  }
  .ds-field__limit.is-near-limit { color: #B45309; }
  .ds-field__limit.is-at-limit { color: var(--ink-2); }

  .ds-field input.is-near-limit,
  .ds-field textarea.is-near-limit {
    border-color: var(--line-2);
  }

  @keyframes ds-limit-flash {
    0%, 40% {
      color: var(--danger);
      border-color: var(--danger);
      caret-color: var(--danger);
      box-shadow: 0 0 0 2px rgba(204, 31, 31, 0.16);
    }
    100% {
      color: var(--ink);
      border-color: var(--line);
      caret-color: auto;
      box-shadow: none;
    }
  }
  .ds-field input.is-limit-pulse,
  .ds-field textarea.is-limit-pulse,
  input.is-limit-pulse,
  textarea.is-limit-pulse {
    animation: ds-limit-flash .42s ease-out;
  }
  .ds-field__limit.is-limit-pulse { color: var(--danger); }
  /* Contador también fuera de .ds-field (forms legacy) */
  .ds-field__limit + .ds-field__hint,
  input + .ds-field__limit,
  textarea + .ds-field__limit {
    display: block;
  }

  /* Alinear visualmente todos los inputs del form de agenda
     (override del min-height variable que cada input declara inline
     para que todos queden exactamente a la misma altura). */
  .ds-panel input[name="fecha_inicio"],
  .ds-panel select[name="hora_inicio"],
  .ds-panel input[name="duracion_minutos"],
  .ds-panel select[name="estatus"] { min-height: 48px !important; }

  /* === Form 'Cuando' (Fecha / Hora / Duracion / Estatus) === */
  /* Grid 4 columnas con alineamiento forzado: cada .ds-field es un
     flex column con min-height identico, asi las labels y los inputs
     quedan exactamente en la misma Y position. */
  .ds-cuando-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr 0.6fr 1fr;
    gap: 14px;
    align-items: start;
  }
  .ds-cuando-grid .ds-field {
    min-height: 82px;     /* label (~22) + gap (6) + input (48) + buffer */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    margin-bottom: 0;     /* override el .ds-field { margin-bottom: 16px } */
  }
  .ds-cuando-grid .ds-field__label {
    height: 22px;          /* forzar misma altura en todos los labels */
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    line-height: 1;
  }
  .ds-cuando-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 16px;
    font-weight: 500;
    border: 2px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    min-height: 48px;
    box-sizing: border-box;
    transition: border-color .15s, background .15s, color .15s;
  }
  .ds-cuando-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
  /* Estado rojo cuando la hora esta ocupada o es del pasado.
     Se aplica con class="ds-cuando-invalid" desde JS. */
  .ds-cuando-invalid input,
  .ds-cuando-invalid select {
    border-color: #CC1F1F !important;
    background: #FFE5E5 !important;
    color: #CC1F1F !important;
  }
  .ds-cuando-invalid input:focus,
  .ds-cuando-invalid select:focus {
    box-shadow: 0 0 0 3px rgba(204,31,31,.2) !important;
  }
  .ds-field__error { font-size: 12px; color: var(--danger); margin-top: 4px; }

  /* Acciones de fila: iconos ojo / editar (listados) */
  .ds-row-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
  .ds-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--ink);
    background: var(--ink);
    color: #fff;
    text-decoration: none;
    transition: background .12s ease, border-color .12s ease, color .12s ease, transform .1s ease;
    cursor: pointer;
    flex-shrink: 0;
  }
  .ds-icon-btn:hover {
    background: #000;
    border-color: #000;
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
  }
  .ds-icon-btn:active { transform: none; }
  .ds-icon-btn svg {
    display: block;
    stroke: #fff;
    color: #fff;
  }

  /* === Time picker custom (agenda) — columnas H | M | a.m./p.m. === */
  .ds-timepick {
    position: relative;
    width: 100%;
  }
  .ds-timepick__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    outline: none;
  }
  .ds-timepick__trigger:hover { border-color: var(--ink-soft); }
  .ds-timepick__trigger:focus,
  .ds-timepick__trigger:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
  }
  .ds-timepick__value {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
  }
  .ds-timepick__icon {
    flex-shrink: 0;
    opacity: 0.55;
    color: var(--ink-soft);
  }
  .ds-timepick__trigger--invalid,
  .ds-cuando-invalid .ds-timepick__trigger {
    border-color: #CC1F1F !important;
    background: #FFE5E5 !important;
    color: #CC1F1F !important;
  }
  .ds-cuando-invalid .ds-timepick__icon { color: #CC1F1F; opacity: 0.8; }

  /* fixed: escapa overflow:hidden del .ds-panel */
  .ds-timepick__panel {
    position: fixed;
    z-index: 9500;
    width: 248px;
    background: #FFFFFF;
    border: 1px solid rgba(0,0,0,.10);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
    padding: 10px;
    animation: ds-popover-in 0.12s ease-out;
  }
  .ds-timepick__panel[hidden] { display: none !important; }

  .ds-timepick__cols {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;
    gap: 6px;
    background: #F7F8FA;
    border-radius: 8px;
    padding: 4px;
  }
  .ds-timepick__col {
    overflow-y: auto;
    max-height: 240px;
    border-radius: 6px;
    background: #FFFFFF;
    scrollbar-width: thin;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
  }
  .ds-timepick__col--ap { max-height: 96px; align-self: start; }

  .ds-timepick__opt {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    padding: 8px 6px;
    margin: 0;
    border-radius: 0;
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    font-family: inherit;
    color: var(--ink);
    cursor: pointer;
    text-align: center;
    line-height: 1.2;
    transition: background .1s ease, color .1s ease, opacity .1s ease;
  }
  .ds-timepick__opt + .ds-timepick__opt {
    border-top: 1px solid rgba(0,0,0,.04);
  }
  .ds-timepick__opt:hover:not(.is-blocked) {
    background: rgba(47, 107, 255, 0.10);
  }
  .ds-timepick__opt.is-active {
    background: #2F6BFF;
    color: #fff;
    border-radius: 6px;
    border-top-color: transparent;
  }
  .ds-timepick__opt.is-active + .ds-timepick__opt {
    border-top-color: transparent;
  }
  .ds-timepick__opt.is-active:hover:not(.is-blocked) {
    background: #2558d6;
    color: #fff;
  }
  /* Ocupada / pasada: rojo + opaco + no clicable */
  .ds-timepick__opt.is-blocked {
    color: #C62828;
    background: #FFF5F5;
    opacity: 0.48;
    cursor: not-allowed;
    text-decoration: line-through;
    pointer-events: none;
  }
  .ds-timepick__opt.is-blocked.is-active {
    background: #FFCDD2;
    color: #B71C1C;
    opacity: 0.65;
  }

  .ds-timepick__legend {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,.06);
    font-size: 11px;
    color: var(--ink-soft);
    flex-wrap: wrap;
  }
  .ds-timepick__legend-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
  }
  .ds-timepick__legend-dot--ok { background: #2F6BFF; }
  .ds-timepick__legend-dot--bad { background: #C62828; opacity: 0.7; }
}

/* === Responsive === */
@media (max-width: 1100px) {
  .ds-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .ds-split-2 { grid-template-columns: 1fr; }
  .ds-row-3 { grid-template-columns: 1fr 1fr; }
  .ds-ph__title { font-size: 24px; }
}
@media (max-width: 900px) {
  .ds-cuando-grid { grid-template-columns: 1fr 1fr; }
}
/* Utilidades de form (desktop + mobile) */
.ds-form-grid {
  display: grid;
  gap: 16px;
}
.ds-form-grid--2 { grid-template-columns: 1.4fr 1fr; }
.ds-form-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
.ds-form-grid--2eq { grid-template-columns: 1fr 1fr; }
.ds-panel__body--form { padding: 20px; }

@media (max-width: 760px) {
  .ds-cuando-grid { grid-template-columns: 1fr; gap: 14px; }
  .ds-form-grid--2,
  .ds-form-grid--2eq,
  .ds-form-grid--3 { grid-template-columns: 1fr; }
  .ds-panel__body--form { padding: 14px; }
  .ds-shell { grid-template-columns: 1fr; }
  /* El sidebar en ≤760px es un drawer (ver bloque v0.13 más abajo).
     Aquí no lo convertimos en rail horizontal: chocaba con el drawer
     y escondía marca, grupos y Cerrar sesión. */
  .ds-tb { padding: 8px 12px; height: auto; flex-wrap: wrap; gap: 8px; padding-top: max(8px, env(safe-area-inset-top, 0px)); }
  .ds-tb__pill { display: none; }
  .ds-page { padding: 12px 12px 96px; } /* espacio para barra inferior */
  .ds-grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ds-row-3 { grid-template-columns: 1fr; }
  .ds-split-2 { grid-template-columns: 1fr; }
  .ds-ph { flex-direction: column; align-items: flex-start; gap: 10px; }
  .ds-ph__l, .ds-ph__title { max-width: 100%; min-width: 0; }
  .ds-ph__r { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
  .ds-ph__r .ds-btn { flex: 1 1 auto; min-height: 44px; justify-content: center; }
  .ds-ph__title { font-size: 20px; line-height: 1.25; white-space: normal; }
  .ds-ph__title--dia {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 24px;
    line-height: 1.15;
  }
  .ds-ph__title--dia .ds-ph__year { font-size: 15px; font-weight: 500; }
  .ds-day-nav { width: 100%; }
  .ds-day-nav__btn { flex: 1; min-height: 44px; }
  .ds-panel__head { flex-wrap: wrap; align-items: flex-start; gap: 10px; }
  .ds-panel__head > [style*="margin-left:auto"] { margin-left: 0 !important; width: 100%; justify-content: stretch; }
  .ds-panel__head > [style*="margin-left:auto"] > div { width: 100%; }
  .ds-panel__head .ds-btn--sm { flex: 1; justify-content: center; }
  .ds-ph__desc { font-size: 13px; }
  .ds-stat__val { font-size: 22px; }

  /* Inputs táctiles: 16px evita zoom automático en iOS/Android */
  .ds-field { margin-bottom: 14px; }
  .ds-field__label { font-size: 13px; margin-bottom: 6px; }
  .ds-field input,
  .ds-field select,
  .ds-field textarea,
  .ds-cuando-input,
  .ds-timepick__trigger {
    font-size: 16px !important;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 10px;
  }
  .ds-field select,
  select.ds-cuando-input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
  }
  .ds-btn, .ds-btn--submit, button[type="submit"] {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 15px;
  }
  /* Botones de acción del form: encima de la bottom nav, no debajo */
  .ds-form-actions {
    position: sticky;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    z-index: 30;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0 8px;
    margin-top: 8px;
    background: linear-gradient(180deg, transparent, var(--bg) 28%);
  }
  .ds-form-actions .ds-btn { flex: 1 1 140px; justify-content: center; }

  /* Tablas de listado: scroll, sin forzar min-width en TODAS las <table> */
  .ds-table-wrap, .ds-panel__body:has(> table), .ds-panel__body:has(> .ds-table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ds-table-wrap > .ds-table,
  .ds-panel__body > .ds-table {
    min-width: 560px;
  }

  /* Time picker panel a ancho completo en móvil */
  .ds-timepick__panel {
    left: 0; right: 0;
    width: 100%;
    max-width: min(360px, calc(100vw - 24px));
  }
  .ds-row-actions { gap: 6px; }
  .ds-icon-btn { width: 40px; height: 40px; }
}

/* === Toast de confirmacion (post-crear registro) === */
.ds-toast-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 17, 21, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: ds-fade-in 0.18s ease-out;
}
@keyframes ds-fade-in { from { opacity: 0; } to { opacity: 1; } }

.ds-toast {
  background: #fff;
  border-radius: 12px;
  padding: 28px 32px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25), 0 4px 12px rgba(0,0,0,.08);
  max-width: 460px;
  width: calc(100% - 48px);
  text-align: center;
  border-top: 4px solid var(--accent);
  animation: ds-pop-in 0.22s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes ds-pop-in { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.ds-toast__icon {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 26px;
  font-weight: 700;
}
.ds-toast__title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
  color: var(--ink);
}
.ds-toast__sub {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 6px;
  font-family: var(--font-mono);
  word-break: break-word;
}
.ds-toast__countdown {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: 16px 0 0;
}
.ds-toast__countdown strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  min-width: 24px;
  display: inline-block;
  text-align: center;
  font-family: var(--font-mono);
}
.ds-toast__progress {
  height: 3px;
  background: var(--bg);
  border-radius: 3px;
  margin: 14px 0 0;
  overflow: hidden;
}
.ds-toast__progress-bar {
  height: 100%;
  background: var(--accent);
  width: 100%;
  transition: width 1s linear;
}
.ds-toast__actions {
  display: flex; gap: 8px;
  margin-top: 22px;
  justify-content: center;
}
.ds-toast__btn-accept,
.ds-toast__btn-reject {
  flex: 1; max-width: 180px;
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit;
}
.ds-toast__btn-accept { background: var(--ink); color: #fff; }
.ds-toast__btn-accept:hover { background: #000; }
.ds-toast__btn-reject { background: #fff; color: var(--danger); border: 1.5px solid var(--danger); }
.ds-toast__btn-reject:hover { background: rgba(204,31,31,.06); }

.ds-toast--closing { opacity: 0; transform: scale(.96); transition: all 0.18s ease-in; }

/* === Minigrid plantillas / indicaciones === */
/* === Indicaciones: grilla unificada minimalista === */
.ds-ind-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.ds-ind-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: inherit;
  color: inherit;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 110px;
  transition: border-color .12s, box-shadow .12s;
}
.ds-ind-card:hover {
  border-color: var(--ink-soft);
  box-shadow: 0 1px 6px rgba(0,0,0,.05);
}
/* Chip de origen (esquina superior) */
.ds-ind-card__chip {
  display: inline-block;
  align-self: flex-start;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--ink-soft);
}
.ds-ind-card__chip--plantilla {
  background: rgba(14, 91, 91, 0.10);
  color: var(--accent, #0E5B5B);
}
.ds-ind-card__chip--libre {
  background: #FFF8E1;
  color: #B45309;
}
.ds-ind-card__chip--plantilla-disponible {
  background: #F0F0F0;
  color: var(--ink-soft);
}
.ds-ind-card__chip--add {
  background: rgba(14, 91, 91, 0.08);
  color: var(--accent, #0E5B5B);
}
/* Titulo: 1 linea con ellipsis */
.ds-ind-card__title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding-right: 60px;  /* deja espacio para las actions a la derecha */
}
/* Preview: 3 lineas con line-clamp */
.ds-ind-card__preview {
  font-size: 11.5px;
  color: var(--ink-soft);
  line-height: 1.4;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}
.ds-ind-card__preview--add {
  color: var(--ink-soft);
  font-style: italic;
  font-size: 11px;
}
/* Acciones inline (lapiz + papelera o + check) — esquina inferior derecha */
.ds-ind-card__actions {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: inline-flex;
  gap: 4px;
}
.ds-ind-card__icon {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  border-radius: 6px;
  cursor: pointer;
  transition: color .12s, background .12s, border-color .12s;
  font-family: inherit;
  padding: 0;
}
.ds-ind-card__icon:hover {
  color: var(--accent, #0E5B5B);
  background: rgba(14, 91, 91, 0.06);
  border-color: rgba(14, 91, 91, 0.20);
}
.ds-ind-card__icon--danger:hover {
  color: var(--danger, #C62828);
  background: rgba(198, 40, 40, 0.06);
  border-color: rgba(198, 40, 40, 0.20);
}
.ds-ind-card__icon--primary {
  color: var(--accent, #0E5B5B);
}
.ds-ind-card__icon--primary:hover {
  background: rgba(14, 91, 91, 0.12);
}
.ds-ind-card__icon--check {
  color: var(--success, #2E7D32);
  cursor: default;
}
/* Plantilla ya asignada: atenuada */
.ds-ind-card--in-use {
  opacity: 0.58;
  background: #FAFAFA;
}
.ds-ind-card--in-use:hover { opacity: 0.85; }
/* Cuando una card entra en modo edicion, suelta las actions absolutas
   y el panel ocupa toda la card (flujo normal, no overlay). */
/* === Modal centrado para editar indicacion (reemplaza al panel inline) === */
/* === Bloque separado de plantillas disponibles (colapsable) === */
.ds-ind-templates {
  border-top: 1px solid var(--line);
  background: #FAFAFA;
}
.ds-ind-templates__head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: transparent;
  border: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.ds-ind-templates__head:hover { background: rgba(0, 0, 0, 0.025); }
.ds-ind-templates__head:focus-visible {
  outline: 2px solid var(--accent, #0E5B5B);
  outline-offset: -2px;
}
.ds-ind-templates__head[aria-expanded="true"] #ds-ind-templates-chev {
  transform: rotate(180deg);
}
.ds-ind-card--plantilla-disponible {
  background: #fff;
}
.ds-ind-card--plantilla-disponible:hover {
  border-color: var(--accent, #0E5B5B);
}
.ds-ind-card--add {
  border: 1.5px dashed var(--line);
  background: transparent;
  cursor: pointer;
  align-items: flex-start;
  justify-content: center;
  color: var(--ink-soft);
  font-family: inherit;
  min-height: 110px;
  padding: 12px 14px;
}
.ds-ind-card--add:hover {
  border-color: var(--accent, #0E5B5B);
  border-style: solid;
  background: rgba(14, 91, 91, 0.04);
  color: var(--accent, #0E5B5B);
}
.ds-ind-card--add .ds-ind-card__title {
  font-weight: 600;
  padding-right: 0;
}
/* Panel de agregar libre (form completo) */
.ds-ind-add-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg, #FAFAFA);
}
@media (max-width: 600px) {
  .ds-ind-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .ds-ind-grid { grid-template-columns: 1fr; }
}
.ds-ind-list { display: flex; flex-direction: column; gap: 12px; }
.ds-ind-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}

/* === Indicaciones colapsable (header clickeable) === */
.ds-ind-section__head {
  transition: background 0.12s ease;
  border-radius: 10px 10px 0 0;
}
.ds-ind-section__head:hover { background: #FAFAFA; }
.ds-ind-section__head:focus-visible {
  outline: 2px solid var(--accent, #0E5B5B);
  outline-offset: -2px;
}
/* Pill mint con el contador de indicaciones */
.ds-ind-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 8px;
  background: rgba(14, 91, 91, 0.10);
  color: var(--accent, #0E5B5B);
  border: 1px solid rgba(14, 91, 91, 0.18);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
/* Chevron rota 180° cuando el bloque esta expandido */
.ds-ind-section__head[aria-expanded="true"] #ds-ind-section-chev {
  transform: rotate(180deg);
}

/* === Modal centrado grande (reemplaza popovers por click-location) === */
.ds-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 20px;
}
.ds-modal[hidden] {
  display: none !important;
}
.ds-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  cursor: pointer;
  animation: ds-modal-fade-in 0.18s ease-out;
}
@keyframes ds-modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.ds-modal__card {
  position: relative;
  background: #fff;
  border-radius: 14px;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.10);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ds-modal-card-in 0.20s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes ds-modal-card-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.ds-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: #FAFAFA;
}
.ds-modal__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  display: inline-flex;
  align-items: center;
}
.ds-modal__close {
  background: transparent;
  border: 0;
  font-size: 24px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-soft);
  transition: background 0.12s, color 0.12s;
}
.ds-modal__close:hover { background: rgba(0, 0, 0, 0.06); color: var(--ink); }
.ds-modal__body {
  padding: 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ds-modal__body label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 4px;
}
.ds-modal__body input,
.ds-modal__body textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 14px;
}
.ds-modal__body textarea {
  font-size: 14px;
  line-height: 1.55;
  min-height: 160px;
  resize: vertical;
}
.ds-modal__body input:focus,
.ds-modal__body textarea:focus {
  border-color: var(--accent, #0E5B5B);
  outline: none;
  box-shadow: 0 0 0 3px rgba(14, 91, 91, 0.14);
}
.ds-modal__foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: #FAFAFA;
}

@media (max-width: 760px) {
  .ds-minigrid { grid-template-columns: 1fr 1fr; }
}

/* === Preferencias de UI (config) === */
.ds-pref-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.ds-pref-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 720px) {
  .ds-pref-grid, .ds-pref-grid--3 { grid-template-columns: 1fr; }
}
.ds-pref-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px 14px 40px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s, background .12s, opacity .12s;
  position: relative;
  opacity: 0.72;
}
.ds-pref-card input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
/* Radio visual (solo uno activo por grupo) */
.ds-pref-card__radio {
  position: absolute;
  left: 14px;
  top: 16px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--line-2);
  background: #fff;
  box-sizing: border-box;
}
.ds-pref-card:hover {
  border-color: var(--ink-soft);
  opacity: 0.9;
}
/* Solo la opción checked se resalta — no clase .is-on estática */
.ds-pref-card:has(input:checked) {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
  background: #FAFAFA;
  opacity: 1;
}
.ds-pref-card:has(input:checked) .ds-pref-card__radio {
  border-color: var(--ink);
  background: radial-gradient(circle, var(--ink) 0 45%, #fff 48%);
}
.ds-pref-card__title { font-size: 14px; font-weight: 700; color: var(--ink); }
.ds-pref-card__desc { font-size: 12.5px; color: var(--ink-soft); line-height: 1.4; }
.ds-pref-card__preview { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.ds-pref-card__bars {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 52px;
}
.ds-pref-card__bars i {
  display: block;
  width: 100%;
  background: #D9DBE3;
  border-radius: 3px;
}
.ds-pref-card__bars--comfortable { gap: 7px; }
.ds-pref-card__bars--comfortable i { height: 9px; }
.ds-pref-card__bars--compact { gap: 5px; }
.ds-pref-card__bars--compact i { height: 7px; }
.ds-pref-card__bars--dense { gap: 3px; }
.ds-pref-card__bars--dense i { height: 5px; }
/* Fallback si :has no existe (Safari viejo) — JS opcional */
.ds-pref-card.is-selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
  background: #FAFAFA;
  opacity: 1;
}
.ds-pref-card.is-selected .ds-pref-card__radio {
  border-color: var(--ink);
  background: radial-gradient(circle, var(--ink) 0 45%, #fff 48%);
}

/* === Horario de sucursal (días + selects de hora) === */
.ds-horario__dias {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.ds-horario__dia {
  position: relative;
  display: inline-flex;
  cursor: pointer;
  user-select: none;
}
.ds-horario__dia input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.ds-horario__dia span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 36px;
  padding: 0 10px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: border-color .12s, background .12s, color .12s, box-shadow .12s;
}
.ds-horario__dia:hover span {
  border-color: var(--ink-soft);
  color: var(--ink);
}
.ds-horario__dia input:checked + span {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.ds-horario__times {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 420px;
}
.ds-horario__times .ds-field {
  flex: 1 1 140px;
  min-width: 140px;
}
.ds-horario__sep {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  color: var(--ink-soft);
  font-size: 16px;
  font-weight: 600;
  padding-bottom: 2px;
}
.ds-horario__select-wrap {
  position: relative;
}
.ds-horario__clock {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  pointer-events: none;
}
.ds-horario__select {
  padding-left: 36px !important;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px !important;
  cursor: pointer;
}
@media (max-width: 480px) {
  .ds-horario__sep { display: none; }
  .ds-horario__times { max-width: none; }
}

/* === Preferencias de interfaz: filas uniformes + tarjetas iguales === */
.ds-pref-panel {
  padding: 8px 28px 20px;
  display: flex;
  flex-direction: column;
}
.ds-pref-row {
  display: grid;
  grid-template-columns: minmax(160px, 200px) minmax(0, 1fr);
  gap: 20px 28px;
  align-items: stretch;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}
.ds-pref-row:last-child { border-bottom: 0; }
.ds-pref-row__meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 4px;
  min-width: 0;
}
.ds-pref-row__title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}
.ds-pref-row__desc {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.4;
}
.ds-pref-row__choices {
  display: grid;
  gap: 10px;
  min-width: 0;
  align-items: stretch;
}
.ds-pref-row__choices--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 420px;
}
.ds-pref-row__choices--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 520px;
}

/* Tarjeta de opción: misma altura y estructura en todas las filas */
.ds-pref-choice {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 108px;
  padding: 12px 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: border-color .12s, background .12s, box-shadow .12s;
  box-sizing: border-box;
}
.ds-pref-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.ds-pref-choice__top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 18px;
}
.ds-pref-choice__radio {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--line-2, #C8C8D0);
  background: #fff;
  box-sizing: border-box;
  flex-shrink: 0;
}
.ds-pref-choice__name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.ds-pref-choice__preview {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 52px;
}
.ds-pref-choice:hover {
  border-color: var(--ink-soft);
  background: #FCFCFD;
}
.ds-pref-choice:has(input:checked) {
  border-color: var(--ink);
  background: #FAFAFA;
  box-shadow: 0 0 0 1px var(--ink);
}
.ds-pref-choice:has(input:checked) .ds-pref-choice__radio {
  border-color: var(--ink);
  background: radial-gradient(circle, var(--ink) 0 45%, #fff 48%);
}

/* Compat: clases viejas por si quedan en cache/templates */
.ds-pref-list { display: none; }

@media (max-width: 720px) {
  .ds-pref-panel { padding: 4px 18px 16px; }
  .ds-pref-row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 16px 0;
  }
  .ds-pref-row__choices--2,
  .ds-pref-row__choices--3 {
    max-width: none;
  }
  .ds-pref-row__choices--3 {
    grid-template-columns: 1fr;
  }
  .ds-pref-choice { min-height: 96px; }
}
@media (max-width: 480px) {
  .ds-pref-row__choices--2 {
    grid-template-columns: 1fr;
  }
}

/* Densidad de grid (body class) */
body.ds-density-compact .ds-table th { padding: 7px 12px; }
body.ds-density-compact .ds-table td { padding: 9px 12px; }
body.ds-density-compact .ds-panel__body { padding: 14px !important; }
body.ds-density-compact .ds-stat { padding: 14px 16px; }
body.ds-density-compact .ds-ph { margin-bottom: 14px; }

body.ds-density-dense .ds-table th { padding: 5px 10px; font-size: 10.5px; }
body.ds-density-dense .ds-table td { padding: 6px 10px; font-size: 12.5px; }
body.ds-density-dense .ds-panel__body { padding: 10px 12px !important; }
body.ds-density-dense .ds-stat { padding: 10px 12px; }
body.ds-density-dense .ds-ph { margin-bottom: 10px; }
body.ds-density-dense .ds-ph__title { font-size: 22px; }

/* Timepicker 24h: ocultar columna a.m./p.m. */
html[data-time-format="24h"] .ds-timepick__col--ap { display: none; }
html[data-time-format="24h"] .ds-timepick__cols {
  grid-template-columns: 1fr 1fr;
}
html[data-time-format="24h"] .ds-timepick__panel { width: 180px; }

/* Odontograma: lista = <select> nativo (no agranda el modal) */
.ds-odon-estado-select-wrap { display: none; }
body.ds-odon-edit-list #ds-odon-estados-grid { display: none; }
body.ds-odon-edit-list .ds-odon-estado-select-wrap { display: block; }
.ds-odon-estado-select {
  width: 100%;
  min-height: 48px;
  padding: 12px 40px 12px 14px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink);
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2.2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  border: 1.5px solid var(--line-2);
  border-radius: 10px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.ds-odon-estado-select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(0,0,0,.08);
}

/* Previews visuales — altura estable dentro de .ds-pref-choice__preview */
.ds-pref-mini-time {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: 52px;
}
.ds-pref-mini-time i {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-style: normal;
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: #F1F2F5;
  border-radius: 6px;
  padding: 5px 8px;
}
.ds-pref-mini-time i small {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: lowercase;
}

.ds-pref-mini-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  width: 100%;
  min-height: 52px;
  align-content: center;
}
.ds-pref-mini-week > * {
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-soft);
  background: #F1F2F5;
  border-radius: 4px;
  height: 24px;
}
.ds-pref-mini-week > b.is-first {
  background: var(--ink);
  color: #fff;
  font-weight: 700;
}

.ds-pref-mini-chips {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  gap: 5px;
  width: 100%;
  min-height: 52px;
}
.ds-pref-mini-chips i {
  display: inline-flex;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1.5px solid;
  background: #fff;
}
.ds-pref-mini-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px 8px 12px;
  border: 1.5px solid var(--line-2);
  border-radius: 10px;
  background: #fff;
  color: var(--ink-soft);
  box-sizing: border-box;
}
.ds-pref-mini-select__val {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.ds-pref-mini-select__val b {
  font-size: 11px;
  line-height: 1;
}

/* Mini preview de tabla con/sin líneas de columna */
.ds-pref-mini-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr 1fr;
  gap: 0;
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--ink-2, var(--ink));
}
.ds-pref-mini-grid > span {
  padding: 4px 5px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-pref-mini-grid > span:nth-child(-n+3) {
  background: #F5F6F8;
  color: var(--ink-soft);
  text-transform: uppercase;
  font-size: 8.5px;
  letter-spacing: .02em;
}
.ds-pref-mini-grid > span:nth-last-child(-n+3) { border-bottom: 0; }
.ds-pref-mini-grid--lines > span {
  border-right: 1px solid var(--line);
}
.ds-pref-mini-grid--lines > span:nth-child(3n) { border-right: 0; }

/* Preview estilo de acciones */
.ds-pref-mini-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 52px;
}
.ds-pref-mini-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  font-style: normal;
  font-size: 13px;
  flex-shrink: 0;
}
.ds-pref-mini-labels {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-height: 52px;
}
.ds-pref-mini-labels i {
  display: inline-flex;
  align-items: center;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
}

/* Tablas con líneas de columna (preferencia grid_lines=on) */
body.ds-grid-lines .ds-table th,
body.ds-grid-lines .ds-table td {
  border-right: 1px solid var(--line);
}
body.ds-grid-lines .ds-table th:last-child,
body.ds-grid-lines .ds-table td:last-child {
  border-right: none;
}
body.ds-grid-lines .ds-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}
body.ds-grid-lines .ds-table th {
  border-bottom: 1px solid var(--line);
}
body.ds-grid-lines .ds-table tr:last-child td {
  border-bottom: none;
}

/* =============================================================
   v0.13 — RESPONSIVE MOBILE (375px+) — solo lo NUEVO
   El codebase ya tiene un bloque @media ≤760px completo en línea 1322
   (sidebar rail, form grids, touch targets, table min-width, etc.).
   Esta capa añade lo que faltaba: drawer overlay animado, bottom nav,
   stats hero utility, sticky first col en tablas, breakpoint ≤480px extra.
   No duplica reglas existentes para evitar conflictos.
   ============================================================= */
@layer components {

  /* === Hamburger button (visible solo en mobile via media query) === */
  .ds-menu-toggle {
    display: none;  /* se muestra en @media ≤760px abajo */
    align-items: center; justify-content: center;
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    color: var(--ink);
    transition: background .15s, transform .1s;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
  }
  .ds-menu-toggle:hover { background: var(--bg); }
  .ds-menu-toggle:active { transform: scale(.95); background: var(--bg); }
  .ds-menu-toggle svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }

  .ds-drawer-close {
    display: none;
    position: absolute;
    top: 14px; right: 10px;
    align-items: center; justify-content: center;
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    z-index: 1;
    -webkit-tap-highlight-color: transparent;
  }
  .ds-drawer-close:active { background: var(--bg); }
  .ds-drawer-close svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

  /* === Drawer backdrop (visible cuando body.ds-menu-open) === */
  .ds-drawer-backdrop {
    position: fixed; inset: 0; z-index: 7999;
    background: rgba(15, 23, 42, 0);
    pointer-events: none;
    transition: background .25s ease;
  }

  /* === Bottom navigation (5 secciones, ocultas en desktop) === */
  .ds-bottom-nav {
    display: none;  /* se muestra en @media ≤760px */
    position: fixed; left: 0; right: 0; bottom: 0;
    z-index: 8500;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 12px rgba(0,0,0,.04);
  }
  .ds-bottom-nav__list {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    list-style: none; margin: 0 auto; padding: 0;
    max-width: 600px;
  }
  .ds-bottom-nav__link {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 10.5px;
    font-weight: 500;
    min-height: 48px;
    border-radius: var(--radius-sm);
    transition: color .15s, background .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .ds-bottom-nav__link:active { background: var(--bg); }
  .ds-bottom-nav__link--on { color: var(--accent); font-weight: 600; }
  .ds-bottom-nav__link svg {
    width: 22px; height: 22px;
    stroke: currentColor; fill: none;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .ds-bottom-nav__label { font-size: 10px; letter-spacing: 0.02em; }

  /* === Stats hero card utility (4→2→1 cols) === */
  .ds-stats-hero {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }
  .ds-stats-hero > div { min-width: 0; }

  /* === Table wrapper scroll-shadow indicator === */
  .ds-table-wrap {
    position: relative;
  }
}

/* =============================================================
   ≤1100px (tablet) — añadir colapso de ds-stats-hero
   ============================================================= */
@media (max-width: 1100px) {
  .ds-stats-hero { grid-template-columns: repeat(2, 1fr); }
}

/* =============================================================
   ≤760px (mobile) — drawer, bottom nav, hamburger, sticky first col
   El resto (form grids, touch targets, sticky form actions, table scroll)
   ya está implementado en línea 1322+.
   ============================================================= */
@media (max-width: 760px) {

  /* === Hamburger visible === */
  .ds-menu-toggle { display: flex; }
  .ds-drawer-close { display: flex; }

  /* === Drawer: panel vertical scrolleable (marca + nav + logout) === */
  .ds-sidebar {
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    width: min(300px, 86vw);
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh;
    z-index: 8000;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4, 0, .2, 1);
    border-right: 1px solid var(--line) !important;
    border-bottom: none !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    visibility: hidden;
    pointer-events: none;
  }
  body.ds-menu-open .ds-sidebar {
    transform: translateX(0);
    box-shadow: 0 24px 60px rgba(0,0,0,.25);
    visibility: visible;
    pointer-events: auto;
  }
  body.ds-menu-open { overflow: hidden; }
  body.ds-menu-open .ds-drawer-backdrop {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    pointer-events: auto;
  }

  .ds-sb__brand { display: flex; position: relative; padding-right: 52px; }
  .ds-sb__group { display: block; }
  .ds-sb__foot {
    display: flex;
    flex-direction: column;
    margin-top: auto;
  }

  /* === Sidebar nav: vertical === */
  .ds-sb__nav,
  .ds-sb__nav--quick {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    padding: 4px 12px !important;
    gap: 0 !important;
  }
  .ds-sb__link {
    white-space: normal !important;
    flex-shrink: 0 !important;
    padding: 12px 14px !important;
    font-size: 14.5px !important;
    min-height: 44px !important;
  }

  /* === Bottom nav visible (debajo del drawer/backdrop) === */
  .ds-bottom-nav { display: block; z-index: 40; }

  /* === Stats hero 2-col en mobile === */
  .ds-stats-hero { grid-template-columns: repeat(2, 1fr); }
  .ds-grid-2 { grid-template-columns: 1fr !important; }

  /* === Page: espacio extra para bottom nav + no desborde horizontal === */
  .ds-page {
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 20px)) !important;
    overflow-x: hidden;
  }
  .ds-main { min-width: 0; overflow-x: hidden; }
  .ds-ph__title { white-space: normal !important; font-size: 22px !important; overflow-wrap: anywhere; }
  .ds-ph__title--dia { font-size: 24px !important; }
  .ds-tb__cur {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }

  /* Grids inline de formularios: una columna. No tocar .fc (FullCalendar). */
  .ds-panel__body > [style*="grid-template-columns"],
  .ds-panel__body[style*="grid-template-columns"],
  .ds-cfg-details [style*="grid-template-columns"],
  .ds-page > form [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  /* Filtros de listados a ancho completo */
  .ds-panel__tools { width: 100%; }
  .ds-panel__tools > input,
  .ds-panel__tools > select {
    flex: 1 1 100%;
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
    font-size: 16px !important;
    min-height: 44px;
  }

  /* Inputs sueltos (config, docs): 16px evita zoom de iOS */
  .ds-page input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
  .ds-page select,
  .ds-page textarea {
    font-size: 16px;
    max-width: 100%;
  }

  /* === Sticky first col en .ds-table-wrap + scroll-shadow indicator === */
  .ds-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ds-table-wrap::after {
    content: '';
    position: sticky;
    right: 0; top: 0; bottom: 0;
    width: 32px;
    background: linear-gradient(to right, transparent, var(--surface) 80%);
    pointer-events: none;
  }
  .ds-table-wrap .ds-table th:first-child,
  .ds-table-wrap .ds-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--line);
  }
  .ds-table-wrap .ds-table thead th:first-child {
    z-index: 2;
  }

  /* Odontograma: 8+8 por arcada (cuadrantes) en vez de 16 columnas minúsculas */
  .ds-odontograma { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 14px 10px; }
  .ds-odontograma__arco {
    grid-template-columns: repeat(8, minmax(40px, 1fr));
    min-width: 340px;
    gap: 4px;
  }
  .ds-odontograma__arco:first-of-type::after { display: none; }
  .ds-pieza__estado { display: none; }
  .ds-odon-resumen__th-notas { min-width: 0; }

  /* FullCalendar: toolbar compacta */
  .fc .fc-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .fc .fc-toolbar-title { font-size: 1.05rem !important; }

  /* Modal a hoja inferior, no recortado por el teclado */
  .ds-modal {
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    align-items: end;
  }
  .ds-modal__card {
    width: 100%;
    max-height: min(92dvh, calc(100dvh - 16px));
    border-radius: 16px 16px 12px 12px;
  }
  .ds-modal__body input,
  .ds-modal__body textarea,
  .ds-modal__body select {
    font-size: 16px;
  }

  /* Login */
  .ds-auth {
    align-items: flex-start;
    padding: 28px 16px 24px;
  }
  .ds-auth__card { padding: 24px 18px; }
}

/* =============================================================
   ≤480px (phone pequeño) — ajustes extra
   ============================================================= */
@media (max-width: 480px) {
  .ds-stats-hero { grid-template-columns: 1fr; }
  .ds-grid-4 { grid-template-columns: 1fr; }
  .ds-bottom-nav__label { display: none; }  /* solo icon */
  .ds-minigrid { grid-template-columns: 1fr; }
}
