/* =====================================================================
   Pulso · Cosmos Global Logistics
   Sistema de diseño según el Manual de Identidad Corporativa de Cosmos:
   Azul 1 #001C2C · Azul 2 #00293B · Azul 3 #003D53 · Arena #C8A484 ·
   Gris #CCCFCE · Blanco. Tipografías: Figtree (texto) y Gruppo (marca).
   ===================================================================== */

@font-face { font-family: "Figtree"; src: url("fuentes/figtree.woff2") format("woff2"); font-weight: 300 900; font-display: swap; }
@font-face { font-family: "Gruppo"; src: url("fuentes/gruppo.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  /* Paleta oficial */
  --azul-1: #001c2c;
  --azul-2: #00293b;
  --azul-3: #003d53;
  --arena: #c8a484;
  --gris: #cccfce;
  --blanco: #ffffff;
  /* Derivados de la paleta */
  --azul-4: #165b73;
  --arena-claro: #dcc3aa;
  --arena-tinta: #8a6a45;
  --arena-lavado: #faf5ef;
  --tinta: #0d1f2a;
  --tinta-suave: #2a3b45;
  --apagado: #5b6b74;
  --linea: #e3e7e9;
  --linea-fuerte: #cdd3d6;
  --lienzo: #f4f5f5;
  --lavado: #f2f6f7;
  /* Responsable de la acción (semántica, en tonos de la marca) */
  --cosmos: #b4472c;   --cosmos-fondo: #fbefe9;
  --proveedor: #0e6278; --proveedor-fondo: #e6f2f5;
  --revision: #8a6a45; --revision-fondo: #f8f1e8;
  --ok: #24745a;       --ok-fondo: #e7f4ee;
  --error: #b3261e;    --error-fondo: #fdeceb;
  /* Forma */
  --r-sm: 8px; --r: 12px; --r-lg: 18px; --r-xl: 24px;
  --sombra: 0 1px 2px rgb(0 28 44 / .06), 0 8px 24px rgb(0 28 44 / .06);
  --sombra-alta: 0 24px 60px rgb(0 28 44 / .22);
  --lateral: 268px;
  --fuente: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --marca: "Gruppo", "Figtree", sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--fuente); color: var(--tinta); background: var(--lienzo); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--azul-3); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
small { font-size: 12.5px; color: var(--apagado); }
:focus-visible { outline: 2px solid var(--arena); outline-offset: 2px; }
[hidden], .hidden { display: none !important; }
.icon { width: 18px; height: 18px; flex: none; }
.muted { color: var(--apagado); }
.eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--arena-tinta); }

/* ---------- Botones ---------- */
button { cursor: pointer; }
.btn, button.primary, button.secondary, .link, .clear-filter,
.edit-user, .toggle-user, .unlock-user, .refresh-one, .mail-one, .preview-ticket-email,
.prepare-ticket-email, .send-one-email, .email-cancel, .summary-cancel, .user-cancel {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 700; font-size: 14px; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:active, button.primary:active, button.secondary:active { transform: translateY(1px); }
button:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary, button.primary, .send-one-email { background: var(--azul-3); color: #fff; }
.btn-primary:hover, button.primary:hover, .send-one-email:hover { background: var(--azul-2); }
.btn-gold { background: var(--arena); color: var(--azul-1); }
.btn-gold:hover { background: var(--arena-claro); }
.btn-outline, button.secondary, .edit-user, .toggle-user, .unlock-user, .prepare-ticket-email,
.email-cancel, .summary-cancel, .user-cancel {
  background: #fff; color: var(--azul-3); border-color: var(--linea-fuerte);
}
.btn-outline:hover, button.secondary:hover, .edit-user:hover, .toggle-user:hover, .unlock-user:hover,
.prepare-ticket-email:hover, .email-cancel:hover, .summary-cancel:hover, .user-cancel:hover { border-color: var(--azul-3); background: var(--lavado); }
.btn-ghost, .link, .clear-filter, .preview-ticket-email { background: transparent; color: var(--azul-3); border-color: transparent; padding: 0 10px; }
.btn-ghost:hover, .link:hover, .clear-filter:hover, .preview-ticket-email:hover { background: var(--lavado); }
.btn-danger { background: #fff; color: var(--error); border-color: #f1c4c0; }
.btn-danger:hover { background: var(--error-fondo); }
.btn-sm, .edit-user, .toggle-user, .unlock-user, .preview-ticket-email, .prepare-ticket-email { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.icon-button, .refresh-one, .mail-one {
  display: inline-grid; place-items: center; width: 36px; height: 36px; min-height: 36px; padding: 0;
  border-radius: 9px; border: 1px solid var(--linea); background: #fff; color: var(--azul-3); text-decoration: none;
}
.icon-button:hover, .refresh-one:hover, .mail-one:hover { border-color: var(--azul-3); background: var(--lavado); }
.close, .email-close, .summary-close, .user-close, .history-close {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px;
  background: var(--lavado); color: var(--tinta-suave); font-size: 20px; line-height: 1;
}
.close:hover, .email-close:hover, .summary-close:hover, .user-close:hover, .history-close:hover { background: var(--linea); }

/* ---------- Estructura: barra lateral + espacio de trabajo ---------- */
.app { display: grid; grid-template-columns: var(--lateral) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px;
  padding: 26px 18px 18px; color: #e8eef1; overflow-y: auto;
  background:
    linear-gradient(180deg, rgb(0 28 44 / .72), var(--azul-1) 58%),
    url("marca/cosmos-patron-azul.jpg") center top / 520px auto,
    var(--azul-1);
}
.brand { display: inline-flex; flex-direction: column; gap: 10px; }
.brand img { width: 178px; height: auto; display: block; }
.brand-product { font-family: var(--marca); font-size: 22px; letter-spacing: .5em; color: var(--arena); padding-left: 2px; line-height: 1; }
.sidebar-brand { padding: 4px 8px 18px; border-bottom: 1px solid rgb(255 255 255 / .08); }
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; }
.nav-label { margin: 14px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: rgb(204 207 206 / .55); }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: 11px; background: transparent; color: #cfd8dc; text-align: left;
  font-weight: 600; font-size: 14.5px; text-decoration: none; position: relative;
}
.nav-item:hover { background: rgb(255 255 255 / .06); color: #fff; }
.nav-item.active { background: rgb(200 164 132 / .14); color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: -18px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--arena); }
.nav-item.active .icon { color: var(--arena); }
.nav-item span { flex: 1; }
.tab-count { min-width: 22px; height: 22px; padding: 0 7px; display: inline-grid; place-items: center; border-radius: 99px; background: var(--arena); color: var(--azul-1); font-size: 12px; font-weight: 800; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.sync-card { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: rgb(255 255 255 / .05); border: 1px solid rgb(255 255 255 / .08); }
.sync-card small { display: block; color: rgb(204 207 206 / .7); font-size: 11.5px; }
.sync-card b { display: block; font-size: 13px; font-weight: 600; color: #fff; }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: #5fc29a; box-shadow: 0 0 0 4px rgb(95 194 154 / .18); flex: none; }
.sync-dot.off { background: var(--arena); box-shadow: 0 0 0 4px rgb(200 164 132 / .2); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: rgb(0 0 0 / .18); }
.user-card > div { flex: 1; min-width: 0; }
.user-card b { display: block; font-size: 13.5px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card small { color: rgb(204 207 206 / .7); font-size: 12px; }
.user-card .icon-button { background: transparent; border-color: rgb(255 255 255 / .12); color: #cfd8dc; }
.user-card .icon-button:hover { background: rgb(255 255 255 / .08); color: #fff; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--arena); color: var(--azul-1); font-weight: 800; flex: none; }
.install-app { display: none; align-items: center; justify-content: center; gap: 8px; min-height: 38px; border-radius: 10px; border: 1px dashed rgb(200 164 132 / .5); background: transparent; color: var(--arena); font-weight: 700; font-size: 13px; }
.install-app.show { display: flex; }
.sidebar-scrim { display: none; }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  min-height: 72px; padding: 14px 36px; background: rgb(244 245 245 / .86);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--linea);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 22px; font-weight: 800; }
.topbar-title p { color: var(--apagado); font-size: 13.5px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.menu-button, .topbar-logo { display: none; }
.content { padding: 28px 36px 56px; max-width: 1480px; width: 100%; }

/* ---------- Vistas ---------- */
.view { display: none; animation: aparecer .25s ease; }
.view.active { display: block; }
@keyframes aparecer { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.panel, .chart-card, .recipient-card, .daily-state, .history-card, .settings-card {
  background: #fff; border: 1px solid var(--linea); border-radius: var(--r-lg); box-shadow: var(--sombra);
}
.panel { margin-top: 22px; overflow: hidden; }
.toolbar, .report-heading, .notify-heading, .users-heading {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.panel > .toolbar { padding: 22px 24px 18px; }
.toolbar h2, .report-heading h2, .notify-heading h2, .users-heading h2 { font-size: 20px; font-weight: 800; margin-top: 4px; }
.toolbar p:not(.eyebrow), .report-heading p:not(.eyebrow), .notify-heading p:not(.eyebrow), .users-heading p:not(.eyebrow) { color: var(--apagado); font-size: 13.5px; margin-top: 4px; }
.report-heading, .notify-heading, .users-heading { margin-bottom: 18px; }

/* KPIs */
.cards, .report-kpis, .notify-kpis, .user-stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.cards article, .report-kpis article, .notify-kpis article, .user-stats article {
  position: relative; padding: 18px 20px; background: #fff; border: 1px solid var(--linea); border-radius: var(--r-lg); box-shadow: var(--sombra); overflow: hidden;
}
.cards article::after { content: ""; position: absolute; right: -18px; top: -18px; width: 76px; height: 76px; border-radius: 50%; background: var(--k-fondo, var(--lavado)); }
.cards article span, .report-kpis article span, .notify-kpis article span, .user-stats article span { display: block; font-size: 13px; font-weight: 600; color: var(--apagado); }
.cards article b, .report-kpis article b, .notify-kpis article b, .user-stats article b { display: block; font-size: 34px; font-weight: 800; line-height: 1.1; margin: 6px 0 2px; color: var(--k, var(--azul-1)); font-variant-numeric: tabular-nums; position: relative; z-index: 1; }
.cards article small { position: relative; z-index: 1; }
.cards article.danger { --k: var(--cosmos); --k-fondo: var(--cosmos-fondo); }
.cards article.blue { --k: var(--proveedor); --k-fondo: var(--proveedor-fondo); }
.cards article.amber { --k: var(--revision); --k-fondo: var(--revision-fondo); }
.cards article.green { --k: var(--ok); --k-fondo: var(--ok-fondo); }
.cards article.active-filter { border-color: var(--k, var(--azul-3)); box-shadow: 0 0 0 3px var(--k-fondo, var(--lavado)); }
.cards article[data-owner-filter] { cursor: pointer; }
.cards article[data-owner-filter]:hover { border-color: var(--linea-fuerte); }

/* Filtros */
.filterbar {
  display: grid; gap: 12px; align-items: end; padding: 16px 24px 18px; background: var(--lavado);
  border-top: 1px solid var(--linea); border-bottom: 1px solid var(--linea);
  grid-template-columns: minmax(220px, 2fr) repeat(5, minmax(130px, 1fr)) repeat(2, minmax(140px, 1fr)) auto;
}
.filterbar label, .multi-field, .history-filters label, .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.filterbar label > span, .multi-field > span, .history-filters label > span, .field > span, .field-label {
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--apagado);
}
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], input[type="time"], input[type="url"], input:not([type]), select, textarea {
  width: 100%; min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--linea-fuerte);
  background: #fff; color: var(--tinta); font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
textarea { padding: 10px 12px; min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--azul-3); box-shadow: 0 0 0 3px rgb(0 61 83 / .12); }
input::placeholder { color: #8a979d; }
.search-field input { padding-left: 38px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6b74' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 12px center / 17px no-repeat; }
.clear-filter { align-self: end; min-height: 42px; }

.multi-select { position: relative; }
.multi-select summary {
  list-style: none; display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 10px 0 12px;
  border: 1px solid var(--linea-fuerte); border-radius: 10px; background: #fff; cursor: pointer; font-size: 14px;
}
.multi-select summary::-webkit-details-marker { display: none; }
.multi-select summary b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.multi-select summary i { font-style: normal; color: var(--apagado); }
.multi-select[open] summary { border-color: var(--azul-3); box-shadow: 0 0 0 3px rgb(0 61 83 / .12); }
.filter-icon { color: var(--arena-tinta); font-weight: 800; font-size: 12px; }
.multi-menu {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; min-width: 100%; width: max-content; max-width: 340px; max-height: 320px; overflow: auto;
  padding: 8px; border-radius: 12px; border: 1px solid var(--linea); background: #fff; box-shadow: var(--sombra-alta);
}
.multi-menu label { display: flex !important; flex-direction: row !important; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; font-size: 14px; cursor: pointer; text-transform: none !important; letter-spacing: 0 !important; color: var(--tinta) !important; font-weight: 500 !important; }
.multi-menu label:hover { background: var(--lavado); }
.multi-menu input { width: 16px; height: 16px; min-height: 0; accent-color: var(--azul-3); }
.multi-actions { display: flex; justify-content: space-between; padding: 2px 4px 8px; margin-bottom: 4px; border-bottom: 1px solid var(--linea); }
.multi-actions button { border: 0; background: none; color: var(--azul-3); font-weight: 700; font-size: 13px; padding: 4px 6px; border-radius: 6px; }
.multi-actions button:hover { background: var(--lavado); }

/* Tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; z-index: 2; padding: 12px 16px; background: #fff; text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--apagado); border-bottom: 1px solid var(--linea); white-space: nowrap; }
td { padding: 14px 16px; border-bottom: 1px solid var(--linea); vertical-align: top; font-size: 14px; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fafbfb; }
tbody tr:last-child td { border-bottom: 0; }
td strong { display: block; font-weight: 700; color: var(--azul-1); }
td small { display: block; margin-top: 2px; }
.tickets-table tbody tr { cursor: pointer; }
.tickets-table td:first-child strong { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.sort-button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; }
.sort-button i { font-style: normal; opacity: .45; }
.sort-button.active { color: var(--azul-3); }
.sort-button.active i { opacity: 1; color: var(--arena-tinta); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty, .no-data, .empty-notify { padding: 40px 24px; text-align: center; color: var(--apagado); }
.contact-email, .contact-phone { color: var(--apagado); font-size: 12.5px; }
.internal-code { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 6px; background: var(--arena-lavado); color: var(--arena-tinta); font-size: 12px; font-weight: 700; }

/* Chips */
.status, .chip, .ticket-type, .role-badge, .account-state, .delivery-status, td > .inc, td > .ritm, .priority {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--lavado); color: var(--tinta-suave);
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .55; }
.ticket-type.inc, .type-pill.inc, span.inc { background: #e9f0f3; color: var(--azul-3); }
.ticket-type.ritm, .type-pill.ritm, span.ritm { background: var(--arena-lavado); color: var(--arena-tinta); }
.owner-cosmos, .status.owner-cosmos, [data-owner-chip="cosmos"] { background: var(--cosmos-fondo); color: var(--cosmos); }
.owner-proveedor, [data-owner-chip="proveedor"] { background: var(--proveedor-fondo); color: var(--proveedor); }
.owner-revision, [data-owner-chip="revision"] { background: var(--revision-fondo); color: var(--revision); }
.owner-ninguno, [data-owner-chip="ninguno"] { background: var(--ok-fondo); color: var(--ok); }
.priority.alta, .priority-alta { background: var(--cosmos-fondo); color: var(--cosmos); }
.priority.media, .priority-media { background: var(--revision-fondo); color: var(--revision); }
.priority.baja, .priority-baja { background: var(--ok-fondo); color: var(--ok); }
.role-badge.admin { background: var(--azul-3); color: #fff; }
.account-state.active, .delivery-status.sent, .delivery-status.enviado, .delivery-status.ok { background: var(--ok-fondo); color: var(--ok); }
.account-state.inactive { background: var(--lavado); color: var(--apagado); }
.delivery-status.error, .delivery-status.failed, .delivery-status.fallido { background: var(--error-fondo); color: var(--error); }
.locked { color: var(--error); }

/* Alertas y progreso */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; margin-bottom: 18px; border: 1px solid; font-size: 14px; }
.alert.error { background: var(--error-fondo); border-color: #f3c7c3; color: #7d1a14; }
.alert.success { background: var(--ok-fondo); border-color: #bfe0d2; color: #17523f; }
.alert.info { background: var(--lavado); border-color: var(--linea-fuerte); color: var(--tinta-suave); }
.alert.warn { background: var(--arena-lavado); border-color: #ead9c6; color: #5d4428; }
.alert .icon { margin-top: 1px; }
.progress { margin-bottom: 18px; padding: 14px 18px; border-radius: 14px; background: #fff; border: 1px solid var(--linea); box-shadow: var(--sombra); }
.progress > div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; margin-bottom: 8px; }
.progress progress { width: 100%; height: 8px; border: 0; border-radius: 99px; overflow: hidden; background: var(--lavado); appearance: none; }
.progress progress::-webkit-progress-bar { background: var(--lavado); }
.progress progress::-webkit-progress-value { background: linear-gradient(90deg, var(--azul-3), var(--arena)); border-radius: 99px; }
.progress progress::-moz-progress-bar { background: linear-gradient(90deg, var(--azul-3), var(--arena)); }
.progress.error { border-color: #f3c7c3; background: var(--error-fondo); }
.readonly-notice { padding: 14px 18px; border-radius: 12px; background: var(--arena-lavado); color: #5d4428; border: 1px solid #ead9c6; margin: 16px 0; }

/* Toasts */
.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--azul-1); color: #fff; box-shadow: var(--sombra-alta); font-size: 14px; animation: aparecer .2s ease; }
.toast.error { background: #6e1a14; }
.toast .icon { color: var(--arena); margin-top: 1px; }

/* ---------- Reportes ---------- */
.report-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
.report-grid .wide { grid-column: 1 / -1; }
.chart-card { padding: 20px 22px; }
.chart-card h3, .chart-title { font-size: 16px; font-weight: 800; }
.chart-card > p, .chart-card > small { color: var(--apagado); font-size: 13px; }
.bar-chart, .ranking, .state-type-chart { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.bar-row > div { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; margin-bottom: 5px; }
.bar-row i, .rank-row i { display: block; height: 8px; border-radius: 99px; background: var(--lavado); overflow: hidden; }
.bar-row em, .rank-row em { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--azul-3), var(--azul-4)); }
.rank-row { display: grid; grid-template-columns: 30px 1fr auto; gap: 12px; align-items: center; }
.rank-row b { font-size: 13.5px; font-weight: 600; display: block; margin-bottom: 5px; }
.rank { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--arena-lavado); color: var(--arena-tinta); font-weight: 800; font-size: 13px; }
.type-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.type-card { padding: 16px; border-radius: 14px; background: var(--lavado); }
.type-card span { font-size: 12px; font-weight: 800; letter-spacing: .1em; color: var(--azul-3); }
.type-card.ritm span { color: var(--arena-tinta); }
.type-card.ritm { background: var(--arena-lavado); }
.type-card b { display: block; font-size: 30px; font-weight: 800; color: var(--azul-1); }
.type-track { height: 10px; border-radius: 99px; margin-top: 14px; background: var(--arena); overflow: hidden; }
.type-track i { display: block; height: 100%; background: var(--azul-3); }
.state-type-legend, .legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--apagado); }
.state-type-legend i, .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.state-type-legend i.inc, .stack-track i.inc { background: var(--azul-3); }
.state-type-legend i.ritm, .stack-track i.ritm { background: var(--arena); }
.stack-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 34px; gap: 12px; align-items: center; font-size: 13.5px; }
.stack-track { display: flex; height: 22px; border-radius: 7px; background: var(--lavado); overflow: hidden; }
.stack-track i { display: grid; place-items: center; font-style: normal; font-size: 11.5px; font-weight: 800; color: #fff; min-width: 0; }
.stack-track i.ritm { color: var(--azul-1); }
.stack-row b { text-align: right; }
.donut-layout { display: grid; grid-template-columns: 170px 1fr; gap: 22px; align-items: center; margin-top: 16px; }
.donut { width: 170px; height: 170px; border-radius: 50%; position: relative; }
.donut::after { content: ""; position: absolute; inset: 26px; border-radius: 50%; background: #fff; }
.donut > * { position: relative; z-index: 1; }
.legend { flex-direction: column; gap: 10px; }
.legend > div, .legend > span { display: flex; justify-content: space-between; gap: 12px; color: var(--tinta); }
.monthly-chart { display: flex; align-items: flex-end; gap: 14px; height: 220px; margin-top: 20px; padding: 0 4px; border-bottom: 1px solid var(--linea); overflow-x: auto; }
.month-col { flex: 1; min-width: 44px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; font-size: 12px; color: var(--apagado); }
.month-col b { color: var(--azul-1); font-size: 13px; }
.month-col i { display: block; width: 100%; max-width: 46px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, var(--azul-4), var(--azul-3)); min-height: 4px; }
.month-col span { padding-bottom: 6px; }

/* ---------- Notificaciones ---------- */
.notify-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.recipient-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); margin-top: 16px; }
.recipient-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.recipient-head { display: flex; gap: 12px; align-items: flex-start; }
.recipient-head > div { flex: 1; min-width: 0; }
.recipient-head h3 { font-size: 15.5px; }
.recipient-head a { font-size: 13px; word-break: break-all; }
.recipient-head > b { padding: 3px 10px; border-radius: 99px; background: var(--arena-lavado); color: var(--arena-tinta); font-size: 12px; white-space: nowrap; }
.state-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.state-chips span { padding: 3px 10px; border-radius: 99px; background: var(--lavado); font-size: 12.5px; }
.email-preview summary { cursor: pointer; color: var(--azul-3); font-weight: 700; font-size: 13.5px; }
.email-preview > div { margin-top: 10px; padding: 14px; border-radius: 12px; background: var(--lavado); font-size: 13.5px; display: flex; flex-direction: column; gap: 8px; }
.email-preview h4 { font-size: 13.5px; margin-top: 6px; }
.email-preview ul { margin: 0; padding-left: 18px; }
.ticket-mail-summary { display: block; }
.daily-groups { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.daily-state { overflow: hidden; }
.daily-state-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: var(--lavado); border-bottom: 1px solid var(--linea); }
.daily-state-head h3 { font-size: 15px; }
.daily-state-head span { font-size: 13px; color: var(--apagado); }
.daily-ticket { display: grid; grid-template-columns: 1.4fr 1fr auto auto; gap: 14px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--linea); }
.daily-ticket:last-child { border-bottom: 0; }
.daily-ticket strong { margin: 0 6px; }
.daily-ticket small, .daily-recipient small { display: block; }
.notification-history { margin-top: 22px; }

/* ---------- Usuarios ---------- */
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.access-panel { margin-top: 22px; }
.access-list { display: flex; flex-direction: column; }
.access-list > * { padding: 12px 24px; border-top: 1px solid var(--linea); font-size: 13.5px; }
.permission-check { display: flex !important; flex-direction: row !important; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--lavado); font-weight: 600 !important; text-transform: none !important; letter-spacing: 0 !important; color: var(--tinta) !important; }
.permission-check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--azul-3); }
.invite-note { font-size: 13px; color: var(--apagado); }

/* ---------- Diálogos ---------- */
dialog {
  width: min(720px, calc(100vw - 28px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: var(--r-xl);
  background: #fff; color: var(--tinta); box-shadow: var(--sombra-alta); overflow: auto;
}
dialog[open] { animation: aparecer .2s ease; }
dialog::backdrop { background: rgb(0 28 44 / .55); backdrop-filter: blur(3px); }
dialog > form, dialog > div, dialog > section { padding: 26px 28px; }
dialog h2 { font-size: 20px; font-weight: 800; }
dialog .close, dialog .email-close, dialog .summary-close, dialog .user-close, dialog .history-close { position: absolute; top: 18px; right: 18px; }
.ticket-detail-modal, .history-modal { width: min(980px, calc(100vw - 28px)); }
.detail-grid, .email-readonly-grid, .user-form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin: 18px 0; }
.detail-grid > div, .email-readonly-grid > div { padding: 12px 14px; border-radius: 12px; background: var(--lavado); }
.detail-grid span, .email-readonly-grid span { display: block; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--apagado); }
.detail-grid b, .email-readonly-grid b { display: block; margin-top: 3px; font-weight: 700; word-break: break-word; }
.comment-row { padding: 16px; border-radius: 14px; border: 1px solid var(--linea); white-space: pre-wrap; font-size: 14px; }
.detail-actions, .email-modal-actions, .user-form-grid + div { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.email-modal-heading, .history-modal-head { display: flex; gap: 14px; align-items: center; padding-right: 40px; }
.email-modal-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--arena-lavado); color: var(--arena-tinta); font-size: 22px; flex: none; }
.email-recipient, .email-cc-field, .email-internal-field { margin-top: 14px; }
.email-edit-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; }
.email-preview-head { font-weight: 700; margin-top: 16px; }
.email-error { color: var(--error); font-size: 13.5px; }
.email-footnote, .summary-info, .summary-intro { font-size: 13px; color: var(--apagado); margin-top: 10px; }
.history-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 16px; }
.history-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-top: 16px; padding: 14px; border-radius: 14px; background: var(--lavado); }
.history-filters label { flex: 1 1 140px; }
.history-timeline { display: flex; flex-direction: column; gap: 0; margin-top: 12px; position: relative; }
.history-card { padding: 14px 16px 14px 18px; margin-left: 14px; margin-bottom: 12px; position: relative; box-shadow: none; }
.history-card::before { content: ""; position: absolute; left: -15px; top: 18px; width: 10px; height: 10px; border-radius: 50%; background: var(--arena); box-shadow: 0 0 0 4px var(--arena-lavado); }
.history-timeline::before { content: ""; position: absolute; left: 4px; top: 10px; bottom: 10px; width: 2px; background: var(--linea); }
.history-event-head { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; }
.history-meta, .history-count, .history-baseline { color: var(--apagado); font-size: 12.5px; }
.history-changes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.history-comment { margin-top: 8px; font-size: 13.5px; white-space: pre-wrap; }
.history-table-wrap { max-height: 420px; overflow: auto; border: 1px solid var(--linea); border-radius: 12px; margin-top: 12px; }
.history-loading, .history-empty { padding: 30px; text-align: center; color: var(--apagado); }

/* ---------- Ingreso, instalación y páginas simples ---------- */
.login-body, .page-auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(420px, .95fr); background: var(--lienzo); }
.auth-art {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 48px 56px; color: #fff; overflow: hidden;
  background: linear-gradient(160deg, rgb(0 28 44 / .55), rgb(0 28 44 / .92)), url("marca/cosmos-patron-azul.jpg") center / cover, var(--azul-1);
}
.auth-art .brand img { width: 230px; }
.auth-art .brand-product { font-size: 28px; }
.auth-art h1 { font-size: clamp(30px, 3.4vw, 46px); font-weight: 800; max-width: 520px; letter-spacing: -.02em; line-height: 1.08; }
.auth-art h1 em { font-style: normal; color: var(--arena); }
.auth-art p { margin-top: 14px; max-width: 460px; color: #c9d4d9; font-size: 16px; }
.auth-points { display: flex; flex-direction: column; gap: 12px; margin-top: 30px; }
.auth-points span { display: flex; gap: 12px; align-items: center; color: #e2e9ec; }
.auth-points .icon { color: var(--arena); }
.auth-art small { color: rgb(204 207 206 / .6); }
.auth-side { display: grid; place-items: center; padding: 40px 28px; }
.login-card, .auth-card { width: min(420px, 100%); }
.auth-card .eyebrow { margin-bottom: 8px; }
.auth-card h2, .login-card h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.auth-card > p, .login-card > p { color: var(--apagado); margin-top: 6px; }
.auth-card form, .login-card form { display: flex; flex-direction: column; gap: 16px; margin-top: 26px; }
.auth-card label, .login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 700; color: var(--tinta-suave); }
.auth-card button[type="submit"], .login-card button { min-height: 48px; font-size: 15px; }
.forgot-link { font-size: 13.5px; font-weight: 700; color: var(--azul-3); text-align: center; }
.brand-mark { display: none; }
.steps { display: flex; gap: 8px; margin: 18px 0 4px; }
.steps span { flex: 1; height: 4px; border-radius: 99px; background: var(--linea); }
.steps span.on { background: var(--arena); }
.code-box { display: block; padding: 14px; border-radius: 12px; background: var(--azul-1); color: #e9eef0; font: 12.5px/1.6 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }

/* ---------- Configuración ---------- */
.settings-grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.settings-main { display: flex; flex-direction: column; gap: 18px; }
.settings-card { padding: 22px 24px; }
.settings-card > header { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.settings-card > header .badge-icon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--lavado); color: var(--azul-3); flex: none; }
.settings-card > header .badge-icon.gold { background: var(--arena-lavado); color: var(--arena-tinta); }
.settings-card > header > div { flex: 1; }
.settings-card h2 { font-size: 17px; font-weight: 800; }
.settings-card header p { color: var(--apagado); font-size: 13.5px; margin-top: 3px; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.field small { font-size: 12.5px; }
.secret-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--ok); }
.secret-state.off { color: var(--cosmos); }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; font-size: 14px; }
.switch input { appearance: none; width: 42px; height: 24px; min-height: 0; padding: 0; border-radius: 99px; background: var(--linea-fuerte); position: relative; border: 0; transition: background .15s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgb(0 0 0 / .2); }
.switch input:checked { background: var(--azul-3); }
.switch input:checked::after { transform: translateX(18px); }
.card-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--linea); }
.test-result { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; min-width: 200px; }
.test-result.ok { color: var(--ok); }
.test-result.error { color: var(--error); }
.status-list { display: flex; flex-direction: column; gap: 2px; }
.status-list div { display: flex; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--linea); font-size: 13.5px; }
.status-list div:last-child { border-bottom: 0; }
.status-list b { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.dot.off { background: var(--cosmos); }
.dot.wait { background: var(--arena); }
.settings-aside { position: sticky; top: 96px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .filterbar { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .filterbar .search-field { grid-column: 1 / -1; }
}
@media (max-width: 1100px) {
  .settings-grid { grid-template-columns: 1fr; }
  .settings-aside { position: static; }
  .history-layout { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 60; transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--sombra-alta); }
  .app.menu-open .sidebar { transform: none; }
  .app.menu-open .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgb(0 28 44 / .45); }
  .nav-item.active::before { left: -18px; }
  .menu-button, .topbar-logo { display: inline-grid; }
  .topbar { padding: 12px 18px; min-height: 64px; }
  .topbar-title h1 { font-size: 18px; }
  .topbar-title p { display: none; }
  .content { padding: 20px 16px 48px; }
  .report-grid { grid-template-columns: 1fr; }
  .page-auth, .login-body { grid-template-columns: 1fr; }
  .auth-art { padding: 32px 26px; min-height: 260px; }
  .auth-art .auth-points, .auth-art > small { display: none; }
}
@media (max-width: 720px) {
  .filterbar { grid-template-columns: 1fr 1fr; padding: 14px 16px; }
  .panel > .toolbar { padding: 18px 16px 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .cards article:first-child { grid-column: 1 / -1; }
  .cards article b { font-size: 28px; }
  .donut-layout { grid-template-columns: 1fr; justify-items: center; }
  .daily-ticket { grid-template-columns: 1fr; }
  .topbar-actions .btn span { display: none; }
  /* La tabla de tickets se convierte en tarjetas */
  .tickets-table thead { display: none; }
  .tickets-table, .tickets-table tbody, .tickets-table tr, .tickets-table td { display: block; width: 100%; }
  .tickets-table tr { padding: 14px 16px; border-bottom: 1px solid var(--linea); }
  .tickets-table td { padding: 3px 0; border: 0; }
  .tickets-table .row-actions { justify-content: flex-start; margin-top: 8px; }
  dialog > form, dialog > div, dialog > section { padding: 22px 18px; }
}

/* ---------- Impresión de reportes ---------- */
@media print {
  .sidebar, .topbar, .tabs, #progress, .filterbar, .toasts, .row-actions, button { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .view { display: none !important; }
  .view#reports { display: block !important; }
  .chart-card, .panel, .report-kpis article { box-shadow: none; break-inside: avoid; }
}

/* Aviso usado por la lógica de tickets (notify) */
.pulso-toast { position: fixed; right: 22px; bottom: 22px; z-index: 210; max-width: min(420px, calc(100vw - 32px)); padding: 14px 18px; border-radius: 14px; background: var(--azul-1); color: #fff; box-shadow: var(--sombra-alta); font-size: 14px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s; }
.pulso-toast.show { opacity: 1; transform: none; }
.pulso-toast.error { background: #6e1a14; }
.owner { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.owner::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.owner.cosmos { background: var(--cosmos-fondo); color: var(--cosmos); }
.owner.proveedor { background: var(--proveedor-fondo); color: var(--proveedor); }
.owner.revision { background: var(--revision-fondo); color: var(--revision); }
.owner.ninguno { background: var(--ok-fondo); color: var(--ok); }

/* ---------- Ajustes de revisión visual ---------- */
.chart-title h3 { font-size: 16px; font-weight: 800; }
.chart-title p { font-size: 13px; font-weight: 400; color: var(--apagado); margin-top: 2px; }
.recipient-head a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; word-break: normal; }
.recipient-head small { display: block; }
.smtp-state { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 700; }
.smtp-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.smtp-state.pending { background: var(--arena-lavado); color: var(--arena-tinta); }
.smtp-state.ready { background: var(--ok-fondo); color: var(--ok); }
.recipient-card button:disabled { background: var(--lavado); color: var(--apagado); border: 1px dashed var(--linea-fuerte, #c9d0d3); cursor: not-allowed; }
.access-list > div { display: grid; grid-template-columns: 150px minmax(140px, 220px) 140px 1fr; gap: 16px; align-items: baseline; }
.access-list > div span { color: var(--apagado); font-variant-numeric: tabular-nums; }
.access-list > div em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--azul-3); background: var(--lavado); padding: 2px 8px; border-radius: 99px; justify-self: start; }
.access-list > div small { color: var(--apagado); }
@media (max-width: 720px) { .access-list > div { grid-template-columns: 1fr; gap: 4px; } }

/* ---------- Multiempresa: usuarios, empresas, Google ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 700; color: var(--tinta-suave); }
.field small, .field .muted { font-weight: 500; color: var(--apagado); }
.warn-text { color: var(--arena-tinta) !important; font-weight: 600; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.input-suffix { position: relative; display: block; }
.input-suffix input { width: 100%; padding-right: 48px; }
.input-suffix em { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 12.5px; color: var(--apagado); }
.test-to { max-width: 230px; min-height: 40px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; background: var(--lavado); color: var(--tinta-suave); font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip.company { background: #e9f0f3; color: var(--azul-3); }
.chip.team { background: var(--arena-lavado); color: var(--arena-tinta); }
.role-badge { display: inline-flex; padding: 4px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; background: var(--lavado); color: var(--azul-3); white-space: nowrap; }
.role-badge.ti { background: #e6f2f5; color: var(--proveedor); }
.role-badge.gerente { background: var(--arena-lavado); color: var(--arena-tinta); }
.role-badge.jefe { background: #eef0fb; color: #3b4a9a; }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state.on { color: var(--ok); }
.state.off { color: var(--apagado); }
.state.locked { color: var(--error); }

.person { display: flex; gap: 12px; align-items: flex-start; min-width: 220px; }
.person b { display: block; color: var(--azul-1); }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.person-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.tag { padding: 1px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; background: var(--lavado); color: var(--apagado); }
.tag.auto { background: #e6f2f5; color: var(--proveedor); }
.tag.ext { background: var(--arena-lavado); color: var(--arena-tinta); }
.tag.google { background: #eef3fe; color: #1a5fd0; }
.users-table td { vertical-align: middle; }
.user-filters { grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(150px, 1fr)); }

.team-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); padding: 0 24px 24px; }
.team-card { border: 1px solid var(--linea); border-radius: var(--r-lg); padding: 16px; background: #fff; }
.team-card header { display: flex; gap: 10px; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--linea); }
.team-card header small { display: block; color: var(--apagado); font-size: 12.5px; }
.team-card ul { list-style: none; margin: 10px 0 0; padding: 0; }
.team-card li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0 6px 14px; border-left: 2px solid var(--arena-claro); font-size: 13.5px; }
.team-card li small { color: var(--apagado); }

.user-dialog { width: min(760px, calc(100vw - 28px)); }
.user-dialog h2 { margin-bottom: 18px; padding-right: 40px; }
.grant-box { border: 1px solid var(--linea); border-radius: var(--r); padding: 14px 16px; margin: 16px 0 0; }
.grant-box legend { padding: 0 6px; font-size: 13px; font-weight: 700; color: var(--tinta-suave); }
.grant-box legend small { font-weight: 500; color: var(--apagado); }
.check-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; font-weight: 600; cursor: pointer; padding: 6px 4px; }
.check input { width: 17px; height: 17px; min-height: 0; margin-top: 1px; accent-color: var(--azul-3); flex: none; }
.check small { font-weight: 500; color: var(--apagado); }
.people-list { max-height: 190px; overflow: auto; margin-top: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 2px 10px; }
.people-list .filtered { display: none; }
.grant-box input[type="search"] { width: 100%; }
.user-dialog .form-grid + .form-grid, .user-dialog fieldset + .form-grid { margin-top: 14px; }
.scope-preview { margin-top: 16px; padding: 14px 16px; border-radius: var(--r); background: var(--azul-1); color: #e7eef1; font-size: 13.5px; }
.scope-preview .eyebrow { color: var(--arena); margin-bottom: 6px; }
.scope-preview ul { margin: 0; padding-left: 18px; }
.scope-preview li { margin: 3px 0; }
.scope-preview b { color: #fff; }
.scope-preview .muted { color: #a9bac2; margin-top: 8px; }

.settings-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.settings-tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 99px; background: #fff; border: 1px solid var(--linea); color: var(--tinta-suave); font-weight: 700; font-size: 13.5px; text-decoration: none; }
.settings-tabs a:hover { border-color: var(--azul-3); color: var(--azul-3); }
.settings-tabs .icon { width: 16px; height: 16px; }
.settings-card { scroll-margin-top: 90px; }
.company-list { display: flex; flex-direction: column; gap: 10px; }
.company-item { border: 1px solid var(--linea); border-radius: var(--r-lg); background: #fff; overflow: hidden; }
.company-item[open] { border-color: var(--linea-fuerte); box-shadow: var(--sombra); }
.company-item > summary { list-style: none; display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer; }
.company-item > summary::-webkit-details-marker { display: none; }
.company-item > form { padding: 4px 16px 16px; border-top: 1px solid var(--linea); padding-top: 16px; }
.company-mark { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--azul-1); color: var(--arena); font-weight: 800; font-size: 17px; flex: none; }
.company-mark.plus { background: var(--arena-lavado); color: var(--arena-tinta); }
.company-sum { flex: 1; min-width: 0; }
.company-sum b { display: block; color: var(--azul-1); }
.company-sum small { color: var(--apagado); }
.company-meta { display: flex; gap: 14px; align-items: center; font-size: 12.5px; color: var(--apagado); flex-wrap: wrap; justify-content: flex-end; }
.company-item .chev { font-style: normal; color: var(--apagado); transition: transform .15s; }
.company-item[open] .chev { transform: rotate(180deg); }
.company-item.new { border-style: dashed; }
.company-form .switch { font-size: 13.5px; }
.copy-box { padding: 14px 16px; border-radius: var(--r); background: var(--lavado); margin-bottom: 18px; font-size: 13.5px; }
.copy-box > p { margin: 0 0 8px; color: var(--tinta-suave); }
.copy-box > div { display: grid; grid-template-columns: 190px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; }
.copy-box span { font-weight: 700; color: var(--apagado); font-size: 12.5px; }
.copy-box code { background: #fff; border: 1px solid var(--linea); border-radius: 8px; padding: 6px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.security-note ul { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--tinta-suave); }
.security-note li { margin: 6px 0; }

.btn-google { background: #fff; color: #1f1f1f; border: 1px solid var(--linea-fuerte); min-height: 50px; font-size: 15px; gap: 12px; margin-top: 26px; text-decoration: none; }
.btn-google:hover { background: var(--lavado); border-color: #b9c2c6; }
.password-login { margin-top: 18px; }
.password-login > summary { cursor: pointer; text-align: center; color: var(--apagado); font-size: 13.5px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 12px; }
.password-login > summary::before, .password-login > summary::after { content: ""; flex: 1; height: 1px; background: var(--linea); }
.password-login > summary::-webkit-details-marker { display: none; }
.password-login form { margin-top: 18px !important; }

.company-tag { display: inline-block; margin-top: 6px; padding: 1px 8px; border-radius: 6px; background: var(--azul-1); color: var(--arena); font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.assign-email { display: grid; grid-template-columns: 1fr minmax(200px, 260px) auto; gap: 12px; align-items: center; margin: 4px 0 16px; padding: 14px 16px; border-radius: var(--r); background: var(--arena-lavado); border: 1px solid #ead9c6; }
.assign-email b { display: block; color: #5d4428; }
.assign-email small { display: block; color: var(--apagado); font-size: 12.5px; }
.change-email { margin-top: 4px; min-height: 26px; font-size: 12px; }

@media (max-width: 960px) {
  .form-grid.three, .user-filters { grid-template-columns: 1fr 1fr; }
  .copy-box > div { grid-template-columns: 1fr auto; }
  .copy-box span { grid-column: 1 / -1; }
  .assign-email { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .form-grid, .form-grid.three, .user-filters { grid-template-columns: 1fr; }
  .company-meta { display: none; }
  .users-table thead { display: none; }
  .users-table tr { display: block; padding: 12px 16px; border-bottom: 1px solid var(--linea); }
  .users-table td { display: block; border: 0; padding: 4px 0; }
}

/* ---------- Ajustes de la segunda revisión ---------- */
.row-actions button.details { min-height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--linea-fuerte); background: #fff; color: var(--azul-3); font-weight: 700; font-size: 13px; }
.row-actions button.details:hover { background: var(--lavado); }
.ticket-detail-modal, .history-modal { padding: 28px 30px; }
.ticket-detail-modal > .eyebrow, .ticket-detail-modal > h2 { padding-right: 48px; }
input[type="search"] { min-height: 40px; padding: 0 12px; border: 1px solid var(--linea-fuerte); border-radius: 10px; background: #fff; font: inherit; color: var(--tinta); }
.users-table td { padding: 12px 12px; }
.users-table td:nth-child(2) { max-width: 150px; font-size: 13px; }
.users-table td small.boss { display: block; margin-top: 6px; color: var(--apagado); font-size: 12px; }
.users-table .user-actions { flex-direction: column; align-items: stretch; flex-wrap: nowrap; }
.users-table .user-actions .btn { white-space: nowrap; }
.user-dialog { max-height: calc(100vh - 32px); }
.user-dialog > form { padding-top: 30px; }
.tickets-table th { white-space: normal; padding: 12px; }
.tickets-table td { padding: 14px 12px; }
.tickets-table td:first-child { min-width: 190px; }
.tickets-table td:nth-child(3) { min-width: 200px; }
.tickets-table .contact-email { word-break: break-all; }
.tickets-table td:last-child { width: 1%; white-space: nowrap; }
.ticket-detail-modal > div, .history-modal > div { padding: 0; }
.ticket-detail-modal blockquote { margin: 8px 0 0; padding: 14px 16px; border-left: 3px solid var(--arena); background: var(--arena-lavado); border-radius: 0 12px 12px 0; }
/* Celular y ticket interno siempre visibles y destacados */
.tickets-table .contact-phone { color: var(--tinta-suave); font-weight: 600; }
.tickets-table .internal-code { display: block; width: fit-content; margin-top: 6px; padding: 2px 9px; background: #e9f0f3; color: var(--azul-3); font-size: 12.5px; font-weight: 800; letter-spacing: .01em; }
.company-mail { grid-column: 1 / -1; }
.company-mail [data-smtp-custom] { margin-top: 12px; }
.ip-list { max-width: 170px; text-align: right; word-break: break-all; font-size: 12px; }
[hidden] { display: none !important; }

/* Estado de sincronización (arriba a la derecha) */
.sync-status { display: flex; align-items: center; gap: 6px; margin-left: 8px; flex-wrap: wrap; justify-content: flex-end; }
.sync-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px; background: #fff; border: 1px solid var(--linea); font-size: 12px; color: var(--apagado); white-space: nowrap; }
.sync-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-fondo); }
.sync-chip.old i { background: var(--arena); box-shadow: 0 0 0 3px var(--arena-lavado); }
.sync-chip b { color: var(--azul-1); font-weight: 700; }
.sync-now { width: 34px; height: 34px; }
.sync-now .icon { width: 17px; height: 17px; }
.sync-now:disabled .icon { animation: girar 1s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .sync-status { order: 10; width: 100%; justify-content: flex-start; margin: 8px 0 0; }
  .sync-now { margin-left: auto; }
}

/* ---------- Revisión final ---------- */
/* Filtros: se acomodan al ancho sin salirse */
.filterbar:not(.user-filters) { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(auto-fill, minmax(140px, 1fr)); gap: 12px 14px; align-items: end; }
.filterbar .multi-select summary b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Tabla de tickets: entra en el panel; columnas más justas */
.tickets-table { width: 100%; table-layout: auto; }
.tickets-table td:first-child { min-width: 170px; max-width: 230px; }
.tickets-table td:nth-child(3) { min-width: 180px; max-width: 240px; }
.tickets-table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.tickets-table .row-actions .mail-one, .tickets-table .row-actions .refresh-one { width: 32px; height: 32px; }
.table-wrap { overflow-x: auto; }
/* Gráfico mensual más compacto */
.monthly-chart { min-height: 0; height: 190px; }
/* Dona: número al centro y leyenda alineada */
.donut > span { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.donut > span b { font-size: 28px; color: var(--azul-1); }
.donut > span small { font-size: 12px; color: var(--apagado); }
.legend > div { display: grid !important; grid-template-columns: 12px 1fr auto; align-items: center; gap: 10px; }
.legend > div span { text-align: left; }
.legend i { margin: 0 !important; }
/* Celular: tarjeta de ticket más compacta */
@media (max-width: 720px) {
  .tickets-table tbody tr { display: grid !important; grid-template-columns: auto auto auto 1fr; gap: 8px 6px; padding: 16px !important; align-items: center; }
  .tickets-table tbody td { display: block; padding: 0 !important; border: 0 !important; min-width: 0 !important; max-width: none !important; }
  .tickets-table tbody td:nth-child(1), .tickets-table tbody td:nth-child(3) { grid-column: 1 / -1; }
  .tickets-table tbody td:nth-child(2) { display: none !important; }
  .tickets-table tbody td:nth-child(7) { grid-column: 1 / 4; font-size: 12.5px; color: var(--apagado); }
  .tickets-table tbody td:nth-child(8) { grid-column: 4; justify-self: end; }
}
/* El tipo (INC/RITM) ya está en el número: se oculta la columna para ganar espacio */
.tickets-table th:nth-child(2), .tickets-table td:nth-child(2) { display: none; }
@media (max-width: 720px) {
  .filterbar:not(.user-filters) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .filterbar:not(.user-filters) > :first-child { grid-column: 1 / -1; }
  .filterbar .multi-select, .filterbar input[type=date] { min-width: 0; width: 100%; }
}
.welcome-empty { display: flex; gap: 18px; align-items: center; padding: 24px 26px; margin-bottom: 18px; border-radius: var(--r-lg); background: linear-gradient(120deg, var(--azul-1), var(--azul-3)); color: #dfe8ec; box-shadow: var(--sombra); }
.welcome-empty h2 { color: #fff; font-size: 19px; margin: 0 0 6px; }
.welcome-empty p { margin: 0; font-size: 14px; color: #c3d0d6; }

/* ---------- Panel lateral del ticket ---------- */
dialog.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(560px, 100vw); max-width: 100vw; border-radius: 22px 0 0 22px; padding: 0 28px 28px; overflow-y: auto; }
dialog.drawer[open] { animation: deslizar .26s cubic-bezier(.2, .8, .2, 1); }
dialog.drawer.switching[open] { animation: none; }
@keyframes deslizar { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
dialog.drawer::backdrop { background: rgb(0 28 44 / .38); backdrop-filter: blur(2px); }
.drawer-bar { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; margin: 0 -28px 18px; padding: 14px 20px; background: rgb(255 255 255 / .94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--linea); }
dialog.drawer .drawer-bar .close { position: static; }
.drawer-nav { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--apagado); }
.drawer-nav .icon-button { font-size: 20px; line-height: 1; }
.drawer-nav .icon-button:disabled { opacity: .35; cursor: default; }
dialog.drawer h2 { font-size: 22px; line-height: 1.25; padding-right: 0 !important; }
.drawer-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 16px; align-items: center; }
.drawer-chips .internal-code { margin: 0; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.contact-btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--linea-fuerte); background: #fff; color: var(--azul-3); font-weight: 700; font-size: 13.5px; text-decoration: none; }
.contact-btn:hover { background: var(--lavado); }
.contact-btn span { font-size: 14px; }
.contact-btn.wa span { color: #25a35a; }
dialog.drawer .detail-grid { grid-template-columns: 1fr 1fr; }
dialog.drawer h3 { margin-top: 22px; }
.recent-list { display: flex; flex-direction: column; gap: 2px; }
.recent-item { display: grid; grid-template-columns: 14px 1fr; gap: 10px; padding: 8px 0; }
.recent-item i { width: 10px; height: 10px; margin-top: 4px; border-radius: 50%; background: var(--arena); box-shadow: 0 0 0 3px var(--arena-lavado); }
.recent-item:first-child i { background: var(--azul-3); box-shadow: 0 0 0 3px #e3edf1; }
.recent-item b { display: block; font-size: 13.5px; color: var(--azul-1); }
.recent-item span { font-size: 12.5px; color: var(--apagado); }
dialog.drawer .detail-actions { position: sticky; bottom: -28px; margin: 22px -28px -28px; padding: 14px 28px; background: #fff; border-top: 1px solid var(--linea); display: flex; justify-content: flex-end; gap: 10px; }
#rows tr { cursor: pointer; transition: background .12s; }
#rows tr:hover { background: #f7f9fa; }
#rows tr.is-open { background: var(--arena-lavado); box-shadow: inset 3px 0 0 var(--arena); }
@media (max-width: 720px) {
  dialog.drawer { width: 100vw; height: 92vh; margin: auto 0 0 0; border-radius: 22px 22px 0 0; }
  @keyframes deslizar { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
}
.drawer-bar { padding: 12px 24px; }
.btn-google + .btn-google { margin-top: 10px; }
.guest-link { margin-top: 22px; text-align: center; font-size: 13.5px; }
.guest-link a { color: var(--arena-tinta); font-weight: 700; }
.or-sep { display: flex; align-items: center; gap: 12px; margin: 18px 0 4px; color: var(--apagado); font-size: 13px; }
.or-sep::before, .or-sep::after { content: ""; flex: 1; height: 1px; background: var(--linea); }
.code-input { font-size: 26px !important; letter-spacing: 10px; text-align: center; font-variant-numeric: tabular-nums; }
.check.remember { margin: 6px 0 4px; font-weight: 600; }
@media (max-width: 960px) {
  .auth-art { min-height: auto; padding-bottom: 36px; }
  .auth-art > div { margin-top: 48px; }
  .auth-side { padding: 32px 24px 48px; place-items: start center; }
}

/* Ticket interno y celular a mano (admin y TI) */
.ticket-data-toggle { margin: -4px 0 12px; font-size: 12.5px; min-height: 30px; }
.ticket-data { grid-template-columns: 1fr; }
.ticket-data-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ticket-data-fields label span { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--apagado); margin-bottom: 4px; }
.ticket-data-fields input { width: 100%; }
.ticket-data-actions { display: flex; justify-content: flex-end; gap: 8px; }
.detail-grid b.is-empty { color: var(--apagado); font-weight: 500; font-style: italic; }
/* Comentarios del portal en texto con saltos de línea */
.ticket-detail-modal blockquote, #emailComment { white-space: pre-line; overflow-wrap: anywhere; }
.recent-list a { color: inherit; font-weight: 600; }
@media (max-width: 560px) { .ticket-data-fields { grid-template-columns: 1fr; } }

.ticket-data-toggle { display: inline-flex; align-items: center; gap: 6px; border: 1px dashed #d8c2a6 !important; background: var(--arena-lavado) !important; color: #5d4428 !important; border-radius: 999px; padding: 0 14px !important; font-weight: 600; }
.ticket-data-toggle:hover { border-style: solid !important; }
/* Contraseña del proveedor */
.secret-box { margin: 8px 0 0; }
.secret-box #mSecretShow { border: 1px dashed #d8c2a6; border-radius: 999px; padding: 0 14px; font-weight: 600; color: #5d4428; background: var(--arena-lavado); }
.secret-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--lavado); margin-top: 6px; }
.secret-row code { font-size: 15px; font-weight: 700; letter-spacing: .04em; user-select: all; overflow-wrap: anywhere; }
.secret-box small { display: block; color: var(--apagado); font-size: 12px; margin-top: 4px; }

/* Filtros v2: lo principal a la vista, el resto en «Más filtros» */
.filterbar.filterbar-v2 { display: block; padding: 16px 24px 14px; }
.filter-main { display: grid; gap: 12px 14px; align-items: end; grid-template-columns: minmax(260px, 2.4fr) repeat(auto-fit, minmax(150px, 1fr)); }
.filter-main > .filter-buttons { display: flex; align-items: end; }
.filter-more { display: grid; gap: 12px 14px; align-items: end; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--linea); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.filter-more[hidden], .period-custom[hidden] { display: none !important; }
.filterbar-v2 select { width: 100%; }
.more-filters { white-space: nowrap; height: 40px; display: inline-flex; align-items: center; gap: 8px; }
.more-filters::after { content: "⌄"; font-size: 12px; transition: transform .2s; }
.more-filters.open::after { transform: rotate(180deg); }
.more-filters em { font-style: normal; font-size: 11px; font-weight: 800; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--azul-1); color: #fff; display: inline-grid; place-items: center; }
.filter-chips { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.filter-chips[hidden] { display: none; }
#chipList { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 11px; border-radius: 999px; background: #fff; border: 1px solid var(--linea); font-size: 12.5px; font-weight: 600; color: var(--azul-1); }
.chip button { border: 0; background: transparent; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; color: var(--apagado); font-size: 11px; min-height: 0; padding: 0; }
.chip button:hover { background: var(--lavado); color: var(--azul-1); }
.multi-search { width: calc(100% - 4px); margin: 2px 2px 6px; height: 34px; }
.multi-menu label small { display: block; font-size: 11px; color: var(--apagado); font-weight: 500; }
.multi-menu label[hidden] { display: none; }
.cards article[data-owner-filter] { transition: transform .15s, box-shadow .15s, border-color .15s; }
.cards article[data-owner-filter]:focus-visible { outline: 2px solid var(--azul-3); outline-offset: 2px; }
.cards article.active { border-color: var(--k, var(--azul-1)); box-shadow: 0 0 0 2px var(--k, var(--azul-1)) inset, 0 8px 20px rgba(0, 28, 44, .08); transform: translateY(-2px); }
@media (max-width: 760px) {
  .filter-main { grid-template-columns: 1fr 1fr; }
  .filter-main .search-field { grid-column: 1 / -1; }
  .filter-main > .filter-buttons { grid-column: 1 / -1; }
  .filter-main > .filter-buttons .more-filters { width: 100%; justify-content: center; }
  .filter-more { grid-template-columns: 1fr 1fr; }
  .filter-chips { flex-direction: column; align-items: flex-start; }
}
.secret-main { flex: 1; min-width: 0; }
.secret-main small { display: block; font-size: 11.5px; color: var(--apagado); margin-top: 2px; }
