/* ═══════════════════════════════════════════════════════════════════════════
   Tandil Shoes — Panel
   Sistema visual estilo iOS/macOS: materiales translúcidos, elevación por
   sombras multicapa, esquinas continuas, y movimiento en todo lo que cambia
   de estado. Los nombres de clase son un contrato con el JS de las vistas:
   se pueden reestilar, no renombrar.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Paleta del sistema (iOS light) */
  --bg: #f2f2f7;              /* systemGroupedBackground */
  --bg-sunk: #e9e9ef;         /* fondo hundido: tracks, celdas de encabezado */
  --panel: #ffffff;
  --panel-2: #fbfbfd;         /* superficie secundaria dentro de un panel */
  --ink: #1c1c1e;             /* label */
  --ink-2: #3c3c43;           /* secondaryLabel */
  --muted: #6c6c70;           /* tertiaryLabel — oscurecido para pasar contraste AA */
  --hair: rgba(60, 60, 67, .13);   /* separator: translúcido, como iOS */
  --hair-solid: #e5e5ea;
  --accent: #1c1c1e;
  --volt: #007aff;            /* systemBlue */
  --volt-soft: rgba(0, 122, 255, .12);
  --good: #248a3d;
  --good-bg: rgba(52, 199, 89, .14);
  --warn: #b25000;
  --warn-bg: rgba(255, 149, 0, .16);
  --bad: #d70015;
  --bad-bg: rgba(255, 59, 48, .13);

  --radius: 16px;             /* esquinas continuas, generosas */
  --radius-sm: 10px;
  --radius-lg: 22px;

  /* Elevación: siempre en capas — una sombra de contacto, una de profundidad */
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px -6px rgba(0, 0, 0, .08);
  --shadow-lift: 0 2px 6px rgba(0, 0, 0, .06), 0 14px 36px -10px rgba(0, 0, 0, .16);
  --shadow-float: 0 12px 28px -6px rgba(0, 0, 0, .18), 0 40px 80px -20px rgba(0, 0, 0, .28);

  /* Movimiento: la curva de iOS. Rápido al salir, suave al asentar. */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --t: .22s var(--ease);
  --t-fast: .14s var(--ease);

  --sidebar-w: 258px;
}

[data-theme="dark"] {
  --bg: #000000;
  --bg-sunk: #1c1c1e;
  --panel: #1c1c1e;           /* systemGray6 dark */
  --panel-2: #2c2c2e;
  --ink: #f2f2f7;
  --ink-2: #d1d1d6;
  --muted: #8e8e93;
  --hair: rgba(84, 84, 88, .5);
  --hair-solid: #38383a;
  --accent: #f2f2f7;
  --volt: #0a84ff;
  --volt-soft: rgba(10, 132, 255, .2);
  --good: #30d158;
  --good-bg: rgba(48, 209, 88, .16);
  --warn: #ff9f0a;
  --warn-bg: rgba(255, 159, 10, .16);
  --bad: #ff453a;
  --bad-bg: rgba(255, 69, 58, .16);

  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 6px 20px -6px rgba(0, 0, 0, .6);
  --shadow-lift: 0 2px 8px rgba(0, 0, 0, .5), 0 16px 40px -12px rgba(0, 0, 0, .7);
  --shadow-float: 0 20px 60px -10px rgba(0, 0, 0, .8);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
/* `hidden` tiene que ganarle a display:flex/grid, si no el login queda visible arriba del panel. */
[hidden] { display: none !important; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--volt); text-decoration: none; transition: opacity var(--t-fast); }
a:hover { opacity: .7; }

::selection { background: var(--volt-soft); }

/* Scrollbars finas, al estilo del sistema */
* { scrollbar-width: thin; scrollbar-color: var(--hair-solid) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--hair-solid); border-radius: 20px; }
*::-webkit-scrollbar-track { background: transparent; }

/* Foco visible para el teclado, invisible para el mouse. */
:focus-visible { outline: 3px solid var(--volt-soft); outline-offset: 2px; border-radius: 6px; }

/* ══════════════════════════════════════════════════════════════
   Login
   ══════════════════════════════════════════════════════════════ */
.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(90% 60% at 15% 0%, rgba(10, 132, 255, .28), transparent 60%),
    radial-gradient(70% 60% at 90% 100%, rgba(191, 90, 242, .22), transparent 55%),
    #0b0b0f;
}
.login-box {
  /* Vidrio esmerilado: el material de iOS. */
  background: rgba(255, 255, 255, .07);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  border: 1px solid rgba(255, 255, 255, .12);
  padding: 36px 32px;
  border-radius: var(--radius-lg);
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-float);
  display: flex; flex-direction: column; gap: 15px;
  color: #f2f2f7;
  animation: pop-in .5s var(--ease-out) both;
}
.login-brand { font-size: 27px; font-weight: 700; letter-spacing: -.03em; }
.login-brand span {
  background: linear-gradient(120deg, #0a84ff, #64d2ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-sub { color: rgba(235, 235, 245, .6); font-size: 13.5px; margin-bottom: 8px; }
.login-box label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; font-weight: 600; color: rgba(235, 235, 245, .6);
  letter-spacing: 0;
}
.login-box input {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
  color: #fff;
  padding: 12px 14px;
  font-size: 15px;
}
.login-box input:focus {
  background: rgba(255, 255, 255, .13);
  border-color: var(--volt);
  outline: none;
  box-shadow: 0 0 0 4px rgba(10, 132, 255, .25);
}
.login-box .btn-primary {
  background: var(--volt); color: #fff; border-color: transparent;
  padding: 13px; font-size: 15px; margin-top: 4px;
  box-shadow: 0 6px 18px -4px rgba(10, 132, 255, .5);
}
.login-box .btn-primary:hover { background: #339dff; }
.login-error { color: #ff6961; font-size: 13px; min-height: 18px; }

@keyframes pop-in {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
}

/* ══════════════════════════════════════════════════════════════
   Layout
   ══════════════════════════════════════════════════════════════ */
#app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--hair);
  display: flex; flex-direction: column;
  padding: 20px 12px 14px;
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  z-index: 40;
}

.brand {
  font-size: 19px; font-weight: 700; letter-spacing: -.03em;
  padding: 2px 12px 20px; display: flex; align-items: center; gap: 9px;
}
.brand span {
  background: linear-gradient(120deg, var(--volt), #64d2ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; padding-bottom: 8px; }

#nav button {
  position: relative;
  background: none; border: 0; text-align: left;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-size: 14px; font-weight: 500;
  cursor: pointer; font-family: inherit;
  display: flex; align-items: center; gap: 11px;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
#nav button svg { width: 19px; height: 19px; flex-shrink: 0; opacity: .75; transition: opacity var(--t-fast); }
#nav button:hover { background: var(--bg-sunk); color: var(--ink); }
#nav button:hover svg { opacity: 1; }
#nav button:active { transform: scale(.975); }
#nav button.active {
  background: var(--volt); color: #fff; font-weight: 600;
  box-shadow: 0 4px 12px -3px rgba(0, 122, 255, .45);
}
#nav button.active svg { opacity: 1; }
#nav .nav-sep {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 16px 12px 6px; font-weight: 600;
}
#nav button .badge {
  margin-left: auto; background: var(--bad); color: #fff;
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px;
  font-variant-numeric: tabular-nums;
}
#nav button.active .badge { background: rgba(255, 255, 255, .25); color: #fff; }

.sidebar-foot {
  border-top: 1px solid var(--hair); padding-top: 12px; margin-top: auto;
  display: flex; align-items: center; gap: 4px;
}
.user { flex: 1; font-size: 12px; overflow: hidden; padding-left: 8px; }
.user b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user span { color: var(--muted); }

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

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--hair);
  /* Barra translúcida: el contenido se ve pasar por debajo. */
  background: color-mix(in srgb, var(--panel) 72%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 21px; font-weight: 700; letter-spacing: -.025em; min-width: 0; }
.topbar-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }

/* Hamburguesa: solo existe cuando la barra lateral se esconde. */
#menu-btn {
  display: none;
  background: none; border: 0; cursor: pointer; color: var(--ink);
  padding: 7px; border-radius: 9px; line-height: 0;
  transition: background var(--t-fast), transform var(--t-fast);
}
#menu-btn:hover { background: var(--bg-sunk); }
#menu-btn:active { transform: scale(.92); }

/* Velo detrás del cajón lateral en pantallas chicas. */
#scrim {
  position: fixed; inset: 0; z-index: 39;
  background: rgba(0, 0, 0, .4);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t);
}

.content { padding: 26px 28px 72px; animation: view-in .32s var(--ease-out) both; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
}

/* ══════════════════════════════════════════════════════════════
   Botones — con respuesta física al presionar
   ══════════════════════════════════════════════════════════════ */
.btn {
  border: 1px solid var(--hair-solid);
  background: var(--panel); color: var(--ink);
  padding: 9px 15px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; letter-spacing: -.01em;
  cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), border-color var(--t-fast), opacity var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-sunk); border-color: var(--muted); box-shadow: var(--shadow); }
.btn:active { transform: scale(.96); box-shadow: none; }

.btn-primary {
  background: var(--volt); color: #fff; border-color: transparent;
  box-shadow: 0 2px 8px -2px rgba(0, 122, 255, .5);
}
.btn-primary:hover { background: #2b90ff; border-color: transparent; box-shadow: 0 6px 18px -4px rgba(0, 122, 255, .55); }

.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: transparent; }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); }

.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }

.btn-ghost {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 13px; font-weight: 500; padding: 7px 9px; border-radius: 8px;
  font-family: inherit;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.btn-ghost:hover { background: var(--bg-sunk); color: var(--ink); }
.btn-ghost:active { transform: scale(.94); }

.btn:disabled, .btn[disabled] { opacity: .45; pointer-events: none; }

/* ══════════════════════════════════════════════════════════════
   Campos
   ══════════════════════════════════════════════════════════════ */
input, select, textarea {
  font-family: inherit; font-size: 14px;
  padding: 9px 12px;
  border: 1px solid var(--hair-solid);
  border-radius: 10px;
  background: var(--panel); color: var(--ink);
  width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  -webkit-appearance: none; appearance: none;
}
select {
  /* Chevron propio: el nativo rompe la estética en cada plataforma. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8a8e' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
  padding-right: 32px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--volt);
  box-shadow: 0 0 0 3.5px var(--volt-soft);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }

input[type="checkbox"], input[type="radio"] { width: auto; }

label.field {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0;
}

/* Interruptor iOS: para cualquier checkbox marcado con .switch */
input[type="checkbox"].switch {
  appearance: none; -webkit-appearance: none;
  width: 50px; height: 30px; border-radius: 20px;
  background: var(--bg-sunk); border: 0;
  position: relative; cursor: pointer; flex-shrink: 0;
  transition: background .26s var(--ease);
}
input[type="checkbox"].switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .22);
  transition: transform .26s var(--ease);
}
input[type="checkbox"].switch:checked { background: #34c759; }
input[type="checkbox"].switch:checked::after { transform: translateX(20px); }

/* ══════════════════════════════════════════════════════════════
   Cards y paneles
   ══════════════════════════════════════════════════════════════ */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px; }

.card {
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  padding: 17px 19px;
  box-shadow: var(--shadow);
  transition: transform var(--t), box-shadow var(--t);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.card .k { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.card .v {
  font-size: 28px; font-weight: 700; letter-spacing: -.035em; margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.card .sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.card .sub.up { color: var(--good); font-weight: 600; }
.card .sub.down { color: var(--bad); font-weight: 600; }

.panel {
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 22px;
}
.panel-head {
  padding: 15px 19px; border-bottom: 1px solid var(--hair);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.panel-head h2 { font-size: 16px; font-weight: 700; letter-spacing: -.02em; }
.panel-body { padding: 19px; }

/* ══════════════════════════════════════════════════════════════
   Tablas — listas agrupadas
   ══════════════════════════════════════════════════════════════ */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11.5px;
  color: var(--muted); font-weight: 600; letter-spacing: 0;
  padding: 11px 18px; border-bottom: 1px solid var(--hair);
  background: var(--panel-2);
  position: sticky; top: 0; z-index: 1;
  white-space: nowrap;
}
td { padding: 12px 18px; border-bottom: 1px solid var(--hair); font-size: 14px; vertical-align: middle; }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: var(--volt-soft); cursor: pointer; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.thumb {
  width: 42px; height: 42px; border-radius: 10px; object-fit: cover;
  background: var(--bg-sunk); flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}
.cell-prod { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-prod b { display: block; font-weight: 600; }
.cell-prod span { color: var(--muted); font-size: 12.5px; }

/* ══════════════════════════════════════════════════════════════
   Chips
   ══════════════════════════════════════════════════════════════ */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0;
  padding: 4px 10px; border-radius: 20px;
  background: var(--bg-sunk); color: var(--ink-2); white-space: nowrap;
}
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad  { background: var(--bad-bg);  color: var(--bad); }
.chip.info { background: var(--volt-soft); color: var(--volt); }

/* ══════════════════════════════════════════════════════════════
   Toolbar
   ══════════════════════════════════════════════════════════════ */
.toolbar { display: flex; gap: 9px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar input[type="search"] {
  max-width: 300px; border-radius: 20px; padding-left: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%238a8a8e' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 12px center;
}
.toolbar select { width: auto; min-width: 140px; }
.toolbar .spacer { flex: 1; }

/* ══════════════════════════════════════════════════════════════
   Modal — hoja que sube (celular) / tarjeta que aparece (escritorio)
   ══════════════════════════════════════════════════════════════ */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .42);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 18px;
  z-index: 100; overflow-y: auto;
  animation: fade-in .2s var(--ease) both;
}
@keyframes fade-in { from { opacity: 0; } }

.modal {
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 640px;
  box-shadow: var(--shadow-float);
  overflow: hidden;
  animation: modal-in .34s var(--ease-out) both;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(20px) scale(.96); }
}
.modal.wide { max-width: 940px; }
.modal-head {
  padding: 18px 22px; border-bottom: 1px solid var(--hair);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.modal-head h3 { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.modal-body { padding: 22px; max-height: 66vh; overflow-y: auto; }
.modal-foot {
  padding: 15px 22px; border-top: 1px solid var(--hair);
  display: flex; justify-content: flex-end; gap: 9px;
  background: var(--panel-2);
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid .full { grid-column: 1 / -1; }

/* ══════════════════════════════════════════════════════════════
   Toasts
   ══════════════════════════════════════════════════════════════ */
#toasts {
  position: fixed; bottom: 22px; right: 22px;
  display: flex; flex-direction: column; gap: 9px; z-index: 200;
}
.toast {
  background: rgba(28, 28, 30, .82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid rgba(255, 255, 255, .1);
  color: #fff;
  padding: 12px 18px; border-radius: 14px;
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-float);
  animation: toast-in .38s var(--ease-out) both;
}
.toast.bad { background: rgba(215, 0, 21, .9); }
.toast.good { background: rgba(36, 138, 61, .92); }
@keyframes toast-in {
  from { transform: translateY(14px) scale(.94); opacity: 0; }
}

/* ══════════════════════════════════════════════════════════════
   Varias
   ══════════════════════════════════════════════════════════════ */
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty b { display: block; font-size: 16px; color: var(--ink); margin-bottom: 5px; font-weight: 600; }

.loading { padding: 48px; text-align: center; color: var(--muted); }
/* La espera respira, no se queda dura. */
.loading::after {
  content: ''; display: block; width: 22px; height: 22px; margin: 14px auto 0;
  border: 2.5px solid var(--hair-solid); border-top-color: var(--volt);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

.split { display: grid; grid-template-columns: 2fr 1fr; gap: 22px; align-items: start; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 1fr 60px; gap: 10px; align-items: center; font-size: 13.5px; }
.bar-track { height: 8px; background: var(--bg-sunk); border-radius: 20px; overflow: hidden; grid-column: 1 / -1; }
.bar-fill { height: 100%; background: var(--volt); border-radius: 20px; transition: width .5s var(--ease-out); }

.variant-row {
  display: grid; grid-template-columns: 1fr 100px 90px 80px 36px; gap: 9px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--hair);
}
.variant-row:last-child { border-bottom: 0; }
.variant-row input { padding: 7px 10px; font-size: 13px; border-radius: 8px; }

/* ══════════════════════════════════════════════════════════════
   Gráficos
   ══════════════════════════════════════════════════════════════ */
.chart { display: grid; grid-template-columns: 50px 1fr; grid-template-rows: 1fr 20px; gap: 5px; }
.chart-y {
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end;
  font-size: 11px; color: var(--muted); padding-right: 7px; font-variant-numeric: tabular-nums;
}
.chart-plot { position: relative; }
.chart-svg { width: 100%; height: 100%; overflow: visible; }
.chart-svg .grid { stroke: var(--hair); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-x { grid-column: 2; display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.chart-dots { position: absolute; inset: 0; }
.chart-dots .dot {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 50%; background: var(--panel); border: 2.5px solid var(--volt);
  opacity: 0; transition: opacity var(--t-fast), transform var(--t-fast);
}
.chart-plot:hover .dot { opacity: 1; }
.chart-dots .dot:hover { opacity: 1; transform: scale(1.4); z-index: 3; }
.chart-dots .tip {
  display: none; position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: rgba(28, 28, 30, .9);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: #fff; padding: 6px 10px; border-radius: 9px; font-size: 11.5px;
  white-space: nowrap; z-index: 5; text-align: center; line-height: 1.35;
  box-shadow: var(--shadow-lift);
}
.chart-dots .tip b { display: block; font-size: 13px; }
.chart-dots .dot:hover .tip { display: block; }

.bars-h { display: flex; flex-direction: column; gap: 10px; }
.bar-h { display: grid; grid-template-columns: 145px 1fr 92px; gap: 12px; align-items: center; font-size: 13px; }
.bar-h-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.bar-h-track { height: 10px; background: var(--bg-sunk); border-radius: 20px; overflow: hidden; }
.bar-h-fill { height: 100%; border-radius: 20px; transition: width .55s var(--ease-out); min-width: 3px; }
.bar-h-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.cols { display: flex; align-items: flex-end; gap: 6px; height: 195px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; min-width: 0; }
.col-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.col-bar {
  width: 100%; border-radius: 7px 7px 3px 3px; min-height: 2px; position: relative;
  transition: height .55s var(--ease-out), filter var(--t-fast);
}
.col-bar:hover { filter: brightness(1.12) saturate(1.1); }
.col-tip {
  display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: rgba(28, 28, 30, .9);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: #fff; padding: 4px 9px; border-radius: 7px; font-size: 11px;
  white-space: nowrap; margin-bottom: 6px; box-shadow: var(--shadow);
}
.col-bar:hover .col-tip { display: block; }
.col-label { font-size: 11px; color: var(--muted); white-space: nowrap; }

.pie-wrap { display: grid; grid-template-columns: 180px 1fr; gap: 24px; align-items: center; }
.pie { width: 180px; height: 180px; }
.pie path, .pie circle { transition: filter var(--t-fast); }
.pie path:hover, .pie circle:hover { filter: brightness(1.1) saturate(1.1); }
.pie-total { font-size: 13px; font-weight: 700; fill: var(--ink); font-family: inherit; }
.pie-sub { font-size: 6px; fill: var(--muted); font-family: inherit; }
.pie-legend { display: flex; flex-direction: column; gap: 8px; }
.pie-item { display: grid; grid-template-columns: 12px 1fr auto 42px; gap: 10px; align-items: center; font-size: 13px; }
.pie-dot { width: 12px; height: 12px; border-radius: 4px; }
.pie-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pie-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.pie-pct { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.funnel { display: flex; flex-direction: column; gap: 14px; }
.funnel-step { display: grid; grid-template-columns: 1fr 195px; gap: 16px; align-items: center; }
.funnel-bar {
  height: 42px; border-radius: 11px;
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 13px; min-width: 64px;
  transition: width .6s var(--ease-out), filter var(--t-fast);
  box-shadow: 0 3px 10px -3px rgba(0, 0, 0, .25);
}
.funnel-bar:hover { filter: brightness(1.08); }
.funnel-n { color: #fff; font-weight: 700; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.funnel-label b { display: block; font-size: 13.5px; font-weight: 600; }
.funnel-drop { font-size: 12px; color: var(--bad); font-weight: 600; }

/* Control segmentado, como el de iOS */
.metric-tabs {
  display: flex; gap: 2px; background: var(--bg-sunk);
  padding: 3px; border-radius: 11px;
}
.metric-tabs button {
  border: 0; background: none; padding: 7px 15px; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--ink-2); font-family: inherit;
  transition: background var(--t), color var(--t), box-shadow var(--t), transform var(--t-fast);
  white-space: nowrap;
}
.metric-tabs button:active { transform: scale(.95); }
.metric-tabs button.on {
  background: var(--panel); color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 3px 8px -3px rgba(0, 0, 0, .12);
}

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ══════════════════════════════════════════════════════════════
   ADAPTACIÓN A PANTALLAS
   Tres tamaños de verdad, no uno con parches:
     · Escritorio  > 1024px  — barra lateral fija
     · Tablet   641–1024px  — barra lateral en cajón, contenido a lo ancho
     · Celular     ≤ 640px  — cajón + una columna, controles gordos
   ══════════════════════════════════════════════════════════════ */

/* ── Tablet y celular: la barra lateral se vuelve un cajón que entra desde el borde ── */
@media (max-width: 1024px) {
  #app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 292px; max-width: 86vw;
    transform: translateX(-100%);
    transition: transform .34s var(--ease-out);
    /* Material translúcido: se ve el contenido detrás, como en iPadOS. */
    background: color-mix(in srgb, var(--panel) 88%, transparent);
    backdrop-filter: saturate(180%) blur(30px);
    -webkit-backdrop-filter: saturate(180%) blur(30px);
    box-shadow: var(--shadow-float);
    padding-top: max(20px, env(safe-area-inset-top));
  }
  body.nav-abierto .sidebar { transform: translateX(0); }
  body.nav-abierto #scrim { opacity: 1; pointer-events: auto; }
  body.nav-abierto { overflow: hidden; }

  #menu-btn { display: inline-flex; }

  .chart-grid { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .pie-wrap { grid-template-columns: 160px 1fr; gap: 18px; }
  .topbar { padding: 14px 20px; }
  .content { padding: 22px 20px 72px; }
}

/* ── Celular ── */
@media (max-width: 640px) {
  body { font-size: 15px; }   /* leer en la mano pide un punto más */

  .topbar { padding: 12px 16px; gap: 8px; }
  .topbar h1 { font-size: 19px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn { padding: 8px 12px; font-size: 13px; }

  .content { padding: 18px 16px 90px; }

  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px 15px; border-radius: 14px; }
  .card .v { font-size: 23px; }
  .card:hover { transform: none; }   /* no hay hover en un dedo */

  .form-grid { grid-template-columns: 1fr; }

  /* Las tablas no se achican: se deslizan de costado, con el ritmo del sistema. */
  .panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .panel-body { padding: 15px; }
  th, td { padding: 11px 14px; white-space: nowrap; }

  /* Los controles se agrandan: el dedo necesita 44px. */
  .btn { padding: 11px 16px; }
  .btn-sm { padding: 8px 12px; }
  input, select, textarea { padding: 11px 13px; font-size: 16px; }  /* 16px evita que iOS haga zoom al tocar */
  .toolbar input[type="search"] { max-width: none; flex: 1 1 100%; }
  .toolbar select { flex: 1; min-width: 0; }

  #nav button { padding: 12px 13px; font-size: 15.5px; }

  .modal-bg { padding: 0; align-items: flex-end; }
  /* En el celular el modal es una hoja que sube desde abajo, pegada al borde. */
  .modal {
    max-width: none; border-radius: 20px 20px 0 0;
    max-height: 92vh; display: flex; flex-direction: column;
    animation: sheet-up .38s var(--ease-out) both;
  }
  @keyframes sheet-up { from { transform: translateY(100%); } }
  .modal-body { max-height: none; flex: 1; padding: 18px; }
  .modal-foot { padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }

  #toasts { left: 14px; right: 14px; bottom: 14px; }
  .toast { text-align: center; }

  .pie-wrap { grid-template-columns: 1fr; justify-items: center; }
  .funnel-step { grid-template-columns: 1fr; gap: 6px; }
  .bar-h { grid-template-columns: 100px 1fr 76px; gap: 8px; font-size: 12.5px; }
  .chart { grid-template-columns: 42px 1fr; }
  .variant-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric-tabs { overflow-x: auto; }
}

/* Quien pidió menos movimiento, recibe menos movimiento. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ══════════════════════════════════════════════════════════════
   Integraciones — hub de tarjetas con logo de marca
   ══════════════════════════════════════════════════════════════ */
.int-section { margin-bottom: 28px; }
.int-section-head { display: flex; align-items: baseline; gap: 10px; margin: 0 2px 12px; }
.int-section-head h2 { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.int-section-head .int-count { font-size: 12px; color: var(--muted); font-weight: 500; }

.int-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }

.int-card {
  background: var(--panel); border: 1px solid var(--hair); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 17px 18px;
  display: flex; flex-direction: column; gap: 12px;
  transition: transform var(--t), box-shadow var(--t);
}
.int-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }

.int-head { display: flex; align-items: center; gap: 12px; }
.int-logo {
  width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0;
  display: grid; place-items: center;
  box-shadow: 0 4px 10px -3px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.18);
}
.int-logo svg { width: 26px; height: 26px; display: block; }
.int-head-txt { min-width: 0; flex: 1; }
.int-head-txt b { display: block; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.int-head-txt .int-sub { font-size: 12px; color: var(--muted); }
.int-body { font-size: 13px; color: var(--ink-2); line-height: 1.5; flex: 1; }
.int-actions { display: flex; gap: 8px; align-items: center; }
.int-actions .spacer { flex: 1; }

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

/* ══════════════════════════════════════════════════════════════
   Ajustes del pase multi-agente (UX/UI): POS responsive, safe-area,
   targets táctiles en mobile. Ver revisión de roles del 14/7.
   ══════════════════════════════════════════════════════════════ */

/* POS: dos columnas + carrito pegajoso SOLO en escritorio. En mobile hereda
   el .split de una columna (el grid inline rompía esto y dejaba el mostrador
   inusable en el celular). */
@media (min-width: 1025px) {
  .split-pos { grid-template-columns: 1.3fr 1fr; align-items: start; }
  .pos-venta { position: sticky; top: 90px; }
}

/* Safe-area de iPhone (notch / barra de gestos): que el título y los toasts
   no queden pegados al borde. */
.topbar { padding-top: max(16px, env(safe-area-inset-top)); }
#toasts { bottom: max(22px, calc(env(safe-area-inset-bottom) + 14px)); }

/* Targets táctiles de 44px en el celular: botones fantasma y de acción de fila. */
@media (max-width: 640px) {
  .btn-ghost { min-width: 44px; min-height: 44px; }
  .btn-sm { min-height: 40px; }
}

/* Fila resaltada por teclado en el buscador del POS. */
#pos-resultados tr.pos-sel { background: var(--volt-soft) !important; }
