/**
 * PLATAFORMA GANADERA — Sistema de Diseño Premium
 * Paleta inspirada en entorno ganadero + tecnología
 * Mobile-first, responsive, dark mode ready
 */

/* ─── CSS CUSTOM PROPERTIES (DESIGN TOKENS) ───────────── */
:root {
    /* Colores primarios */
    --color-primary: #10B981;
    --color-primary-light: #34D399;
    --color-primary-dark: #059669;
    --color-primary-50: rgba(16, 185, 129, 0.06);
    --color-primary-100: rgba(16, 185, 129, 0.12);
    --color-primary-rgb: 16, 185, 129;

    /* Acentos */
    --color-accent: #F59E0B;
    --color-accent-light: #FBBF24;
    --color-accent-dark: #D97706;
    --color-copper: #B87333;
    --color-amber: #F59E0B;
    --color-teal: #14B8A6;
    --color-purple: #8B5CF6;
    --color-indigo: #6366F1;
    --color-pink: #EC4899;
    --color-cyan: #06B6D4;

    /* Gradientes premium */
    --gradient-primary: linear-gradient(135deg, #10B981 0%, #059669 100%);
    --gradient-accent: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    --gradient-hero: linear-gradient(135deg, #065F46 0%, #047857 40%, #0D9488 100%);
    --gradient-sidebar: linear-gradient(180deg, #0F172A 0%, #131B2E 50%, #0F172A 100%);
    --gradient-card-mint: linear-gradient(135deg, #D1FAE5 0%, #A7F3D0 100%);
    --gradient-card-purple: linear-gradient(135deg, #EDE9FE 0%, #DDD6FE 50%, #C4B5FD 100%);
    --gradient-card-blue: linear-gradient(135deg, #DBEAFE 0%, #BFDBFE 100%);
    --gradient-card-amber: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    --gradient-card-pink: linear-gradient(135deg, #FCE7F3 0%, #FBCFE8 100%);
    --gradient-card-cyan: linear-gradient(135deg, #CFFAFE 0%, #A5F3FC 100%);
    --gradient-card-dark: linear-gradient(135deg, #1E293B 0%, #334155 100%);
    --gradient-glass: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.6) 100%);

    /* Fondos */
    --bg-body: #F0F4F8;
    --bg-surface: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F8FAFC;
    --bg-elevated: #FFFFFF;
    --bg-input: #F1F5F9;
    --bg-sidebar: #0F172A;
    --bg-header: #FFFFFF;
    --bg-hover: rgba(0,0,0,0.02);

    /* Texto */
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --text-inverse: #FFFFFF;
    --text-accent: #D97706;

    /* Bordes */
    --border-color: #E2E8F0;
    --border-color-light: #F1F5F9;
    --border-radius: 14px;
    --border-radius-sm: 10px;
    --border-radius-lg: 18px;
    --border-radius-xl: 24px;
    --border-radius-full: 50%;

    /* Sombras — soft & layered */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.03);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.15);
    --shadow-card: 0 2px 8px rgba(0,0,0,0.04), 0 0 1px rgba(0,0,0,0.06);
    --shadow-card-hover: 0 8px 24px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
    --shadow-colored: 0 4px 16px rgba(16, 185, 129, 0.2);

    /* Espaciado */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Tipografía */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.8125rem;
    --font-size-base: 0.875rem;
    --font-size-md: 1rem;
    --font-size-lg: 1.15rem;
    --font-size-xl: 1.3rem;
    --font-size-2xl: 1.6rem;
    --font-size-3xl: 2.2rem;
    --font-size-4xl: 2.8rem;
    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-weight-black: 800;

    /* Estados */
    --color-success: #10B981;
    --color-warning: #F59E0B;
    --color-danger: #EF4444;
    --color-info: #3B82F6;

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 76px;
    --header-height: 68px;
    --content-max-width: 1440px;

    /* Transiciones */
    --transition-fast: 150ms ease;
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition-bounce: 600ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Glass morphism */
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-blur: 16px;

    /* Short aliases for inline styles */
    --primary: var(--color-primary);
    --primary-light: var(--color-primary-light);
    --accent: var(--color-accent);
    --danger: var(--color-danger);
    --warning: var(--color-warning);
    --success: var(--color-success);
    --info: var(--color-info);
    --card-bg: var(--bg-card);
    --card: var(--bg-card);
    --border: var(--border-color);
    --border-light: var(--border-color-light);
    --radius: var(--border-radius);
    --radius-sm: var(--border-radius-sm);
    --radius-lg: var(--border-radius-lg);
    --bg: var(--bg-body);
    --text: var(--text-primary);
    --text-dim: var(--text-muted);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background-color: var(--bg-body);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.011em;
}

a {
    color: var(--color-primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:visited {
    color: var(--color-primary-light);
}
a:hover {
    color: var(--color-accent);
}
a:active {
    color: var(--color-primary-dark);
}

/* Prevent anchor pseudo-classes from overriding .btn colors */
a.btn,
a.btn:visited,
a.btn:hover,
a.btn:focus,
a.btn:active {
    color: revert-layer;
}
a.btn-primary,
a.btn-primary:visited,
a.btn-primary:hover,
a.btn-primary:focus,
a.btn-primary:active {
    color: #fff;
}
a.btn-secondary,
a.btn-secondary:visited {
    color: var(--text-primary);
}
a.btn-danger,
a.btn-danger:visited,
a.btn-danger:hover,
a.btn-danger:active {
    color: #fff;
}
a.btn-accent,
a.btn-accent:visited,
a.btn-accent:hover,
a.btn-accent:active {
    color: #fff;
}
a.btn-success,
a.btn-success:visited,
a.btn-success:hover,
a.btn-success:active {
    color: #fff;
}
a.btn-warning,
a.btn-warning:visited,
a.btn-warning:hover,
a.btn-warning:active {
    color: #fff;
}
a.btn-outline,
a.btn-outline:visited {
    color: var(--text-secondary);
}
a.btn-outline:hover {
    color: var(--color-primary);
}
a.btn-ghost,
a.btn-ghost:visited {
    color: var(--text-secondary);
}
a.btn-ghost:hover {
    color: var(--color-primary);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ─── LAYOUT PRINCIPAL ─────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    background: var(--gradient-sidebar);
    border-right: none;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 2px 0 16px rgba(0,0,0,0.1);
}

.app-sidebar::-webkit-scrollbar {
    width: 3px;
}
.app-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
}
.app-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.app-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsed sidebar → shift content */
.app-sidebar.collapsed ~ .sidebar-overlay ~ .app-content,
.app-sidebar.collapsed ~ .app-content {
    margin-left: var(--sidebar-collapsed);
}

.content-area {
    flex: 1;
    padding: var(--space-lg) var(--space-xl);
    width: 100%;
    max-width: var(--content-max-width);
    margin: 0 auto;
}

.app-header {
    height: var(--header-height);
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(0,0,0,0.03);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-xl);
    position: sticky;
    top: 0;
    z-index: 50;
}

/* (app-content styles moved above to merge with app-main) */

/* ─── SIDEBAR HEADER ───────────────────────────────────── */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    min-height: 64px;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    min-width: 0;
}

.brand-logo svg,
.brand-logo img {
    flex-shrink: 0;
}

.brand-logo-img {
    height: 40px;
    width: auto;
    object-fit: contain;
    border-radius: 6px;
}

.login-logo-img {
    height: 80px;
    width: auto;
    object-fit: contain;
    margin-bottom: 8px;
    border-radius: 10px;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}

.brand-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #F1F5F9;
    white-space: nowrap;
    letter-spacing: -0.02em;
    transition: opacity 0.2s, width 0.2s;
    overflow: hidden;
}

/* ─── MODERN FLOATING SIDEBAR TOGGLE ───────────────────── */
.sidebar-toggle-pill {
    position: absolute;
    top: 50%;
    right: -14px;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: #FFFFFF;
    color: var(--text-muted);
    cursor: pointer;
    z-index: 110;
    opacity: 0;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    padding: 0;
}

.app-sidebar:hover .sidebar-toggle-pill,
.sidebar-toggle-pill:focus-visible {
    opacity: 1;
}

.sidebar-toggle-pill:hover {
    background: var(--bg-card-hover);
    border-color: #ccc;
    color: var(--text-secondary);
    transform: translateY(-50%);
}

.sidebar-toggle-pill:active {
    transform: translateY(-50%) scale(0.95);
}

.sidebar-toggle-pill svg {
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.app-sidebar.collapsed .sidebar-toggle-pill {
    opacity: 1;
    right: -14px;
}

.app-sidebar.collapsed .sidebar-toggle-pill svg {
    transform: rotate(180deg);
}

/* ─── SIDEBAR COLLAPSED STATE ──────────────────────────── */
.app-sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.app-sidebar.collapsed .brand-name,
.app-sidebar.collapsed .nav-section-title,
.app-sidebar.collapsed .sidebar-footer {
    opacity: 0;
    width: 0;
    overflow: hidden;
    pointer-events: none;
    transition: opacity 0.2s, width 0.2s;
}

.app-sidebar.collapsed .nav-item span {
    opacity: 0;
    width: 0;
    overflow: hidden;
    pointer-events: none;
    position: absolute;
}

.app-sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 16px 8px;
}

.app-sidebar.collapsed .brand-logo {
    justify-content: center;
    gap: 0;
}

.app-sidebar.collapsed .brand-logo-img {
    height: 32px;
    width: auto;
    transition: height 0.3s cubic-bezier(0.4,0,0.2,1);
}

.app-sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
    position: relative;
}

.app-sidebar.collapsed .nav-item .nav-icon {
    width: 22px;
    height: 22px;
}

.app-sidebar.collapsed .nav-item .nav-badge {
    position: absolute;
    top: 4px;
    right: 8px;
    padding: 1px 5px;
    font-size: 0.65rem;
}

.app-sidebar.collapsed .sidebar-nav {
    padding: var(--space-sm) 0;
}

/* Collapsed nav-item tooltip on hover */
.app-sidebar.collapsed .nav-item[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: #0F172A;
    color: #F1F5F9;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 8px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    transform: translateY(-50%) translateX(-6px);
    z-index: 200;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.app-sidebar.collapsed .nav-item[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-md) 0;
}

.nav-section {
    margin-bottom: var(--space-md);
}

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 600;
    color: rgba(148, 163, 184, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 24px 22px 8px;
    margin-bottom: 0;
    transition: opacity 0.2s, width 0.2s;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px 10px 20px;
    color: rgba(203, 213, 225, 0.8);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    border: none;
    background: none;
    width: calc(100% - 16px);
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    margin: 1px 8px;
    border-radius: 10px;
    min-height: 42px;
}

.nav-item:hover {
    color: #F1F5F9;
    background: rgba(255, 255, 255, 0.06);
}

.nav-item:visited {
    color: rgba(203, 213, 225, 0.8);
}

.nav-item.active,
.nav-item.active:visited {
    color: #fff;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.15);
    color: #34D399;
}

.nav-item.active .nav-icon {
    color: #34D399;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: #34D399;
    border-radius: 0 3px 3px 0;
}

.nav-item .nav-icon {
    width: 20px;
    height: 20px;
    font-size: 20px;
    flex-shrink: 0;
    opacity: 0.6;
    color: inherit;
}

.nav-item:hover .nav-icon {
    opacity: 1;
}

.nav-item.active .nav-icon {
    opacity: 1;
    color: #34D399;
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--color-danger);
    color: white;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* ─── HEADER ───────────────────────────────────────────── */
.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

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

.btn-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: var(--space-sm);
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
}
.btn-menu-toggle:hover {
    color: var(--text-primary);
    background: var(--color-primary-50);
}

/* Sidebar footer */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    transition: opacity var(--transition-fast);
}

.ranch-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    background: rgba(255,255,255,0.06);
    color: rgba(203, 213, 225, 0.8);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ranch-selector:hover {
    background: rgba(255,255,255,0.1);
    color: #F1F5F9;
}

.ranch-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-bar {
    position: relative;
    width: 360px;
}

.search-bar input {
    width: 100%;
    height: 42px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: 22px;
    padding: 0 var(--space-md) 0 42px;
    color: var(--text-primary);
    font-size: var(--font-size-base);
    transition: all var(--transition-base);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.08), 0 2px 8px rgba(16,185,129,0.06);
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.search-bar .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.header-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 10px;
    cursor: pointer;
    border-radius: 12px;
    position: relative;
    transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.header-btn:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

.header-btn .badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--color-danger);
    border-radius: 50%;
    border: 2px solid var(--bg-header);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--border-radius);
    transition: background var(--transition-fast);
}
.user-menu:hover {
    background: var(--color-primary-50);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-full);
    background: linear-gradient(135deg, var(--color-primary), var(--color-teal));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-bold);
    color: white;
    font-size: var(--font-size-sm);
    box-shadow: 0 2px 8px rgba(4, 120, 87, 0.2);
}

.user-info {
    display: flex;
    flex-direction: column;
}
.user-info .user-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    line-height: 1.2;
}
.user-info .user-role {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* User Dropdown */
.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 180px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color-light);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-xl);
    z-index: 200;
    overflow: hidden;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
}
.dropdown-item:hover {
    background: var(--color-primary-50);
    color: var(--text-primary);
}

.user-menu {
    position: relative;
}

/* ─── NOTIFICATION DROPDOWN ────────────────────────────── */
.notif-dropdown-wrapper {
    position: relative;
}

.notification-count {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    background: var(--color-danger);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    border-radius: 10px;
    padding: 0 4px;
    pointer-events: none;
    animation: notifPulse 2s ease-in-out infinite;
}

@keyframes notifPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.notif-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: -60px;
    width: 380px;
    max-height: 500px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color-light);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15), 0 4px 12px rgba(0,0,0,0.08);
    z-index: 300;
    overflow: hidden;
    animation: notifDropIn 0.2s ease-out;
}

@keyframes notifDropIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 10px;
    border-bottom: 1px solid var(--border-color);
}

.notif-dropdown-header h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.notif-dropdown-header .btn-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.15s;
}
.notif-dropdown-header .btn-link:hover {
    background: var(--color-primary-50);
}

.notif-dropdown-body {
    max-height: 360px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.notif-dropdown-body::-webkit-scrollbar { width: 4px; }
.notif-dropdown-body::-webkit-scrollbar-track { background: transparent; }
.notif-dropdown-body::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.notif-dropdown-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 36px 16px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.notif-item {
    display: flex;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-color-light, rgba(0,0,0,0.04));
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.notif-item:hover {
    background: var(--color-primary-50);
}
.notif-item:last-child {
    border-bottom: none;
}
.notif-item.unread {
    background: rgba(4,120,87,0.04);
}
.notif-item.unread::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--color-primary);
    border-radius: 50%;
}

.notif-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.notif-item-icon.critical { background: rgba(220,38,38,0.1); }
.notif-item-icon.high { background: rgba(234,179,8,0.12); }
.notif-item-icon.medium { background: rgba(59,130,246,0.1); }
.notif-item-icon.low { background: rgba(100,116,139,0.1); }

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

.notif-item-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.notif-item-msg {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notif-item-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 3px;
    opacity: 0.7;
}

.notif-dropdown-footer {
    padding: 10px 18px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.notif-dropdown-footer .btn-link {
    display: inline-block;
    color: var(--color-primary);
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    padding: 4px 12px;
    border-radius: 6px;
    transition: all 0.15s;
}
.notif-dropdown-footer .btn-link:hover {
    background: var(--color-primary-50);
    text-decoration: none;
}

@media(max-width: 480px) {
    .notif-dropdown {
        position: fixed;
        top: 56px;
        right: 8px;
        left: 8px;
        width: auto;
        max-height: calc(100vh - 80px);
    }
}

/* Search Results Dropdown */
.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color-light);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-xl);
    max-height: 360px;
    overflow-y: auto;
    z-index: 200;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-color);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--color-primary-50); }

.search-result-type {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ─── JS TOOLTIP POPUPS ────────────────────────────────── */
.tooltip-popup {
    position: fixed;
    background: #1e293b;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
    animation: tooltipIn 0.15s ease;
}
@keyframes tooltipIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── CARDS ────────────────────────────────────────────── */
.card {
    background: #FFFFFF;
    border: none;
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.card:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-1px);
}

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

.card-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

/* ─── STAT CARDS (KPI) ─────────────────────────────────── */
.stat-card {
    background: var(--bg-card);
    border: none;
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg);
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--stat-color, var(--color-primary));
    opacity: 0;
    transition: opacity var(--transition-base);
}

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

.stat-card:hover::before {
    opacity: 1;
}

/* ─── STAT ICON ─── */
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.3rem;
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: var(--font-weight-black);
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: 2px;
}

.stat-trend {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    margin-top: var(--space-xs);
    display: flex;
    align-items: center;
    gap: 4px;
}
.stat-trend.up { color: var(--color-success); }
.stat-trend.down { color: var(--color-danger); }

/* ─── GRID ─────────────────────────────────────────────── */
.grid {
    display: grid;
    gap: var(--space-lg);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ─── BUTTONS ──────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
    position: relative;
    overflow: hidden;
    min-height: 44px;
    letter-spacing: 0.01em;
}
.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3);
}
.btn-primary:hover {
    background: var(--color-primary-dark);
    color: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    transform: translateY(-1px);
}
.btn-primary:active {
    background: #047857;
    transform: scale(0.98);
    box-shadow: 0 1px 2px rgba(16, 185, 129, 0.2);
}

.btn-secondary {
    background: #FFFFFF;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: var(--bg-body);
    border-color: #ccc;
}

.btn-accent {
    background: var(--color-accent);
    color: #fff;
}
.btn-accent:hover {
    background: var(--color-accent-dark);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border-color-light);
    color: var(--text-secondary);
}
.btn-outline:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-50);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
}
.btn-ghost:hover {
    background: var(--color-primary-50);
    color: var(--color-primary);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}
.btn-danger:hover {
    background: #B91C1C;
    color: #fff;
}

.btn-success {
    background: var(--color-success);
    color: #fff;
}
.btn-success:hover {
    background: #15803D;
    color: #fff;
}

.btn-warning {
    background: var(--color-warning);
    color: #fff;
}
.btn-warning:hover {
    background: #B45309;
    color: #fff;
}

.btn-sm {
    padding: 8px 16px;
    font-size: var(--font-size-sm);
    border-radius: var(--border-radius-sm);
    min-height: 36px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: var(--font-size-md);
    min-height: 52px;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--border-radius-sm);
    min-height: 44px;
}

/* ─── FORMS ────────────────────────────────────────────── */
.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

/* Shared base for all form controls */
.form-control,
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    height: 44px;
    background-color: var(--bg-input);
    background-image: none;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0 var(--space-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    min-height: 44px;
}

.form-control:hover,
.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: #c5c9d0;
}

.form-control:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
    background-color: #FFFFFF;
}

.form-control::placeholder,
.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

/* Textarea specifics */
textarea.form-control,
textarea.form-input,
.form-textarea {
    height: auto;
    min-height: 80px;
    padding: var(--space-sm) var(--space-md);
    resize: vertical;
    line-height: 1.5;
}

/* Select specifics — custom dropdown arrow */
select.form-control,
select.form-input,
.form-select {
    cursor: pointer;
    padding-right: 40px;
    background-color: var(--bg-elevated);
    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='%23475569' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 12px;
}

select.form-control:hover,
select.form-input:hover,
.form-select:hover {
    background-color: var(--bg-card-hover);
    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='%23334155' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 12px;
}

select.form-control:focus,
select.form-input:focus,
.form-select:focus {
    background-color: var(--bg-elevated);
    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='%23047857' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 12px;
}

/* Select option styling */
.form-select option,
select.form-control option,
select.form-input option {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: var(--font-size-base);
}

/* Small variant for filter bars */
.form-input-sm,
.form-select-sm {
    height: 36px;
    font-size: var(--font-size-sm);
    padding: 0 var(--space-sm);
    border-radius: var(--border-radius-sm);
}

.form-select-sm,
select.form-input-sm {
    padding-right: 32px;
    background-position: right 10px center;
}

/* Date and number inputs */
input[type="date"].form-input,
input[type="date"].form-control,
input[type="time"].form-input,
input[type="time"].form-control,
input[type="number"].form-input,
input[type="number"].form-control {
    padding-right: var(--space-sm);
}

/* Ensure date inputs show calendar icon styled */
input[type="date"].form-input::-webkit-calendar-picker-indicator,
input[type="date"].form-control::-webkit-calendar-picker-indicator,
input[type="time"].form-input::-webkit-calendar-picker-indicator,
input[type="time"].form-control::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
}

/* Multi-select */
select[multiple].form-select,
select[multiple].form-control,
select[multiple].form-input {
    height: auto;
    min-height: 80px;
    padding: var(--space-sm);
    background-image: none !important;
}

/* Form row layout */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

/* Form actions (button group at bottom of a form) */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding-top: var(--space-md);
    margin-top: var(--space-md);
    border-top: 1px solid var(--border-color);
}

/* Filter bar layout */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    align-items: center;
    margin-bottom: var(--space-lg);
}

/* Disabled state */
.form-input:disabled,
.form-select:disabled,
.form-control:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-surface);
}

.form-error {
    font-size: var(--font-size-xs);
    color: var(--color-danger);
    margin-top: 4px;
}

/* Required field indicator */
.form-label.required::after {
    content: ' *';
    color: var(--color-danger);
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-bar .form-input,
    .filter-bar .form-select {
        width: 100%;
        max-width: none !important;
    }
}

/* ─── CHIPS / BADGES ───────────────────────────────────── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
}

.chip-primary { background: var(--color-primary-100); color: var(--color-primary-light); }
.chip-success { background: rgba(34, 197, 94, 0.15); color: var(--color-success); }
.chip-warning { background: rgba(245, 158, 11, 0.15); color: var(--color-warning); }
.chip-danger  { background: rgba(239, 68, 68, 0.15);  color: var(--color-danger);  }
.chip-info    { background: rgba(59, 130, 246, 0.15);  color: var(--color-info);    }
.chip-accent  { background: rgba(176, 125, 43, 0.15);  color: var(--color-accent);  }

/* ─── TABLES ───────────────────────────────────────────── */
.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius-lg);
    border: none;
    background: #FFFFFF;
    box-shadow: var(--shadow-card);
}

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

.data-table th {
    background: #F8FAFC;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color-light);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    min-height: 48px;
    vertical-align: middle;
}

.data-table tr:hover td {
    background: rgba(16, 185, 129, 0.03);
}

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

/* ─── TOAST NOTIFICATIONS ──────────────────────────────── */
.toast-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    box-shadow: var(--shadow-xl);
    animation: toastSlideIn 0.3s var(--transition-spring);
    min-width: 300px;
    max-width: 450px;
}

.toast.toast-success { border-left: 4px solid var(--color-success); }
.toast.toast-warning { border-left: 4px solid var(--color-warning); }
.toast.toast-danger  { border-left: 4px solid var(--color-danger);  }
.toast.toast-info    { border-left: 4px solid var(--color-info);    }

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

/* ─── MODAL ────────────────────────────────────────────── */

/*
 * Inline modals (in HTML) are hidden by default.
 * They become visible via Modal.open(id) which adds .active class.
 * Two patterns exist:
 *   Pattern A: <div class="modal" id="X">  (outer is .modal)
 *   Pattern B: <div class="modal-overlay" id="X"> (outer is .modal-overlay)
 */

/* Hide inline modals (those with an ID) by default */
.modal-overlay[id],
.modal[id] {
    display: none;
}

/* When activated, show them */
.modal-overlay[id].active,
.modal[id].active {
    display: flex;
}

/* Pattern A: when .modal is the outer wrapper, make it a full-screen flex container */
.modal[id].active {
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 0;
    max-width: none;
    max-height: none;
    overflow: visible;
    animation: none;
}

/* Pattern A overlay child */
.modal[id].active > .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 0;
}

/* Pattern A content child */
.modal[id].active > .modal-content {
    position: relative;
    z-index: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color-light);
    border-radius: var(--border-radius-xl);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideUp 0.3s var(--transition-spring);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15);
}

.modal[id].active > .modal-content.modal-lg {
    max-width: 800px;
}

/* Pattern B: .modal-overlay is the wrapper — standard overlay behavior */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    animation: fadeIn 0.2s ease;
}

/* Dynamic modals (no ID, created from JS) — always visible */
.modal-overlay:not([id]) {
    display: flex;
}

/* The modal card itself */
.modal-overlay > .modal,
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color-light);
    border-radius: var(--border-radius-xl);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideUp 0.3s var(--transition-spring);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

.modal-header {
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0;
    z-index: 1;
}

.modal-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--color-danger);
}

.modal-body {
    padding: var(--space-lg) var(--space-xl);
}

.modal-footer {
    padding: var(--space-md) var(--space-xl);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    position: sticky;
    bottom: 0;
    background: var(--bg-card);
    border-radius: 0 0 var(--border-radius-xl) var(--border-radius-xl);
}

/* Ensure form controls inside modals fit properly */
.modal-body .form-group {
    margin-bottom: var(--space-md);
}

.modal-body .form-group:last-child {
    margin-bottom: 0;
}

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

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── LOADING ──────────────────────────────────────────── */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.skeleton {
    background: linear-gradient(
        90deg,
        #E2E8F0 25%,
        #F1F5F9 50%,
        #E2E8F0 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--border-radius-sm);
}

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

/* ─── EMPTY STATE ──────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
}

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

.empty-state .empty-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.empty-state .empty-text {
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
}

/* ─── PAGE HEADER ──────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
}
.page-title .material-icons-round {
    color: var(--color-primary);
    opacity: 0.85;
}

/* Page header h1 icons (views without .page-title class) */
.page-header h1 {
    display: flex;
    align-items: center;
}
.page-header h1 .material-icons-round {
    color: var(--color-primary);
    opacity: 0.85;
}

.page-subtitle {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

/* ─── COUNTERS ANIMADOS ────────────────────────────────── */
.counter {
    display: inline-block;
}

/* ─── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
        --header-height: 60px;
    }

    .app-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
        box-shadow: none;
    }
    .app-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.25);
    }

    /* On mobile, no margin - sidebar is overlay */
    .app-content {
        margin-left: 0 !important;
    }

    .app-sidebar.collapsed ~ .sidebar-overlay ~ .app-content,
    .app-sidebar.collapsed ~ .app-content {
        margin-left: 0 !important;
    }

    .btn-menu-toggle {
        display: flex;
        width: 42px;
        height: 42px;
        align-items: center;
        justify-content: center;
        border-radius: 12px;
    }

    /* Hide collapse pill on mobile */
    .sidebar-toggle-pill {
        display: none !important;
    }

    /* On mobile when open, always show full sidebar */
    .app-sidebar.open .brand-name,
    .app-sidebar.open .nav-section-title,
    .app-sidebar.open .nav-item span,
    .app-sidebar.open .sidebar-footer {
        display: revert;
        opacity: 1;
        width: auto;
        pointer-events: auto;
        position: static;
    }

    .search-bar {
        width: 100%;
        max-width: 200px;
    }
    .search-bar input {
        height: 38px;
        font-size: 0.8125rem;
    }

    .user-info {
        display: none;
    }

    .app-content {
        padding: var(--space-md);
    }

    .content-area {
        padding: var(--space-md);
    }

    .grid-4, .grid-3, .grid-2 {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
    }

    .header-actions {
        width: 100%;
        display: flex;
        gap: 8px;
    }

    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    .modal {
        border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0 !important;
        max-height: 90vh;
    }

    /* Table responsive cards on mobile */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    .stat-card {
        padding: var(--space-md);
    }

    .stat-value {
        font-size: var(--font-size-xl);
    }

    .search-bar {
        display: none;
    }

    .toast-container {
        left: var(--space-md);
        right: var(--space-md);
    }

    .toast {
        min-width: unset;
        max-width: 100%;
    }
}

/* ─── SIDEBAR OVERLAY (MOBILE) ─────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* ─── UTILITIES ────────────────────────────────────────── */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.text-accent { color: var(--color-accent); }

.bg-success-soft { background: rgba(34, 197, 94, 0.1); }
.bg-warning-soft { background: rgba(245, 158, 11, 0.1); }
.bg-danger-soft { background: rgba(239, 68, 68, 0.1); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── SVG ICON SYSTEM ──────────────────────────────────── */
.icon-svg {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    line-height: 1;
}
.btn .icon-svg {
    margin-right: 0.35rem;
}
.btn-sm .icon-svg {
    width: 14px !important;
    height: 14px !important;
}

/* ─── KPI CARDS (Unified) ──────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.kpi-card {
    background: var(--bg-card);
    border: none;
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    text-align: center;
    transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
    box-shadow: var(--shadow-card);
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-hover);
}
.kpi-card.kpi-green  { border-left: 3px solid var(--color-primary); }
.kpi-card.kpi-amber  { border-left: 3px solid var(--color-accent); }
.kpi-card.kpi-blue   { border-left: 3px solid var(--color-info); }
.kpi-card.kpi-purple { border-left: 3px solid #8B5CF6; }
.kpi-card.kpi-red    { border-left: 3px solid var(--color-danger); }

.kpi-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.5rem;
}
.kpi-icon-wrap.green  { background: rgba(16,185,129,0.1); color: var(--color-primary); }
.kpi-icon-wrap.amber  { background: rgba(245,158,11,0.1); color: var(--color-accent); }
.kpi-icon-wrap.blue   { background: rgba(59,130,246,0.1); color: var(--color-info); }
.kpi-icon-wrap.purple { background: rgba(139,92,246,0.1); color: #8B5CF6; }
.kpi-icon-wrap.red    { background: rgba(239,68,68,0.1); color: var(--color-danger); }

.kpi-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.1;
}
.kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ─── SHARED LAYOUT HELPERS ────────────────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: #FFFFFF;
    border: none;
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    text-align: center;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}
.stat-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-3px); }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 800; color: var(--color-primary); letter-spacing: -0.03em; }
.stat-card .stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; font-weight: 500; }
.stat-card.accent .stat-value { color: var(--color-accent); }
.stat-card.primary .stat-value { color: var(--color-primary); }
.stat-card.warn .stat-value   { color: var(--color-warning); }
.stat-card.danger .stat-value  { color: var(--color-danger); }

.filters-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 14px 16px;
    background: #FFFFFF;
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-card);
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1rem;
}
@media(max-width: 768px) {
    .stats-row { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
    .kpi-grid  { grid-template-columns: 1fr 1fr; }
    .form-row  { grid-template-columns: 1fr; }
    .filters-bar { flex-direction: column; }
    .filters-bar .form-input,
    .filters-bar .form-select {
        max-width: none !important;
        width: 100%;
    }
}

/* ─── TABS ─────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}
.tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s;
}
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab:hover  { color: var(--text-primary); }
.tab-panel  { display: none; }
.tab-panel.active { display: block; }

/* ─── DOCUMENT LIST ─────────────────────────────────────── */
.doc-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color-light);
    transition: background 0.15s;
}
.doc-item:last-child { border-bottom: none; }
.doc-item:hover { background: var(--bg-hover); }
.doc-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border-radius: 8px;
    border: 1px solid var(--border-color-light);
}
.doc-info { flex: 1; min-width: 0; }
.doc-title {
    font-weight: 600;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.doc-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.doc-desc { font-size: 0.82rem; color: var(--text-secondary); margin-top: 4px; }
.doc-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Document drop zone */
.doc-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    transition: border-color 0.2s, background 0.2s;
}
.doc-drop-zone:hover {
    border-color: var(--color-primary);
    background: rgba(var(--color-primary-rgb, 59,130,246), 0.04);
}

/* ─── SEVERITY BADGES ──────────────────────────────────── */
.severity-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}
.severity-badge.critical { background: rgba(220,53,69,0.12); color: #DC2626; }
.severity-badge.high     { background: rgba(234,88,12,0.12); color: #EA580C; }
.severity-badge.medium   { background: rgba(202,138,4,0.12); color: #CA8A04; }
.severity-badge.low      { background: rgba(4,120,87,0.1); color: #047857; }

/* ─── DISPOSAL TYPE BADGES ─────────────────────────────── */
.disp-type {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ─── REPORT STYLES ────────────────────────────────────── */
.report-summary {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.report-kpi {
    text-align: center;
    padding: 14px 18px;
    border: 1px solid var(--border-color-light);
    border-radius: 10px;
    min-width: 110px;
    flex: 1;
    background: var(--bg-card);
}
.report-kpi .value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--color-primary);
    line-height: 1.2;
}
.report-kpi .label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.report-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.75rem;
}
.report-table th,
.report-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color-light);
    font-size: 0.85rem;
}
.report-table th {
    background: var(--bg-surface, #F8FAFC);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.report-chart {
    max-height: 320px;
    margin-top: 1rem;
}

/* ─── BREEDER ITEMS ────────────────────────────────────── */
.breeder-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color-light);
    transition: background 0.15s;
}
.breeder-item:last-child { border-bottom: none; }
.breeder-item:hover { background: var(--bg-hover, rgba(0,0,0,0.02)); }

/* ─── LINK PRIMARY ─────────────────────────────────────── */
.link-primary {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}
.link-primary:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

/* ─── TEXT HELPERS ──────────────────────────────────────── */
.text-danger { color: var(--color-danger, #DC2626) !important; }
.text-muted { color: var(--text-muted) !important; }

@media (max-width: 600px) {
    .report-summary { gap: 8px; }
    .report-kpi { padding: 10px 12px; min-width: 80px; }
    .report-kpi .value { font-size: 1.2rem; }
}

/* ─── PWA INSTALL BANNER ───────────────────────────────── */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-color-light);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 9998;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
}
.pwa-install-banner.show {
    transform: translateY(0);
}

.pwa-install-icon {
    flex-shrink: 0;
}

.pwa-install-text {
    flex: 1;
    min-width: 0;
}
.pwa-install-text strong {
    display: block;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 600;
}
.pwa-install-text small {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.pwa-install-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.pwa-install-dismiss {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: color 0.15s;
}
.pwa-install-dismiss:hover {
    color: var(--text-primary);
}

.pwa-install-accept {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.pwa-install-accept:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(4,120,87,0.2);
}

/* ─── PWA NOTIFICATION PROMPT ──────────────────────────── */
.pwa-notif-prompt {
    position: fixed;
    top: 80px;
    right: 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color-light);
    border-radius: 12px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 9997;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    max-width: 340px;
    transform: translateX(120%) scale(0.9);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.pwa-notif-prompt.show {
    transform: translateX(0) scale(1);
    opacity: 1;
}

.pwa-notif-content {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
}
.pwa-notif-content svg {
    flex-shrink: 0;
    color: var(--color-accent);
}

.pwa-notif-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.pwa-notif-no {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
}
.pwa-notif-no:hover { color: var(--text-primary); }

.pwa-notif-yes {
    background: var(--color-accent);
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.pwa-notif-yes:hover {
    background: var(--color-accent-light);
}

/* ─── PWA UPDATE BANNER ────────────────────────────────── */
.pwa-update-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--color-primary-dark);
    color: white;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 9999;
    font-size: 0.85rem;
    font-weight: 500;
    transform: translateY(-100%);
    transition: transform 0.35s ease;
}
.pwa-update-banner.show {
    transform: translateY(0);
}

.pwa-update-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pwa-update-btn {
    background: white;
    color: var(--color-primary-dark);
    border: none;
    padding: 5px 16px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.pwa-update-btn:hover {
    background: var(--color-accent);
    color: white;
}

@media (max-width: 480px) {
    .pwa-install-banner {
        flex-wrap: wrap;
    }
    .pwa-install-actions {
        width: 100%;
        justify-content: flex-end;
    }
    .pwa-notif-prompt {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* ─── DARK THEME ───────────────────────────────────────── */
[data-theme="dark"] {
    --bg-body: #0B0F19;
    --bg-surface: #141827;
    --bg-card: #1A1F35;
    --bg-card-hover: #222842;
    --bg-elevated: #1A1F35;
    --bg-input: #141827;
    --bg-sidebar: #0B0F19;
    --bg-header: rgba(20, 24, 39, 0.9);
    --bg-hover: rgba(255,255,255,0.03);

    --text-primary: #E2E8F0;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --text-inverse: #0F172A;

    --border-color: rgba(255,255,255,0.06);
    --border-color-light: rgba(255,255,255,0.04);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.35);
    --shadow-glow: none;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.2), 0 1px 2px rgba(0,0,0,0.15);
    --shadow-card-hover: 0 4px 16px rgba(0,0,0,0.3);
    --glass-bg: rgba(26, 31, 53, 0.9);
    --glass-border: rgba(255,255,255,0.06);
}
[data-theme="dark"] .form-select,
[data-theme="dark"] select.form-control,
[data-theme="dark"] select.form-input {
    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='%2394A3B8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 12px;
}
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] select.form-control:focus,
[data-theme="dark"] select.form-input:focus {
    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='%2334D399' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 12px;
}
[data-theme="dark"] .nav-item {
    color: rgba(203, 213, 225, 0.7);
}
[data-theme="dark"] .nav-item:visited {
    color: rgba(203, 213, 225, 0.7);
}
[data-theme="dark"] .nav-item:hover {
    color: #F1F5F9;
    background: rgba(255,255,255,0.05);
}
[data-theme="dark"] .nav-item.active,
[data-theme="dark"] .nav-item.active:visited {
    background: rgba(16, 185, 129, 0.12);
    color: #34D399;
}
[data-theme="dark"] .nav-section-title {
    color: rgba(100, 116, 139, 0.6);
}
[data-theme="dark"] .brand-name {
    color: #E2E8F0;
}
[data-theme="dark"] .app-sidebar {
    background: #0B0F19;
    border-right: none;
    box-shadow: 2px 0 16px rgba(0,0,0,0.3);
}
[data-theme="dark"] .sidebar-header {
    border-bottom-color: rgba(255,255,255,0.04);
}
[data-theme="dark"] .sidebar-footer {
    border-top-color: rgba(255,255,255,0.04);
}
[data-theme="dark"] .ranch-selector {
    background: rgba(255,255,255,0.04);
    color: rgba(203, 213, 225, 0.7);
}
[data-theme="dark"] .ranch-selector:hover {
    background: rgba(255,255,255,0.07);
    color: #E2E8F0;
}
[data-theme="dark"] .app-header {
    border-bottom-color: rgba(255,255,255,0.04);
    box-shadow: none;
    background: rgba(20, 24, 39, 0.9);
    backdrop-filter: blur(12px);
}
[data-theme="dark"] .sidebar-toggle-pill {
    background: var(--bg-surface);
    border-color: var(--border-color);
}
[data-theme="dark"] .sidebar-toggle-pill:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color-light);
}
[data-theme="dark"] .app-sidebar.collapsed .nav-item[data-tooltip]::after {
    background: #334155;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* Dark mode — document items */
[data-theme="dark"] .doc-icon {
    background: var(--bg-input);
    border-color: var(--border-color);
}
[data-theme="dark"] .doc-drop-zone {
    border-color: var(--border-color);
}
[data-theme="dark"] .doc-drop-zone:hover {
    background: rgba(4, 120, 87, 0.06);
}

/* Dark mode — report tables */
[data-theme="dark"] .report-table th {
    background: var(--bg-input);
    color: var(--text-secondary);
}
[data-theme="dark"] .report-table td {
    border-color: var(--border-color);
}
[data-theme="dark"] .report-kpi {
    border-color: var(--border-color);
}

/* Dark mode — severity badge */
[data-theme="dark"] .severity-badge.critical { background: rgba(220,53,69,0.2); color: #ff6b7a; }
[data-theme="dark"] .severity-badge.high { background: rgba(220,115,0,0.2); color: #ffa040; }
[data-theme="dark"] .severity-badge.medium { background: rgba(255,193,7,0.2); color: #ffc107; }
[data-theme="dark"] .severity-badge.low { background: rgba(4,120,87,0.15); color: #34d399; }

/* Theme toggle button icons */
[data-theme="dark"] #btnThemeToggle .icon-sun { display: none; }
[data-theme="dark"] #btnThemeToggle .icon-moon { display: block !important; }

/* ─── UI MODERNIZATION — MATERIAL DESIGN 2026 ─────────── */

/* Enhanced page transitions */
.content-area {
    animation: pageSlideIn 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes pageSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Stat cards — Material elevation with accent strip */
.stats-row .stat-card {
    position: relative;
    overflow: hidden;
    border: none;
    box-shadow: var(--shadow-card);
}
.stats-row .stat-card::after {
    content: '';
    position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
    background: var(--color-primary);
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.stats-row .stat-card:hover::after { opacity: 1; }
.stats-row .stat-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.stats-row .stat-card.accent::after { background: var(--color-accent); }
.stats-row .stat-card.warn::after { background: var(--color-warning); }
.stats-row .stat-card.danger::after { background: var(--color-danger); }
.stats-row .stat-card.primary::after { background: var(--color-primary); }

/* Page headers — clean Material style */
.page-header {
    background: transparent;
    margin: 0 0 var(--space-lg);
    padding: 0 0 var(--space-md);
    border-bottom: none;
    box-shadow: none;
    border-radius: 0;
    position: relative;
}
.page-header::after {
    display: none;
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}
.page-header .page-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Material Ripple effect for interactive elements */
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 10%, transparent 10%);
    transform: scale(10);
    opacity: 0;
    transition: transform 0.5s, opacity 0.8s;
    pointer-events: none;
}
.btn:active::after {
    transform: scale(0);
    opacity: 1;
    transition: 0s;
}

/* Task card — elevated */
.task-card {
    border-radius: var(--border-radius-lg) !important;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
    border: none !important;
    box-shadow: var(--shadow-card);
}
.task-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

/* Modal — Material Design */
.modal-overlay.active .modal {
    animation: modalSlideUp 0.35s cubic-bezier(0.0, 0.0, 0.2, 1);
}
.modal {
    border-radius: var(--border-radius-xl) !important;
    border: none !important;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15) !important;
}
.modal-header {
    padding: 20px 24px !important;
    border-bottom: 1px solid var(--border-color-light) !important;
}
.modal-body {
    padding: 24px !important;
}

/* Table styling — clean, no borders */
.table-responsive {
    border-radius: var(--border-radius-lg);
    overflow: hidden;
}

/* Empty states — more inviting */
.empty-state {
    padding: 4rem 2rem;
}

/* Floating action button style for primary actions on mobile */
@media (max-width: 768px) {
    .header-actions .btn-primary,
    .page-header-actions .btn-primary,
    .page-header > .btn-primary,
    .page-header > div:last-child > .btn-primary,
    .page-header > button.btn-primary {
        position: fixed;
        bottom: 24px;
        right: 24px;
        z-index: 90;
        border-radius: 50px;
        padding: 14px 24px;
        box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
        font-size: 0.9rem;
        min-height: 52px;
    }
    .header-actions .btn-primary:hover,
    .page-header-actions .btn-primary:hover,
    .page-header > .btn-primary:hover {
        box-shadow: 0 6px 24px rgba(16, 185, 129, 0.45);
    }
    .page-header {
        padding: 0 0 var(--space-md);
        margin: 0 0 var(--space-md);
    }
    .content-area {
        padding-bottom: 80px; /* Space for FAB */
    }
}

/* Loading skeleton — Material */
.skeleton {
    background: linear-gradient(90deg, var(--bg-input) 25%, rgba(0,0,0,0.04) 50%, var(--bg-input) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--border-radius);
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Badge improvements */
.stock-badge, .sale-status, .mov-type, .severity-badge, .disp-type {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Table action buttons — bigger touch targets */
.data-table .btn-sm {
    min-height: 36px;
    min-width: 36px;
    padding: 6px 12px;
}

/* Scrollbar improvements */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.25);
}

/* Material-style chip/tag for categories */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    min-height: 32px;
}

/* Bottom navigation for mobile (quick access) */
@media (max-width: 768px) {
    .stats-row {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    .stat-card .stat-value {
        font-size: 1.4rem;
    }
    .stat-card .stat-label {
        font-size: 0.72rem;
    }
    .filters-bar {
        gap: 0.5rem;
    }
    .filters-bar .form-input,
    .filters-bar .form-select {
        max-width: none !important;
    }
}

/* Notification dropdown dark mode */
[data-theme="dark"] .notif-dropdown {
    box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.2);
}
[data-theme="dark"] .notif-item.unread {
    background: rgba(4,120,87,0.08);
}
[data-theme="dark"] .notification-count {
    border: 2px solid var(--bg-header);
}

/* Calendar modal dark mode */
[data-theme="dark"] .cal-modal-event:hover {
    background: rgba(255,255,255,0.04);
}

/* Evidence gallery dark mode */
[data-theme="dark"] .evidence-item {
    border-color: var(--border-color);
}
[data-theme="dark"] .evidence-upload-btn {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* ─── ENTRANCE ANIMATION SYSTEM ────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes slideInUp {
    from { opacity: 0; transform: translateY(30px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes floatBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.2); }
    50% { box-shadow: 0 0 20px 4px rgba(16, 185, 129, 0.15); }
}
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Animate-on-scroll classes */
.anim-fade-up {
    animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.anim-fade-down {
    animation: fadeInDown 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.anim-scale-in {
    animation: scaleIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.anim-slide-up {
    animation: slideInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* Staggered delays for children */
.anim-stagger > *:nth-child(1) { animation-delay: 0ms; }
.anim-stagger > *:nth-child(2) { animation-delay: 60ms; }
.anim-stagger > *:nth-child(3) { animation-delay: 120ms; }
.anim-stagger > *:nth-child(4) { animation-delay: 180ms; }
.anim-stagger > *:nth-child(5) { animation-delay: 240ms; }
.anim-stagger > *:nth-child(6) { animation-delay: 300ms; }
.anim-stagger > *:nth-child(7) { animation-delay: 360ms; }
.anim-stagger > *:nth-child(8) { animation-delay: 420ms; }
.anim-stagger > *:nth-child(9) { animation-delay: 480ms; }

/* ─── GRADIENT CARD SYSTEM ─────────────────────────────── */
.grad-card {
    border: none;
    border-radius: var(--border-radius-xl);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-card);
}
.grad-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}
.grad-card--mint { background: var(--gradient-card-mint); }
.grad-card--purple { background: var(--gradient-card-purple); }
.grad-card--blue { background: var(--gradient-card-blue); }
.grad-card--amber { background: var(--gradient-card-amber); }
.grad-card--pink { background: var(--gradient-card-pink); }
.grad-card--cyan { background: var(--gradient-card-cyan); }
.grad-card--dark { background: var(--gradient-card-dark); color: #E2E8F0; }
.grad-card--glass {
    background: var(--gradient-glass);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.4);
}

/* Decorative shapes inside gradient cards */
.grad-card::after {
    content: '';
    position: absolute;
    top: -30%;
    right: -15%;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    pointer-events: none;
}
.grad-card::before {
    content: '';
    position: absolute;
    bottom: -20%;
    left: -10%;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    pointer-events: none;
}

.grad-card .grad-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0.7;
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
}
.grad-card .grad-card-value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    position: relative;
    z-index: 1;
}
.grad-card .grad-card-sub {
    font-size: 0.78rem;
    font-weight: 500;
    opacity: 0.6;
    margin-top: 4px;
    position: relative;
    z-index: 1;
}
.grad-card .grad-card-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.25);
    z-index: 1;
}
.grad-card--dark .grad-card-icon {
    background: rgba(255,255,255,0.1);
}

/* ─── PILL TABS (Period Selector) ──────────────────────── */
.pill-tabs {
    display: inline-flex;
    background: rgba(0,0,0,0.04);
    border-radius: 30px;
    padding: 3px;
    gap: 2px;
}
.pill-tab {
    padding: 8px 18px;
    border-radius: 30px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
}
.pill-tab:hover {
    color: var(--text-primary);
}
.pill-tab.active {
    background: #FFFFFF;
    color: var(--text-primary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* ─── MICRO-SPARKLINE INSIDE CARDS ─────────────────────── */
.mini-chart {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 32px;
    margin-top: 8px;
    position: relative;
    z-index: 1;
}
.mini-chart-bar {
    flex: 1;
    border-radius: 3px 3px 0 0;
    min-height: 4px;
    background: rgba(0,0,0,0.12);
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.grad-card--dark .mini-chart-bar {
    background: rgba(255,255,255,0.15);
}

/* ─── GLASS MORPHISM PANELS ────────────────────────────── */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-card);
}

/* ─── NUMBER COUNTER ANIMATION ─────────────────────────── */
.counter-animated {
    display: inline-block;
    transition: transform 0.2s;
}
.counter-animated.counting {
    animation: counterBounce 0.3s ease;
}
@keyframes counterBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* ─── FLOATING DECORATIVE SHAPES (for hero areas) ──────── */
.floating-shapes {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}
.floating-shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.08;
    animation: floatBob 6s ease-in-out infinite;
}
.floating-shape:nth-child(1) {
    width: 200px; height: 200px;
    top: -40px; right: -30px;
    background: rgba(255,255,255,0.5);
    animation-duration: 7s;
}
.floating-shape:nth-child(2) {
    width: 120px; height: 120px;
    bottom: -20px; left: 20%;
    background: rgba(255,255,255,0.3);
    animation-duration: 5s;
    animation-delay: -2s;
}
.floating-shape:nth-child(3) {
    width: 80px; height: 80px;
    top: 30%; right: 20%;
    background: rgba(255,255,255,0.2);
    animation-duration: 8s;
    animation-delay: -4s;
}
