:root {
  --acento: #0f766e;
  --acento-2: #115e59;
  --acento-suave: #ccfbf1;
  --ambar: #b45309;
  --ambar-suave: #fef3c7;
  --rojo: #b91c1c;
  --rojo-suave: #fee2e2;
  --verde: #15803d;
  --verde-suave: #dcfce7;
  --fondo: #f3f5f4;
  --tarjeta: #ffffff;
  --texto: #18211f;
  --texto-2: #5b6764;
  --borde: #dde3e1;
  --campo: #f8faf9;
  --sombra: 0 1px 2px rgba(16, 24, 22, .06), 0 4px 14px rgba(16, 24, 22, .06);
  --radio: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --acento: #2dd4bf;
    --acento-2: #14b8a6;
    --acento-suave: #123b37;
    --ambar: #fbbf24;
    --ambar-suave: #3b2e10;
    --rojo: #f87171;
    --rojo-suave: #3f1717;
    --verde: #4ade80;
    --verde-suave: #12321f;
    --fondo: #0b1513;
    --tarjeta: #14201e;
    --texto: #e6eeec;
    --texto-2: #9aaba7;
    --borde: #26332f;
    --campo: #0f1a18;
    --sombra: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
h1, h2 { margin: 0; }
h2 { font-size: 1rem; font-weight: 650; margin-bottom: 12px; }
h2 small { font-weight: 400; color: var(--texto-2); font-size: .82rem; }
em { color: var(--texto-2); font-style: normal; font-size: .85em; }

.barra-sup {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  background: var(--acento); color: #fff;
}
@media (prefers-color-scheme: dark) { .barra-sup { background: var(--tarjeta); color: var(--texto); border-bottom: 1px solid var(--borde); } }
.barra-sup h1 { font-size: 1.15rem; font-weight: 650; }
.chip-red { font-size: .75rem; background: rgba(0,0,0,.25); padding: 3px 10px; border-radius: 99px; }

main { max-width: 640px; margin: 0 auto; padding: 12px 12px 8px; }
.pantalla { display: none; }
.pantalla.activa { display: block; }

.tarjeta {
  background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra);
  border: 1px solid var(--borde); padding: 16px; margin-bottom: 12px;
}
.campo { display: block; margin-bottom: 12px; }
.campo > span {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: .82rem; color: var(--texto-2); margin-bottom: 4px; font-weight: 550;
}
input, select {
  width: 100%; min-height: 48px; padding: 10px 12px;
  font: inherit; color: var(--texto); background: var(--campo);
  border: 1.5px solid var(--borde); border-radius: 12px; outline: none;
  appearance: none; -webkit-appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--texto-2) 50%), linear-gradient(135deg, var(--texto-2) 50%, transparent 50%);
  background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px;
}
input:focus, select:focus { border-color: var(--acento); box-shadow: 0 0 0 3px color-mix(in srgb, var(--acento) 22%, transparent); }
input[type=date] { min-width: 0; }
.invalido { border-color: var(--rojo) !important; }

.dos-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.dos-col > * { min-width: 0; }
@media (max-width: 360px) { .dos-col { grid-template-columns: 1fr; } }


.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 50px; padding: 10px 16px; border-radius: 14px; border: 1.5px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-align: center; user-select: none;
  -webkit-tap-highlight-color: transparent; transition: transform .08s, filter .15s;
}
.btn:active { transform: scale(.98); }
.btn-pri { background: var(--acento); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-pri { color: #04201d; } }
.btn-sec { background: var(--acento-suave); color: var(--acento-2); border-color: transparent; }
@media (prefers-color-scheme: dark) { .btn-sec { color: var(--acento); } }
.btn-peligro { background: var(--rojo-suave); color: var(--rojo); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-icono {
  min-width: 48px; min-height: 48px; border-radius: 12px; border: 1.5px solid var(--borde);
  background: var(--campo); color: var(--texto); font-size: 1.1rem; cursor: pointer;
}
.btn-link { background: none; border: 0; color: var(--acento); font: inherit; font-weight: 600; padding: 8px 0; cursor: pointer; }
.fila-btn { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.acciones { display: flex; gap: 10px; margin: 4px 0 16px; }
.acciones .btn { flex: 1; min-height: 56px; font-size: 1.05rem; }

.zona-foto {
  border: 2px dashed var(--borde); border-radius: 14px; min-height: 120px;
  display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--campo);
}
.zona-foto img { max-width: 100%; max-height: 360px; display: block; object-fit: contain; }
.foto-vacia { color: var(--texto-2); font-size: .9rem; text-align: center; padding: 16px; margin: 0; }


/* Historial */
.filtros input[type=search] { margin-bottom: 10px; }
.filtros .campo { margin-bottom: 6px; }
.resumen-lista { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 4px 0; color: var(--texto-2); }
.resumen-lista strong { color: var(--texto); font-size: 1.25rem; }
.lista { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; gap: 12px; align-items: center; padding: 12px; margin-bottom: 8px; cursor: pointer;
  background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 14px; box-shadow: var(--sombra);
}
.item img, .item .sin-foto { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none; background: var(--campo); }
.item .sin-foto { display: flex; align-items: center; justify-content: center; color: var(--texto-2); }
.item .info { flex: 1; min-width: 0; }
.item .l1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .l2 { font-size: .82rem; color: var(--texto-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .monto { font-weight: 700; text-align: right; white-space: nowrap; }
.vacio { text-align: center; color: var(--texto-2); padding: 24px; }

.ayuda-mini { font-size: .85rem; color: var(--texto-2); margin: 6px 0 0; }
.texto p, .texto li { font-size: .95rem; }
.texto h2 { margin-top: 18px; }
.texto h2:first-child { margin-top: 0; }
.texto ol, .texto ul { padding-left: 20px; }

/* Barra inferior */
.barra-inf {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--tarjeta); border-top: 1px solid var(--borde);
  padding-bottom: env(safe-area-inset-bottom);
}
.barra-inf button {
  background: none; border: 0; color: var(--texto-2); font: inherit; font-size: .72rem; font-weight: 600;
  padding: 8px 0 10px; min-height: 60px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px;
  -webkit-tap-highlight-color: transparent;
}
.barra-inf button span { font-size: 1.25rem; line-height: 1.2; }
.barra-inf button.activa { color: var(--acento); }

/* Dialogos */
dialog { border: 0; padding: 0; color: var(--texto); background: var(--tarjeta); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.hoja {
  width: 100%; max-width: 640px; max-height: 92vh; margin: auto auto 0; border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); overflow-y: auto;
}
.hoja-cab { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.hoja-cab h2 { margin: 0; font-size: 1.1rem; }
.modal { width: min(92vw, 420px); border-radius: 18px; padding: 18px; }
.modal p { margin: 0 0 8px; font-size: 1rem; }

.det-foto { width: 100%; max-height: 420px; object-fit: contain; border-radius: 12px; background: var(--campo); margin-bottom: 10px; }
.det-tabla { width: 100%; border-collapse: collapse; font-size: .93rem; }
.det-tabla th { text-align: left; color: var(--texto-2); font-weight: 550; padding: 7px 8px 7px 0; vertical-align: top; width: 42%; }
.det-tabla td { padding: 7px 0; overflow-wrap: anywhere; }
.det-tabla tr + tr { border-top: 1px solid var(--borde); }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: #1f2a28; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: .92rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); z-index: 50;
}
.toast.ver { opacity: 1; transform: translateX(-50%) translateY(0); }
