/* ============================================================ Panel de gestión */
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --texto: #0f172a;
  --texto-2: #334155;
  --suave: #64748b;
  --borde: #e5e9f0;
  --borde-fuerte: #cfd6e2;

  --primario: #2563eb;
  --primario-hover: #1d4ed8;
  --primario-suave: #eaf1fe;
  --verde: #15803d;
  --verde-suave: #e7f6ec;
  --ambar: #b45309;
  --ambar-suave: #fdf3e2;
  --rojo: #b91c1c;
  --rojo-suave: #fdecec;
  --violeta: #6d28d9;
  --violeta-suave: #f1ebfd;
  --gris-suave: #eef1f6;

  /* Colores por línea de negocio (gráficas y etiquetas) */
  --c-reparacion: #2563eb;
  --c-kayak: #0d9488;
  --c-seo: #d97706;
  --c-manual: #94a3b8;

  --lateral: #0b2340;
  --lateral-2: #0f2d52;
  --lateral-texto: #b8c4d9;
  --lateral-activo: #ffffff;
  --marca: #7ac142;

  --radio: 12px;
  --radio-s: 8px;
  --sombra: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --sombra-l: 0 10px 30px -12px rgba(16, 24, 40, .25);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1220;
    --panel: #131b2c;
    --panel-2: #172135;
    --texto: #e7ecf4;
    --texto-2: #c3cddd;
    --suave: #8b98ad;
    --borde: #222d42;
    --borde-fuerte: #2f3c55;
    --primario: #4f8cff;
    --primario-hover: #74a3ff;
    --primario-suave: #1a2a4a;
    --verde: #4ade80;
    --verde-suave: #14321f;
    --ambar: #fbbf24;
    --ambar-suave: #3a2c10;
    --rojo: #f87171;
    --rojo-suave: #3d1a1a;
    --violeta: #a78bfa;
    --violeta-suave: #2a1f47;
    --gris-suave: #1c2639;
    --c-reparacion: #4f8cff;
    --c-kayak: #2dd4bf;
    --c-seo: #fbbf24;
    --c-manual: #64748b;
    --lateral: #070d18;
    --lateral-2: #0d1729;
    --sombra: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14px/1.5 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'cv11', 'ss01';
  background: var(--bg);
  color: var(--texto);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primario); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.25; font-weight: 650; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 14px; }
h3 { font-size: 11px; font-weight: 600; margin: 18px 0 8px; color: var(--suave); text-transform: uppercase; letter-spacing: .06em; }
code { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12px; background: var(--gris-suave); padding: 1px 5px; border-radius: 4px; }

.ico { width: 18px; height: 18px; flex: none; vertical-align: -4px; }
.btn .ico { width: 16px; height: 16px; vertical-align: -3px; }

/* ------------------------------------------------------------ estructura */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.lateral {
  background: linear-gradient(180deg, var(--lateral) 0%, var(--lateral-2) 100%);
  color: var(--lateral-texto);
  padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.marca { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; color: #fff; text-decoration: none; }
.marca:hover { text-decoration: none; }
.marca-icono {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #2563eb, #0d9488); color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .35);
}
.marca-texto { font-weight: 650; font-size: 15px; line-height: 1.15; letter-spacing: -.01em; }
.marca-texto small { display: block; font-weight: 450; font-size: 11.5px; color: var(--lateral-texto); letter-spacing: 0; }
.lateral nav { flex: 1; overflow-y: auto; }
.nav-seccion { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: rgba(184, 196, 217, .55); padding: 14px 10px 6px; }
.lateral nav a {
  display: flex; gap: 11px; align-items: center; padding: 8px 10px; border-radius: 8px;
  color: var(--lateral-texto); margin-bottom: 1px; font-weight: 500; position: relative;
  transition: background .12s, color .12s;
}
.lateral nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.lateral nav a.activo { background: rgba(255, 255, 255, .1); color: var(--lateral-activo); }
.lateral nav a.activo::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--marca); }
.lateral nav a .ico { opacity: .85; }
.nav-badge { margin-left: auto; background: var(--marca); color: #0b2340; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.usuario-caja { display: flex; align-items: center; gap: 10px; padding: 12px 8px 2px; border-top: 1px solid rgba(255, 255, 255, .08); margin-top: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .12); color: #fff; font-weight: 600; font-size: 13px; flex: none; }
.usuario-caja .nombre { color: #fff; font-weight: 500; font-size: 13px; line-height: 1.2; }
.usuario-caja .email { font-size: 11.5px; color: var(--lateral-texto); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.usuario-caja button { margin-left: auto; background: none; border: 0; color: var(--lateral-texto); cursor: pointer; padding: 6px; border-radius: 6px; }
.usuario-caja button:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.barra-movil { display: none; }

main { padding: 28px 32px 64px; max-width: 1360px; width: 100%; min-width: 0; }

/* ------------------------------------------------------------ cabeceras de página */
.cabecera { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.cabecera .sub { color: var(--suave); font-size: 13.5px; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.miga { font-size: 12.5px; color: var(--suave); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }

/* ------------------------------------------------------------ tarjetas y rejillas */
.tarjeta { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 20px; margin-bottom: 18px; box-shadow: var(--sombra); }
.tarjeta > h2:first-child { margin-top: 0; }
.tarjeta-cab { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.tarjeta-cab h2 { margin: 0; }
.tarjeta-cab a { font-size: 13px; font-weight: 500; }
.rejilla { display: grid; gap: 18px; }
.r2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.r3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.r4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.r-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.rejilla > .tarjeta { margin-bottom: 0; }
.rejilla + .rejilla, .rejilla + .tarjeta, .tarjeta + .rejilla { margin-top: 18px; }

.kpi { position: relative; }
.kpi .etq { color: var(--suave); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.kpi .valor { font-size: 26px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin: 6px 0 2px; line-height: 1.2; }
.kpi .det { color: var(--suave); font-size: 12.5px; }
.kpi-icono { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--primario-suave); color: var(--primario); }
.kpi-icono .ico { width: 16px; height: 16px; }
.kpi-icono.verde { background: var(--verde-suave); color: var(--verde); }
.kpi-icono.ambar { background: var(--ambar-suave); color: var(--ambar); }
.kpi-icono.violeta { background: var(--violeta-suave); color: var(--violeta); }
.kpi-icono.teal { background: color-mix(in srgb, var(--c-kayak) 14%, transparent); color: var(--c-kayak); }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; padding: 1px 7px 1px 4px; border-radius: 999px; }
.delta .ico { width: 14px; height: 14px; vertical-align: -2px; }
.delta.sube { background: var(--verde-suave); color: var(--verde); }
.delta.baja { background: var(--rojo-suave); color: var(--rojo); }
.delta.igual { background: var(--gris-suave); color: var(--suave); }

/* ------------------------------------------------------------ tablas */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-weight: 600; color: var(--suave); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 12px; border-bottom: 1px solid var(--borde); white-space: nowrap; background: var(--panel-2);
}
thead tr th:first-child { border-top-left-radius: 8px; }
thead tr th:last-child { border-top-right-radius: 8px; }
td { padding: 11px 12px; border-bottom: 1px solid var(--borde); vertical-align: top; color: var(--texto-2); }
td strong, td a strong { color: var(--texto); }
td a strong { white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--panel-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabla-scroll { overflow-x: auto; }
.tarjeta.tabla-scroll { padding: 6px; }
.tarjeta.tabla-scroll > h2 { padding: 14px 14px 0; }
.vacio { color: var(--suave); padding: 28px 16px; text-align: center; }
.tabla-compacta td { padding: 9px 4px; }
.tabla-compacta tr:hover { background: none; }

/* ------------------------------------------------------------ formularios */
label { display: block; font-size: 12.5px; color: var(--texto-2); margin-bottom: 5px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--borde-fuerte); border-radius: var(--radio-s);
  background: var(--panel); color: var(--texto); font: inherit; transition: border-color .12s, box-shadow .12s;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--primario) 35%, var(--borde-fuerte)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primario); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primario) 18%, transparent); }
input[readonly] { background: var(--panel-2); }
textarea { min-height: 88px; resize: vertical; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primario); }
.campo { margin-bottom: 14px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--texto); font-weight: 450; }
.filtros {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px;
  background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 12px; box-shadow: var(--sombra);
}
.filtros > * { width: auto; }
.filtros label { margin-bottom: 3px; font-size: 11.5px; }
.filtros input, .filtros select { min-width: 150px; padding: 7px 10px; }

/* ------------------------------------------------------------ botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px;
  border-radius: var(--radio-s); border: 1px solid var(--borde-fuerte); background: var(--panel); color: var(--texto);
  font: inherit; font-weight: 550; font-size: 13.5px; cursor: pointer; white-space: nowrap; line-height: 1.3;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05); transition: background .12s, border-color .12s, box-shadow .12s, transform .05s;
}
.btn:hover { background: var(--panel-2); border-color: var(--suave); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primario) 25%, transparent); }
.btn.primario { background: var(--primario); border-color: var(--primario); color: #fff; }
.btn.primario:hover { background: var(--primario-hover); border-color: var(--primario-hover); }
.btn.peligro { color: var(--rojo); }
.btn.peligro:hover { background: var(--rojo-suave); border-color: var(--rojo); }
.btn.peq { padding: 5px 10px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

/* ------------------------------------------------------------ etiquetas */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 550;
  background: var(--gris-suave); color: var(--suave); white-space: nowrap; line-height: 1.6;
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.chip.verde { background: var(--verde-suave); color: var(--verde); }
.chip.azul { background: var(--primario-suave); color: var(--primario); }
.chip.ambar { background: var(--ambar-suave); color: var(--ambar); }
.chip.rojo { background: var(--rojo-suave); color: var(--rojo); }
.chip.violeta { background: var(--violeta-suave); color: var(--violeta); }

/* ------------------------------------------------------------ avisos */
.aviso { padding: 11px 14px; border-radius: var(--radio-s); margin-bottom: 18px; border: 1px solid transparent; font-weight: 500; }
.aviso.ok { background: var(--verde-suave); color: var(--verde); border-color: color-mix(in srgb, var(--verde) 25%, transparent); }
.aviso.error { background: var(--rojo-suave); color: var(--rojo); border-color: color-mix(in srgb, var(--rojo) 25%, transparent); }
.aviso.info { background: var(--ambar-suave); color: var(--ambar); border-color: color-mix(in srgb, var(--ambar) 25%, transparent); }
.aviso ul { margin: 4px 0 0; padding-left: 18px; font-weight: 450; }

/* ------------------------------------------------------------ facturas / líneas */
.lineas td { padding: 5px 4px; }
.lineas input, .lineas select { padding: 7px 9px; }
.totales { margin-left: auto; width: 300px; }
.totales div { display: flex; justify-content: space-between; padding: 5px 0; color: var(--texto-2); font-variant-numeric: tabular-nums; }
.totales .total { font-weight: 700; font-size: 18px; color: var(--texto); border-top: 1px solid var(--borde); padding-top: 10px; margin-top: 4px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; word-break: break-all; color: var(--suave); }
.suave { color: var(--suave); }
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin: 0; }
.dl dt { color: var(--suave); font-size: 13px; }
.dl dd { margin: 0; }

/* ------------------------------------------------------------ dashboard */
.saludo h1 { font-size: 24px; }
.grafica { width: 100%; height: auto; display: block; }
.grafica text { fill: var(--suave); font-size: 11px; font-family: inherit; }
.grafica .eje { stroke: var(--borde); }
.leyenda-g { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--texto-2); }
.leyenda-g span { display: inline-flex; align-items: center; gap: 6px; }
.leyenda-g i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.barra-h { height: 8px; border-radius: 99px; background: var(--gris-suave); overflow: hidden; display: flex; }
.barra-h > span { display: block; height: 100%; }
.fila-dato { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--borde); }
.fila-dato:last-child { border-bottom: 0; }
.fila-dato .izq { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fila-dato .izq > div { min-width: 0; }
.fila-dato .t { color: var(--texto); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-dato .s { color: var(--suave); font-size: 12.5px; }
.tarea { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--borde); margin-bottom: 8px; color: var(--texto); background: var(--panel); }
.tarea:hover { border-color: var(--primario); text-decoration: none; background: var(--panel-2); }
.tarea .n { margin-left: auto; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.tarea .s { color: var(--suave); font-size: 12.5px; }
.tarea-icono { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.ocupacion { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.ocupacion .dia { text-align: center; }
.ocupacion .dia .b { height: 64px; border-radius: 6px; background: var(--gris-suave); position: relative; overflow: hidden; }
.ocupacion .dia .b span { position: absolute; left: 0; right: 0; bottom: 0; background: var(--c-kayak); border-radius: 6px 6px 0 0; }
.ocupacion .dia small { display: block; font-size: 11px; color: var(--suave); margin-top: 4px; }
.ocupacion .dia strong { display: block; font-size: 12px; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ calendario kayaks */
.cal { border-collapse: separate; border-spacing: 3px; font-size: 12px; }
.cal th, .cal td { padding: 5px 2px; text-align: center; border: 0; min-width: 32px; background: none; text-transform: none; letter-spacing: 0; }
.cal td.prod { text-align: left; white-space: nowrap; padding-right: 12px; font-weight: 600; position: sticky; left: 0; background: var(--panel); color: var(--texto); }
.cal .celda { border-radius: 6px; font-variant-numeric: tabular-nums; font-weight: 650; }
.cal .libre { background: var(--verde-suave); color: var(--verde); }
.cal .poco { background: var(--ambar-suave); color: var(--ambar); }
.cal .lleno { background: var(--rojo-suave); color: var(--rojo); }
.cal .bloq { background: var(--gris-suave); color: var(--suave); }
.cal th.hoy, .cal td.hoy { outline: 2px solid var(--primario); outline-offset: -1px; }
.cal th.finde { color: var(--primario); }
.cal tbody tr:hover { background: none; }
.leyenda { display: flex; gap: 14px; font-size: 12px; color: var(--suave); margin-top: 12px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------ acceso */
.acceso { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.acceso-arte {
  background: radial-gradient(1200px 600px at 10% 10%, rgba(37, 99, 235, .55), transparent 60%),
              radial-gradient(900px 500px at 90% 90%, rgba(13, 148, 136, .45), transparent 60%),
              linear-gradient(160deg, #0b2340, #0f2d52);
  color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.acceso-arte h2 { font-size: 30px; line-height: 1.2; letter-spacing: -.02em; max-width: 420px; font-weight: 650; margin: 0 0 14px; }
.acceso-arte p { color: #c7d2e5; max-width: 420px; margin: 0; }
.acceso-lineas { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 26px; }
.acceso-lineas span { display: inline-flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12); padding: 7px 12px; border-radius: 999px; font-size: 13px; }
.acceso-form { display: grid; place-items: center; padding: 32px 20px; background: var(--panel); }
.acceso-form .caja { width: 100%; max-width: 360px; }
.acceso-form h1 { font-size: 24px; }
.acceso-form .btn.primario { width: 100%; padding: 11px; margin-top: 4px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .r4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .r-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .barra-movil {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--lateral); color: #fff;
    position: sticky; top: 0; z-index: 20;
  }
  .barra-movil button { background: none; border: 0; color: #fff; padding: 6px; cursor: pointer; }
  .lateral { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 30; transform: translateX(-100%); transition: transform .2s; height: 100vh; }
  body.menu-abierto .lateral { transform: none; box-shadow: var(--sombra-l); }
  body.menu-abierto::after { content: ''; position: fixed; inset: 0; background: rgba(2, 6, 23, .45); z-index: 25; }
  main { padding: 18px 16px 48px; }
  .r2, .r3, .r4 { grid-template-columns: 1fr; }
  .acceso { grid-template-columns: 1fr; }
  .acceso-arte { display: none; }
  .totales { width: 100%; }
}
@media print {
  .lateral, .barra-movil, .acciones, .filtros { display: none !important; }
  .app { display: block; }
  .tarjeta { box-shadow: none; }
}
