/* ════════════════════════════════════════════════
   CONTA360 – Design System v2
   ════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ─── Design Tokens ─── */
:root {
  /* Colors - Dark */
  --bg-base:        #0b0f1a;
  --bg-surface:     #111827;
  --bg-elevated:    #1a2235;
  --bg-overlay:     rgba(0,0,0,0.6);
  --bg-card:        rgba(255,255,255,0.03);

  --border:         rgba(255,255,255,0.08);
  --border-soft:    rgba(255,255,255,0.04);
  --border-focus:   rgba(79,142,247,0.5);

  /* Accent */
  --accent:         #4f8ef7;
  --accent-hover:   #3b7de8;
  --accent-active:  #2d6fd4;
  --accent-glow:    rgba(79,142,247,0.25);
  --accent-bg:      rgba(79,142,247,0.1);

  /* Status */
  --success:        #22c55e;
  --success-bg:     rgba(34,197,94,0.12);
  --warning:        #f59e0b;
  --warning-bg:     rgba(245,158,11,0.12);
  --error:          #ef4444;
  --error-bg:       rgba(239,68,68,0.12);
  --info:           #3b82f6;
  --info-bg:        rgba(59,130,246,0.12);

  /* Text */
  --text-primary:   #f0f4ff;
  --text-secondary: #94a3b8;
  --text-muted:     #4b5563;
  --text-inverse:   #0b0f1a;

  /* Shadows */
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow:         0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:      0 10px 40px rgba(0,0,0,0.5);

  /* Radius */
  --radius-xs:      4px;
  --radius-sm:      8px;
  --radius:         12px;
  --radius-lg:      16px;
  --radius-xl:      24px;
  --radius-full:    9999px;

  /* Transitions */
  --transition:     0.2s ease;
  --transition-slow:0.3s ease;

  /* Z-index */
  --z-toast:        999;
  --z-modal:        1000;
  --z-loader:       2000;
}

/* ─── Light Theme ─── */
[data-theme="light"] {
  --bg-base:        #f0f4ff;
  --bg-surface:     #ffffff;
  --bg-elevated:    #f1f5f9;
  --bg-overlay:     rgba(0,0,0,0.4);
  --bg-card:        rgba(37,99,235,0.03);

  --border:         rgba(37,99,235,0.12);
  --border-soft:    rgba(37,99,235,0.06);
  --border-focus:   rgba(37,99,235,0.4);

  --accent:         #2563eb;
  --accent-hover:   #1d4ed8;
  --accent-active:  #1e40af;
  --accent-glow:    rgba(37,99,235,0.2);
  --accent-bg:      rgba(37,99,235,0.06);

  --success:        #16a34a;
  --success-bg:     rgba(22,163,74,0.1);
  --warning:        #d97706;
  --warning-bg:     rgba(217,119,6,0.1);
  --error:          #dc2626;
  --error-bg:       rgba(220,38,38,0.1);
  --info:           #2563eb;
  --info-bg:        rgba(37,99,235,0.1);

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-inverse:   #ffffff;

  --shadow-sm:      0 1px 3px rgba(37,99,235,0.06), 0 1px 2px rgba(37,99,235,0.04);
  --shadow:         0 4px 20px rgba(37,99,235,0.08);
  --shadow-lg:      0 10px 40px rgba(37,99,235,0.12);
}

/* ─── Reset & Base ─── */
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--transition-slow), color var(--transition-slow);
}

/* ─── Skip Link (Accessibility) ─── */
.skip-link {
  position: absolute;
  top: -40px;
  left: 16px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  z-index: var(--z-loader);
  transition: top var(--transition);
  text-decoration: none;
}
.skip-link:focus { top: 16px; }

/* ─── Focus Visible ─── */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(79,142,247,0.25); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: rgba(79,142,247,0.4); }

.hidden { display: none !important; }

/* ════════════════════════════════════════════════
   SCREENS
   ════════════════════════════════════════════════ */
.screen { height: 100vh; width: 100vw; }
.screen.active { display: flex; }
.screen.hidden { display: none; }

/* ════════════════════════════════════════════════
   AUTH / LOGIN
   ════════════════════════════════════════════════ */
#screen-login {
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(79,142,247,0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(139,92,246,0.08) 0%, transparent 50%),
    var(--bg-base);
}
.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 24px;
  animation: fadeUp 0.4s ease;
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo .logo-icon {
  display: block;
  margin: 0 auto 12px;
  filter: drop-shadow(0 4px 12px var(--accent-glow));
}
.auth-logo h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.auth-logo p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

.auth-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg), 0 0 60px rgba(79,142,247,0.04);
}

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab {
  flex: 1;
  padding: 14px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.tab::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  right: 50%;
  height: 2px;
  background: var(--accent);
  transition: all var(--transition);
}
.tab.active { color: var(--text-primary); }
.tab.active::after { left: 0; right: 0; }
.tab:hover { color: var(--text-primary); background: var(--accent-bg); }

/* Form */
.auth-form { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Input wrapper with icons */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrap .input-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--transition);
}
.input-wrap:focus-within .input-icon { color: var(--accent); }
.input-wrap input {
  padding-left: 40px;
  padding-right: 40px;
}
.input-toggle {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  transition: all var(--transition);
}
.input-toggle:hover { color: var(--text-primary); background: var(--accent-bg); }

/* ════════════════════════════════════════════════
   APP LAYOUT
   ════════════════════════════════════════════════ */
#screen-app { flex-direction: row; background: var(--bg-base); }

/* ─── Sidebar ─── */
.sidebar {
  width: 240px;
  min-width: 240px;
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background var(--transition-slow);
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  position: relative;
}
.nav-item:hover { background: var(--accent-bg); color: var(--accent); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.nav-icon {
  flex-shrink: 0;
  color: currentColor;
  opacity: 0.85;
}
.nav-item.active .nav-icon { opacity: 1; }
.sidebar-section { padding: 14px 10px; flex: 1; overflow-y: auto; }
.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1px;
  padding: 0 14px;
  margin-bottom: 8px;
}
.sidebar-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 14px;
  display: flex;
  align-items: center;
}
.sidebar-empresa-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  font-size: 12px;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.sidebar-empresa-item:hover { background: var(--accent-bg); color: var(--accent); }
.sidebar-empresa-item.active { background: var(--accent-bg); color: var(--accent); }
.empresa-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.empresa-ruc-sm { font-size: 10px; color: var(--text-muted); }

/* ─── Main Content ─── */
.main-content {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-base);
  position: relative;
  transition: background var(--transition-slow);
}
.view { display: none; padding: 28px 32px; animation: fadeUp 0.3s ease; }
.view.active { display: block; }
.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.view-header h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.subtitle { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ════════════════════════════════════════════════
   STATS CARDS
   ════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--accent-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-top: 4px;
  letter-spacing: -0.5px;
}

/* ════════════════════════════════════════════════
   CARDS
   ════════════════════════════════════════════════ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; }

/* ════════════════════════════════════════════════
   TABLES & FILTERS
   ════════════════════════════════════════════════ */
.email-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}
.filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}
.filter-search { position: relative; margin-left: auto; }
.filter-search input { padding: 7px 12px 7px 34px; font-size: 13px; }
.filter-search .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.email-table-wrap { overflow-x: auto; }
table.email-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.email-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.email-table tbody tr {
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background var(--transition);
}
table.email-table tbody tr:nth-child(even) { background: var(--bg-card); }
table.email-table tbody tr:hover { background: var(--accent-bg); }
table.email-table tbody td {
  padding: 12px 16px;
  color: var(--text-secondary);
  vertical-align: middle;
}
table.email-table tbody td.td-num {
  color: var(--text-muted);
  font-size: 12px;
  width: 40px;
  text-align: center;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-surface);
}
.pagination-btns { display: flex; gap: 4px; }
.pg-btn {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.pg-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pg-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pg-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ════════════════════════════════════════════════
   EMPRESAS GRID
   ════════════════════════════════════════════════ */
.empresas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.empresa-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.empresa-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
}
.empresa-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.empresa-card-name { font-weight: 700; font-size: 15px; color: var(--text-primary); }
.empresa-card-ruc { font-size: 12px; color: var(--text-muted); }
.empresa-card-stats { display: flex; gap: 16px; }
.empresa-stat { font-size: 12px; color: var(--text-muted); }
.empresa-stat strong { color: var(--text-primary); font-size: 13px; }
.empresa-card-actions { display: flex; gap: 6px; }

/* ════════════════════════════════════════════════
   FORMS & INPUTS
   ════════════════════════════════════════════════ */
.field-hint { font-size: 11px; color: var(--text-muted); }
.field-hint a { color: var(--accent); text-decoration: none; }
.field-hint a:hover { text-decoration: underline; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.required { color: var(--error); }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], select.select, .select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  padding: 10px 14px;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}
input::placeholder { color: var(--text-muted); }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
select option { background: var(--bg-surface); color: var(--text-primary); }
input[type="date"] { color-scheme: dark; }
[data-theme="light"] input[type="date"] { color-scheme: light; }

/* ════════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 0 4px 14px var(--accent-glow); }
.btn-secondary { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--accent-bg); color: var(--accent); }
.btn-outline { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-outline:hover { background: var(--accent-bg); }
.btn-danger { background: var(--error-bg); color: var(--error); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; border-radius: var(--radius-xs); }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--accent-bg); color: var(--accent); }

/* Theme toggle */
.theme-toggle {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ════════════════════════════════════════════════
   BADGES
   ════════════════════════════════════════════════ */
.badge {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
  margin-left: auto;
}
.cat-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.cat-SUNAT { background: var(--warning-bg); color: var(--warning); }
.cat-BANCO { background: var(--success-bg); color: var(--success); }
.cat-COMPROBANTE { background: var(--info-bg); color: var(--info); }
.cat-RRHH { background: rgba(139,92,246,0.12); color: #8b5cf6; }
.cat-OTRO { background: rgba(100,116,139,0.12); color: #64748b; }

.status-badge { font-size: 10px; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-full); }
.status-unread { background: var(--info-bg); color: var(--info); }
.status-read { background: var(--bg-card); color: var(--text-muted); }

/* ════════════════════════════════════════════════
   DIVIDERS & COLLAPSIBLE
   ════════════════════════════════════════════════ */
.collapsible-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  font-family: inherit;
  transition: color var(--transition);
}
.collapsible-toggle:hover { color: var(--text-primary); }
.collapsible-body { padding-top: 12px; display: flex; flex-direction: column; gap: 12px; }

.divider {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ════════════════════════════════════════════════
   MODALS
   ════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: 24px;
  animation: fadeIn 0.2s ease;
}
.modal {
  width: 100%;
  max-width: 540px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.25s ease;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.25s ease;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  transition: color var(--transition);
}
.btn-close:hover { color: var(--text-primary); }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ════════════════════════════════════════════════
   TOAST
   ════════════════════════════════════════════════ */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: var(--z-toast);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  max-width: 360px;
  display: flex;
  align-items: center;
  backdrop-filter: blur(8px);
}
.toast.toast-exit { animation: toastOut 0.3s ease forwards; }
.toast.success { background: var(--success-bg); border: 1px solid rgba(34,197,94,0.25); color: var(--success); }
.toast.error { background: var(--error-bg); border: 1px solid rgba(239,68,68,0.25); color: var(--error); }
.toast.info { background: var(--info-bg); border: 1px solid rgba(59,130,246,0.25); color: var(--info); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to { opacity: 0; transform: translateX(20px) scale(0.95); }
}

.form-error {
  color: var(--error);
  font-size: 12px;
  padding: 10px 14px;
  background: var(--error-bg);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(239,68,68,0.2);
}

/* ════════════════════════════════════════════════
   EMPTY STATE
   ════════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 20px;
  color: var(--text-muted);
  text-align: center;
}
.empty-state svg { color: var(--text-muted); opacity: 0.4; }
.empty-state p { font-size: 14px; }
.empty-state .btn { margin-top: 4px; }
.empty-state.full { grid-column: 1 / -1; }
.h100 { height: 100%; }

/* ════════════════════════════════════════════════
   LOADER
   ════════════════════════════════════════════════ */
.global-loader {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: var(--z-loader);
}
.global-loader p { color: var(--text-secondary); font-size: 14px; font-weight: 500; }

/* ════════════════════════════════════════════════
   ANIMATIONS
   ════════════════════════════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .empresas-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .main-content { width: 100%; }
  .view { padding: 16px; }
  .view-header { flex-direction: column; }
  .view-header h2 { font-size: 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }
  .field-row { grid-template-columns: 1fr; }
  .auth-container { padding: 16px; }
  .empresas-grid { grid-template-columns: 1fr; }
  .email-filters { gap: 8px; }
  .filter-search { margin-left: 0; width: 100%; }
  .filter-search input { width: 100% !important; }
}

/* ════════════════════════════════════════════════
   SIRE SPECIFIC
   ════════════════════════════════════════════════ */
.sire-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 2px solid var(--border); }
.sire-tab  { background: transparent; border: none; padding: 10px 20px; font-size: 14px; cursor: pointer;
              color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px;
              transition: all 0.2s ease; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.sire-tab:hover { color: var(--text-primary); }
.sire-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.sire-resumen-header { display: flex; justify-content: space-between; align-items: flex-start;
                        flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.sire-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }

/* SIRE table */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody tr { border-bottom: 1px solid var(--border-soft); transition: background 0.2s ease; }
.data-table tbody tr:hover { background: var(--accent-bg); }
.data-table tbody td { padding: 10px 14px; color: var(--text-secondary); }
.table-wrapper { overflow-x: auto; }

/* CPE tipo badge */
.cpe-tipo { background: rgba(99,179,237,0.15); color: var(--info); border-radius: var(--radius-xs); padding: 2px 8px;
             font-size: 11px; font-weight: 600; white-space: nowrap; }

/* SIRE stat cards */
.sire-stats .stat-card { padding: 14px 18px; }
.stat-val { font-size: 22px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.5px; }
.stat-lbl { font-size: 11px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }

/* ════════════════════════════════════════════════
   RUC INFO MODAL
   ════════════════════════════════════════════════ */
.ruc-info-modal .ruc-header { display: flex; justify-content: space-between; align-items: flex-start;
                               gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.ruc-info-modal h2 { font-size: 18px; margin-bottom: 4px; }
.ruc-number { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.ruc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ruc-field { background: var(--bg-card); border-radius: var(--radius-sm); padding: 10px 14px; }
.ruc-field.ruc-full { grid-column: 1 / -1; }
.ruc-field label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; display: block; margin-bottom: 4px; }
.ruc-field span { font-size: 13px; color: var(--text-primary); }
.ruc-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ruc-tag { background: var(--info-bg); color: var(--info); border-radius: var(--radius-full);
            padding: 3px 12px; font-size: 12px; font-weight: 500; }
.ruc-rep { padding: 6px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; color: var(--text-primary); }
.ruc-badges { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.estado-badge { border-radius: var(--radius-full); padding: 4px 14px; font-size: 12px; font-weight: 600; }
.estado-badge.activo { background: var(--success-bg); color: var(--success); }
.estado-badge.baja { background: var(--error-bg); color: var(--error); }
.cond-badge { border-radius: var(--radius-full); padding: 3px 10px; font-size: 11px;
               background: var(--bg-card); color: var(--text-secondary); }
.source-badge { font-size: 11px; border-radius: var(--radius-xs); padding: 2px 8px; display: inline-block; font-weight: 600; }
.source-badge.api { background: var(--success-bg); color: var(--success); }
.source-badge.pub { background: var(--bg-card); color: var(--text-secondary); }

/* ════════════════════════════════════════════════
   BUZON TABS
   ════════════════════════════════════════════════ */
.buzon-tabs-bar { display: flex; gap: 2px; margin-bottom: 10px; border-bottom: 2px solid var(--border); }
.buzon-tab-btn {
  padding: 10px 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.buzon-tab-btn:hover { color: var(--text-secondary); }
.buzon-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ════════════════════════════════════════════════
   MICRO-INTERACTIONS & SKELETON LOADING
   ════════════════════════════════════════════════ */
@keyframes skeleton {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-card) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-text { height: 14px; width: 80%; margin-bottom: 6px; }
.skeleton-text:last-child { width: 60%; }
.skeleton-circle { width: 32px; height: 32px; border-radius: 50%; }
.skeleton-rect { height: 40px; width: 100%; }

/* Button press effect */
.btn:active:not(:disabled) { transform: scale(0.97); }
.nav-item:active { transform: scale(0.98); }

/* Smooth scrollbar */
.main-content, .sidebar-section, .modal-body, .table-wrapper {
  scroll-behavior: smooth;
}

/* Spinner keyframe for buzón modal */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
