/* ========================================================
   Pixel Gestor · Design System v1.0
   Cumplimiento estricto con design.md · Pixel de Barrio
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* --- 1. Tokens Oficiales de Marca (design.md §3) --- */
  --color-primary: #C96A4A;          /* Terracota insignia de marca */
  --color-primary-hover: #B55839;
  --color-primary-light: rgba(201, 106, 74, 0.12);
  --color-primary-rgb: 201, 106, 74;

  --color-secondary: #F7E9D7;        /* Crema cálida de barrio */
  --color-text: #2E2A26;             /* Antracita profundo */
  --color-accent: #D7C7B8;           /* Taupe cálido y divisores */

  /* Estados funcionales armónicos */
  --color-emerald: #15803D;
  --color-emerald-light: rgba(21, 128, 61, 0.12);
  --color-amber: #B45309;
  --color-amber-light: rgba(180, 83, 9, 0.12);
  --color-rose: #BE123C;
  --color-rose-light: rgba(190, 18, 60, 0.12);
  --color-blue: #1D4ED8;
  --color-blue-light: rgba(29, 78, 216, 0.12);

  /* --- 2. Tipografía Oficial (design.md §4) --- */
  --font-primary: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* --- 3. Formas y Bordes (design.md §6) --- */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  /* --- 4. Espaciado (design.md §12) --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;

  /* --- 5. Modo Luz Cálida de Barrio (Default / Light) --- */
  --bg-app: #FAF6F0;
  --bg-sidebar: #F4ECE1;
  --bg-sidebar-active: #EADBC8;
  --bg-card: #FFFFFF;
  --bg-card-hover: #FBF8F4;
  --bg-input: #FFFFFF;
  --border-color: rgba(46, 42, 38, 0.10);
  --border-focus: #C96A4A;

  --text-main: #2E2A26;
  --text-muted: #6B635B;
  --text-dim: #988E84;

  --shadow-sm: 0 1px 3px rgba(46, 42, 38, 0.05);
  --shadow-md: 0 4px 16px rgba(46, 42, 38, 0.07);
  --shadow-lg: 0 12px 32px rgba(46, 42, 38, 0.10);
}

/* Modo Nocturno / Grafito Cálido */
[data-theme="dark"] {
  --bg-app: #181513;
  --bg-sidebar: #201C18;
  --bg-sidebar-active: #2C2621;
  --bg-card: #24201C;
  --bg-card-hover: #2E2822;
  --bg-input: #1C1815;
  --border-color: rgba(215, 199, 184, 0.12);
  --border-focus: #C96A4A;

  --text-main: #FBF9F5;
  --text-muted: #BBB1A6;
  --text-dim: #847B72;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.60);
}

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

body {
  font-family: var(--font-primary);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Tipografía */
h1 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-main);
}

h3 {
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--text-main);
}

h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

p {
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Utilidades */
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-emerald); }
.text-danger { color: var(--color-rose); }
.text-amber { color: var(--color-amber); }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.hidden { display: none !important; }

/* Botones (design.md §7) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.88rem;
  font-weight: 500;
  font-family: var(--font-primary);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--color-primary);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.28);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  box-shadow: 0 4px 14px rgba(var(--color-primary-rgb), 0.38);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--bg-card-hover);
  border-color: rgba(var(--color-primary-rgb), 0.35);
  color: var(--color-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--color-primary);
  padding: 6px 12px;
}

.btn-ghost:hover {
  background: var(--color-primary-light);
}

.btn-danger {
  background-color: var(--color-rose);
  color: #FFFFFF;
}

.btn-danger:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-success {
  background-color: var(--color-emerald);
  color: #FFFFFF;
}

.btn-success:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon-only {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.btn-icon-only:hover {
  background: var(--bg-card-hover);
  border-color: var(--color-primary);
}

/* Auth Barrier */
.auth-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(24, 21, 19, 0.85);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.brand-isotipo {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #C96A4A 0%, #A84D30 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(201, 106, 74, 0.35);
  flex-shrink: 0;
}

.brand-isotipo svg {
  width: 22px;
  height: 22px;
  fill: #FFFFFF;
}

.auth-brand h2 {
  font-size: 1.35rem;
  margin-bottom: 2px;
}

.auth-hint {
  margin-top: 20px;
  padding: 12px;
  background: var(--color-primary-light);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* Layout Principal */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 270px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: all 0.25s ease;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-color);
}

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

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.brand-tag {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--color-primary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  padding: 12px 12px 4px 12px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-family: var(--font-primary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all 0.15s ease;
  position: relative;
}

.nav-item:hover {
  background-color: var(--bg-sidebar-active);
  color: var(--text-main);
}

.nav-item.active {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background-color: var(--color-primary);
}

.nav-icon {
  font-size: 1.1rem;
  width: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.badge-counter {
  margin-left: auto;
  background: var(--color-primary);
  color: #FFFFFF;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.profile-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.profile-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.profile-role {
  font-size: 0.7rem;
  color: var(--color-primary);
  font-weight: 500;
}

.sidebar-actions {
  display: flex;
  gap: 6px;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

/* Topbar */
.topbar {
  padding: 18px 32px;
  background-color: var(--bg-app);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(10px);
}

.topbar-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.cmd-k-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.cmd-k-badge:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.cmd-k-badge kbd {
  background: var(--color-secondary);
  color: var(--text-main);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 600;
}

[data-theme="dark"] .cmd-k-badge kbd {
  background: var(--bg-sidebar-active);
}

.env-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-emerald);
}

.status-dot.pulse {
  box-shadow: 0 0 0 0 rgba(21, 128, 61, 0.4);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(21, 128, 61, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(21, 128, 61, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(21, 128, 61, 0); }
}

/* Viewport & Secciones */
.view-viewport {
  padding: 32px;
  flex: 1;
}

.view-section {
  display: none;
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* KPI Cards (design.md §11) */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  gap: 18px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-sm);
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--color-primary-rgb), 0.3);
  box-shadow: var(--shadow-md);
}

.kpi-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.icon-primary { background: var(--color-primary-light); color: var(--color-primary); }
.icon-warning { background: var(--color-amber-light); color: var(--color-amber); }
.icon-info { background: var(--color-blue-light); color: var(--color-blue); }
.icon-success { background: var(--color-emerald-light); color: var(--color-emerald); }

.kpi-data {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
  margin-bottom: 6px;
}

.kpi-foot {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* Cards & Contenedores */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.card.no-padding {
  padding: 0;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.card-head.in-card {
  padding: 20px 24px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border-color);
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-icon {
  font-size: 1.3rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.card-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 24px;
}

@media (max-width: 1080px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Toolbars de Sección */
.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex: 1;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 260px;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: var(--font-primary);
  font-size: 0.85rem;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s ease;
}

.search-box input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
}

.search-icon {
  position: absolute;
  left: 12px;
  font-size: 0.9rem;
  color: var(--text-dim);
  pointer-events: none;
}

.form-select {
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: var(--font-primary);
  font-size: 0.85rem;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.form-select:focus {
  border-color: var(--border-focus);
}

/* Filter Tabs */
.filter-tabs {
  display: flex;
  background: var(--bg-sidebar);
  padding: 4px;
  border-radius: var(--radius-md);
  gap: 4px;
}

.tab-pill {
  padding: 6px 14px;
  border-radius: calc(var(--radius-md) - 4px);
  background: transparent;
  border: 0;
  font-family: var(--font-primary);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-pill:hover {
  color: var(--text-main);
}

.tab-pill.active {
  background: var(--bg-card);
  color: var(--color-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Tablas de Datos */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.86rem;
}

.data-table th {
  padding: 14px 20px;
  background-color: var(--bg-sidebar);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tr:hover td {
  background-color: var(--bg-card-hover);
}

.table-empty {
  text-align: center;
  padding: 40px !important;
  color: var(--text-muted);
}

/* Avatar de Comercio en Tabla */
.biz-row-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.biz-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--color-secondary);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  overflow: hidden;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.biz-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.biz-title-wrap {
  display: flex;
  flex-direction: column;
}

.biz-name {
  font-weight: 600;
  color: var(--text-main);
}

.biz-slug {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* Badges & Tags */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.claimed {
  background: var(--color-emerald-light);
  color: var(--color-emerald);
}

.status-badge.unclaimed {
  background: var(--color-amber-light);
  color: var(--color-amber);
}

.status-badge.pending {
  background: var(--color-amber-light);
  color: var(--color-amber);
}

.status-badge.approved {
  background: var(--color-emerald-light);
  color: var(--color-emerald);
}

.status-badge.rejected {
  background: var(--color-rose-light);
  color: var(--color-rose);
}

.badge-tag {
  background: var(--color-primary-light);
  color: var(--color-primary);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
}

.role-badge {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
}

.role-admin { background: rgba(201, 106, 74, 0.15); color: var(--color-primary); }
.role-merchant { background: rgba(29, 78, 216, 0.12); color: var(--color-blue); }
.role-customer { background: rgba(107, 99, 91, 0.15); color: var(--text-muted); }

/* Acciones en tabla */
.table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.btn-table-action {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-table-action:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--bg-card-hover);
}

.btn-table-action.danger:hover {
  border-color: var(--color-rose);
  color: var(--color-rose);
}

/* Categorías Breakdown (design.md) */
.category-breakdown {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cat-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cat-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 500;
}

.cat-progress-track {
  width: 100%;
  height: 7px;
  background: var(--bg-sidebar-active);
  border-radius: 4px;
  overflow: hidden;
}

.cat-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #C96A4A 0%, #E68A6C 100%);
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* Categorías Grid */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.cat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.cat-card:hover {
  border-color: rgba(var(--color-primary-rgb), 0.3);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.cat-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.cat-card-icon {
  font-size: 1.8rem;
  width: 48px;
  height: 48px;
  background: var(--color-secondary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-theme="dark"] .cat-card-icon {
  background: var(--bg-sidebar-active);
}

.cat-card-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.cat-card-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* Modales */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(24, 21, 19, 0.7);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

.modal-window {
  width: 100%;
  max-width: 620px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-window.large {
  max-width: 820px;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-badge-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-primary);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 600;
}

.modal-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-close {
  background: transparent;
  border: 0;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.btn-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bg-card);
}

/* Formularios */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-main);
}

.form-group input,
.form-group textarea,
.form-group select {
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-primary);
  font-size: 0.88rem;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* Command Palette (Cmd + K) */
.cmd-palette-window {
  width: 100%;
  max-width: 580px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cmd-input-wrap {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.cmd-input-wrap input {
  width: 100%;
  border: 0;
  background: transparent;
  font-family: var(--font-primary);
  font-size: 1.1rem;
  color: var(--text-main);
  outline: none;
}

.cmd-results-list {
  max-height: 360px;
  overflow-y: auto;
  padding: 10px;
}

.cmd-group-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 12px 4px 12px;
}

.cmd-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.1s ease;
  color: var(--text-main);
}

.cmd-item:hover,
.cmd-item.selected {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.cmd-item-icon {
  font-size: 1.1rem;
}

.cmd-item-text {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 500;
}

.cmd-item-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Vista previa fotos */
.photo-preview-box {
  width: 100%;
  height: 120px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-color);
  overflow: hidden;
  background: var(--bg-sidebar);
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Evidencia Documental (Claims) */
.evidence-box {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.evidence-content {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.info-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}

.info-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.info-value {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
}

/* Auditoría Lista */
.audit-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.audit-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
}

.audit-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.95rem;
}

.audit-details {
  flex: 1;
}

.audit-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
}

.audit-action {
  font-weight: 600;
  color: var(--text-main);
}

.audit-time {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.audit-desc {
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* Diagnóstico Sistema */
.sys-info-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sys-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-sidebar);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.sys-label {
  color: var(--text-muted);
  font-weight: 500;
}

.sys-value {
  font-weight: 600;
  color: var(--text-main);
}

/* Paginación */
.pagination-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.pagination-pages {
  display: flex;
  gap: 4px;
}

.page-btn {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.8rem;
}

.page-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #FFFFFF;
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInRight 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 0.88rem;
}

.toast-success { border-left: 4px solid var(--color-emerald); }
.toast-error { border-left: 4px solid var(--color-rose); }
.toast-info { border-left: 4px solid var(--color-primary); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    z-index: 1000;
  }
  .sidebar.mobile-open {
    left: 0;
  }
  .topbar {
    padding: 14px 20px;
  }
  .view-viewport {
    padding: 20px;
  }
}
