/* ============================================================
   ISO 9001 QMS - Quality Management System
   Professional Dark Theme Stylesheet
   Part of QMSPM Ecosystem - masconsulta.com
   ============================================================ */

/* ============================================================
   1. CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================================ */
:root {
  /* --- Brand & Accent --- */
  --color-brand: #0E7490;
  --color-brand-light: #22D3EE;
  --color-brand-dark: #0A5A6E;
  --color-brand-hover: #0C8DAD;
  --color-brand-subtle: rgba(14, 116, 144, 0.12);
  --color-brand-muted: rgba(14, 116, 144, 0.25);
  --color-brand-ring: rgba(14, 116, 144, 0.45);

  /* --- Backgrounds --- */
  --bg-body: #0F0D12;
  --bg-surface: #1C1820;
  --bg-surface-alt: #141217;
  --bg-elevated: #231F28;
  --bg-card: rgba(28, 24, 32, 0.95);
  --bg-card-hover: rgba(35, 31, 40, 0.98);
  --bg-input: rgba(15, 13, 18, 0.7);
  --bg-input-focus: rgba(15, 13, 18, 0.9);
  --bg-sidebar: #110F14;
  --bg-header: rgba(17, 15, 20, 0.92);
  --bg-overlay: rgba(0, 0, 0, 0.6);
  --bg-tooltip: #2D2833;
  --bg-dropdown: #1E1A23;

  /* --- Borders --- */
  --border-default: rgba(255, 255, 255, 0.06);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-hover: rgba(255, 255, 255, 0.1);
  --border-focus: var(--color-brand);
  --border-strong: rgba(255, 255, 255, 0.15);
  --border-input: rgba(255, 255, 255, 0.08);

  /* --- Text --- */
  --text-primary: #E5E7EB;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;
  --text-disabled: #4B5563;
  --text-inverse: #0F0D12;
  --text-link: var(--color-brand-light);
  --text-on-brand: #FFFFFF;

  /* --- Semantic Colors --- */
  --color-success: #059669;
  --color-success-light: #10B981;
  --color-success-subtle: rgba(5, 150, 105, 0.12);
  --color-success-bg: rgba(5, 150, 105, 0.08);
  --color-success-ring: rgba(5, 150, 105, 0.4);

  --color-warning: #D97706;
  --color-warning-light: #FBBF24;
  --color-warning-subtle: rgba(217, 119, 6, 0.12);
  --color-warning-bg: rgba(217, 119, 6, 0.08);
  --color-warning-ring: rgba(217, 119, 6, 0.4);

  --color-danger: #DC2626;
  --color-danger-light: #EF4444;
  --color-danger-subtle: rgba(220, 38, 38, 0.12);
  --color-danger-bg: rgba(220, 38, 38, 0.08);
  --color-danger-ring: rgba(220, 38, 38, 0.4);

  --color-info: #2563EB;
  --color-info-light: #3B82F6;
  --color-info-subtle: rgba(37, 99, 235, 0.12);
  --color-info-bg: rgba(37, 99, 235, 0.08);
  --color-info-ring: rgba(37, 99, 235, 0.4);

  /* --- Neutral palette --- */
  --color-neutral-50: #F9FAFB;
  --color-neutral-100: #F3F4F6;
  --color-neutral-200: #E5E7EB;
  --color-neutral-300: #D1D5DB;
  --color-neutral-400: #9CA3AF;
  --color-neutral-500: #6B7280;
  --color-neutral-600: #4B5563;
  --color-neutral-700: #374151;
  --color-neutral-800: #1F2937;
  --color-neutral-900: #111827;

  /* --- Typography --- */
  --font-sans: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;

  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  --tracking-tight: -0.025em;
  --tracking-normal: 0;
  --tracking-wide: 0.025em;

  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* --- Spacing --- */
  --space-0: 0;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* --- Border Radius --- */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-full: 9999px;

  /* --- Shadows --- */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow-brand: 0 0 20px rgba(14, 116, 144, 0.15);
  --shadow-glow-success: 0 0 20px rgba(5, 150, 105, 0.15);
  --shadow-glow-danger: 0 0 20px rgba(220, 38, 38, 0.15);

  /* --- Transitions --- */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 300ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* --- Z-Index Scale --- */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-header: 300;
  --z-sidebar: 400;
  --z-overlay: 500;
  --z-modal: 600;
  --z-toast: 700;
  --z-tooltip: 800;
  --z-max: 9999;

  /* --- Layout --- */
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 64px;
  --header-height: 56px;
  --content-max-width: 1400px;
  --content-padding: var(--space-6);
}


/* ============================================================
   2. RESET & BASE STYLES
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  tab-size: 4;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-body);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(14, 116, 144, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(14, 116, 144, 0.03) 0%, transparent 60%);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--font-normal);
  line-height: var(--leading-tight);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-md); }

p {
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-brand-light);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

img, svg {
  display: block;
  max-width: 100%;
}

ul, ol {
  list-style: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

hr {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: var(--space-6) 0;
}

::selection {
  background: var(--color-brand-muted);
  color: var(--text-primary);
}

::-moz-selection {
  background: var(--color-brand-muted);
  color: var(--text-primary);
}

/* Focus Visible Utility */
:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}


/* ============================================================
   3. SCROLLBAR STYLES
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}


/* ============================================================
   4. APP LAYOUT
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-slow);
}

.app-layout.sidebar-collapsed .app-main {
  margin-left: var(--sidebar-collapsed-width);
}

.app-content {
  flex: 1;
  padding: var(--content-padding);
  padding-top: calc(var(--header-height) + var(--content-padding));
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.content-header h1,
.content-header h2 {
  margin: 0;
}

.content-header .header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.page-subtitle {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: var(--font-normal);
  margin-bottom: 0;
}

.content-section {
  margin-bottom: var(--space-8);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-default);
}


/* ============================================================
   5. SIDEBAR NAVIGATION
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-default);
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-slow), transform var(--transition-slow);
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  height: var(--header-height);
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  flex-shrink: 0;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-logo-text .app-name {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: 1.2;
}

.sidebar-logo-text .app-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.2;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-3) 0;
}

.sidebar-section {
  margin-bottom: var(--space-2);
}

.sidebar-section-title {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  padding: var(--space-3) var(--space-5) var(--space-2);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-5);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  white-space: nowrap;
  overflow: hidden;
  border-radius: 0;
  transition: all var(--transition-fast);
  position: relative;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--color-brand);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
  transition: height var(--transition-fast);
}

.sidebar-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-item.active {
  color: var(--color-brand-light);
  background: var(--color-brand-subtle);
}

.sidebar-item.active::before {
  height: 60%;
}

.sidebar-item .sidebar-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: var(--text-md);
  opacity: 0.7;
}

.sidebar-item.active .sidebar-icon {
  opacity: 1;
}

.sidebar-item .sidebar-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-item .sidebar-badge {
  font-size: var(--text-xs);
  background: var(--color-brand);
  color: white;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: var(--font-semibold);
  flex-shrink: 0;
}

.sidebar-item .sidebar-badge.danger {
  background: var(--color-danger);
}

.sidebar-item .sidebar-badge.warning {
  background: var(--color-warning);
}

/* Collapsible sidebar sub-sections */
.sidebar-collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  cursor: pointer;
}

.sidebar-collapsible-header .collapse-icon {
  font-size: var(--text-xs);
  transition: transform var(--transition-fast);
  opacity: 0.5;
}

.sidebar-collapsible-header.expanded .collapse-icon {
  transform: rotate(90deg);
}

.sidebar-sub-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-slow);
}

.sidebar-sub-items.expanded {
  max-height: 500px;
}

.sidebar-sub-items .sidebar-item {
  padding-left: calc(var(--space-5) + var(--space-8));
  font-size: var(--text-xs);
}

/* Sidebar Footer */
.sidebar-footer {
  border-top: 1px solid var(--border-default);
  padding: var(--space-3) var(--space-5);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.sidebar-user:hover {
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  flex-shrink: 0;
}

.sidebar-user-info {
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: var(--text-xs);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar collapsed state */
.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

.sidebar-collapsed .sidebar-logo-text,
.sidebar-collapsed .sidebar-section-title,
.sidebar-collapsed .sidebar-label,
.sidebar-collapsed .sidebar-badge,
.sidebar-collapsed .sidebar-user-info,
.sidebar-collapsed .sidebar-sub-items,
.sidebar-collapsed .collapse-icon {
  display: none;
}

.sidebar-collapsed .sidebar-item {
  justify-content: center;
  padding: var(--space-3);
}

.sidebar-collapsed .sidebar-item .sidebar-icon {
  font-size: var(--text-lg);
}

/* Sidebar toggle button */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  position: absolute;
  right: -14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: calc(var(--z-sidebar) + 1);
}

.sidebar-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
  border-color: var(--border-hover);
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: calc(var(--z-sidebar) - 1);
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.sidebar-overlay.visible {
  display: block;
  opacity: 1;
}


/* ============================================================
   6. APP HEADER
   ============================================================ */
.app-header {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--header-height);
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-default);
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  transition: left var(--transition-slow);
}

.sidebar-collapsed .app-header {
  left: var(--sidebar-collapsed-width);
}

.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.hamburger-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.header-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.header-breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.header-breadcrumb a:hover {
  color: var(--text-secondary);
}

.header-breadcrumb .breadcrumb-separator {
  color: var(--text-disabled);
  font-size: var(--text-xs);
}

.header-breadcrumb .breadcrumb-current {
  color: var(--text-primary);
  font-weight: var(--font-medium);
}

.header-spacer {
  flex: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Empresa Selector */
.empresa-selector {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-default);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  white-space: nowrap;
}

.empresa-selector:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.empresa-selector .empresa-name {
  font-weight: var(--font-medium);
  color: var(--text-primary);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empresa-selector .empresa-nit {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Notification Bell */
.header-notification {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.header-notification:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.header-notification .notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--color-danger);
  color: white;
  font-size: 10px;
  font-weight: var(--font-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-header);
  line-height: 1;
}

/* User Menu */
.header-user-menu {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.header-user-menu:hover {
  background: rgba(255, 255, 255, 0.06);
}

.header-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
}


/* ============================================================
   7. CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-card-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  gap: var(--space-3);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--text-primary);
  margin: 0;
}

.card-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.card-body {
  color: var(--text-secondary);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.card-sm {
  padding: var(--space-4);
}

.card-lg {
  padding: var(--space-8);
}

.card-flat {
  border: none;
  background: var(--bg-surface);
}

.card-interactive {
  cursor: pointer;
}

.card-interactive:hover {
  transform: translateY(-1px);
}

/* Card grid layout */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-6);
}

.card-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-6);
}

.card-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
}

.card-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-6);
}


/* ============================================================
   8. KPI CARDS
   ============================================================ */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--kpi-color, var(--color-brand));
}

.kpi-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.kpi-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.kpi-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  background: var(--kpi-bg, var(--color-brand-subtle));
  color: var(--kpi-color, var(--color-brand));
}

.kpi-card-trend {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
}

.kpi-card-trend.up {
  color: var(--color-success-light);
  background: var(--color-success-subtle);
}

.kpi-card-trend.down {
  color: var(--color-danger-light);
  background: var(--color-danger-subtle);
}

.kpi-card-trend.neutral {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
}

.kpi-card-value {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--space-1);
}

.kpi-card-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: var(--font-medium);
}

.kpi-card-footer {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* KPI color variants */
.kpi-card.brand   { --kpi-color: var(--color-brand);   --kpi-bg: var(--color-brand-subtle); }
.kpi-card.success  { --kpi-color: var(--color-success); --kpi-bg: var(--color-success-subtle); }
.kpi-card.warning  { --kpi-color: var(--color-warning); --kpi-bg: var(--color-warning-subtle); }
.kpi-card.danger   { --kpi-color: var(--color-danger);  --kpi-bg: var(--color-danger-subtle); }
.kpi-card.info     { --kpi-color: var(--color-info);    --kpi-bg: var(--color-info-subtle); }

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}


/* ============================================================
   9. BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  line-height: 1.5;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn .btn-icon {
  font-size: 1.1em;
  flex-shrink: 0;
}

/* Primary */
.btn-primary {
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  color: var(--text-on-brand);
  border-color: var(--color-brand);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--color-brand-hover), var(--color-brand));
  box-shadow: var(--shadow-glow-brand);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: none;
}

/* Success */
.btn-success {
  background: linear-gradient(135deg, var(--color-success), #047857);
  color: white;
  border-color: var(--color-success);
}

.btn-success:hover {
  background: linear-gradient(135deg, var(--color-success-light), var(--color-success));
  box-shadow: var(--shadow-glow-success);
  transform: translateY(-1px);
}

.btn-success:active {
  transform: translateY(0);
}

/* Danger */
.btn-danger {
  background: linear-gradient(135deg, var(--color-danger), #B91C1C);
  color: white;
  border-color: var(--color-danger);
}

.btn-danger:hover {
  background: linear-gradient(135deg, var(--color-danger-light), var(--color-danger));
  box-shadow: var(--shadow-glow-danger);
  transform: translateY(-1px);
}

.btn-danger:active {
  transform: translateY(0);
}

/* Warning */
.btn-warning {
  background: linear-gradient(135deg, var(--color-warning), #B45309);
  color: white;
  border-color: var(--color-warning);
}

.btn-warning:hover {
  background: linear-gradient(135deg, var(--color-warning-light), var(--color-warning));
  transform: translateY(-1px);
}

.btn-warning:active {
  transform: translateY(0);
}

/* Info */
.btn-info {
  background: linear-gradient(135deg, var(--color-info), #1D4ED8);
  color: white;
  border-color: var(--color-info);
}

.btn-info:hover {
  background: linear-gradient(135deg, var(--color-info-light), var(--color-info));
  transform: translateY(-1px);
}

.btn-info:active {
  transform: translateY(0);
}

/* Outline variants */
.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.btn-outline:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--text-muted);
}

.btn-outline-primary {
  background: transparent;
  color: var(--color-brand);
  border-color: var(--color-brand);
}

.btn-outline-primary:hover {
  background: var(--color-brand-subtle);
  color: var(--color-brand-light);
}

.btn-outline-danger {
  background: transparent;
  color: var(--color-danger);
  border-color: var(--color-danger);
}

.btn-outline-danger:hover {
  background: var(--color-danger-subtle);
  color: var(--color-danger-light);
}

.btn-outline-success {
  background: transparent;
  color: var(--color-success);
  border-color: var(--color-success);
}

.btn-outline-success:hover {
  background: var(--color-success-subtle);
  color: var(--color-success-light);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

/* Link style button */
.btn-link {
  background: transparent;
  color: var(--text-link);
  border: none;
  padding: 0;
  text-decoration: underline;
}

.btn-link:hover {
  color: var(--color-brand-light);
}

/* Sizes */
.btn-xs {
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-md);
}

.btn-xl {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-lg);
}

/* Icon button */
.btn-icon-only {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-icon-only.btn-sm {
  width: 28px;
  height: 28px;
}

.btn-icon-only.btn-lg {
  width: 44px;
  height: 44px;
}

/* Block button */
.btn-block {
  display: flex;
  width: 100%;
}

/* Button group */
.btn-group {
  display: inline-flex;
  gap: 0;
}

.btn-group .btn {
  border-radius: 0;
}

.btn-group .btn:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.btn-group .btn:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.btn-group .btn + .btn {
  margin-left: -1px;
}

/* Loading state */
.btn.loading {
  color: transparent;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
}


/* ============================================================
   10. FORMS
   ============================================================ */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.form-label .required {
  color: var(--color-danger);
  margin-left: 2px;
}

.form-hint {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.form-control {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  line-height: 1.5;
  appearance: none;
  -webkit-appearance: none;
}

.form-control::placeholder {
  color: var(--text-disabled);
}

.form-control:hover {
  border-color: var(--border-hover);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-brand-ring);
  background: var(--bg-input-focus);
}

.form-control:disabled,
.form-control[readonly] {
  opacity: 0.6;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.02);
}

/* Control sizes */
.form-control-sm {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
}

.form-control-lg {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-md);
}

/* Textarea */
textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

/* Select */
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
  cursor: pointer;
}

select.form-control option {
  background: var(--bg-dropdown);
  color: var(--text-primary);
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  cursor: pointer;
}

.form-check-input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  position: relative;
}

.form-check-input[type="radio"] {
  border-radius: var(--radius-full);
}

.form-check-input:checked {
  background: var(--color-brand);
  border-color: var(--color-brand);
}

.form-check-input:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.form-check-input[type="checkbox"]:checked::after {
  width: 4px;
  height: 8px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: translate(-50%, -60%) rotate(45deg);
}

.form-check-input[type="radio"]:checked::after {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: white;
}

.form-check-input:focus-visible {
  box-shadow: 0 0 0 3px var(--color-brand-ring);
}

.form-check-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

/* Toggle / Switch */
.form-switch {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.form-switch-track {
  width: 40px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  position: relative;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.form-switch-track.active {
  background: var(--color-brand);
}

.form-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: white;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.form-switch-track.active .form-switch-thumb {
  transform: translateX(18px);
}

.form-switch-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* Input group */
.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-control {
  border-radius: 0;
  flex: 1;
}

.input-group .form-control:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group .form-control:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.input-group-prepend,
.input-group-append {
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-input);
  color: var(--text-muted);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.input-group-prepend {
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group-append {
  border-left: none;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.input-group .btn {
  border-radius: 0;
}

.input-group .btn:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Validation states */
.form-control.is-valid {
  border-color: var(--color-success);
}

.form-control.is-valid:focus {
  box-shadow: 0 0 0 3px var(--color-success-ring);
}

.form-control.is-invalid {
  border-color: var(--color-danger);
}

.form-control.is-invalid:focus {
  box-shadow: 0 0 0 3px var(--color-danger-ring);
}

.form-feedback {
  font-size: var(--text-xs);
  margin-top: var(--space-1);
}

.form-feedback.valid {
  color: var(--color-success-light);
}

.form-feedback.invalid {
  color: var(--color-danger-light);
}

/* Form layout */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.form-inline {
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.form-inline .form-group {
  margin-bottom: 0;
}

/* File input */
.form-file {
  position: relative;
}

.form-file-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.form-file-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  justify-content: center;
  color: var(--text-muted);
}

.form-file-label:hover {
  border-color: var(--color-brand);
  background: var(--color-brand-subtle);
  color: var(--text-secondary);
}

/* Search input */
.form-search {
  position: relative;
}

.form-search .search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: var(--text-md);
}

.form-search .form-control {
  padding-left: var(--space-10);
}

.form-search .search-clear {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.form-search .search-clear:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}


/* ============================================================
   11. TABLES
   ============================================================ */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-default);
  background: var(--bg-card);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th {
  text-align: left;
  font-weight: var(--font-semibold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-default);
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

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

/* Striped */
.table-striped tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

/* Hover */
.table-hover tbody tr {
  transition: background var(--transition-fast);
}

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

/* Small table */
.table-sm th,
.table-sm td {
  padding: var(--space-2) var(--space-3);
}

/* Bordered */
.table-bordered th,
.table-bordered td {
  border: 1px solid var(--border-default);
}

/* Sortable columns */
.table th.sortable {
  cursor: pointer;
  user-select: none;
}

.table th.sortable:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
}

.table th.sortable .sort-icon {
  margin-left: var(--space-1);
  opacity: 0.3;
  transition: opacity var(--transition-fast);
}

.table th.sortable.asc .sort-icon,
.table th.sortable.desc .sort-icon {
  opacity: 1;
  color: var(--color-brand);
}

/* Row selection */
.table tbody tr.selected {
  background: var(--color-brand-subtle);
}

/* Cell alignment */
.table .text-right {
  text-align: right;
}

.table .text-center {
  text-align: center;
}

/* Table actions column */
.table .actions-cell {
  text-align: right;
  white-space: nowrap;
}

.table .actions-cell .btn {
  margin-left: var(--space-1);
}

/* Row status indicators */
.table .row-indicator {
  width: 3px;
  padding: 0;
  position: relative;
}

.table .row-indicator::after {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: var(--radius-full);
}

.table .row-indicator.success::after { background: var(--color-success); }
.table .row-indicator.warning::after { background: var(--color-warning); }
.table .row-indicator.danger::after  { background: var(--color-danger); }
.table .row-indicator.info::after    { background: var(--color-info); }


/* ============================================================
   12. BADGES / PILLS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  line-height: 1.4;
  border-radius: var(--radius-full);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.badge-default {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.badge-primary {
  background: var(--color-brand-subtle);
  color: var(--color-brand-light);
}

.badge-success {
  background: var(--color-success-subtle);
  color: var(--color-success-light);
}

.badge-warning {
  background: var(--color-warning-subtle);
  color: var(--color-warning-light);
}

.badge-danger {
  background: var(--color-danger-subtle);
  color: var(--color-danger-light);
}

.badge-info {
  background: var(--color-info-subtle);
  color: var(--color-info-light);
}

.badge-secondary {
  background: rgba(107, 114, 128, 0.15);
  color: var(--text-muted);
}

/* Solid badge variants */
.badge-solid-primary {
  background: var(--color-brand);
  color: white;
}

.badge-solid-success {
  background: var(--color-success);
  color: white;
}

.badge-solid-warning {
  background: var(--color-warning);
  color: white;
}

.badge-solid-danger {
  background: var(--color-danger);
  color: white;
}

.badge-solid-info {
  background: var(--color-info);
  color: white;
}

/* Dot badge */
.badge-dot {
  padding-left: 0;
}

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.badge-dot.success::before { background: var(--color-success); }
.badge-dot.warning::before { background: var(--color-warning); }
.badge-dot.danger::before  { background: var(--color-danger); }
.badge-dot.info::before    { background: var(--color-info); }
.badge-dot.primary::before { background: var(--color-brand); }

/* Large badge */
.badge-lg {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
}

/* Outline badge */
.badge-outline {
  background: transparent;
  border: 1px solid currentColor;
}

/* Closable badge */
.badge .badge-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
  margin-left: 2px;
}

.badge .badge-close:hover {
  opacity: 1;
}


/* ============================================================
   13. MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-2xl);
  width: 100%;
  max-width: 800px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-2xl);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-slow);
  overflow: hidden;
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal-sm { max-width: 480px; }
.modal-lg { max-width: 960px; }
.modal-xl { max-width: 1200px; }
.modal-full { max-width: calc(100vw - var(--space-8)); max-height: calc(100vh - var(--space-8)); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.modal-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-default);
  flex-shrink: 0;
}

.modal-footer .btn {
  min-width: 100px;
}

/* Confirmation modal */
.modal-confirm .modal-body {
  text-align: center;
  padding: var(--space-8) var(--space-6);
}

.modal-confirm .modal-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
  font-size: var(--text-2xl);
}

.modal-confirm .modal-icon.danger {
  background: var(--color-danger-subtle);
  color: var(--color-danger-light);
}

.modal-confirm .modal-icon.warning {
  background: var(--color-warning-subtle);
  color: var(--color-warning-light);
}

.modal-confirm .modal-icon.success {
  background: var(--color-success-subtle);
  color: var(--color-success-light);
}

.modal-confirm .modal-footer {
  justify-content: center;
}


/* ============================================================
   14. TABS
   ============================================================ */
.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--border-default);
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
}

.tab-btn:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
  color: var(--color-brand-light);
  border-bottom-color: var(--color-brand);
}

.tab-btn .tab-count {
  font-size: var(--text-xs);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.tab-btn.active .tab-count {
  background: var(--color-brand-subtle);
  color: var(--color-brand-light);
}

.tab-content {
  padding: var(--space-5) 0;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.2s ease-in-out;
}

/* Pill tabs variant */
.tab-nav-pills {
  display: flex;
  gap: var(--space-2);
  border-bottom: none;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-lg);
  padding: var(--space-1);
}

.tab-nav-pills .tab-btn {
  border-bottom: none;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
}

.tab-nav-pills .tab-btn.active {
  background: var(--color-brand);
  color: white;
}


/* ============================================================
   15. TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-3);
  pointer-events: none;
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  pointer-events: all;
  transform: translateX(120%);
  opacity: 0;
  transition: all var(--transition-slow);
  max-width: 100%;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.hiding {
  transform: translateX(120%);
  opacity: 0;
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.toast-body {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toast-message {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.toast-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  flex-shrink: 0;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.toast-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  transition: width linear;
}

/* Toast variants */
.toast.success { border-left: 3px solid var(--color-success); }
.toast.success .toast-icon { color: var(--color-success); }
.toast.success .toast-progress { background: var(--color-success); }

.toast.warning { border-left: 3px solid var(--color-warning); }
.toast.warning .toast-icon { color: var(--color-warning); }
.toast.warning .toast-progress { background: var(--color-warning); }

.toast.danger { border-left: 3px solid var(--color-danger); }
.toast.danger .toast-icon { color: var(--color-danger); }
.toast.danger .toast-progress { background: var(--color-danger); }

.toast.info { border-left: 3px solid var(--color-info); }
.toast.info .toast-icon { color: var(--color-info); }
.toast.info .toast-progress { background: var(--color-info); }


/* ============================================================
   16. PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.pagination-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pagination-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-hover);
}

.pagination-btn.active {
  background: var(--color-brand);
  color: white;
  border-color: var(--color-brand);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.pagination-ellipsis {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.pagination-info {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-left: var(--space-4);
}

/* Pagination wrapper */
.pagination-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) 0;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.pagination-wrapper .per-page-select {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.pagination-wrapper .per-page-select select {
  padding: var(--space-1) var(--space-2);
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--text-sm);
}


/* ============================================================
   17. FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.filter-bar .form-search {
  flex: 1;
  min-width: 200px;
}

.filter-bar .form-control {
  background: rgba(255, 255, 255, 0.04);
  border-color: transparent;
}

.filter-bar .form-control:focus {
  background: var(--bg-input-focus);
  border-color: var(--color-brand);
}

.filter-bar .filter-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.filter-bar .filter-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

.filter-bar .filter-divider {
  width: 1px;
  height: 24px;
  background: var(--border-default);
}

/* Filter chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-hover);
}

.filter-chip.active {
  background: var(--color-brand-subtle);
  color: var(--color-brand-light);
  border-color: var(--color-brand);
}

.filter-chip .chip-remove {
  display: inline-flex;
  margin-left: 2px;
  opacity: 0.6;
}

.filter-chip .chip-remove:hover {
  opacity: 1;
}

/* Active filters summary */
.active-filters {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.active-filters .clear-all {
  font-size: var(--text-xs);
  color: var(--color-brand);
  cursor: pointer;
  text-decoration: underline;
}


/* ============================================================
   18. CHART CONTAINER
   ============================================================ */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  position: relative;
}

.chart-container .chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.chart-container .chart-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--text-primary);
}

.chart-container .chart-legend {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.chart-container .legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.chart-container .legend-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
}

.chart-area {
  position: relative;
  min-height: 250px;
}

.chart-area canvas {
  width: 100% !important;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-6);
}


/* ============================================================
   19. RISK MATRIX (5x5)
   ============================================================ */
.risk-matrix {
  display: grid;
  grid-template-columns: auto repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr) auto;
  gap: 2px;
  background: var(--border-default);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--border-default);
}

.risk-matrix-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  text-align: center;
}

.risk-matrix-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  padding: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.risk-matrix-cell:hover {
  filter: brightness(1.15);
  z-index: 1;
  transform: scale(1.02);
}

.risk-matrix-cell .risk-count {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.3);
  color: white;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
}

/* Risk levels - from low (green) to critical (dark red) */
.risk-matrix-cell.risk-low      { background: #065F46; color: white; }
.risk-matrix-cell.risk-moderate  { background: #047857; color: white; }
.risk-matrix-cell.risk-medium    { background: #B45309; color: white; }
.risk-matrix-cell.risk-high      { background: #C2410C; color: white; }
.risk-matrix-cell.risk-critical  { background: #991B1B; color: white; }
.risk-matrix-cell.risk-extreme   { background: #7F1D1D; color: white; }

/* Axis labels */
.risk-matrix-ylabel {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  padding: var(--space-2);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  min-width: 36px;
}

.risk-matrix-xlabel {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  padding: var(--space-2);
  min-height: 36px;
}

.risk-matrix-corner {
  background: var(--bg-surface);
}

/* Risk matrix axis titles */
.risk-matrix-wrapper {
  position: relative;
  padding-left: var(--space-8);
  padding-bottom: var(--space-8);
}

.risk-matrix-axis-y {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  white-space: nowrap;
}

.risk-matrix-axis-x {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  white-space: nowrap;
}

/* Risk level legend */
.risk-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

.risk-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.risk-legend-color {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-sm);
}


/* ============================================================
   20. PROCESS MAP (PHVA / 4 rows)
   ============================================================ */
.process-map {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
}

.process-map-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--text-primary);
  text-align: center;
  margin-bottom: var(--space-4);
}

.process-row {
  display: flex;
  gap: var(--space-3);
  align-items: stretch;
}

.process-row-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  min-width: 36px;
  color: white;
}

.process-row-label.estrategico  { background: #1E40AF; }
.process-row-label.misional     { background: var(--color-brand-dark); }
.process-row-label.apoyo        { background: #7C3AED; }
.process-row-label.evaluacion   { background: #B45309; }

.process-row-items {
  display: flex;
  gap: var(--space-3);
  flex: 1;
  flex-wrap: wrap;
  align-items: stretch;
}

.process-item {
  flex: 1;
  min-width: 120px;
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.process-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.process-item-icon {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-1);
}

.process-item-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

.process-item-code {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Arrows between process rows */
.process-flow-arrows {
  display: flex;
  justify-content: center;
  padding: var(--space-2) 0;
  color: var(--text-muted);
  font-size: var(--text-lg);
}

/* PHVA cycle indicator */
.phva-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.phva-step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
}

.phva-step.planear   { background: rgba(37,99,235,0.15); color: #60A5FA; }
.phva-step.hacer     { background: rgba(14,116,144,0.15); color: var(--color-brand-light); }
.phva-step.verificar { background: rgba(217,119,6,0.15); color: var(--color-warning-light); }
.phva-step.actuar    { background: rgba(5,150,105,0.15); color: var(--color-success-light); }

.phva-arrow {
  color: var(--text-disabled);
  font-size: var(--text-sm);
}


/* ============================================================
   21. WORKFLOW / TIMELINE STEPS
   ============================================================ */
.workflow-steps {
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow-x: auto;
  padding: var(--space-4) 0;
}

.workflow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 140px;
  position: relative;
  flex: 1;
}

.workflow-step::after {
  content: '';
  position: absolute;
  top: 18px;
  left: calc(50% + 24px);
  right: calc(-50% + 24px);
  height: 2px;
  background: var(--border-strong);
}

.workflow-step:last-child::after {
  display: none;
}

.workflow-step.completed::after {
  background: var(--color-success);
}

.workflow-step.active::after {
  background: linear-gradient(90deg, var(--color-brand) 50%, var(--border-strong) 50%);
}

.workflow-step-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: var(--text-sm);
  z-index: 1;
  transition: all var(--transition-fast);
  margin-bottom: var(--space-3);
}

.workflow-step.completed .workflow-step-icon {
  background: var(--color-success);
  border-color: var(--color-success);
  color: white;
}

.workflow-step.active .workflow-step-icon {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: white;
  box-shadow: 0 0 0 4px var(--color-brand-ring);
}

.workflow-step.error .workflow-step-icon {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: white;
}

.workflow-step-label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.workflow-step.active .workflow-step-label {
  color: var(--color-brand-light);
  font-weight: var(--font-semibold);
}

.workflow-step-desc {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 120px;
}

/* Vertical timeline */
.timeline {
  position: relative;
  padding-left: var(--space-8);
}

.timeline::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-default);
}

.timeline-item {
  position: relative;
  padding-bottom: var(--space-6);
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: calc(-1 * var(--space-8) + 7px);
  top: 4px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 2px solid var(--border-strong);
  z-index: 1;
}

.timeline-item.completed .timeline-dot {
  background: var(--color-success);
  border-color: var(--color-success);
}

.timeline-item.active .timeline-dot {
  background: var(--color-brand);
  border-color: var(--color-brand);
  box-shadow: 0 0 0 4px var(--color-brand-ring);
}

.timeline-date {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.timeline-content {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.timeline-content strong {
  color: var(--text-primary);
}


/* ============================================================
   22. STATUS INDICATORS
   ============================================================ */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.status-dot.green,
.status-dot.success,
.status-dot.conforme {
  background: var(--color-success);
  box-shadow: 0 0 6px var(--color-success);
}

.status-dot.yellow,
.status-dot.warning,
.status-dot.observacion {
  background: var(--color-warning);
  box-shadow: 0 0 6px var(--color-warning);
}

.status-dot.red,
.status-dot.danger,
.status-dot.no-conforme {
  background: var(--color-danger);
  box-shadow: 0 0 6px var(--color-danger);
}

.status-dot.blue,
.status-dot.info {
  background: var(--color-info);
  box-shadow: 0 0 6px var(--color-info);
}

.status-dot.gray,
.status-dot.inactive {
  background: var(--text-muted);
}

/* Pulsing animation */
.status-dot.pulse {
  animation: statusPulse 2s ease-in-out infinite;
}

.status-dot.green.pulse  { animation-name: statusPulseGreen; }
.status-dot.yellow.pulse { animation-name: statusPulseYellow; }
.status-dot.red.pulse    { animation-name: statusPulseRed; }

@keyframes statusPulseGreen {
  0%, 100% { box-shadow: 0 0 4px var(--color-success); }
  50%      { box-shadow: 0 0 12px var(--color-success), 0 0 24px rgba(5, 150, 105, 0.3); }
}

@keyframes statusPulseYellow {
  0%, 100% { box-shadow: 0 0 4px var(--color-warning); }
  50%      { box-shadow: 0 0 12px var(--color-warning), 0 0 24px rgba(217, 119, 6, 0.3); }
}

@keyframes statusPulseRed {
  0%, 100% { box-shadow: 0 0 4px var(--color-danger); }
  50%      { box-shadow: 0 0 12px var(--color-danger), 0 0 24px rgba(220, 38, 38, 0.3); }
}

/* Status with label */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.status-indicator .status-label {
  color: var(--text-secondary);
}


/* ============================================================
   23. DROPDOWN MENUS
   ============================================================ */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: var(--z-dropdown);
  min-width: 200px;
  padding: var(--space-2);
  background: var(--bg-dropdown);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: all var(--transition-fast);
}

.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-menu.right {
  left: auto;
  right: 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.dropdown-item.danger {
  color: var(--color-danger-light);
}

.dropdown-item.danger:hover {
  background: var(--color-danger-subtle);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-default);
  margin: var(--space-2) 0;
}

.dropdown-header {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}


/* ============================================================
   24. TOOLTIPS
   ============================================================ */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-1) var(--space-3);
  background: var(--bg-tooltip);
  color: var(--text-primary);
  font-size: var(--text-xs);
  border-radius: var(--radius-md);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  pointer-events: none;
  z-index: var(--z-tooltip);
  box-shadow: var(--shadow-md);
}

.tooltip:hover::after {
  opacity: 1;
  visibility: visible;
}


/* ============================================================
   25. SPINNER / LOADING
   ============================================================ */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--color-brand);
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

.spinner-white {
  border-color: rgba(255, 255, 255, 0.2);
  border-top-color: white;
}

/* Loading overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 13, 18, 0.8);
  z-index: 10;
  border-radius: inherit;
}

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.loading-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.04) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-2);
}

.skeleton-text:last-child {
  width: 70%;
}

.skeleton-title {
  height: 24px;
  width: 50%;
  margin-bottom: var(--space-4);
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

.skeleton-card {
  height: 160px;
}

/* Progress bar */
.progress {
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-brand-dark), var(--color-brand));
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.progress-bar.success { background: linear-gradient(90deg, #047857, var(--color-success)); }
.progress-bar.warning { background: linear-gradient(90deg, #B45309, var(--color-warning)); }
.progress-bar.danger  { background: linear-gradient(90deg, #B91C1C, var(--color-danger)); }

.progress-sm { height: 4px; }
.progress-lg { height: 12px; }

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}


/* ============================================================
   26. EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-8);
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.empty-state-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.empty-state-description {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 360px;
  margin-bottom: var(--space-6);
  line-height: var(--leading-relaxed);
}


/* ============================================================
   27. ALERTS / CALLOUTS
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid;
  margin-bottom: var(--space-4);
}

.alert-icon {
  flex-shrink: 0;
  font-size: var(--text-lg);
  margin-top: 1px;
}

.alert-body {
  flex: 1;
}

.alert-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  margin-bottom: 2px;
}

.alert-message {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.alert-info {
  background: var(--color-info-bg);
  border-color: rgba(37, 99, 235, 0.2);
  color: var(--color-info-light);
}

.alert-success {
  background: var(--color-success-bg);
  border-color: rgba(5, 150, 105, 0.2);
  color: var(--color-success-light);
}

.alert-warning {
  background: var(--color-warning-bg);
  border-color: rgba(217, 119, 6, 0.2);
  color: var(--color-warning-light);
}

.alert-danger {
  background: var(--color-danger-bg);
  border-color: rgba(220, 38, 38, 0.2);
  color: var(--color-danger-light);
}

.alert-close {
  flex-shrink: 0;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.alert-close:hover {
  opacity: 1;
}


/* ============================================================
   28. AVATARS
   ============================================================ */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  color: white;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  flex-shrink: 0;
  overflow: hidden;
}

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

.avatar-xs { width: 24px; height: 24px; font-size: 10px; }
.avatar-sm { width: 28px; height: 28px; font-size: var(--text-xs); }
.avatar-lg { width: 48px; height: 48px; font-size: var(--text-lg); }
.avatar-xl { width: 64px; height: 64px; font-size: var(--text-2xl); }

.avatar-group {
  display: flex;
}

.avatar-group .avatar {
  border: 2px solid var(--bg-body);
  margin-left: -8px;
}

.avatar-group .avatar:first-child {
  margin-left: 0;
}

.avatar-group .avatar-more {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: var(--text-xs);
}


/* ============================================================
   29. DOCUMENT / AUDIT COMPONENTS
   ============================================================ */

/* Document list */
.doc-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.doc-list-item:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border-hover);
}

.doc-list-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  flex-shrink: 0;
}

.doc-list-icon.pdf  { background: rgba(220,38,38,0.12); color: var(--color-danger-light); }
.doc-list-icon.doc  { background: rgba(37,99,235,0.12); color: var(--color-info-light); }
.doc-list-icon.xls  { background: rgba(5,150,105,0.12); color: var(--color-success-light); }

.doc-list-info {
  flex: 1;
  min-width: 0;
}

.doc-list-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-list-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: flex;
  gap: var(--space-4);
  margin-top: 2px;
}

/* Audit finding card */
.finding-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  border-left: 4px solid var(--finding-color, var(--border-strong));
  transition: all var(--transition-fast);
}

.finding-card:hover {
  box-shadow: var(--shadow-card-hover);
}

.finding-card.nc-mayor    { --finding-color: var(--color-danger); }
.finding-card.nc-menor    { --finding-color: var(--color-warning); }
.finding-card.observacion { --finding-color: var(--color-info); }
.finding-card.oportunidad { --finding-color: var(--color-success); }
.finding-card.fortaleza   { --finding-color: var(--color-brand); }

/* Compliance gauge */
.compliance-gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.compliance-gauge-ring {
  position: relative;
  width: 120px;
  height: 120px;
}

.compliance-gauge-ring svg {
  transform: rotate(-90deg);
}

.compliance-gauge-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
}

.compliance-gauge-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Requirement checklist */
.requirement-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.requirement-item:last-child {
  border-bottom: none;
}

.requirement-clause {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-brand);
  background: var(--color-brand-subtle);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
}

.requirement-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  flex: 1;
}

.requirement-status {
  flex-shrink: 0;
}


/* ============================================================
   30. UTILITIES
   ============================================================ */

/* Display */
.d-none      { display: none !important; }
.d-flex      { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-grid      { display: grid !important; }
.d-block     { display: block !important; }
.d-inline    { display: inline !important; }

/* Flex utilities */
.flex-row       { flex-direction: row; }
.flex-column    { flex-direction: column; }
.flex-wrap      { flex-wrap: wrap; }
.flex-nowrap    { flex-wrap: nowrap; }
.flex-1         { flex: 1; }
.flex-auto      { flex: auto; }
.flex-none      { flex: none; }
.flex-grow-0    { flex-grow: 0; }
.flex-grow-1    { flex-grow: 1; }
.flex-shrink-0  { flex-shrink: 0; }

/* Alignment */
.items-start    { align-items: flex-start; }
.items-center   { align-items: center; }
.items-end      { align-items: flex-end; }
.items-stretch  { align-items: stretch; }
.justify-start  { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end    { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around  { justify-content: space-around; }
.self-start     { align-self: flex-start; }
.self-center    { align-self: center; }
.self-end       { align-self: flex-end; }

/* Gap */
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* Margin */
.m-0  { margin: 0; }
.m-1  { margin: var(--space-1); }
.m-2  { margin: var(--space-2); }
.m-3  { margin: var(--space-3); }
.m-4  { margin: var(--space-4); }
.m-auto { margin: auto; }

.mt-0  { margin-top: 0; }
.mt-1  { margin-top: var(--space-1); }
.mt-2  { margin-top: var(--space-2); }
.mt-3  { margin-top: var(--space-3); }
.mt-4  { margin-top: var(--space-4); }
.mt-5  { margin-top: var(--space-5); }
.mt-6  { margin-top: var(--space-6); }
.mt-8  { margin-top: var(--space-8); }

.mb-0  { margin-bottom: 0; }
.mb-1  { margin-bottom: var(--space-1); }
.mb-2  { margin-bottom: var(--space-2); }
.mb-3  { margin-bottom: var(--space-3); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-5  { margin-bottom: var(--space-5); }
.mb-6  { margin-bottom: var(--space-6); }
.mb-8  { margin-bottom: var(--space-8); }

.ml-0  { margin-left: 0; }
.ml-1  { margin-left: var(--space-1); }
.ml-2  { margin-left: var(--space-2); }
.ml-3  { margin-left: var(--space-3); }
.ml-4  { margin-left: var(--space-4); }
.ml-auto { margin-left: auto; }

.mr-0  { margin-right: 0; }
.mr-1  { margin-right: var(--space-1); }
.mr-2  { margin-right: var(--space-2); }
.mr-3  { margin-right: var(--space-3); }
.mr-4  { margin-right: var(--space-4); }
.mr-auto { margin-right: auto; }

/* Padding */
.p-0  { padding: 0; }
.p-1  { padding: var(--space-1); }
.p-2  { padding: var(--space-2); }
.p-3  { padding: var(--space-3); }
.p-4  { padding: var(--space-4); }
.p-5  { padding: var(--space-5); }
.p-6  { padding: var(--space-6); }
.p-8  { padding: var(--space-8); }

.px-0 { padding-left: 0; padding-right: 0; }
.px-2 { padding-left: var(--space-2); padding-right: var(--space-2); }
.px-3 { padding-left: var(--space-3); padding-right: var(--space-3); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.px-5 { padding-left: var(--space-5); padding-right: var(--space-5); }
.px-6 { padding-left: var(--space-6); padding-right: var(--space-6); }

.py-0 { padding-top: 0; padding-bottom: 0; }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.py-3 { padding-top: var(--space-3); padding-bottom: var(--space-3); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.py-5 { padding-top: var(--space-5); padding-bottom: var(--space-5); }
.py-6 { padding-top: var(--space-6); padding-bottom: var(--space-6); }

/* Text */
.text-xs    { font-size: var(--text-xs); }
.text-sm    { font-size: var(--text-sm); }
.text-base  { font-size: var(--text-base); }
.text-md    { font-size: var(--text-md); }
.text-lg    { font-size: var(--text-lg); }
.text-xl    { font-size: var(--text-xl); }
.text-2xl   { font-size: var(--text-2xl); }
.text-3xl   { font-size: var(--text-3xl); }
.text-4xl   { font-size: var(--text-4xl); }

.font-normal   { font-weight: var(--font-normal); }
.font-medium   { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold     { font-weight: var(--font-bold); }

.text-left    { text-align: left; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }

.text-primary   { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted     { color: var(--text-muted) !important; }
.text-disabled  { color: var(--text-disabled) !important; }
.text-brand     { color: var(--color-brand) !important; }
.text-success   { color: var(--color-success-light) !important; }
.text-warning   { color: var(--color-warning-light) !important; }
.text-danger    { color: var(--color-danger-light) !important; }
.text-info      { color: var(--color-info-light) !important; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.font-mono { font-family: var(--font-mono); }
.font-display { font-family: var(--font-display); }

.uppercase    { text-transform: uppercase; }
.lowercase    { text-transform: lowercase; }
.capitalize   { text-transform: capitalize; }
.no-wrap      { white-space: nowrap; }

/* Border */
.border        { border: 1px solid var(--border-default); }
.border-top    { border-top: 1px solid var(--border-default); }
.border-bottom { border-bottom: 1px solid var(--border-default); }
.border-left   { border-left: 1px solid var(--border-default); }
.border-right  { border-right: 1px solid var(--border-default); }
.border-none   { border: none; }

.rounded-sm  { border-radius: var(--radius-sm); }
.rounded-md  { border-radius: var(--radius-md); }
.rounded-lg  { border-radius: var(--radius-lg); }
.rounded-xl  { border-radius: var(--radius-xl); }
.rounded-2xl { border-radius: var(--radius-2xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Sizing */
.w-full  { width: 100%; }
.h-full  { height: 100%; }
.w-auto  { width: auto; }
.h-auto  { height: auto; }
.min-w-0 { min-width: 0; }

/* Overflow */
.overflow-auto    { overflow: auto; }
.overflow-hidden  { overflow: hidden; }
.overflow-x-auto  { overflow-x: auto; }
.overflow-y-auto  { overflow-y: auto; }

/* Position */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.sticky   { position: sticky; }

/* Cursor */
.cursor-pointer    { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }

/* Visibility */
.opacity-0    { opacity: 0; }
.opacity-50   { opacity: 0.5; }
.opacity-100  { opacity: 1; }
.invisible    { visibility: hidden; }

/* Shadow */
.shadow-sm  { box-shadow: var(--shadow-sm); }
.shadow-md  { box-shadow: var(--shadow-md); }
.shadow-lg  { box-shadow: var(--shadow-lg); }
.shadow-xl  { box-shadow: var(--shadow-xl); }
.shadow-none { box-shadow: none; }

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: var(--space-4) 0;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* ============================================================
   31. ANIMATIONS
   ============================================================ */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

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

@keyframes slideDown {
  from { transform: translateY(-10px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

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

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

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

.animate-fade-in    { animation: fadeIn 0.3s ease-in-out; }
.animate-slide-up   { animation: slideUp 0.3s ease-out; }
.animate-slide-down { animation: slideDown 0.3s ease-out; }
.animate-scale-in   { animation: scaleIn 0.2s ease-out; }
.animate-bounce     { animation: bounce 1s ease infinite; }
.animate-shake      { animation: shake 0.4s ease; }

/* Transition utilities */
.transition-all  { transition: all var(--transition-base); }
.transition-fast { transition: all var(--transition-fast); }
.transition-slow { transition: all var(--transition-slow); }
.transition-none { transition: none; }


/* ============================================================
   32. RESPONSIVE - Mobile First
   ============================================================ */

/* Tablet: 768px+ */
@media (min-width: 768px) {
  .hidden-md-up  { display: none !important; }
}

/* Desktop: 1024px+ */
@media (min-width: 1024px) {
  .hidden-lg-up  { display: none !important; }
}

/* Wide: 1280px+ */
@media (min-width: 1280px) {
  .hidden-xl-up  { display: none !important; }
}

/* --- Mobile: below 768px --- */
@media (max-width: 767px) {
  :root {
    --content-padding: var(--space-4);
  }

  .hidden-mobile { display: none !important; }

  /* Sidebar collapses off-screen */
  .sidebar {
    transform: translateX(-100%);
    z-index: var(--z-sidebar);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .app-main {
    margin-left: 0;
  }

  .app-header {
    left: 0;
    padding: 0 var(--space-4);
  }

  .hamburger-btn {
    display: flex;
  }

  .sidebar-collapsed .app-main {
    margin-left: 0;
  }

  .sidebar-collapsed .app-header {
    left: 0;
  }

  /* Content adjustments */
  .content-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-title {
    font-size: var(--text-2xl);
  }

  /* Grids stack */
  .card-grid,
  .card-grid-2,
  .card-grid-3,
  .card-grid-4 {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  /* Tables */
  .table-container {
    border-radius: var(--radius-lg);
  }

  /* Modal */
  .modal-overlay {
    padding: var(--space-3);
    align-items: flex-end;
  }

  .modal {
    max-height: 90vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  /* Filter bar */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar .form-search {
    min-width: 100%;
  }

  /* Workflow steps */
  .workflow-steps {
    flex-direction: column;
    align-items: stretch;
  }

  .workflow-step {
    flex-direction: row;
    text-align: left;
    min-width: auto;
    gap: var(--space-3);
  }

  .workflow-step::after {
    top: auto;
    bottom: -2px;
    left: 18px;
    right: auto;
    width: 2px;
    height: var(--space-6);
  }

  /* Process map */
  .process-row {
    flex-direction: column;
  }

  .process-row-label {
    writing-mode: horizontal-tb;
    transform: none;
    min-width: auto;
    padding: var(--space-2) var(--space-3);
  }

  /* Toast */
  .toast-container {
    left: var(--space-4);
    right: var(--space-4);
    bottom: var(--space-4);
    max-width: none;
  }

  /* Empresa selector */
  .empresa-selector .empresa-nit {
    display: none;
  }

  /* Pagination */
  .pagination-wrapper {
    flex-direction: column;
    align-items: center;
  }

  /* Risk matrix */
  .risk-matrix {
    font-size: 10px;
  }

  .risk-matrix-cell {
    min-height: 48px;
  }
}

/* Small mobile: below 480px */
@media (max-width: 479px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .btn-group {
    flex-direction: column;
    width: 100%;
  }

  .btn-group .btn {
    border-radius: 0;
  }

  .btn-group .btn:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  .btn-group .btn:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
  }

  .header-actions {
    gap: var(--space-1);
  }
}

/* Tablet specific: 768px - 1023px */
@media (min-width: 768px) and (max-width: 1023px) {
  .card-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}


/* ============================================================
   33. PRINT STYLES
   ============================================================ */
@media print {
  *,
  *::before,
  *::after {
    background: white !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
    background: white !important;
  }

  .sidebar,
  .app-header,
  .hamburger-btn,
  .toast-container,
  .modal-overlay,
  .btn,
  .filter-bar,
  .pagination,
  .sidebar-toggle,
  .sidebar-overlay,
  .dropdown-menu {
    display: none !important;
  }

  .app-main {
    margin-left: 0 !important;
  }

  .app-content {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .card {
    border: 1px solid #ddd !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .card:hover {
    transform: none !important;
  }

  .table {
    border-collapse: collapse;
  }

  .table th,
  .table td {
    border: 1px solid #ddd !important;
    padding: 4pt 8pt;
  }

  .table th {
    background: #f5f5f5 !important;
    font-weight: bold;
  }

  .badge {
    border: 1px solid #999 !important;
    padding: 1pt 4pt;
  }

  .kpi-card-value {
    font-size: 18pt;
  }

  .page-title {
    font-size: 18pt;
    border-bottom: 2px solid #000;
    padding-bottom: 4pt;
    margin-bottom: 8pt;
  }

  h1, h2, h3 {
    page-break-after: avoid;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #666 !important;
  }

  a[href^="#"]::after,
  a[href^="javascript"]::after {
    content: "";
  }

  .risk-matrix-cell {
    border: 1px solid #999 !important;
  }

  .risk-matrix-cell.risk-low      { background: #d1fae5 !important; color: #065f46 !important; }
  .risk-matrix-cell.risk-moderate  { background: #a7f3d0 !important; color: #047857 !important; }
  .risk-matrix-cell.risk-medium    { background: #fde68a !important; color: #92400e !important; }
  .risk-matrix-cell.risk-high      { background: #fecaca !important; color: #991b1b !important; }
  .risk-matrix-cell.risk-critical  { background: #fca5a5 !important; color: #7f1d1d !important; }
  .risk-matrix-cell.risk-extreme   { background: #f87171 !important; color: #450a0a !important; }

  .process-row-label {
    border: 1px solid #999 !important;
  }

  .process-row-label.estrategico  { background: #dbeafe !important; color: #1e40af !important; }
  .process-row-label.misional     { background: #cffafe !important; color: #0e7490 !important; }
  .process-row-label.apoyo        { background: #ede9fe !important; color: #7c3aed !important; }
  .process-row-label.evaluacion   { background: #fef3c7 !important; color: #b45309 !important; }

  .status-dot {
    border: 1px solid currentColor;
    box-shadow: none !important;
  }

  /* Print header */
  .print-header {
    display: block !important;
    text-align: center;
    margin-bottom: 16pt;
    padding-bottom: 8pt;
    border-bottom: 1px solid #999;
  }

  .print-header .company-name {
    font-size: 14pt;
    font-weight: bold;
  }

  .print-header .report-title {
    font-size: 12pt;
    color: #666 !important;
  }

  .print-header .report-date {
    font-size: 9pt;
    color: #999 !important;
  }

  /* Page footer */
  @page {
    margin: 2cm;
  }
}

/* Print header - hidden on screen */
.print-header {
  display: none;
}


/* ============================================================
   34. ISO 9001 SPECIFIC COMPONENTS
   ============================================================ */

/* Clause compliance matrix */
.clause-matrix {
  display: grid;
  grid-template-columns: 60px 1fr 120px 120px;
  gap: 1px;
  background: var(--border-default);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--border-default);
}

.clause-matrix-header {
  background: rgba(255, 255, 255, 0.04);
  padding: var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
}

.clause-matrix-cell {
  background: var(--bg-card);
  padding: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
}

.clause-matrix-cell.clause-number {
  font-family: var(--font-mono);
  color: var(--color-brand);
  font-weight: var(--font-semibold);
  font-size: var(--text-xs);
  justify-content: center;
}

/* CAPA (Corrective and Preventive Actions) tracker */
.capa-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-4);
  align-items: start;
}

.capa-type {
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  text-transform: uppercase;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.capa-type.correctiva {
  background: var(--color-danger-subtle);
  color: var(--color-danger-light);
}

.capa-type.preventiva {
  background: var(--color-warning-subtle);
  color: var(--color-warning-light);
}

.capa-type.mejora {
  background: var(--color-success-subtle);
  color: var(--color-success-light);
}

/* Context of organization diagram */
.context-diagram {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: var(--space-4);
  padding: var(--space-6);
}

.context-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  text-align: center;
}

.context-box-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.context-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.context-center .org-circle {
  width: 160px;
  height: 160px;
  border-radius: var(--radius-full);
  border: 3px solid var(--color-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-4);
}

.context-center .org-circle .org-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--color-brand-light);
}

/* Indicator dashboard gauge */
.gauge-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.gauge-row:last-child {
  border-bottom: none;
}

.gauge-label {
  flex: 1;
  min-width: 0;
}

.gauge-label-text {
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: var(--font-medium);
}

.gauge-label-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.gauge-bar {
  flex: 2;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.gauge-bar .progress {
  flex: 1;
}

.gauge-value {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  min-width: 48px;
  text-align: right;
}

.gauge-target {
  font-size: var(--text-xs);
  color: var(--text-muted);
  min-width: 48px;
  text-align: right;
}

/* Internal audit plan calendar */
.audit-calendar {
  display: grid;
  grid-template-columns: 200px repeat(12, 1fr);
  gap: 1px;
  background: var(--border-default);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--border-default);
}

.audit-calendar-header {
  background: rgba(255, 255, 255, 0.04);
  padding: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-align: center;
  color: var(--text-muted);
}

.audit-calendar-process {
  background: var(--bg-card);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
}

.audit-calendar-cell {
  background: var(--bg-card);
  padding: var(--space-1);
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.audit-calendar-cell.planned {
  background: var(--color-brand-subtle);
}

.audit-calendar-cell.executed {
  background: var(--color-success-subtle);
}

.audit-calendar-cell.overdue {
  background: var(--color-danger-subtle);
}

.audit-calendar-mark {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
}

.audit-calendar-mark.planned  { background: var(--color-brand); }
.audit-calendar-mark.executed { background: var(--color-success); }
.audit-calendar-mark.overdue  { background: var(--color-danger); }

/* Document control info strip */
.doc-control-strip {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-wrap: wrap;
}

.doc-control-strip .doc-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.doc-control-strip .doc-field-label {
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.doc-control-strip .doc-field-value {
  color: var(--text-secondary);
}


/* ============================================================
   35. DARK THEME OVERRIDES FOR NATIVE ELEMENTS
   ============================================================ */

/* Date and time inputs */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

/* Number input arrows */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 0.5;
}

/* Range input */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--color-brand);
  cursor: pointer;
  border: 2px solid var(--bg-body);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--color-brand);
  cursor: pointer;
  border: 2px solid var(--bg-body);
}

/* Color input */
input[type="color"] {
  -webkit-appearance: none;
  width: 40px;
  height: 32px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  padding: 2px;
  cursor: pointer;
  background: var(--bg-input);
}

/* Details/Summary */
details {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

details summary {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
  transition: all var(--transition-fast);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

details summary::-webkit-details-marker {
  display: none;
}

details summary::before {
  content: '';
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

details[open] summary::before {
  transform: rotate(90deg);
}

details summary:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

details > :not(summary) {
  padding: var(--space-4);
}

/* Code blocks */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 2px var(--space-2);
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  color: var(--color-brand-light);
}

pre {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

/* Blockquote */
blockquote {
  border-left: 3px solid var(--color-brand);
  padding: var(--space-3) var(--space-5);
  margin: var(--space-4) 0;
  color: var(--text-secondary);
  font-style: italic;
  background: rgba(14, 116, 144, 0.04);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Mark / Highlight */
mark {
  background: rgba(217, 119, 6, 0.25);
  color: var(--text-primary);
  padding: 1px 4px;
  border-radius: var(--radius-sm);
}

/* Keyboard shortcut */
kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}
