/* =========================================================
   Facturación Electrónica DIAN – Light Professional Theme
   ========================================================= */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --bg:          #f8fafc;
  --surface:     #ffffff;
  --surface-alt: #f8fafc;
  --border:      #e2e8f0;
  --border-mid:  #cbd5e1;
  --text:        #0f172a;
  --text-muted:  #64748b;
  --text-light:  #64748b;

  /* Sidebar */
  --nav-bg:      #0f172a;
  --nav-border:  #1e293b;
  --nav-text:    #cbd5e1;
  --nav-muted:   #94a3b8;
  --nav-hover:   rgba(255,255,255,0.06);
  --nav-active:  rgba(37,99,235,0.18);
  --nav-active-t:#ffffff;

  /* Brand */
  --acc:         #2563eb;
  --acc-light:   #f8fafc;
  --acc-hover:   #1d4ed8;

  /* Semantic - High Contrast */
  --ok:          #059669;
  --ok-bg:       #ecfdf5;
  --ok-border:   #a7f3d0;
  --warn:        #b45309;
  --warn-bg:     #fffbeb;
  --warn-border: #fde68a;
  --danger:      #b91c1c;
  --danger-bg:   #fef2f2;
  --danger-border:#fecaca;
  --info:        #0369a1;
  --info-bg:     #f0f9ff;
  --info-border: #bae6fd;

  --radius:      12px;
  --shadow-sm:   0 1px 2px rgba(15,23,42,.05);
  --shadow-md:   0 4px 6px -1px rgba(15,23,42,.07), 0 2px 4px -2px rgba(15,23,42,.05);
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  border-width: 0;
  border-style: solid;
  border-color: #e2e8f0;
}
body {
  margin: 0;
  font: 14.5px/1.6 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */
.nav {
  background: var(--nav-bg);
  border-right: 1px solid var(--nav-border);
  padding: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.nav-header {
  padding: 1.4rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand {
  font-weight: 800;
  font-size: 1.15rem;
  margin: 0 0 0.15rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.01em;
}
.brand-icon {
  width: 32px;
  height: 32px;
  background: var(--acc);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.brand-sub {
  font-size: 0.72rem;
  color: var(--nav-muted);
  font-weight: 500;
  margin: 0;
}

.tenant-box {
  margin: 0.85rem 1.25rem 0;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
}
.tenant-box .lbl {
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--nav-muted);
  font-weight: 600;
}
.tenant-box .val {
  font-weight: 700;
  font-size: 0.88rem;
  color: #fff;
  margin: 0.2rem 0 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tenant-box .nit {
  font-size: 0.74rem;
  color: var(--nav-muted);
  margin-bottom: 0.4rem;
}
.tenant-box select {
  width: 100%;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  padding: 0.35rem 0.5rem;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.25);
  color: #fff;
}

.nav-body { padding: 0.65rem 0.75rem; flex: 1; }
.nav-section {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--nav-muted);
  margin: 1.25rem 0.6rem 0.4rem;
  font-weight: 700;
}
.nav-body a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--nav-text);
  text-decoration: none !important;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.13s, color 0.13s, box-shadow 0.13s;
}
.nav-body a:hover { background: var(--nav-hover); color: #fff; }
.nav-body a.active { 
  background: var(--nav-active); 
  color: #ffffff; 
  font-weight: 600; 
  box-shadow: inset 3px 0 0 #38bdf8; 
}
.nav-body a .icon { font-size: 1.15rem; width: 22px; text-align: center; flex-shrink: 0; }

.nav-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.nav-footer a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--nav-muted);
  text-decoration: none;
  font-size: 0.83rem;
  font-weight: 500;
  transition: color 0.13s;
}
.nav-footer a:hover { color: #fff; }

/* ── Main Content ───────────────────────────────────────── */
main { padding: 1.75rem 2.5rem 3rem; width: 100%; }

/* ── Form & Settings Layouts ────────────────────────────── */
.config-layout { 
  width: 100%; 
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border);
}
h1 { font-size: 1.45rem; margin: 0; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; margin: 0 0 0.75rem; color: var(--text); font-weight: 600; }
h3 { font-size: 0.95rem; margin: 0 0 0.5rem; color: var(--text); font-weight: 600; }
.who { color: var(--text-muted); font-size: 0.84rem; }
.muted { color: var(--text-muted); }

/* ── KPI Cards ──────────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.cards article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.cards article::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--acc);
}
.cards article:nth-child(2)::before { background: var(--ok); }
.cards article:nth-child(3)::before { background: var(--warn); }
.cards article:nth-child(4)::before { background: var(--info); }
.cards article:nth-child(5)::before { background: #7c3aed; }

.kpi-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-val { font-size: 1.6rem; font-weight: 800; color: var(--text); margin: 0.25rem 0 0.1rem; letter-spacing: -0.03em; }
.kpi-sub { font-size: 0.75rem; color: var(--text-light); }

/* Legacy .muted inside cards */
.cards .muted:first-child { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Surface Panels ─────────────────────────────────────── */
.panel, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

/* ── Filters Bar ────────────────────────────────────────── */
.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.filters label { min-width: 140px; flex: 1; }

/* ── Form Controls ──────────────────────────────────────── */
label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}
label input, label select, label textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
}
.req { color: var(--danger); font-weight: bold; margin-left: 0.2rem; }

input, select, textarea {
  font: inherit;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border: 1.5px solid var(--border-mid);
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  font-size: 0.88rem;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--acc);
  box-shadow: 0 0 0 3px rgba(71,85,105,0.12);
}
input[type="file"] {
  padding: 0.45rem 0.5rem;
  border: 1.5px dashed var(--border-mid);
  background: var(--bg);
  cursor: pointer;
}
input[type="file"]::file-selector-button {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  margin-right: 0.6rem;
  transition: all 0.15s;
}
input[type="file"]::file-selector-button:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}
textarea {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.82rem;
  resize: vertical;
}

/* ── Buttons ────────────────────────────────────────────── */
button, .btn {
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  background: var(--acc);
  color: #fff;
  border: 0;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.52rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.14s, transform 0.08s, box-shadow 0.14s;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--acc-hover); box-shadow: var(--shadow-sm); }
button:active, .btn:active { transform: scale(0.98); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border-mid);
  box-shadow: none;
}
.btn-secondary:hover { background: var(--surface-alt); border-color: var(--border-mid); }
.btn-success  { background: var(--ok); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-warning  { background: var(--warn); color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-sm { padding: 0.32rem 0.65rem; font-size: 0.78rem; border-radius: 6px; }

/* ── Tables ─────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 0.875rem;
}
th, td {
  text-align: left;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
th {
  color: #475569;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #f8fafc;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--acc-light); }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ── Status Tags / Badges ───────────────────────────────── */
.tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.tag-ok, .tag-accepted, .tag-sent {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: var(--ok-border);
}
.tag-produccion {
  background: #f0fdf4;
  color: #15803d;
  border-color: #86efac;
}
.tag-warn, .tag-xml_generated, .tag-pending {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: var(--warn-border);
}
.tag-habilitacion {
  background: #fdf4ff;
  color: #7c3aed;
  border-color: #e9d5ff;
}
.tag-danger, .tag-rejected, .tag-failed {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}
.tag-info {
  background: var(--info-bg);
  color: var(--info);
  border-color: var(--info-border);
}

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info);
  font-weight: 500;
  font-size: 0.88rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.alert-ok {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok);
}
.error, .alert-error {
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-weight: 500;
  font-size: 0.88rem;
}
.alert-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn);
}

/* ── Mono / Code ─────────────────────────────────────────── */
.mono {
  word-break: break-all;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.78rem;
  background: var(--surface-alt);
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text);
}
pre.code-block {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.79rem;
  color: #e2e8f0;
  max-height: 380px;
  line-height: 1.6;
}

/* ── Layout Helpers ─────────────────────────────────────── */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.1rem; margin-top: 1rem; }
.actions { grid-column: 1 / -1; display: flex; gap: 0.6rem; align-items: center; margin-top: 0.5rem; flex-wrap: wrap; }
.span { grid-column: 1 / -1; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; background: var(--surface); }
.check { display: flex; flex-direction: row; align-items: center; gap: 0.5rem; margin: 0.3rem 0; color: var(--text); font-size: 0.88rem; font-weight: normal; }
.check input { width: auto; margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.9rem; }
.pager { display: flex; gap: 1rem; align-items: center; color: var(--text-muted); margin-top: 0.75rem; font-size: 0.86rem; }

/* ── QR & PDF ────────────────────────────────────────────── */
.qr-box {
  background: #fff;
  padding: 0.55rem;
  border-radius: var(--radius);
  display: inline-block;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* ── Login ───────────────────────────────────────────────── */
.login {
  width: min(420px, 92vw);
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem 2.25rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login .brand { justify-content: center; margin-bottom: 0.25rem; font-size: 1.35rem; }
.login .brand-sub { text-align: center; color: var(--text-muted); margin-bottom: 1.5rem; }
.login h2 { text-align: center; margin-bottom: 1.25rem; font-size: 1.1rem; }
.login label { color: var(--text-muted); }

/* ── Divider ─────────────────────────────────────────────── */
.divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .nav { flex-direction: row; flex-wrap: wrap; align-items: center; height: auto; position: relative; }
  .split { grid-template-columns: 1fr; }
  main { padding: 1rem; }
}
