/* =========================================================
   Cierres Unificados - RestoSoft
   Paleta: azules de marca (logo) + tonos de la version anterior
   ========================================================= */

:root {
  /* Marca */
  --brand-900: #00415C;
  --brand-800: #00557A;
  --brand-700: #00668F;   /* hover / texto sobre fondos claros */
  --brand-600: #0077A8;   /* primario (contraste AA con blanco) */
  --brand-500: #0080B3;   /* azul del logo */
  --brand-400: #2CB0D1;   /* celeste del logo */
  --brand-300: #51A3CB;   /* azul medio del logo */
  --brand-200: #CDE2EE;   /* encabezados de tabla (version anterior) */
  --brand-100: #E5EEF2;   /* filas alternas (version anterior) */
  --brand-50:  #F2F8FB;
  --focus:     #4D9AF2;   /* borde del menu anterior, ahora anillo de foco */

  /* Neutros */
  --ink-900: #0F1C24;
  --ink-700: #33444F;
  --ink-500: #5B6B76;
  --ink-400: #8496A1;
  --line:    #DCE5EA;
  --line-soft: #EBF1F4;
  --surface: #FFFFFF;
  --bg:      #F4F7F9;

  /* Estados */
  --success: #13795B;  --success-bg: #E3F5EE;
  --warning: #9A5B00;  --warning-bg: #FDF1DC;
  --danger:  #B42318;  --danger-bg:  #FDECEA;

  /* Canales de venta (paleta validada para daltonismo) */
  --ch-mesas:    #00668F;
  --ch-delivery: #1FA5C9;
  --ch-take:     #D9822B;

  /* Formas de pago (paleta validada para daltonismo, distinta de los canales) */
  --pg-efectivo: #2E8B57;
  --pg-tarjeta:  #6F55C4;
  --pg-mp:       #C4508A;
  --pg-otros:    #A07A1F;

  /* Escala */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 28, 36, .06);
  --shadow:    0 1px 3px rgba(15, 28, 36, .06), 0 4px 16px rgba(15, 28, 36, .06);
  --shadow-lg: 0 10px 40px rgba(0, 65, 92, .18);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

/* El atributo hidden siempre gana sobre el display de los componentes */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-900);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--brand-600); }
a:hover { color: var(--brand-800); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 40px; height: 40px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 100;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--brand-600); color: #fff; text-decoration: none;
}
.skip-link:focus { top: 12px; color: #fff; }

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--ink-500); }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.topbar::before {
  content: ""; display: block; height: 3px;
  background: linear-gradient(90deg, var(--brand-500), var(--brand-400));
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; height: 60px;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  color: var(--ink-900); text-decoration: none;
}
.brand:hover { color: var(--ink-900); }
.brand img { width: 36px; height: 36px; border-radius: 9px; }
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.1; }
.brand-sub { display: block; font-size: 12px; font-weight: 500; color: var(--ink-500); }

/* Menu principal */
.mainnav { display: flex; align-items: center; gap: 4px; margin-right: auto; margin-left: 24px; }
.mainnav-link {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 12px;
  border-radius: var(--radius-sm); color: var(--ink-700); font-size: 14px; font-weight: 600; text-decoration: none;
  transition: background-color .15s, color .15s;
}
.mainnav-link:hover { background: var(--brand-50); color: var(--brand-800); }
.mainnav-link.is-active { background: var(--brand-100); color: var(--brand-800); }

.userbar { display: flex; align-items: center; gap: 8px; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--brand-50);
  color: var(--ink-700); font-weight: 500; font-size: 14px;
}
.avatar {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-600); color: #fff;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
}

/* ---------- Contenido ---------- */
.page { flex: 1; padding: 32px 0 48px; }

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  flex-wrap: wrap; gap: 16px; margin-bottom: 24px;
}
.page-title { font-size: 24px; font-weight: 700; }
.page-sub { margin-top: 4px; color: var(--ink-500); }

.breadcrumb {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  margin: 0 0 6px; padding: 0; list-style: none;
  font-size: 13px; color: var(--ink-500);
}
.breadcrumb li { display: flex; align-items: center; gap: 4px; }
.breadcrumb a, .breadcrumb span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 6px; margin: 0 -2px; border-radius: var(--radius-sm);
}
.breadcrumb a { color: var(--brand-600); font-weight: 500; text-decoration: none; }
.breadcrumb a:hover { background: var(--brand-100); color: var(--brand-800); }
.breadcrumb .icon { width: 14px; height: 14px; }
.breadcrumb .sep { color: var(--ink-400); }
.breadcrumb [aria-current] { color: var(--ink-900); font-weight: 600; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-body { padding: 20px 24px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 24px; border-bottom: 1px solid var(--line-soft);
}
.card-title { font-size: 16px; font-weight: 600; }

.stack > * + * { margin-top: 20px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; font-weight: 600;
  text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); color: #fff; }
.btn-primary:active { background: var(--brand-800); }
.btn-ghost { background: transparent; color: var(--ink-700); border-color: var(--line); }
.btn-ghost:hover { background: var(--brand-50); color: var(--brand-800); border-color: var(--brand-200); }
.btn-block { width: 100%; min-height: 44px; }
.btn[disabled] { opacity: .7; cursor: progress; }
.btn .spin { display: none; }
.btn.is-loading .spin { display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-700); }
.input, .select {
  width: 100%; height: 42px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink-900);
  font: inherit; font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.input:hover, .select:hover { border-color: var(--ink-400); }
.input:focus, .select:focus {
  outline: none; border-color: var(--brand-600);
  box-shadow: 0 0 0 3px rgba(77, 154, 242, .3);
}
.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B6B76' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
.static-value {
  display: flex; align-items: center; gap: 8px;
  min-height: 42px; padding: 9px 12px;
  border-radius: var(--radius-sm); background: var(--brand-50);
  color: var(--ink-900); font-weight: 500;
}
.static-value .icon { color: var(--brand-600); }

.input-group { position: relative; }
.input-group .input { padding-right: 48px; }
.input-action {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--ink-500); cursor: pointer;
}
.input-action:hover { background: var(--brand-50); color: var(--brand-700); }

.filters .btn { min-height: 42px; }
.filters { display: grid; gap: 16px; align-items: end; }
.filters-cierres { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 170px 170px auto; }
.filters-grupo { grid-template-columns: 190px 190px auto; justify-content: start; }
/* Campos de fecha: iOS y Android les imponen ancho minimo, alto y alineacion propios */
input[type="date"].input {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; min-width: 0; max-width: 100%;
  line-height: 22px; text-align: left; cursor: text;
}
input[type="date"].input::-webkit-date-and-time-value { text-align: left; margin: 0; }
input[type="date"].input::-webkit-datetime-edit { padding: 0; }
input[type="date"].input::-webkit-calendar-picker-indicator { margin-left: 4px; opacity: .6; cursor: pointer; }

/* Periodos rapidos */
.presets {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line-soft);
}
.chip {
  display: inline-flex; align-items: center; min-height: 34px; padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink-700);
  font-size: 13px; font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--brand-300); background: var(--brand-50); color: var(--brand-800); }
.chip.is-active { border-color: var(--brand-600); background: var(--brand-600); color: #fff; }
.chip.is-active:hover { background: var(--brand-700); color: #fff; }

/* ---------- Alertas ---------- */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: 14px;
}
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert .icon { margin-top: 1px; }

/* ---------- Login ---------- */
.auth {
  flex: 1; display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh;
}
.auth-brand {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px;
  background:
    radial-gradient(circle at 85% 15%, rgba(44, 176, 209, .55), transparent 45%),
    linear-gradient(150deg, var(--brand-500) 0%, var(--brand-800) 60%, var(--brand-900) 100%);
  color: #fff;
}
.auth-brand::after {
  content: ""; position: absolute; right: -80px; bottom: -80px;
  width: 360px; height: 360px; border-radius: 48px; transform: rotate(18deg);
  background: rgba(255, 255, 255, .06);
}
.auth-logo { display: flex; align-items: center; gap: 14px; font-weight: 700; font-size: 18px; }
.auth-logo img { width: 48px; height: 48px; border-radius: 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }
.auth-pitch { position: relative; z-index: 1; max-width: 440px; }
.auth-pitch h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }
.auth-pitch p { margin-top: 14px; font-size: 16px; color: rgba(255, 255, 255, .85); }
.auth-features { margin: 28px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.auth-features li { display: flex; align-items: center; gap: 12px; color: rgba(255, 255, 255, .92); }
.auth-features .icon {
  width: 34px; height: 34px; padding: 8px; border-radius: 9px;
  background: rgba(255, 255, 255, .14);
}
.auth-foot { position: relative; z-index: 1; font-size: 13px; color: rgba(255, 255, 255, .7); }
.auth-foot a { color: #fff; }

.auth-panel { display: grid; place-items: center; padding: 48px 24px; background: var(--surface); }
.auth-form { width: 100%; max-width: 380px; }
.auth-form h2 { font-size: 24px; font-weight: 700; }
.auth-form .lead { margin: 6px 0 28px; color: var(--ink-500); }
.auth-form .field + .field { margin-top: 16px; }
.auth-form .btn-block { margin-top: 24px; }
.auth-form .alert { margin-bottom: 20px; }

/* ---------- Seleccion de grupo ---------- */
.choice-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px;
}
.choice {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 18px 18px; text-align: left;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm);
  font: inherit; color: var(--ink-900); text-decoration: none; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.choice:hover { color: var(--ink-900); border-color: var(--brand-300); box-shadow: var(--shadow); transform: translateY(-1px); }
.choice-icon {
  display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 10px; background: var(--brand-100); color: var(--brand-700);
}
.choice-name { flex: 1; font-weight: 600; }
.choice > .icon { color: var(--ink-400); }

/* ---------- Acceso destacado (informe del grupo) ---------- */
.feature {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 24px; margin-bottom: 28px;
  border-radius: var(--radius-lg);
  background: linear-gradient(120deg, var(--brand-600), var(--brand-500) 55%, var(--brand-400));
  color: #fff; text-decoration: none; box-shadow: var(--shadow);
  transition: box-shadow .15s, transform .15s;
}
.feature:hover { color: #fff; box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.feature-icon {
  display: grid; place-items: center; width: 48px; height: 48px; flex-shrink: 0;
  border-radius: 12px; background: rgba(255, 255, 255, .18);
}
.feature-text { flex: 1; display: flex; flex-direction: column; }
.feature-title { font-size: 17px; font-weight: 700; }
.feature-sub { font-size: 14px; color: rgba(255, 255, 255, .88); }

.section-title { margin-bottom: 12px; font-size: 15px; font-weight: 600; color: var(--ink-700); }

/* ---------- Ranking (barras horizontales) ---------- */
.bar-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.bar-row {
  display: grid; grid-template-columns: minmax(110px, 200px) 1fr minmax(150px, auto);
  align-items: center; gap: 16px; font-size: 14px;
}
.bar-name { color: var(--ink-900); font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-name:hover { color: var(--brand-700); text-decoration: underline; }
.bar-track { display: block; height: 14px; }
.bar { display: block; height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--brand-600); }
.bar-value { text-align: right; font-weight: 600; }

/* ---------- Subtabla del detalle por dia ---------- */
.subtable-wrap {
  overflow-x: auto; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line-soft);
}
.subtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.subtable th, .subtable td { padding: 8px 14px; white-space: nowrap; }
.subtable th {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-500); text-align: left; border-bottom: 1px solid var(--line-soft);
}
.subtable th .swatch { display: inline-block; margin-right: 4px; vertical-align: 0; }
.subtable td { border-bottom: 1px solid var(--line-soft); color: var(--ink-700); }
.subtable td a { font-weight: 600; text-decoration: none; }
.subtable td a:hover { text-decoration: underline; }
.subtable .right { text-align: right; }
.subtable .strong { color: var(--ink-900); font-weight: 600; }
.subtable tfoot td { border-bottom: 0; background: var(--brand-50); color: var(--ink-900); font-weight: 700; }
/* La primera columna queda fija al desplazar la subtabla */
.subtable th:first-child, .subtable td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.subtable tfoot td:first-child { background: var(--brand-50); }

/* ---------- Resumen (ultimo cierre) ---------- */
.summary { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; }
.stat { padding: 20px 24px; container-type: inline-size; }
.stat-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--ink-500);
}
.stat-label .icon { width: 16px; height: 16px; color: var(--brand-600); }
.stat-value { margin-top: 8px; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
/* El importe se achica segun el ancho de su tarjeta para entrar siempre en un renglon */
@container (max-width: 260px) {
  .stat-value.num { font-size: clamp(18px, 10.5cqi, 28px); }
}
.stat-meta { margin-top: 2px; font-size: 13px; color: var(--ink-500); }

.split { margin-top: 18px; }
.split-bar {
  display: flex; gap: 2px; height: 10px; border-radius: 4px; overflow: hidden;
  background: var(--line-soft);
}
.split-seg { height: 100%; min-width: 2px; }
.legend {
  display: flex; flex-wrap: wrap; gap: 8px 20px;
  margin: 12px 0 0; padding: 0; list-style: none; font-size: 13px;
}
.legend li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--ink-700); }
.legend strong { color: var(--ink-900); font-weight: 600; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.ch-mesas    { background: var(--ch-mesas); }
.ch-delivery { background: var(--ch-delivery); }
.ch-take     { background: var(--ch-take); }
.pg-efectivo { background: var(--pg-efectivo); }
.pg-tarjeta  { background: var(--pg-tarjeta); }
.pg-mp       { background: var(--pg-mp); }
.pg-otros    { background: var(--pg-otros); }

.stat-wide { grid-column: 1 / -1; }
.stat-empty { margin-top: 10px; color: var(--ink-500); font-size: 14px; }
.partial { display: inline-flex; align-items: center; gap: 4px; color: var(--warning); }
.partial .icon { width: 14px; height: 14px; }
.detail-empty { font-size: 13px; color: var(--ink-500); }
.kv .swatch { display: inline-block; width: 8px; height: 8px; margin-right: 4px; }
.day-pagos {
  margin-top: 12px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line-soft);
}
.day-pagos .detail-head { margin-bottom: 0; flex-wrap: wrap; }
.day-pagos .detail-head .muted { font-weight: 400; }
.day-pagos .split { margin-top: 10px; }

/* ---------- Tabla de cierres ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table > thead > tr > th {
  padding: 10px 16px; text-align: left; white-space: nowrap;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--brand-800); background: var(--brand-100);
  border-bottom: 1px solid var(--brand-200);
}
.table > tbody > tr > td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table .right { text-align: right; }
.table .col-toggle { width: 48px; padding-right: 0; }

.row-main { cursor: pointer; transition: background-color .12s; }
.row-main:hover { background: var(--brand-50); }
.row-main.is-open { background: var(--brand-50); }
.row-main.is-open td { border-bottom-color: transparent; }
.row-main .total { font-weight: 700; }
.cierre-id { font-weight: 600; color: var(--ink-500); }
.cell-meta { display: none; margin-top: 2px; font-size: 12px; font-weight: 400; color: var(--ink-500); }
.cell-meta .pv-tag { margin-left: 4px; }

.pv-tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--brand-100); color: var(--brand-800);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.turno { font-weight: 600; }

.toggle {
  display: grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink-500); cursor: pointer;
  transition: transform .2s, background-color .15s, color .15s;
}
.toggle:hover { color: var(--brand-700); border-color: var(--brand-200); }
.toggle[aria-expanded="true"] { transform: rotate(90deg); color: var(--brand-700); background: var(--brand-100); }
.toggle .icon { width: 16px; height: 16px; }

.table > tbody > .row-detail > td { padding: 0 16px 20px; background: var(--brand-50); border-bottom: 1px solid var(--line); }
.detail { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
/* Fila 1: los tres canales; fila 2: otros y formas de pago */
.detail-block { grid-column: span 2; }
.detail-block:nth-child(n+4) { grid-column: span 3; }
.detail-block {
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line-soft);
}
.detail-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  font-size: 13px; font-weight: 600; color: var(--ink-700);
}
.detail-head .icon { width: 15px; height: 15px; color: var(--brand-600); }
.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv th { padding: 0 0 4px; font-size: 11px; font-weight: 600; color: var(--ink-400); text-align: right; text-transform: uppercase; letter-spacing: .04em; }
.kv th:first-child { text-align: left; }
.kv td { padding: 3px 0; text-align: right; color: var(--ink-700); }
.kv td:first-child { text-align: left; color: var(--ink-500); white-space: nowrap; }
.kv tr.kv-total td { padding-top: 6px; border-top: 1px solid var(--line-soft); color: var(--ink-900); font-weight: 600; }

.table-foot {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 12px 24px; font-size: 13px; color: var(--ink-500);
}

/* ---------- Estado vacio ---------- */
.empty { padding: 56px 24px; text-align: center; }
.empty-icon {
  display: inline-grid; place-items: center; width: 72px; height: 72px; margin-bottom: 16px;
  border-radius: 50%; background: var(--brand-100); color: var(--brand-600);
}
.empty h2 { font-size: 18px; font-weight: 600; }
.empty p { max-width: 420px; margin: 6px auto 0; color: var(--ink-500); }
.empty-action { margin-top: 20px; }

/* ---------- Pie ---------- */
.footer { border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  padding-top: 16px; padding-bottom: 16px; font-size: 13px; color: var(--ink-500);
}
.footer a { color: var(--ink-500); text-decoration: none; }
.footer a:hover { color: var(--brand-700); text-decoration: underline; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .summary { grid-template-columns: 1fr 1fr; }
  .summary .stat-main { grid-column: 1 / -1; }
  .detail { grid-template-columns: 1fr 1fr; }
  .detail-block, .detail-block:nth-child(n+4) { grid-column: auto; }
  .detail-block:nth-child(3) { grid-column: 1 / -1; }
  .filters-cierres { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters-cierres .btn { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .hide-md { display: none; }
  .cell-meta:not(.cell-meta-sm) { display: block; }
  .subtable-wrap, .day-pagos { max-width: calc(100vw - 100px); }
}

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-brand { padding: 28px 24px; }
  .auth-pitch h1 { font-size: 24px; }
  .auth-features, .auth-foot, .auth-brand::after { display: none; }
  .auth-panel { place-items: start center; padding-top: 32px; }
}

@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .page { padding-top: 20px; }
  .page-title { font-size: 20px; }
  .card-body, .stat { padding: 16px; }
  .card-header, .table-foot { padding-left: 16px; padding-right: 16px; }
  .filters, .filters-grupo { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* 16px evita que iOS haga zoom al tocar un campo */
  .input, .select { font-size: 16px; }
  input[type="date"].input { padding-left: 10px; padding-right: 8px; }
  .filters .field-wide, .filters .btn { grid-column: 1 / -1; }
  .presets { flex-wrap: nowrap; overflow-x: auto; margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .summary { grid-template-columns: 1fr; }
  .detail { grid-template-columns: 1fr; }
  .detail-block, .detail-block:nth-child(3), .detail-block:nth-child(n+4) { grid-column: auto; }
  .stat-value { font-size: 24px; }
  .user-name, .btn-label { display: none; }
  .user-chip { padding-right: 4px; }
  .brand-sub { display: none; }
  /* En celular el menu queda en iconos */
  .mainnav { margin-left: 8px; gap: 2px; }
  .mainnav-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .mainnav-link { padding: 8px 10px; }
  .hide-sm { display: none; }
  .cell-meta-sm { display: block; }

  /* Objetivos tactiles de al menos 36-40px */
  .chip { min-height: 40px; }
  .toggle { width: 36px; height: 36px; }
  .table .col-toggle { width: 44px; }
  .breadcrumb a, .breadcrumb span { min-height: 36px; }
  .bar-name { display: flex; align-items: center; min-height: 36px; }
  .subtable td a { display: inline-flex; align-items: center; min-height: 36px; min-width: 40px; }
  .footer a { display: inline-block; padding: 10px 0; }
  /* Indica que los periodos rapidos siguen hacia la derecha */
  .presets { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .presets.at-end { -webkit-mask-image: none; mask-image: none; }
  /* La subtabla se desplaza dentro de su recuadro sin ensanchar la tabla principal */
  .subtable-wrap, .day-pagos { max-width: calc(100vw - 84px); }
  .bar-row { grid-template-columns: 1fr auto; gap: 4px 12px; }
  .bar-track { grid-column: 1 / -1; grid-row: 2; }
  .feature { padding: 16px; }
  .table > thead > tr > th, .table > tbody > tr > td { padding-left: 10px; padding-right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Celulares angostos: las fechas no entran lado a lado sin cortar el año */
@media (max-width: 400px) {
  .filters, .filters-grupo { grid-template-columns: minmax(0, 1fr); }
}

/* =========================================================
   Informe desde Excel (prueba)
   ========================================================= */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 40px 24px; border: 2px dashed var(--brand-200); border-radius: var(--radius-lg);
  background: var(--brand-50); cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--brand-600); background: var(--brand-100); }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.dropzone-icon {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  background: var(--surface); color: var(--brand-600); box-shadow: var(--shadow-sm);
}
.dropzone-title { font-size: 16px; font-weight: 600; color: var(--ink-900); }
.dropzone-title u { color: var(--brand-600); text-underline-offset: 3px; }
.dropzone-sub { max-width: 460px; font-size: 13px; color: var(--ink-500); }
.dropzone-actions { display: flex; justify-content: center; margin-top: 16px; }
#xl-error { margin-top: 16px; }

.alert-warning { background: var(--warning-bg); color: var(--warning); }

.xl-local { margin: 4px 0 2px; font-size: 22px; font-weight: 700; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.stat-value-text { font-size: 20px; line-height: 1.3; overflow-wrap: anywhere; }

.segmented { display: inline-flex; padding: 3px; border-radius: var(--radius-sm); background: var(--brand-50); border: 1px solid var(--line); }
.seg {
  min-height: 32px; padding: 4px 14px; border: 0; border-radius: 4px; background: transparent;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-500); cursor: pointer;
}
.seg:hover { color: var(--brand-800); }
.seg.is-active { background: var(--surface); color: var(--brand-700); box-shadow: var(--shadow-sm); }

.chart-box { position: relative; width: 100%; }
.xl-insight { margin-bottom: 12px; color: var(--ink-700); }
.xl-insight strong { color: var(--ink-900); }

.xl-tops { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.xl-tops .bar-row { grid-template-columns: minmax(120px, 1.3fr) 1fr auto; }
.bar-rank {
  display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 8px; flex-shrink: 0;
  border-radius: 50%; background: var(--brand-100); color: var(--brand-700); font-size: 11px; font-weight: 700;
}
span.bar-name { display: flex; align-items: center; min-width: 0; }

.xl-detalle-head { flex-wrap: wrap; }
.xl-buscar { width: 260px; max-width: 100%; }
.xl-sin-resultados { padding: 20px 24px; }
.cell-meta-inline { display: block; font-size: 12px; color: var(--ink-500); }
.xl-subgrupo td {
  padding-top: 12px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--brand-700); background: var(--brand-50);
}
.xl-productos td:first-child { white-space: normal; min-width: 180px; }

@media (max-width: 900px) {
  .xl-tops { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .dropzone { padding: 28px 16px; }
  .xl-buscar { width: 100%; }
  .xl-tops .bar-row { grid-template-columns: 1fr auto; }
  .xl-productos td:first-child { min-width: 0; }
  .seg { min-height: 36px; }
}

/* Columnas por rubro: con muchos rubros el grafico se desliza en pantallas angostas */
.chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart-box-cols { height: 420px; }

/* Clasificacion ABC (escala de un solo tono: A oscuro -> C claro) */
.abc { display: grid; gap: 10px; margin: 4px 0 20px; }
.abc-fila { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 12px; }
.abc-titulo { font-size: 13px; font-weight: 600; color: var(--ink-700); }
.abc-barra { display: flex; gap: 2px; height: 30px; border-radius: 6px; overflow: hidden; background: var(--line-soft); }
.abc-seg {
  display: flex; align-items: center; justify-content: center; gap: 4px; min-width: 2px;
  font-size: 12px; white-space: nowrap; overflow: hidden;
}
.abc-a { background: var(--brand-800); color: #fff; }
.abc-b { background: var(--brand-400); color: var(--ink-900); }
.abc-c { background: var(--brand-200); color: var(--ink-900); }

.abc-grupos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.abc-grupo { padding: 14px 16px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--surface); }
.abc-grupo-head { display: flex; align-items: center; gap: 10px; }
.abc-grupo-head strong { display: block; font-size: 14px; }
.abc-chip {
  display: grid; place-items: center; width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 8px; font-weight: 700; font-size: 14px;
}
.abc-rango { display: block; font-size: 12px; color: var(--ink-500); }
.abc-datos { display: grid; gap: 2px; margin-top: 10px; font-size: 13px; color: var(--ink-500); }
.abc-datos strong { color: var(--ink-900); }
.abc-lista { margin-top: 10px; font-size: 13px; }
.abc-lista summary {
  display: inline-flex; align-items: center; min-height: 36px;
  color: var(--brand-600); font-weight: 600; cursor: pointer;
}
.abc-lista summary:hover { color: var(--brand-800); }
.abc-lista ul { max-height: 260px; overflow-y: auto; margin: 4px 0 0; padding: 0 4px 0 0; list-style: none; }
.abc-lista li {
  display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: baseline;
  padding: 5px 0; border-bottom: 1px solid var(--line-soft);
}
.abc-n { color: var(--ink-400); font-size: 12px; text-align: right; }

@media (max-width: 900px) {
  .abc-grupos { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .chart-box-cols { height: 320px; }
  .abc-fila { grid-template-columns: 1fr; gap: 4px; }
}

/* Celulares angostos: en la barra superior queda solo el logo para que entre el menu */
@media (max-width: 400px) {
  .brand-name { display: none; }
}
