/* Horas · Folveon — base compartida con Facturas, tokens del brand kit v2.0 (brand.folveon.com) */
:root {
  --navy: #071120;
  --navy-profundo: #020617;
  --superficie: #0F172A;
  --superficie-2: #16213A;
  --teal: #2DD4BF;
  --teal-fuerte: #14B8A6;
  --teal-claro: #5EEAD4;
  --teal-oscuro: #042F2E;
  --teal-suave: rgba(45, 212, 191, 0.16);
  --ambar: #F59E0B;
  --ambar-claro: #FBBF24;
  --ambar-suave: rgba(245, 158, 11, 0.14);
  --blanco: #FFFFFF;
  --texto: #E2E8F0;
  --texto-suave: #CBD5E1;
  --texto-secundario: #94A3B8;
  --borde: rgba(148, 163, 184, 0.18);
  --borde-acento: rgba(45, 212, 191, 0.35);
  --exito: #22C55E;
  --exito-suave: rgba(34, 197, 94, 0.14);
  --error: #EF4444;
  --error-suave: rgba(239, 68, 68, 0.14);

  --grad-boton: linear-gradient(135deg, #5EEAD4 0%, #2DD4BF 45%, #14B8A6 100%);
  --sombra: 0 24px 80px rgba(2, 6, 23, 0.45);
  --glow: 0 16px 38px -10px rgba(45, 212, 191, 0.42);

  --radio-sm: 0.75rem;
  --radio: 1rem;
  --radio-lg: 1.4rem;
  --sidebar-w: 232px;
  --banner-h: 0px;
  --topbar-h: 0px;

  --font-titulos: "Sora", sans-serif;
  --font-cuerpo: "Manrope", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
body.con-banner { --banner-h: 34px; }

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  color: var(--texto);
  font-family: var(--font-cuerpo);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
body {
  background:
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.14), transparent 28%),
    radial-gradient(circle at 90% 12%, rgba(245, 158, 11, 0.08), transparent 18%),
    linear-gradient(180deg, #020617 0%, #071120 52%, #020617 100%);
  background-attachment: fixed;
  background-color: var(--navy);
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-claro); }
h1, h2, h3 { margin: 0; font-family: var(--font-titulos); font-weight: 700; color: var(--blanco); letter-spacing: -0.01em; }
h1 { font-size: 1.7rem; }
p { margin: 0 0 0.5rem; }
.muted { color: var(--texto-secundario); }
.accent { color: var(--teal); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.16em; font-weight: 700; color: var(--teal-claro); margin-bottom: 8px; }
code { font-family: var(--font-mono); }
[hidden] { display: none !important; }
svg[stroke="currentColor"] { stroke-linecap: round; stroke-linejoin: round; }
/* Barras de desplazamiento con los colores de la marca (no las grises del sistema) */
html { scrollbar-color: rgba(148, 163, 184, 0.35) var(--navy-profundo); }
.sel__lista, .ultimos__lista, .table-wrap, textarea { scrollbar-width: thin; scrollbar-color: rgba(45, 212, 191, 0.4) transparent; }


/* === Layout === */
.sidebar {
  position: fixed;
  top: var(--banner-h); left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.92) 0%, rgba(2, 6, 23, 0.92) 100%);
  border-right: 1px solid var(--borde);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  z-index: 50;
  transition: transform 0.25s ease;
}
.sidebar__brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; color: inherit; }
.sidebar__brand:hover { color: inherit; }
.sidebar__logo { width: 48px; height: 48px; filter: drop-shadow(0 0 16px rgba(45, 212, 191, 0.35)); }
.sidebar__title { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar__title strong { font-family: var(--font-titulos); font-size: 1.1rem; color: var(--blanco); }
.sidebar__title span { color: var(--teal-claro); font-size: 0.92rem; font-weight: 600; }
.sidebar__nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radio-sm);
  color: var(--texto-secundario);
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--superficie); color: var(--texto); }
.nav-item.is-active { background: var(--teal-suave); color: var(--teal); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar__logout button { width: 100%; justify-content: flex-start; }

.topbar { display: none; }
.menu-toggle {
  display: inline-flex;
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--superficie);
  border: 1px solid var(--borde);
  color: var(--texto);
  cursor: pointer;
  align-items: center; justify-content: center;
}
.menu-toggle svg { width: 20px; height: 20px; }

.main {
  margin-left: var(--sidebar-w);
  padding: calc(var(--banner-h) + 36px) 36px 64px;
  min-height: 100vh;
  max-width: calc(1320px + var(--sidebar-w));
}
.main--auth { margin: 0; max-width: none; }

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap;
  gap: 16px; margin-bottom: 24px;
}
.page-header__actions { display: flex; gap: 8px; }
.volver { display: inline-block; font-size: 0.88rem; margin-bottom: 6px; color: var(--texto-secundario); }
.volver:hover { color: var(--teal); }

/* === Cards === */
.card {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--borde);
  border-radius: var(--radio-lg);
  padding: 24px;
  margin-bottom: 20px;
  position: relative;
  /* Sin overflow:hidden: los desplegables y calendarios no se recortan en el borde */
}
.card::before {
  content: "";
  position: absolute; top: 0; left: 24px; right: 24px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--borde-acento), transparent);
}
.card--sutil { background: rgba(15, 23, 42, 0.45); }
.card--centro { max-width: 520px; margin: 10vh auto; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.card__title {
  font-family: var(--font-cuerpo);
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--teal-claro); font-weight: 700;
  margin: 26px 0 14px;
}
.card__title:first-of-type { margin-top: 0; }

/* === Formularios === */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field__label {
  font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--texto-secundario);
}
.field--full { grid-column: 1 / -1; }
.field--span2 { grid-column: span 2; }
.field small { font-size: 0.8rem; }
.field__error { color: var(--error); }
.field__warn { color: var(--ambar-claro); }

input[type="text"], input[type="password"], input[type="search"], input[type="email"], select, textarea {
  background: rgba(2, 6, 23, 0.6);
  border: 1px solid var(--borde);
  color: var(--texto);
  border-radius: var(--radio-sm);
  padding: 11px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
  transition: border 0.15s, box-shadow 0.15s, background 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-suave);
  background: var(--superficie);
}
input:disabled, select:disabled { opacity: 0.6; cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: #64748B; }
.field--error input, .field--error select, .field--error textarea { border-color: var(--error); background: rgba(239, 68, 68, 0.06); }
.field--error label { color: var(--error); }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394A3B8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
select option { background: var(--superficie); color: var(--texto); }
textarea { resize: vertical; min-height: 80px; }
.input-mono, .input-codigo { font-family: var(--font-mono); letter-spacing: 0.06em; }
.input-codigo { font-size: 1.4rem; text-align: center; letter-spacing: 0.4em; }

.input-pw { position: relative; }
.input-pw input { padding-right: 46px; }
.input-pw__toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border: 0; background: transparent; color: var(--texto-secundario);
  cursor: pointer; border-radius: 8px; display: grid; place-items: center;
}
.input-pw__toggle:hover { color: var(--teal); }
.input-pw__toggle svg { width: 18px; height: 18px; }

.input-accion { display: flex; gap: 8px; align-items: stretch; }
.input-accion input { flex: 1; min-width: 0; }
.input-accion .btn { flex-shrink: 0; }
.padron-estado { min-height: 1.2em; color: var(--texto-secundario); }
.padron-estado.is-ok { color: var(--teal-claro); }
.padron-estado.is-error { color: var(--ambar-claro); }

.segmented { display: inline-flex; border: 1px solid var(--borde); border-radius: 999px; padding: 3px; background: rgba(2, 6, 23, 0.6); align-self: flex-start; }
.segmented__opt { cursor: pointer; }
.segmented__opt input { position: absolute; opacity: 0; pointer-events: none; }
.segmented__opt span { display: block; padding: 7px 18px; border-radius: 999px; font-weight: 700; font-size: 0.9rem; color: var(--texto-secundario); transition: all 0.15s; }
.segmented__opt input:checked + span { background: var(--teal-suave); color: var(--teal); }
.segmented__opt input:focus-visible + span { box-shadow: 0 0 0 3px var(--teal-suave); }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

.filtros { display: grid; grid-template-columns: 1fr 200px auto; gap: 14px; align-items: end; margin-bottom: 18px; }
.filtros__acciones { display: flex; gap: 8px; }

/* === Botones === */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: inherit; font-size: 0.95rem; font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--grad-boton); color: var(--teal-oscuro); box-shadow: var(--glow); }
.btn--primary:hover { filter: brightness(1.08); transform: translateY(-1px); color: var(--teal-oscuro); }
.btn--primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; filter: none; }
.btn--ghost { background: transparent; border-color: rgba(148, 163, 184, 0.35); color: var(--texto); }
.btn--ghost:hover { background: var(--superficie); border-color: var(--teal); color: var(--teal); }
.btn--ghost:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--block { width: 100%; }
.btn--sm { padding: 8px 14px; font-size: 0.85rem; }

/* === Acceso === */
body.is-auth .main { display: grid; place-items: center; padding: calc(var(--banner-h) + 20px) 20px 20px; }
.auth-card {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--borde);
  border-radius: var(--radio-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--sombra), 0 0 32px rgba(45, 212, 191, 0.12);
  position: relative;
  overflow: hidden;
}
.auth-card--ancha { max-width: 540px; }
.auth-card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--teal), var(--teal-claro), transparent);
}
.auth-card__brand { text-align: center; margin-bottom: 28px; }
.auth-card__brand img { width: 64px; height: 64px; margin-bottom: 14px; filter: drop-shadow(0 0 22px rgba(45, 212, 191, 0.45)); }
.auth-card__brand h1 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form__hint { text-align: center; font-size: 0.88rem; margin: 0; }
.auth-form__hint.error { color: var(--error); }
.auth-card__footer { text-align: center; font-size: 0.78rem; margin: 22px 0 0; }

.qr-box { display: flex; gap: 20px; align-items: center; margin-bottom: 22px; }
.qr-box__img { flex-shrink: 0; background: #fff; border-radius: var(--radio-sm); padding: 6px; line-height: 0; }
.qr-box__img svg { width: 150px; height: 150px; }
.qr-box__manual { min-width: 0; }
.secreto { display: block; font-size: 0.9rem; color: var(--teal-claro); word-break: break-all; background: rgba(2, 6, 23, 0.6); padding: 8px 10px; border-radius: 8px; margin-top: 6px; }

.recovery-box { text-align: center; margin-bottom: 18px; }
.recovery-code {
  font-family: var(--font-mono); font-size: 1.15rem; letter-spacing: 0.06em; color: var(--teal-claro);
  background: rgba(2, 6, 23, 0.7); border: 1px dashed var(--borde-acento); border-radius: var(--radio-sm);
  padding: 14px; margin-bottom: 10px; word-break: break-all; user-select: all;
}

.aviso { border-radius: var(--radio-sm); padding: 14px 16px; margin: 18px 0; font-size: 0.92rem; border: 1px solid var(--borde); }
.aviso strong { display: block; margin-bottom: 2px; }
.aviso--warn { background: var(--ambar-suave); border-color: rgba(245, 158, 11, 0.45); }
.aviso--warn strong { color: var(--ambar-claro); }
.aviso__acciones { margin-top: 10px; }

/* === Mensajes (toast) === */
.flash-stack {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
  transition: transform 0.2s ease; /* sube si taparía un botón (app.js) */
}
.flash {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-radius: var(--radio-sm); font-size: 0.92rem;
  border: 1px solid transparent; background: var(--superficie);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  animation: flash-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.flash--success { background: linear-gradient(180deg, rgba(34, 197, 94, 0.18), rgba(34, 197, 94, 0.08)), var(--superficie); border-color: rgba(34, 197, 94, 0.4); color: #86EFAC; }
.flash--error { background: linear-gradient(180deg, rgba(239, 68, 68, 0.18), rgba(239, 68, 68, 0.08)), var(--superficie); border-color: rgba(239, 68, 68, 0.45); color: #FCA5A5; }
.flash__close { background: none; border: none; color: inherit; font-size: 1.2rem; cursor: pointer; opacity: 0.7; line-height: 1; padding: 0 4px; }
.flash__close:hover { opacity: 1; }
.flash.is-leaving { animation: flash-out 0.3s ease forwards; }
@keyframes flash-in { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes flash-out { to { opacity: 0; transform: translateX(20px); } }

/* === Tablas === */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.badge--ok { background: var(--exito-suave); color: #4ADE80; }
.badge--muted { background: rgba(148, 163, 184, 0.14); color: var(--texto-secundario); }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table th {
  text-align: left; padding: 10px 12px;
  font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--texto-secundario); font-weight: 700;
  border-bottom: 1px solid var(--borde);
}
.data-table td { padding: 12px; border-bottom: 1px solid var(--borde); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(45, 212, 191, 0.09); }
.data-table tbody tr:hover .data-table__titulo { color: var(--teal-claro); }
.doc-tipo { color: var(--texto-secundario); margin-right: 0.2em; }
.data-table tr.is-inactivo td { opacity: 0.55; }
.data-table__titulo { font-weight: 700; color: var(--blanco); }
.data-table__titulo:hover { color: var(--teal); }
.data-table__sub { font-size: 0.82rem; }
.data-table__email { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--texto-suave); }
.data-table__actions { display: flex; gap: 6px; justify-content: flex-end; }
.col-acciones { width: 1%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: transparent; border: 1px solid var(--borde); color: var(--texto-secundario);
  cursor: pointer; transition: all 0.15s;
}
.icon-btn svg { width: 14px; height: 14px; }
.icon-btn:hover { color: var(--teal); border-color: var(--teal); background: var(--teal-suave); }
.icon-btn--acento { color: var(--teal); border-color: var(--borde-acento); }
.icon-btn--danger:hover { color: var(--error); border-color: var(--error); background: var(--error-suave); }
.inline-form { display: inline-block; margin: 0; }
.empty-state { text-align: center; padding: 32px; color: var(--texto-secundario); display: flex; flex-direction: column; gap: 6px; }
.fila-estado { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.fila-estado p { margin: 0; }

/* === Responsive === */
@media (max-width: 960px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  body.con-menu { --topbar-h: 56px; }
  .topbar {
    display: flex; align-items: center; gap: 12px;
    position: fixed; top: var(--banner-h); left: 0; right: 0; z-index: 300;
    height: var(--topbar-h); padding: 0 16px;
    background: var(--navy); border-bottom: 1px solid var(--borde);
  }
  .topbar__brand { display: flex; align-items: center; gap: 10px; color: var(--blanco); font-family: var(--font-titulos); font-size: 1.05rem; }
  .topbar__brand:hover { color: var(--blanco); }
  .topbar__logo { width: 30px; height: 30px; }
  .sidebar { top: calc(var(--banner-h) + var(--topbar-h)); transform: translateX(-100%); box-shadow: var(--sombra); z-index: 290;
             background: var(--navy-profundo); }
  /* Con el menú abierto, el resto queda atenuado (no se ve el contenido a través del menú) */
  body.menu-abierto::before { content: ""; position: fixed; inset: 0; z-index: 280; background: rgba(2, 6, 23, 0.7); }
  .sidebar.is-open { transform: none; }
  .sidebar__brand { display: none; }
  .main { margin-left: 0; padding: calc(var(--banner-h) + var(--topbar-h) + 20px) 16px 48px; }
  .filtros { grid-template-columns: 1fr 1fr; }
  .filtros__buscar { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .field--span2 { grid-column: auto; }
  .auth-card { padding: 28px 20px; }
  .qr-box { flex-direction: column; text-align: center; }
  .input-accion { flex-direction: column; }
  .flash-stack { bottom: calc(16px + var(--alto-barra-fija, 0px)); right: 16px; left: 16px; width: auto; }
  .main { padding-bottom: calc(48px + var(--alto-toasts, 0px)); }
  h1 { font-size: 1.45rem; overflow-wrap: anywhere; }
  /* Listas como tarjetas compactas: dos columnas; nombre, cliente, email y acciones a lo ancho */
  .data-table:not(.tabla-items) tbody tr { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 18px; }
  .data-table:not(.tabla-items) td[data-label="Cliente"], .data-table:not(.tabla-items) td[data-label="Email"] { grid-column: 1 / -1; }
  .data-table:not(.tabla-items) td.col-importe { text-align: left; }
  .data-table:not(.tabla-items) td.col-acciones { align-self: end; }
  .data-table:not(.tabla-items) td.col-acciones .data-table__actions { justify-content: flex-end; flex-wrap: nowrap; }
  /* Clientes (con columna Email): las acciones van en su propia línea */
  .data-table:not(.tabla-items) tr:has(td[data-label="Email"]) td.col-acciones { grid-column: 1 / -1; }
  .data-table:not(.tabla-items) tr:has(td[data-label="Email"]) .data-table__actions { justify-content: flex-start; }
  .banner-prueba__detalle { display: none; }
  /* Listas como tarjetas (las tablas de ítems siguen siendo tablas: no quedan bloques sueltos) */
  .data-table:not(.tabla-items) thead { display: none; }
  .data-table:not(.tabla-items), .data-table:not(.tabla-items) tbody, .data-table:not(.tabla-items) tr,
  .data-table:not(.tabla-items) td { display: block; width: 100%; }
  .data-table:not(.tabla-items) tr { border: 1px solid var(--borde); border-radius: var(--radio-sm); margin-bottom: 10px; padding: 6px 4px; }
  .data-table:not(.tabla-items) td { border: 0; padding: 6px 10px; }
  .tabla-items td { padding: 10px 6px; }
  .data-table td[data-label]::before { content: attr(data-label); display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--texto-secundario); font-weight: 700; }
  .data-table__email { max-width: none; white-space: normal; word-break: break-all; }
  .data-table__actions { justify-content: flex-start; }
  .fila-estado { flex-direction: column; align-items: flex-start; }
}
