/* Facturador SUNAT — CSS propio, autocontenido (sin CDN, sin build). */
:root {
  --azul: #1e3a8a;
  --azul-claro: #2563eb;
  --azul-hover: #1d4ed8;
  --verde: #059669;
  --rojo: #dc2626;
  --amarillo: #d97706;
  --gris-bg: #f1f5f9;
  --gris-borde: #e2e8f0;
  --gris-texto: #475569;
  --texto: #0f172a;
  --blanco: #ffffff;
  --sombra: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --radio: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--gris-bg);
  color: var(--texto);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--azul-claro); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout con barra lateral */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--azul); color: #e0e7ff;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar .brand { padding: 20px 18px; font-size: 18px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar .brand small { display:block; font-weight:400; font-size:12px; color:#c7d2fe; }
.sidebar nav { padding: 12px 0; flex: 1; }
.sidebar nav a {
  display: block; padding: 11px 18px; color: #c7d2fe; font-size: 14px; border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,.12); color: #fff; border-left-color: #fff; font-weight: 600; }
.sidebar .foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }

/* Contenido */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--blanco); border-bottom: 1px solid var(--gris-borde);
  padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar .empresa-sel { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.topbar .empresa-sel select { max-width: 320px; }
.content { padding: 24px; flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }

/* Tarjetas */
.card { background: var(--blanco); border: 1px solid var(--gris-borde); border-radius: var(--radio); box-shadow: var(--sombra); }
.card .card-body { padding: 20px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat { padding: 18px 20px; }
.stat .label { font-size: 13px; color: var(--gris-texto); }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 4px; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table.tabla { width: 100%; border-collapse: collapse; background: var(--blanco); }
table.tabla th, table.tabla td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--gris-borde); font-size: 14px; }
table.tabla th { background: #f8fafc; color: var(--gris-texto); font-weight: 600; text-transform: uppercase; font-size: 12px; letter-spacing: .03em; }
table.tabla tbody tr:hover { background: #f8fafc; }

/* Formularios */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--gris-texto); }
.field .hint { font-size: 12px; color: #94a3b8; }
input, select, textarea {
  font: inherit; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: var(--texto); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--azul-claro); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.field .error { color: var(--rojo); font-size: 12px; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* Botones */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent; font-size: 14px; font-weight: 600; cursor: pointer; background: #e2e8f0; color: var(--texto); }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--azul-claro); color: #fff; }
.btn-primary:hover { background: var(--azul-hover); }
.btn-success { background: var(--verde); color: #fff; }
.btn-danger { background: var(--rojo); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-ghost { background: transparent; border-color: #cbd5e1; }

/* Badges / alertas */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.green { background: #d1fae5; color: #065f46; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.yellow { background: #fef3c7; color: #92400e; }
.badge.gray { background: #e2e8f0; color: #334155; }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--azul), var(--azul-claro)); padding: 20px; }
.login-card { background: #fff; border-radius: 14px; box-shadow: 0 20px 40px rgba(0,0,0,.25); width: 100%; max-width: 380px; padding: 32px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p.sub { color: var(--gris-texto); font-size: 14px; margin: 0 0 22px; }

.muted { color: var(--gris-texto); }
.text-right { text-align: right; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

/* Responsive */
@media (max-width: 820px) {
  .sidebar { width: 64px; }
  .sidebar .brand small, .sidebar nav a span, .sidebar .foot span { display: none; }
  .sidebar nav a { text-align: center; padding: 14px 0; }
}
