/**
 * Ultra Modern FinTech Design System for e-CF Facturación Dominicana
 */
:root {
  --bg-body: #070d18;
  --bg-surface: #0e172a;
  --bg-surface-hover: #15223c;
  --bg-card: rgba(15, 23, 42, 0.78);
  --bg-card-solid: #0d1527;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-card: rgba(255, 255, 255, 0.12);
  --border-light: rgba(255, 255, 255, 0.16);
  --border-focus: #3b82f6;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.35);
  --gradient-brand: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  --gradient-card: linear-gradient(145deg, rgba(26, 38, 64, 0.5) 0%, rgba(13, 21, 39, 0.8) 100%);
  --gradient-badge: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(99, 102, 241, 0.15) 100%);

  /* Fiscal Status Badges */
  --ok: #10b981;
  --ok-bg: rgba(16, 185, 129, 0.12);
  --ok-border: rgba(16, 185, 129, 0.35);

  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.12);
  --warn-border: rgba(245, 158, 11, 0.35);

  --crit: #ef4444;
  --crit-bg: rgba(239, 68, 68, 0.12);
  --crit-border: rgba(239, 68, 68, 0.35);

  --info: #06b6d4;
  --info-bg: rgba(6, 182, 212, 0.12);
  --info-border: rgba(6, 182, 212, 0.35);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 48px -8px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 32px -4px rgba(59, 130, 246, 0.25);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-body);
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(59, 130, 246, 0.14) 0%, transparent 40%),
    radial-gradient(circle at 90% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 50% 85%, rgba(14, 165, 233, 0.08) 0%, transparent 55%),
    radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body.center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

/* Typography & Titles */
h1 {
  font-size: 1.95rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  color: #fff;
  margin: 0.2em 0 0.8em;
  line-height: 1.25;
}

h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -0.025em;
  margin: 1.8em 0 0.8em;
}

h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #e2e8f0;
  margin: 0.4em 0;
}

p { margin-bottom: 1rem; }

a {
  color: var(--primary);
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

a:hover {
  color: #60a5fa;
}

code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(255, 255, 255, 0.07);
  color: #93c5fd;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.88em;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.muted { color: var(--text-muted); }
.r { text-align: right; }

/* Main Container */
main {
  max-width: 1260px;
  margin: 0 auto;
  padding: 38px 30px;
  animation: pageIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px) scale(0.995); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header & Navigation Bar */
.top {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7, 13, 24, 0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 13px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.3);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  color: #fff;
  text-decoration: none;
}

.brand span {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.16);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.top nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.top nav a {
  color: var(--text-muted);
  font-size: 0.90rem;
  font-weight: 600;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.top nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.top nav a.on {
  color: #fff;
  background: var(--gradient-brand);
  box-shadow: 0 4px 14px var(--primary-glow);
  font-weight: 700;
}

.who {
  display: flex;
  align-items: center;
  gap: 12px;
}

.who a {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.88rem;
  color: #e2e8f0;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  transition: all 0.2s ease;
}

.who a:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.18);
}

.who form { margin: 0; }
.who .link {
  color: #fca5a5;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.09);
  border: 1px solid rgba(239, 68, 68, 0.22);
  transition: all 0.2s ease;
  cursor: pointer;
}

.who .link:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fff;
  border-color: rgba(239, 68, 68, 0.4);
}

/* Dashboard Action Row */
.header-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 28px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

/* Stat Cards */
.grid4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat {
  background: var(--bg-card);
  background-image: var(--gradient-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-card);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow-md);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.stat::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.5), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stat:hover {
  transform: translateY(-4px);
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.stat:hover::after {
  opacity: 1;
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.stat-header span {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.stat:hover .stat-icon {
  transform: scale(1.08);
}

.icon-blue { background: rgba(59, 130, 246, 0.16); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.25); }
.icon-yellow { background: rgba(245, 158, 11, 0.16); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.25); }
.icon-indigo { background: rgba(99, 102, 241, 0.16); color: #818cf8; border: 1px solid rgba(99, 102, 241, 0.25); }
.icon-red { background: rgba(239, 68, 68, 0.16); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.25); }
.icon-green { background: rgba(16, 185, 129, 0.16); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.25); }

.stat b {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.035em;
  line-height: 1.15;
  display: block;
}

/* Card General */
.card {
  background: var(--bg-card);
  background-image: var(--gradient-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
}

/* Modern Login Form */
.login {
  width: 100%;
  max-width: 440px;
  padding: 44px 38px;
  background: #0d1527;
  background-image: radial-gradient(at 50% 0%, rgba(59, 130, 246, 0.18) 0px, transparent 65%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 22px;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(59, 130, 246, 0.18);
  display: grid;
  gap: 20px;
  animation: popIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* Tables */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-card);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
  margin-bottom: 26px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 15px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.92rem;
}

th {
  background: rgba(13, 22, 41, 0.9);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

th.r, td.r { text-align: right; }

tbody tr {
  transition: background-color 0.15s ease;
}

tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.04);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* e-NCF Pill Badge */
.encf-badge {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.14);
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid rgba(59, 130, 246, 0.3);
  display: inline-block;
  font-size: 0.92em;
  letter-spacing: 0.02em;
  transition: all 0.2s ease;
}

.encf-badge:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(59, 130, 246, 0.6);
  transform: scale(1.02);
  color: #93c5fd;
}

/* Fiscal Badges with Pulse Dots */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.badge.aceptado {
  background: var(--ok-bg);
  color: #34d399;
  border-color: var(--ok-border);
}

.badge.aceptado_condicional {
  background: rgba(132, 204, 22, 0.15);
  color: #bef264;
  border-color: rgba(132, 204, 22, 0.35);
}

.badge.rechazado, .badge.error_envio {
  background: var(--crit-bg);
  color: #f87171;
  border-color: var(--crit-border);
}

.badge.pendiente_envio {
  background: var(--warn-bg);
  color: #fbbf24;
  border-color: var(--warn-border);
}

.badge.enviado {
  background: var(--info-bg);
  color: #38bdf8;
  border-color: var(--info-border);
}

.badge.cont {
  background: rgba(154, 52, 18, 0.25);
  color: #fdba74;
  border-color: rgba(234, 88, 12, 0.4);
}

/* Inputs, Buttons & Controls */
label {
  display: grid;
  gap: 7px;
  font-size: 0.90rem;
  color: var(--text-muted);
  font-weight: 600;
}

label.check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

label.check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: rgba(13, 21, 39, 0.85);
  color: #fff;
  width: 100%;
  transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: #111d38;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 11px 22px;
  border: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.btn.primary {
  background: var(--gradient-brand);
  border: none;
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn.primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.55);
  transform: translateY(-2px);
}

.btn.link {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  color: var(--primary);
  cursor: pointer;
}

.btn.link:hover {
  transform: none;
  text-decoration: underline;
}

/* Alerts */
.alert {
  padding: 15px 22px;
  border-radius: var(--radius-md);
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.94rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}

.alert.ok {
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  color: #6ee7b7;
}

.alert.warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: #fcd34d;
}

.alert.crit {
  background: var(--crit-bg);
  border: 1px solid var(--crit-border);
  color: #fca5a5;
}

/* Grid & Layout Helpers */
.cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.cols3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stack {
  display: grid;
  gap: 20px;
}

.stack.narrow {
  max-width: 480px;
}

.filters {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.filters label {
  flex: 1;
  min-width: 170px;
}

fieldset {
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 10px 0;
}

legend {
  padding: 0 10px;
  font-weight: 700;
  font-size: 0.92rem;
  color: #93c5fd;
}

dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 16px;
  font-size: 0.92rem;
}

dt {
  color: var(--text-muted);
  font-weight: 600;
}

dd {
  color: #fff;
  margin: 0;
}

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Responsive */
@media (max-width: 900px) {
  .top {
    flex-direction: column;
    align-items: stretch;
    padding: 16px 20px;
    gap: 14px;
  }
  .top nav {
    overflow-x: auto;
    width: 100%;
    padding: 4px;
  }
  .who {
    justify-content: space-between;
  }
  main {
    padding: 24px 16px;
  }
  .grid4 {
    grid-template-columns: 1fr;
  }
}
