/* ============================================================
   Sompopo Payment Center — Tema ejecutivo ERP (§4)
   Fondo blanco · naranja + café · botones cuadrados · denso.
   Naranja muestreado del favicon oficial: #F15A2C
   ============================================================ */

:root {
  --bg: #FFFFFF;
  --surface: #F7F5F2;          /* paneles / encabezados de tabla (blanco cálido) */
  --surface-2: #F0ECE6;
  --border: #E6E1DB;           /* divisores sutiles */
  --border-strong: #D6CFC6;

  --primary: #F15A2C;          /* NARANJA Sompopo (muestreado) */
  --primary-hover: #D8481E;
  --primary-soft: #FDEDE5;     /* fondo suave naranja */

  --secondary: #5A3320;        /* CAFÉ Sompopo */
  --secondary-hover: #442617;
  --secondary-2: #6E4528;
  --secondary-soft: #F3ECE7;

  --text: #2B2622;
  --muted: #857B72;
  --on-dark: #FBF7F3;

  --positive: #2E7D32;
  --positive-soft: #E7F2E8;
  --warning: #C9621A;
  --warning-soft: #FBEEE2;
  --danger: #B3261E;
  --danger-soft: #FBE9E8;
  --info: #1F5C8B;
  --info-soft: #E8F0F6;

  --radius: 2px;               /* botones/cajas casi cuadrados */
  --shadow: 0 1px 2px rgba(43, 38, 34, 0.06);
  --sidebar-w: 232px;
  --topbar-h: 52px;

  --font: "Segoe UI", "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-hover); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 600; color: var(--text); margin: 0 0 .4rem; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }

/* ---------- Layout administrativo ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--secondary);
  color: var(--on-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 20;
}
.sidebar__brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: 0 14px;
  background: rgba(0,0,0,.12);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar__brand img { height: 30px; width: auto; }
.sidebar__brand b { font-size: .9rem; font-weight: 600; letter-spacing: .2px; color: #fff; }
.sidebar__brand span { font-size: .62rem; color: rgba(255,255,255,.6); display:block; line-height:1; }

.sidebar__section {
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.45);
  padding: 14px 16px 4px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 7px 16px;
  color: rgba(255,255,255,.82);
  font-size: .82rem;
  border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active {
  background: rgba(241,90,44,.16);
  color: #fff;
  border-left-color: var(--primary);
  font-weight: 600;
}
.nav a .ico { width: 16px; text-align: center; opacity: .9; }

.sidebar__foot {
  margin-top: auto;
  padding: 10px 16px;
  font-size: .68rem;
  color: rgba(255,255,255,.5);
  border-top: 1px solid rgba(255,255,255,.08);
}

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  position: sticky; top: 0; z-index: 10;
}
.topbar__title { font-size: .98rem; font-weight: 600; }
.topbar__title small { color: var(--muted); font-weight: 400; margin-left: .4rem; font-size: .75rem; }
.topbar__user { display: flex; align-items: center; gap: .6rem; font-size: .8rem; color: var(--muted); }
.topbar__user .avatar {
  width: 28px; height: 28px; border-radius: var(--radius);
  background: var(--secondary); color: #fff; display: grid; place-items: center;
  font-size: .72rem; font-weight: 600;
}

.content { padding: 18px 20px 60px; max-width: 1500px; }

/* ---------- Encabezado de página ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; gap: 1rem; }
.page-head h1 { margin: 0; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: .82rem; }
.page-head__actions { display: flex; gap: .5rem; flex-shrink: 0; }

/* ---------- Botones (cuadrados) ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  border: 1px solid var(--border-strong);
  background: #fff; color: var(--text);
  padding: 6px 12px;
  font-size: .8rem; font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
  line-height: 1.2;
  transition: background .12s, border-color .12s;
  text-decoration: none;
}
.btn:hover { background: var(--surface); text-decoration: none; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--secondary { background: var(--secondary); border-color: var(--secondary); color: #fff; }
.btn--secondary:hover { background: var(--secondary-2); border-color: var(--secondary-2); }
.btn--danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); }
.btn--success { background: var(--positive); border-color: var(--positive); color: #fff; }
.btn--success:hover { filter: brightness(.94); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface); }
.btn--sm { padding: 3px 8px; font-size: .72rem; }
.btn--block { width: 100%; justify-content: center; }

/* ---------- Paneles / tarjetas (uso limitado, bordes sutiles) ---------- */
.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.panel__head {
  padding: 9px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-weight: 600; font-size: .85rem;
  display: flex; align-items: center; justify-content: space-between;
}
.panel__body { padding: 14px; }
.panel__body--flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid--3, .grid--4 { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Stat cards (KPIs del dashboard) ---------- */
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat__label { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stat__value { font-size: 1.5rem; font-weight: 700; margin-top: 2px; }
.stat__sub { font-size: .74rem; color: var(--muted); margin-top: 2px; }
.stat--accent { border-top: 3px solid var(--primary); }
.stat--brown { border-top: 3px solid var(--secondary); }

/* ---------- Tablas densas (superficie principal de trabajo) ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .8rem; }
table.tbl thead th {
  background: var(--surface);
  text-align: left;
  font-weight: 600;
  color: var(--secondary);
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
table.tbl tbody td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr:hover { background: var(--surface); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tbl .muted { color: var(--muted); }
.tbl--rows tbody tr { cursor: pointer; }

.empty { padding: 30px; text-align: center; color: var(--muted); font-size: .85rem; }

/* ---------- Badges de estado ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: 2px 8px; border-radius: var(--radius);
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge--ingested  { background: var(--surface-2); color: var(--muted); border-color: var(--border-strong); }
.badge--in_review { background: var(--info-soft); color: var(--info); }
.badge--authorized{ background: var(--secondary-soft); color: var(--secondary); }
.badge--scheduled { background: var(--primary-soft); color: var(--primary-hover); }
.badge--paid      { background: var(--positive-soft); color: var(--positive); }
.badge--rejected  { background: var(--danger-soft); color: var(--danger); }
.badge--late      { background: var(--warning-soft); color: var(--warning); }
.badge--neutral   { background: var(--surface-2); color: var(--muted); border-color: var(--border-strong); }
.badge--ok        { background: var(--positive-soft); color: var(--positive); }
.badge--dot::before { content: "●"; font-size: .6em; }

/* ---------- Panel de estado de integración ---------- */
.integration { display: flex; align-items: center; gap: .5rem; }
.status-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: 3px 10px; border-radius: var(--radius);
  font-size: .72rem; font-weight: 700;
  background: var(--positive-soft); color: var(--positive);
  border: 1px solid #BBD9BC;
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--positive); box-shadow: 0 0 0 3px rgba(46,125,50,.18); }
.status-pill--off { background: var(--surface-2); color: var(--muted); border-color: var(--border-strong); }
.status-pill--off .dot { background: var(--muted); box-shadow: none; }

/* ---------- Formularios compactos ---------- */
.form-row { margin-bottom: 12px; }
.form-grid { display: grid; gap: 12px 16px; grid-template-columns: repeat(2, 1fr); }
.form-grid--3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .form-grid, .form-grid--3 { grid-template-columns: 1fr; } }
label.lbl { display: block; font-size: .74rem; font-weight: 600; color: var(--secondary); margin-bottom: 3px; }
label.lbl .req { color: var(--danger); }
.help { font-size: .7rem; color: var(--muted); margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: .82rem;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(241,90,44,.25); outline-offset: -1px; border-color: var(--primary); }
textarea { resize: vertical; min-height: 64px; }
.inline-form { display: inline; }

.checkbox { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; }

/* ---------- Alertas / flash ---------- */
.alert { padding: 9px 12px; border-radius: var(--radius); font-size: .82rem; margin-bottom: 14px; border: 1px solid; display: flex; gap: .5rem; align-items: flex-start; }
.alert--success { background: var(--positive-soft); border-color: #BBD9BC; color: #205723; }
.alert--error   { background: var(--danger-soft); border-color: #E5B6B3; color: #8A1D17; }
.alert--info    { background: var(--info-soft); border-color: #Bcd4e6; color: #174a6e; }
.alert--warning { background: var(--warning-soft); border-color: #EAC59E; color: #8a4413; }

/* ---------- Utilidades ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .35rem; } .gap-2 { gap: .7rem; } .gap-3 { gap: 1rem; }
.mt-1{margin-top:.4rem}.mt-2{margin-top:.8rem}.mt-3{margin-top:1.2rem}
.mb-0{margin-bottom:0}.mb-1{margin-bottom:.4rem}.mb-2{margin-bottom:.8rem}
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.text-sm { font-size: .76rem; }
.text-xs { font-size: .68rem; }
.fw-600 { font-weight: 600; }
.nowrap { white-space: nowrap; }
.w-full { width: 100%; }
.tag { font-size: .68rem; padding: 1px 6px; background: var(--surface-2); border:1px solid var(--border); border-radius: var(--radius); color: var(--muted); }
.divider { height:1px; background: var(--border); margin: 14px 0; }
.bank-logo { height: 22px; width: auto; vertical-align: middle; }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.progress { background: var(--surface-2); border-radius: var(--radius); height: 8px; overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; background: var(--primary); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: .82rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

/* ---------- Pantallas guest (login / OTP / portal landing) ---------- */
.guest { min-height: 100vh; display: grid; place-items: center; background: var(--surface); padding: 20px; }
.guest__card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.guest__head { padding: 22px 24px 6px; text-align: center; }
.guest__head img { height: 40px; }
.guest__body { padding: 10px 24px 24px; }
.guest__foot { text-align: center; font-size: .72rem; color: var(--muted); padding: 14px; }

/* ---------- Tarjetas de lote (pantalla de Lotes) ---------- */
.lote-card { background:#fff; border:1px solid var(--border); border-radius:var(--radius); border-left:4px solid var(--primary); display:flex; flex-direction:column; }
.lote-card.is-draft { border-left-color: var(--muted); }
.lote-card.is-authorized { border-left-color: var(--primary); }
.lote-card__head { padding:10px 14px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; }
.lote-card__date { font-weight:700; font-size:1rem; }
.lote-card__date small { display:block; font-size:.66rem; font-weight:400; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; }
.lote-card__body { padding:12px 14px; display:flex; flex-direction:column; gap:8px; }
.lote-card__total { font-size:1.6rem; font-weight:800; color:var(--secondary); line-height:1; }
.lote-card__total small { font-size:.66rem; font-weight:600; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; display:block; margin-bottom:2px; }
.lote-card__meta { display:flex; align-items:center; justify-content:space-between; font-size:.78rem; color:var(--muted); }
.lote-card__foot { padding:10px 14px; border-top:1px solid var(--border); display:flex; gap:.4rem; align-items:center; }
.cover-ok { color:var(--positive); font-weight:600; font-size:.74rem; }
.cover-bad { color:var(--danger); font-weight:600; font-size:.74rem; }

/* ---------- Modales ---------- */
.modal-overlay { display:none; position:fixed; inset:0; background:rgba(43,38,34,.5); z-index:100; align-items:center; justify-content:center; padding:20px; }
.modal-overlay.open { display:flex; }
.modal { background:#fff; border-radius:4px; width:100%; max-width:580px; max-height:90vh; overflow:auto; box-shadow:0 12px 44px rgba(0,0,0,.3); border-top:4px solid var(--primary); }
.modal__head { padding:14px 18px; border-bottom:1px solid var(--border); font-weight:700; font-size:1rem; color:var(--secondary); display:flex; align-items:center; justify-content:space-between; }
.modal__x { background:none; border:none; font-size:1.5rem; cursor:pointer; color:var(--muted); line-height:1; padding:0 4px; }
.modal__body { padding:16px 18px; }
.modal__foot { padding:14px 18px; border-top:1px solid var(--border); display:flex; gap:.5rem; justify-content:flex-end; }

/* ---------- Overlay de sincronización con Odoo ---------- */
.sync-overlay { display:none; position:fixed; inset:0; background:rgba(43,38,34,.80); z-index:200; align-items:center; justify-content:center; }
.sync-overlay.open { display:flex; }
.sync-card { background:#fff; border-radius:6px; padding:30px 34px; width:430px; max-width:92vw; text-align:center; box-shadow:0 14px 56px rgba(0,0,0,.45); }
.sync-badge { display:inline-block; background:#714B67; color:#fff; font-weight:700; padding:4px 12px; border-radius:3px; font-size:.78rem; letter-spacing:.6px; }
.sync-card h3 { margin:16px 0 4px; color:var(--secondary); font-size:1.05rem; }
.sync-step { color:var(--muted); font-size:.86rem; min-height:1.3em; margin:6px 0 14px; }
.sync-pct { margin-top:8px; font-weight:800; color:var(--primary-hover); font-size:1.1rem; }
.sync-spin { width:40px;height:40px;border:4px solid var(--surface-2);border-top-color:#714B67;border-radius:50%;margin:0 auto 4px;animation:spin 1s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }

/* ---------- Indicador Host-to-Host ---------- */
.h2h { display:inline-flex; align-items:center; gap:.4rem; font-size:.72rem; font-weight:700; color:var(--positive); background:var(--positive-soft); border:1px solid #BBD9BC; padding:3px 10px; border-radius:var(--radius); }
.h2h .dot { width:8px;height:8px;border-radius:50%;background:var(--positive); box-shadow:0 0 0 3px rgba(46,125,50,.18); animation:pulse 1.6s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }

/* ---------- Dropzone (subir factura) ---------- */
.dropzone { border:2px dashed var(--border-strong); border-radius:6px; padding:34px 20px; text-align:center; cursor:pointer; background:var(--surface); transition:border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color:var(--primary); background:var(--primary-soft); }
.dropzone img { height:52px; opacity:.92; margin-bottom:8px; }
.dropzone p { margin:4px 0; color:var(--muted); font-size:.86rem; }
.dropzone .link { color:var(--primary-hover); font-weight:700; }
.preview-box { border:1px solid var(--border); border-radius:4px; margin-top:14px; overflow:hidden; }
.preview-box .ph { padding:8px 12px; background:var(--surface); border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center; font-size:.82rem; }
.preview-box embed, .preview-box img { display:block; width:100%; max-height:430px; background:#fff; }

/* ---------- Overlay Revisión Inteligente ---------- */
.ai-overlay { display:none; position:fixed; inset:0; background:rgba(43,38,34,.82); z-index:200; align-items:center; justify-content:center; }
.ai-overlay.open { display:flex; }
.ai-card { background:#fff; border-radius:8px; padding:34px 38px; width:440px; max-width:92vw; text-align:center; box-shadow:0 14px 56px rgba(0,0,0,.45); }
.ai-logo { height:66px; animation:aipulse 1.4s ease-in-out infinite; }
@keyframes aipulse { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.13);opacity:.7} }
.ai-card h3 { margin:16px 0 6px; color:var(--secondary); font-size:1.1rem; }
.ai-step { color:var(--muted); font-size:.9rem; min-height:1.3em; }
.ai-bar { margin-top:16px; height:6px; background:var(--surface-2); border-radius:4px; overflow:hidden; }
.ai-bar > span { display:block; height:100%; width:35%; background:linear-gradient(90deg,var(--primary),var(--primary-hover)); border-radius:4px; animation:aiload 1.3s ease-in-out infinite; }
@keyframes aiload { 0%{margin-left:-35%} 100%{margin-left:100%} }

/* Badge "Desde Odoo" (logo oficial) en facturas importadas */
.badge-odoo { display:inline-flex; align-items:center; gap:5px; background:#fff; border:1px solid #d9d2e6; color:#714B67; border-radius:var(--radius); padding:2px 8px; font-size:.7rem; font-weight:700; white-space:nowrap; }
.badge-odoo img { height:15px; display:block; }

/* ---------- Portal proveedor (un poco más cálido) ---------- */
.portal-topbar { background: var(--secondary); color: #fff; height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
.portal-topbar img { height: 32px; }
.portal-topbar .who { font-size: .8rem; color: rgba(255,255,255,.85); }
.portal-wrap { max-width: 1080px; margin: 0 auto; padding: 22px 18px 60px; }
.portal-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.portal-tabs a { padding: 9px 16px; font-size: .85rem; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.portal-tabs a:hover { color: var(--text); text-decoration: none; }
.portal-tabs a.active { color: var(--primary-hover); border-bottom-color: var(--primary); }
