/* ===================================================================
   Asistente Contable · Facturas Paraguay — estilos (mobile-first)
   Paleta: Azul #0D3B65 · Verde #4DB69C · Hueso #E9E5D6
                  Gris #4A4A4A · Negro #1B1B1B
   =================================================================== */
:root {
  --navy:   #0D3B65;
  --navy-d: #092A4A;
  --green:  #4DB69C;
  --green-d:#3A9A82;
  --sand:   #E9E5D6;
  --sand-d: #DAD4C0;
  --paper:  #F7F6F1;
  --gray:   #4A4A4A;
  --gray-l: #7A7A7A;
  --ink:    #1B1B1B;
  --white:  #FFFFFF;
  --line:   rgba(13,59,101,.14);
  --danger: #B5524B;
  --warn:   #C9921F;
  --ok:     #2E7D5B;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(9,42,74,.06), 0 10px 30px rgba(9,42,74,.10);
  --shadow-sm: 0 1px 3px rgba(9,42,74,.12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; color: var(--navy); font-weight: 700; letter-spacing: -.01em; }
[hidden] { display: none !important; }
.muted { color: var(--gray-l); font-size: .85em; }

/* ── Botones ── */
.btn {
  font-family: var(--font); font-weight: 650; font-size: .95rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .7em 1.1em; cursor: pointer; touch-action: manipulation;
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-d); }
.btn-green { background: var(--green); color: #06382c; }
.btn-green:hover { background: var(--green-d); }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { background: var(--sand); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: .45em .8em; font-size: .82rem; }

/* ── Login ── */
.login-screen {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 1.5rem;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-d) 60%, #061d33 100%);
}
.login-card {
  width: 100%; max-width: 380px; background: #fff;
  border-radius: var(--radius); padding: 2rem 1.6rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .9rem;
}
.brand-mark { font-weight: 800; letter-spacing: .12em; color: var(--navy); font-size: 1.4rem; }
.brand-sub { color: var(--green-d); font-size: .8rem; font-weight: 600; }
.login-title { font-size: 1.25rem; margin-top: .3rem; }
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--gray); }
.field input, .field select {
  font-family: var(--font); font-size: 1rem; padding: .65em .8em;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus { outline: 2px solid var(--green); border-color: var(--green); }
.login-error { color: var(--danger); font-size: .85rem; margin: 0; }
.login-foot { color: rgba(255,255,255,.6); font-size: .75rem; margin-top: 1.2rem; }

/* ── Layout app ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1rem; box-shadow: var(--shadow-sm);
}
.topbar .brand-mark { color: #fff; font-size: 1.1rem; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.period-select {
  font-family: var(--font); font-weight: 600; font-size: .9rem;
  background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25);
  border-radius: var(--radius-sm); padding: .4em .6em;
}
.period-select option { color: var(--ink); }
.icon-btn { background: none; border: none; color: #fff; font-size: 1.2rem; cursor: pointer; padding: .3em; border-radius: 8px; }
.icon-btn:hover { background: rgba(255,255,255,.12); }

.wrap { max-width: 760px; margin: 0 auto; padding: 1rem; padding-bottom: 4rem; display: flex; flex-direction: column; gap: 1rem; }

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow-sm); }
.card h2 { font-size: 1.05rem; margin-bottom: .7rem; }
.section-hint { color: var(--gray-l); font-size: .8rem; margin: 0 0 .7rem; }

/* ── Carga ── */
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.upload-btn {
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  padding: 1.1rem .5rem; border-radius: var(--radius); cursor: pointer; border: 2px dashed transparent;
  font-weight: 700; font-size: 1rem; touch-action: manipulation;
}
.upload-compra { background: #eef6f3; color: var(--green-d); border-color: var(--green); }
.upload-venta  { background: #eaf1f8; color: var(--navy);    border-color: var(--navy); }
.upload-btn .ico { font-size: 1.6rem; }
.upload-btn .lbl-sub { font-size: .72rem; font-weight: 500; color: var(--gray-l); }

/* ── Resumen IVA/IRP ── */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .8rem; }
.kpi .k-label { font-size: .72rem; color: var(--gray-l); text-transform: uppercase; letter-spacing: .04em; }
.kpi .k-value { font-size: 1.25rem; font-weight: 800; color: var(--navy); margin-top: .15rem; }
.kpi.k-pay .k-value { color: var(--danger); }
.kpi.k-fav .k-value { color: var(--ok); }
.kpi-row { display: flex; justify-content: space-between; font-size: .85rem; color: var(--gray); padding: .2rem 0; }
.venc-note { font-size: .78rem; color: var(--warn); margin-top: .5rem; font-weight: 600; }

/* ── Lista de facturas ── */
.factura-list { display: flex; flex-direction: column; gap: .6rem; }
.factura {
  display: flex; align-items: center; gap: .7rem; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .7rem; cursor: pointer;
}
.factura:hover { border-color: var(--green); }
.factura .thumb { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; background: var(--sand); flex: none; }
.factura .f-main { flex: 1; min-width: 0; }
.factura .f-emisor { font-weight: 650; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.factura .f-meta { font-size: .76rem; color: var(--gray-l); }
.factura .f-total { font-weight: 800; color: var(--navy); font-size: .95rem; text-align: right; white-space: nowrap; }
.badge { display: inline-block; font-size: .68rem; font-weight: 700; padding: .15em .55em; border-radius: 999px; }
.badge-compra { background: #eef6f3; color: var(--green-d); }
.badge-venta  { background: #eaf1f8; color: var(--navy); }
.badge-warn   { background: #fbf0d8; color: var(--warn); }
.empty { text-align: center; color: var(--gray-l); padding: 1.5rem .5rem; font-size: .9rem; }

/* ── Reportes ── */
.report-grid { display: flex; flex-direction: column; gap: .55rem; }

/* ── Modal ── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(9,42,74,.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 40; padding: 0;
}
.modal {
  background: #fff; width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0; padding: 1.2rem; box-shadow: var(--shadow);
}
.modal h2 { margin-bottom: .8rem; }
.modal .preview { width: 100%; max-height: 240px; object-fit: contain; border-radius: var(--radius-sm); background: var(--sand); margin-bottom: .8rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.form-grid .full { grid-column: 1 / -1; }
.modal-actions { display: flex; gap: .6rem; margin-top: 1rem; }
.modal-actions .btn { flex: 1; }
.chk { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--gray); }
.chk input { width: 1.1rem; height: 1.1rem; accent-color: var(--green); }

/* ── Toast / overlay ── */
.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: .7em 1.2em; border-radius: 999px;
  font-size: .9rem; z-index: 60; box-shadow: var(--shadow); max-width: 90vw; text-align: center;
}
.toast-error { background: var(--danger); }
.overlay {
  position: fixed; inset: 0; background: rgba(247,246,241,.85); z-index: 70;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
}
.spinner { width: 44px; height: 44px; border: 4px solid var(--sand-d); border-top-color: var(--green); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.overlay-text { color: var(--navy); font-weight: 600; }

@media (min-width: 620px) {
  .modal-bg { align-items: center; }
  .modal { border-radius: var(--radius); }
}
