@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Outfit:wght@600;700;800&display=swap');

:root {
  --bg: #0b1120;
  --card: #151f32;
  --card-2: #101827;
  --muted: #94a3b8;
  --text: #f8fafc;
  --line: rgba(255,255,255,.09);
  --blue: #3b82f6;
  --green: #10b981;
  --teal: #14b8a6;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 10px;
  --shadow: 0 16px 42px rgba(0,0,0,.36);
}

body.light-theme {
  --bg: #f1f5f9;
  --card: #ffffff;
  --card-2: #f8fafc;
  --muted: #64748b;
  --text: #0f172a;
  --line: #e2e8f0;
  --shadow: 0 14px 34px rgba(15,23,42,.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
}

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  padding: 22px 16px;
  background: var(--card-2);
  border-right: 1px solid var(--line);
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #021a25; font: 800 .82rem Outfit, sans-serif;
}
.brand strong { display: block; font: 800 1.05rem Outfit, sans-serif; }
.brand span { display: block; color: var(--muted); font-size: .74rem; margin-top: 2px; }
nav { display: grid; gap: 6px; }
nav a {
  color: var(--muted); text-decoration: none; padding: 11px 12px;
  border-radius: var(--radius); font-size: .88rem; font-weight: 700;
}
nav a.active, nav a:hover { color: var(--text); background: rgba(20,184,166,.14); }
.ghost-btn, .secondary-btn, .primary-btn {
  border: 1px solid var(--line); color: var(--text); background: transparent;
  border-radius: var(--radius); min-height: 38px; padding: 9px 13px;
  font: 700 .86rem Inter, sans-serif; cursor: pointer;
}
.ghost-btn { width: 100%; margin-top: 20px; color: var(--muted); }
.secondary-btn { background: rgba(148,163,184,.10); }
.primary-btn {
  border-color: rgba(20,184,166,.55);
  color: #052e2b;
  background: linear-gradient(135deg, #2dd4bf, #60a5fa);
}
.primary-btn:disabled { opacity: .55; cursor: wait; }

.main { margin-left: 250px; width: calc(100% - 250px); padding: 26px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 4px; color: #5eead4; font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
h1, h2 { font-family: Outfit, Inter, sans-serif; letter-spacing: -.03em; }
h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.7rem); }
h2 { margin: 0; font-size: 1.25rem; }
.topbar p, .panel-head p { margin: 5px 0 0; color: var(--muted); max-width: 720px; }
.top-actions, .row-actions, .submit-row { display: flex; gap: 10px; align-items: center; }
.user-pill { border: 1px solid var(--line); border-radius: 999px; padding: 9px 12px; color: var(--muted); font-size: .82rem; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.kpi, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.kpi { padding: 16px; }
.kpi span { color: var(--muted); font-size: .75rem; font-weight: 800; text-transform: uppercase; }
.kpi strong { display: block; margin-top: 8px; font-size: 1.65rem; }
.panel { padding: 18px; margin-bottom: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 12px; margin-bottom: 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: minmax(0, 2fr) minmax(120px, .8fr) minmax(120px, .8fr) 90px; }
label { color: var(--muted); font-size: .78rem; font-weight: 800; }
input, select {
  width: 100%; min-height: 40px; margin-top: 6px; padding: 9px 10px;
  color: var(--text); background: var(--card-2); border: 1px solid var(--line);
  border-radius: 9px; outline: none; font: 500 .9rem Inter, sans-serif;
}
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(20,184,166,.16); }
.manual-box { border: 1px dashed rgba(20,184,166,.55); background: rgba(20,184,166,.08); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.manual-line { align-items: end; border-top: 1px solid var(--line); padding-top: 10px; }
.line-toolbar { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; }
.line-toolbar span, .hint { color: var(--muted); font-size: .8rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 1080px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; background: var(--card-2); }
td { font-size: .86rem; }
td input, td select { margin: 0; min-height: 34px; font-size: .82rem; }
.empty { color: var(--muted); text-align: center; padding: 28px; }
.qty { max-width: 82px; }
.desc-cell strong { display: block; }
.desc-cell span { color: var(--muted); font-size: .76rem; }
.form-msg { flex: 1; color: var(--muted); font-size: .86rem; }
.submit-row { justify-content: space-between; margin-top: 14px; }
.notifications { display: grid; gap: 8px; margin-bottom: 14px; }
.notice { border: 1px solid rgba(245,158,11,.28); background: rgba(245,158,11,.10); border-radius: 10px; padding: 10px 12px; color: var(--text); font-size: .86rem; }
.notice.subdued { border-color: var(--line); background: rgba(148,163,184,.08); color: var(--muted); margin-bottom: 12px; }
.reception-list { display: grid; gap: 10px; }
.rx-card { border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); padding: 13px; }
.rx-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.rx-title { font-weight: 800; }
.rx-meta { color: var(--muted); font-size: .8rem; margin-top: 3px; }
.badge { display: inline-flex; border-radius: 999px; padding: 4px 9px; font-size: .72rem; font-weight: 800; border: 1px solid var(--line); }
.badge.COMPLETA { color: #34d399; background: rgba(16,185,129,.12); }
.badge.PARCIAL { color: #fbbf24; background: rgba(245,158,11,.12); }
.badge.CON_DIFERENCIAS, .badge.BLOQUEADA_POR_DIFERENCIAS { color: #f87171; background: rgba(239,68,68,.12); }
.rx-lines { margin-top: 10px; display: grid; gap: 6px; }
.rx-line { color: var(--muted); font-size: .8rem; }
.pay-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.link-invoice { display: grid; grid-template-columns: minmax(220px, 1fr) auto; gap: 8px; margin-top: 10px; align-items: end; }
.evidence-link { display: inline-flex; margin-top: 8px; color: var(--teal); font-size: .82rem; font-weight: 800; text-decoration: none; }

@media (max-width: 900px) {
  .sidebar { position: sticky; top: 0; width: 100%; height: auto; display: block; }
  .app-shell { display: block; }
  .main { margin-left: 0; width: 100%; padding: 14px; }
  .topbar, .panel-head { display: block; }
  .top-actions, .row-actions, .submit-row { margin-top: 12px; align-items: stretch; flex-direction: column; }
  .kpis, .grid.two, .grid.three, .grid.four, .link-invoice { grid-template-columns: 1fr; }
  nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ghost-btn { margin-top: 12px; }
}
