/* ============================================
   PLATAFORMA BUHO — Premium Design System v19.0
   ============================================ */

/* --- CSS Variables / Design Tokens --- */
:root {
    /* Colors - Dark Neon Yellow Theme (Premium Slate) */
    --bg-primary: #020617;
    --bg-secondary: #000000;
    --bg-card: #0f172a;
    --bg-card-hover: #1e293b;
    --bg-input: #020617;
    --bg-sidebar: #020617;
    --bg-topbar: rgba(2, 6, 23, 0.8);
    
    --border-primary: rgba(230, 255, 42, 0.1);
    --border-hover: rgba(230, 255, 42, 0.25);
    --border-active: rgba(230, 255, 42, 0.4);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #475569;
    --text-accent: #e6ff2a;
    
    --accent-primary: #e6ff2a;
    --accent-secondary: #c9e600;
    --accent-gradient: linear-gradient(135deg, #e6ff2a, #d4eb00);
    --accent-glow: rgba(230, 255, 42, 0.12);
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --info: #0ea5e9;
    --info-bg: rgba(14, 165, 233, 0.1);
    
    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Outfit', 'Inter', system-ui;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.8125rem;
    --font-size-base: 0.875rem;
    --font-size-md: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    
    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --topbar-height: 64px;
    --border-radius: 16px;
    --border-radius-sm: 8px;
    
    /* Shadows - Refined Depth */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 8px 30px -4px rgba(0,0,0,0.4);
    --shadow-lg: 0 20px 50px -12px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px rgba(230, 255, 42, 0.1);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Glassmorphism Utilities */
.glass {
    background: rgba(15, 23, 42, 0.6) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(230, 255, 42, 0.2) !important;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37) !important;
}

body.light-mode .glass {
    background: rgba(255, 255, 255, 0.6) !important;
    border: 1px solid rgba(15, 23, 42, 0.1) !important;
}

.glass-pill {
    background: rgba(230, 255, 42, 0.1);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(230, 255, 42, 0.2);
    border-radius: 20px;
    padding: 4px 12px;
}

/* --- Light Mode Overrides (Contrast Focused) --- */
body.light-mode {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-input: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-topbar: rgba(255, 255, 255, 0.9);
    
    --border-primary: rgba(15, 23, 42, 0.12); /* Slightly darker for better definition */
    --border-hover: rgba(15, 23, 42, 0.2);
    --border-active: rgba(15, 23, 42, 0.3);
    
    --text-primary: #020617; /* Slate 950 - Absolute Black contrast */
    --text-secondary: #0f172a; /* Slate 900 - High hierarchy */
    --text-muted: #475569; /* Slate 600 - More legible */
    --text-accent: #166534; /* Darker emerald for readability in Light Mode */
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px -4px rgba(0,0,0,0.18);

    /* Component Overrides for Legibility */
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --border-primary: #e2e8f0;
}

/* Specific component fixes for Light Mode */
body.light-mode .card, 
body.light-mode .stat-card, 
body.light-mode .table-wrapper {
    background-color: #ffffff;
    color: #0f172a;
    border-color: #e2e8f0;
}

body.light-mode .stat-value,
body.light-mode .card-title,
body.light-mode table th {
    color: #0f172a !important;
}

body.light-mode .dashboard-hero h2,
body.light-mode .dashboard-hero p {
    color: #0f172a !important;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

a { color: var(--accent-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--accent-secondary); }

h1, h2, h3, h4, .page-title, .card-title, .sidebar-title, .login-logo h1 {
    font-family: var(--font-heading);
    letter-spacing: -0.02em;
}

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

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-primary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* --- Login Screen --- */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.login-bg-effects {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 8s ease-in-out infinite;
}

.orb-1 {
    width: 400px; height: 400px;
    background: radial-gradient(circle, #e6ff2a 0%, transparent 70%);
    top: -100px; left: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 350px; height: 350px;
    background: radial-gradient(circle, #c9e600 0%, transparent 70%);
    bottom: -80px; right: -80px;
    animation-delay: -3s;
}

.orb-3 {
    width: 250px; height: 250px;
    background: radial-gradient(circle, #a1b800 0%, transparent 70%);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -5s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -30px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(20px, 10px) scale(1.02); }
}

.login-card {
    position: relative;
    z-index: 1;
    background: rgba(24, 24, 27, 0.7);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-primary);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.logo-icon {
    font-size: 56px;
    display: block;
    margin-bottom: 12px;
    animation: pulseGlow 3s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(230, 255, 42, 0.3)); }
    50% { filter: drop-shadow(0 0 25px rgba(230, 255, 42, 0.5)); }
}

.login-logo h1 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin-top: 4px;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--transition-fast);
}

.input-wrapper input,
.input-wrapper select,
.input-wrapper textarea {
    width: 100%;
    padding: 12px 14px 12px 44px;
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    transition: all var(--transition-fast);
    outline: none;
}

input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    transition: all var(--transition-fast);
    outline: none;
}

input:focus, select:focus, textarea:focus,
.input-wrapper input:focus,
.input-wrapper select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper input:focus + .input-icon,
.input-wrapper input:focus ~ .input-icon {
    color: var(--accent-primary);
}

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

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.error-message {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--border-radius-xs);
    font-size: var(--font-size-sm);
    margin-bottom: 16px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

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

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: var(--font-size-base);
    font-weight: 600;
    font-family: var(--font-family);
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #000000;
    box-shadow: 0 4px 15px rgba(230, 255, 42, 0.2);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(230, 255, 42, 0.3);
}

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

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

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

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #0d9668; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: var(--warning); color: #1a1a2e; }

.btn-sm {
    padding: 6px 14px;
    font-size: var(--font-size-xs);
}

.btn-full {
    width: 100%;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--border-radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Loading state for buttons */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: currentColor;
    animation: spinner 0.6s linear infinite;
}

body.light-mode .btn-primary.btn-loading::after {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: #000;
}

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

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: all var(--transition-slow);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-primary);
}

.logo-icon-sm {
    font-size: 28px;
}

.sidebar-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-toggle {
    display: none;
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

.sidebar-toggle svg {
    width: 20px;
    height: 20px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 16px 12px 6px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: rgba(230, 255, 42, 0.08);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(230, 255, 42, 0.12);
    color: var(--accent-primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent-gradient);
    border-radius: 0 3px 3px 0;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--accent-primary);
    color: #000000;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-primary);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--border-radius-sm);
    background: rgba(230, 255, 42, 0.05);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: #000000;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-transform: capitalize;
}

/* --- Main Content Area --- */
#main-app {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-slow);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--topbar-height);
    background: var(--bg-topbar);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

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

.page-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.theme-toggle, .lang-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
}

.theme-toggle:hover, .lang-toggle:hover {
    background: var(--bg-card-hover);
    color: var(--accent-primary);
    border-color: var(--border-primary);
}

.lang-toggle {
    width: auto;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
}

.notification-bell {
    position: relative;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background var(--transition-fast);
}

.notification-bell:hover {
    background: var(--bg-card);
}

.notification-bell svg {
    width: 22px;
    height: 22px;
    color: var(--text-secondary);
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.page-content {
    padding: 24px;
    min-height: calc(100vh - var(--topbar-height));
    animation: fadeIn 0.3s ease;
}

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

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius);
    padding: 24px;
    transition: all var(--transition-base);
}

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

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

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

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

.premium-card {
    position: relative;
    padding: 24px;
    border-radius: 16px;
    color: white;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    cursor: pointer;
    overflow: hidden;
    border: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.premium-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

.premium-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    pointer-events: none;
}

.premium-card.purple { background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%); }
.premium-card.blue   { background: linear-gradient(135deg, #3b82f6 0%, #2dd4bf 100%); }
.premium-card.amber  { background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%); }
.premium-card.green  { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.premium-card.red    { background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%); }
.premium-card.gold   { background: linear-gradient(135deg, #eab308 0%, #d97706 100%); }

.dashboard-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
}

.agency-selector {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.agency-selector:hover {
    border-color: var(--purple);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
}

.sparkline-container {
    height: 40px;
    width: 100px;
    margin-left: auto;
    opacity: 0.8;
}

.sparkline-path {
    fill: none;
    stroke: white;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.stat-icon {
    font-size: 28px;
    background: rgba(255, 255, 255, 0.2);
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    backdrop-filter: blur(4px);
    flex-shrink: 0;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all var(--transition-base);
    cursor: default;
}

.stat-card.purple { border-left: 4px solid #8b5cf6; background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), transparent); }
.stat-card.blue   { border-left: 4px solid #3b82f6; background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), transparent); }
.stat-card.amber  { border-left: 4px solid #f59e0b; background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), transparent); }
.stat-card.green  { border-left: 4px solid #10b981; background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), transparent); }
.stat-card.red    { border-left: 4px solid #ef4444; background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), transparent); }

/* Ajustes específicos para Modo Claro */
body.light-mode .stat-card {
    background: #ffffff;
    box-shadow: var(--shadow-sm);
}
body.light-mode .stat-card.blue { background: linear-gradient(135deg, #eff6ff, #ffffff); }
body.light-mode .stat-card.amber { background: linear-gradient(135deg, #fffbeb, #ffffff); }
body.light-mode .stat-card.green { background: linear-gradient(135deg, #f0fdf4, #ffffff); }
body.light-mode .stat-card.red { background: linear-gradient(135deg, #fef2f2, #ffffff); }

.stat-content { flex: 1; }

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

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

/* --- Tables --- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-primary);
}

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

th {
    background: var(--bg-input);
    padding: 12px 16px;
    text-align: left;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-primary);
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    font-size: var(--font-size-sm);
    border-bottom: 1px solid rgba(99, 102, 241, 0.06);
    color: var(--text-primary);
}

tr:hover td {
    background: rgba(99, 102, 241, 0.04);
}

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

/* --- Status Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    white-space: nowrap;
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.badge-nuevo, .badge-recibida, .badge-generada, .badge-pending, .badge-pendiente 
    { background: var(--info-bg); color: var(--info); }
.badge-nuevo::before, .badge-recibida::before, .badge-generada::before, .badge-pending::before, .badge-pendiente::before 
    { background: var(--info); }

.badge-en_proceso, .badge-asignada, .badge-en_diseno, .badge-en_revision
    { background: rgba(139, 92, 246, 0.12); color: #a78bfa; }
.badge-en_proceso::before, .badge-asignada::before, .badge-en_diseno::before, .badge-en_revision::before
    { background: #a78bfa; }

.badge-revision_interna, .badge-enviada, .badge-enviado_al_cliente, .badge-enviado, .badge-con_cambios
    { background: var(--warning-bg); color: var(--warning); }
.badge-revision_interna::before, .badge-enviada::before, .badge-enviado_al_cliente::before, .badge-enviado::before, .badge-con_cambios::before
    { background: var(--warning); }

.badge-aprobado, .badge-approved, .badge-pagada, .badge-completada, .badge-active, .badge-finalizado
    { background: var(--success-bg); color: var(--success); }
.badge-aprobado::before, .badge-approved::before, .badge-pagada::before, .badge-completada::before, .badge-active::before, .badge-finalizado::before
    { background: var(--success); }

.badge-con_cambios, .badge-changes_requested, .badge-vencida
    { background: var(--danger-bg); color: var(--danger); }
.badge-con_cambios::before, .badge-changes_requested::before, .badge-vencida::before
    { background: var(--danger); }

.badge-rejected, .badge-cancelado, .badge-cancelada, .badge-cerrada, .badge-inactive, .badge-suspended, .badge-cancelled, .badge-rechazada
    { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }
.badge-rejected::before, .badge-cancelado::before, .badge-cancelada::before, .badge-cerrada::before, .badge-inactive::before, .badge-suspended::before, .badge-cancelled::before, .badge-rechazada::before
    { background: var(--text-muted); }

.badge-alta { background: var(--danger-bg); color: var(--danger); }
.badge-alta::before { background: var(--danger); }
.badge-media { background: var(--warning-bg); color: var(--warning); }
.badge-media::before { background: var(--warning); }
.badge-baja { background: var(--success-bg); color: var(--success); }
.badge-baja::before { background: var(--success); }

/* --- Progress Bar --- */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 3px;
    transition: width var(--transition-slow);
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-sm);
    padding: 14px 20px;
    min-width: 300px;
    max-width: 420px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
}

.toast.removing {
    animation: slideOutRight 0.3s ease forwards;
}

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

.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-message { font-size: var(--font-size-sm); color: var(--text-primary); flex: 1; }

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

/* --- Modals --- */
.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: 20px;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.modal-header h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.modal-body {
    padding: 24px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* --- Activity List --- */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(99, 102, 241, 0.06);
    font-size: var(--font-size-sm);
}

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

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-primary);
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-text { color: var(--text-primary); flex: 1; }
.activity-time { color: var(--text-muted); font-size: var(--font-size-xs); white-space: nowrap; }

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: var(--font-size-md);
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* --- Notification List --- */
.notification-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notification-item {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.notification-item:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}

.notification-item.unread {
    border-left: 3px solid var(--accent-primary);
}

.notification-item .notif-icon { font-size: 20px; flex-shrink: 0; }
.notification-item .notif-content { flex: 1; }
.notification-item .notif-title { font-weight: 600; font-size: var(--font-size-sm); }
.notification-item .notif-message { font-size: var(--font-size-xs); color: var(--text-secondary); margin-top: 2px; }
.notification-item .notif-time { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 4px; }

/* --- Grid Layouts --- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* --- Detail View --- */
.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.detail-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
}

.detail-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.detail-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.detail-section {
    margin-bottom: 24px;
}

.detail-section-title {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--text-accent);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-primary);
}

/* --- Tabs --- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-primary);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab {
    padding: 12px 20px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.tab:hover { color: var(--text-primary); }
.tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

/* --- Search Bar --- */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-input input {
    padding-left: 40px;
}

.search-input svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.filter-group {
    display: flex;
    gap: 8px;
}

.filter-group select {
    min-width: 140px;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination-btn {
    padding: 8px 14px;
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-xs);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

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

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

.pagination-info {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    margin: 0 8px;
}

/* --- Loading Spinner --- */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-primary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text-muted);
    gap: 12px;
}

/* --- Comment Box --- */
.comment-box {
    display: flex;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-sm);
    margin-bottom: 8px;
}

.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.comment-body { flex: 1; }
.comment-author { font-weight: 600; font-size: var(--font-size-sm); }
.comment-role { font-size: var(--font-size-xs); color: var(--text-muted); margin-left: 6px; }
.comment-text { font-size: var(--font-size-sm); color: var(--text-secondary); margin-top: 4px; }
.comment-time { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 4px; }

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .page-content {
        padding: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .detail-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .login-card {
        margin: 16px;
        padding: 32px 24px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .topbar {
        padding: 0 16px;
    }
    
    .search-bar {
        flex-direction: column;
    }
}

/* --- Reports Premium Tabs (Pills) --- */
.reports-header.sticky-tabs {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-primary);
    padding: 10px 0 20px 0;
    margin-bottom: 20px;
}

.reports-tabs-pills {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 8px;
    border-radius: 50px;
    width: fit-content;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
}

.pill-btn {
    padding: 12px 28px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 50px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.pill-btn:hover {
    color: var(--text-primary);
    background: rgba(230, 255, 42, 0.1);
    border-color: rgba(230, 255, 42, 0.2);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.pill-btn.active {
    background: linear-gradient(135deg, #e6ff2a 0%, #a3cf06 100%);
    color: #000 !important;
    box-shadow: 0 10px 25px rgba(230, 255, 42, 0.4);
    transform: translateY(-2px) scale(1.05);
    border-color: #e6ff2a;
}

body.light-mode .pill-btn.active {
    background: linear-gradient(135deg, #e6ff2a 0%, #a3cf06 100%);
    color: #000 !important;
    box-shadow: 0 8px 20px rgba(22, 101, 52, 0.2);
}

@media (max-width: 768px) {
    .reports-tabs-pills {
        width: 100%;
        border-radius: var(--border-radius-sm);
    }
    .pill-btn {
        flex: 1;
        justify-content: center;
        padding: 10px;
    }
}

/* --- Calendar v17.0 --- */
.calendar-container {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--border-primary);
    background: rgba(255, 255, 255, 0.02);
}

.calendar-grid {
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important;
    border-left: 1px solid var(--border-primary);
    border-top: 1px solid var(--border-primary);
    background: var(--bg-card);
}

.cal-day-header {
    padding: 12px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.1);
    border-right: 1px solid var(--border-primary);
    border-bottom: 1px solid var(--border-primary);
}

.cal-day {
    min-height: 120px;
    padding: 10px;
    border-right: 1px solid var(--border-primary);
    border-bottom: 1px solid var(--border-primary);
    position: relative;
    transition: background 0.2s;
    cursor: pointer;
}

.cal-day:hover { background: rgba(99, 102, 241, 0.05); }
.cal-day.empty { background: rgba(0, 0, 0, 0.05); cursor: default; }
.cal-day.today { background: rgba(230, 255, 42, 0.05); }
.cal-day.today .day-number { 
    background: #e6ff2a; 
    color: #000; 
    width: 24px; 
    height: 24px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border-radius: 50%;
    font-weight: 700;
}

.day-number {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.day-events {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cal-event-pill {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s;
}

.cal-event-pill:hover { transform: scale(1.02); filter: brightness(1.1); }
.cal-event-pill.type-reunion { background: rgba(59, 130, 246, 0.2); color: #60a5fa; border-left: 3px solid #3b82f6; }
.cal-event-pill.type-grabacion { background: rgba(239, 68, 68, 0.2); color: #f87171; border-left: 3px solid #ef4444; }
.cal-event-pill.type-otro { background: rgba(168, 85, 247, 0.2); color: #c084fc; border-left: 3px solid #a855f7; }

.event-detail-view h3 { margin-bottom: 5px; }
.event-detail-view label { margin-top: 15px; }

