/* ORDIVA · estilos comunes. Tema claro por defecto (crema de la marca); oscuro con el botón de la cabecera.
   La paleta de la marca está en marca.css (cargar antes). */

:root {
  --bg: #F8F4E9;
  --panel: #ffffff;
  --panel-2: #F1EDE0;
  --border: #D8D2C0;
  --text: #1A1F1E;
  --muted: #5B6270;
  --accent: #1F6F6D;
  --accent-light: #2A8280;
  --accent-text: #ffffff;
  --enlace: #1F6F6D;
  --aviso: #8A5A00;
  --aviso-fondo: #E6C88F44;
  --red: #B3321F;
  --green: #1F6F3A;
  --cabecera: #0F3D3A;
  --radio: 12px;
  --sombra: 0 2px 10px rgba(15, 61, 58, .10);
  color-scheme: light;
}
[data-theme=dark] {
  --bg: #0B1F1E;
  --panel: #102B29;
  --panel-2: #163735;
  --border: #2A4B48;
  --text: #EAF3EE;
  --muted: #A9C2BB;
  --accent: #7EC3B3;
  --accent-light: #9AD3C5;
  --accent-text: #0F3D3A;
  --enlace: #7EC3B3;
  --aviso: #E6C88F;
  --aviso-fondo: rgba(230, 200, 143, .14);
  --red: #F08A7E;
  --green: #7EC3B3;
  --sombra: 0 2px 10px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--fuente-texto, system-ui, sans-serif);
  background: var(--bg); color: var(--text); min-height: 100vh; font-size: 15px; line-height: 1.4;
}
a { color: var(--enlace); }
[hidden] { display: none !important; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }

/* ─── Cabecera ─── */
.cabecera { background: var(--cabecera); color: #fff; padding: 10px 16px; display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 10; }
.cabecera a { color: #fff; text-decoration: none; }
.cabecera .titulo { flex: 1; font-weight: 600; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cabecera button { background: transparent; border: 1px solid rgba(255,255,255,.25); color: #fff; border-radius: 8px; padding: 6px 10px; font-size: .9rem; cursor: pointer; }
.cabecera .volver { font-size: 1.3rem; padding: 0 6px; }

.pagina { max-width: 1480px; margin: 0 auto; padding: 16px; }
.pagina.movil { max-width: 560px; }

/* ─── Inicio: botones grandes ─── */
.botones-grandes { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 8px; }
@media (min-width: 700px) { .botones-grandes { grid-template-columns: 1fr 1fr; } }
.boton-grande { display: flex; align-items: center; gap: 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radio);
  padding: 22px 20px; font-size: 1.25rem; font-weight: 600; color: var(--text); text-decoration: none; box-shadow: var(--sombra); min-height: 84px; }
.boton-grande:active { transform: scale(.98); }
.boton-grande .icono { font-size: 2rem; width: 2.4rem; text-align: center; }
.boton-grande.secundario { font-size: 1.05rem; padding: 14px 18px; min-height: 60px; }

/* ─── Formularios ─── */
.campo { margin-bottom: 14px; }
.campo label, .etiqueta { display: block; font-weight: 600; margin-bottom: 5px; font-size: .95rem; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--enlace); outline-offset: 1px; }
.control-grande { font-size: 1.2rem; padding: 14px; min-height: 54px; }
textarea { min-height: 80px; resize: vertical; }
.fila-dos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fila-tres { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.ayuda { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.error { color: var(--red); min-height: 1.2em; margin: 6px 0; font-weight: 600; }
input[type=checkbox] { width: auto; transform: scale(1.3); margin-right: 8px; }

/* ─── Botones ─── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 9px 14px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primario { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primario:hover:not(:disabled) { background: var(--accent-light); }
.btn-peligro { color: var(--red); border-color: var(--red); background: transparent; }
.btn-grande { width: 100%; font-size: 1.2rem; padding: 16px; min-height: 58px; margin-top: 6px; }
.btn-pequeno { padding: 5px 10px; font-size: .85rem; }

/* Selector de dos o más opciones de un toque (origen, ámbito). */
.selector { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; margin-bottom: 14px; }
.selector button { font: inherit; font-size: 1.1rem; font-weight: 700; padding: 16px 8px; border-radius: 12px; cursor: pointer;
  background: var(--panel-2); color: var(--text); border: 2px solid var(--border); }
.selector button[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* Botón de foto */
.boton-foto { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; padding: 20px; margin-bottom: 14px; border: 2px dashed var(--border);
  border-radius: var(--radio); font-family: inherit; font-size: 1.15rem; font-weight: 700; cursor: pointer; background: var(--panel); color: var(--text); }
.boton-foto .icono { font-size: 2rem; }
.miniatura { max-width: 100%; max-height: 260px; border-radius: 10px; display: block; margin: 0 auto 12px; border: 1px solid var(--border); }

/* ─── Tarjetas, avisos, listas ─── */
.tarjeta { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radio); padding: 14px; margin-bottom: 12px; }
.aviso-caja { background: var(--aviso-fondo); border: 1px solid var(--aviso); color: var(--text); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.aviso-caja.peligro { border-color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.aviso-caja.ok { border-color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.lista { list-style: none; }
.lista li { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 8px; display: flex; gap: 10px; align-items: center; }
.lista li .principal { flex: 1; min-width: 0; }
.lista li .secundario { color: var(--muted); font-size: .88rem; }
.lista li .cifra { font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.dia { margin-bottom: 16px; }
.dia-cabecera { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 6px; color: var(--muted); }
.chip { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--border); color: var(--muted); }
.chip.casa { border-color: var(--accent); color: var(--enlace); }
.chip.empresa { border-color: var(--accent); color: var(--enlace); }
.cifra-grande { font-size: 2rem; font-weight: 800; }
.muted { color: var(--muted); }

/* ─── Tablas (escritorio) ─── */
.tabla-envoltura { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table.tabla { border-collapse: collapse; width: 100%; background: var(--panel); font-size: .9rem; }
.tabla th, .tabla td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.tabla th { background: var(--panel-2); font-weight: 600; white-space: nowrap; }
.tabla td.num, .tabla th.num { text-align: right; white-space: nowrap; }
.tabla tfoot td { font-weight: 700; background: var(--panel-2); }
.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filtros .campo { margin-bottom: 0; min-width: 140px; }
.pestanas { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.pestanas button { font: inherit; background: none; border: none; color: var(--muted); padding: 10px 12px; cursor: pointer; border-bottom: 3px solid transparent; font-weight: 600; }
.pestanas button[aria-selected=true] { color: var(--text); border-bottom-color: var(--accent); }

/* ─── Aviso flotante y diálogo ─── */
#aviso-global { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--green); color: var(--accent-text); padding: 12px 18px; border-radius: 10px;
  box-shadow: var(--sombra); z-index: 100; font-weight: 600; max-width: 92vw; }
#aviso-global.error { background: var(--red); }
.velo { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.dialogo { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radio); padding: 18px; width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; }
.dialogo h3 { margin-bottom: 12px; }
.dialogo .botones { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

/* ─── Login ─── */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-caja { width: 100%; max-width: 380px; }
.login-marca { text-align: center; margin-bottom: 22px; }
.login-marca img { width: 72px; height: 72px; border-radius: 16px; }
.login-marca .nombre { font-size: 1.6rem; font-weight: 800; margin-top: 8px; }

@media (max-width: 700px) {
  .solo-escritorio { display: none !important; }
  .fila-tres { grid-template-columns: 1fr 1fr; }
}

/* Selector de empresa de la cabecera (solo si el cliente tiene varias) */
.cabecera select { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: 4px 8px; font: inherit; max-width: 46vw; }
.cabecera select option { color: #000; }
.insignia { display: inline-block; font-size: .72rem; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--border); color: var(--muted); }
.insignia.ok { border-color: var(--green); color: var(--green); }
.insignia.no { border-color: var(--red); color: var(--red); }
.modulo-fila { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--border); }
.modulo-fila .texto { flex: 1; }
.repetible { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.tabla td.num.neg { color: var(--red); font-weight: 600; }
