/* ============================================
   ERP WORKSHOP - DESIGN SYSTEM
   Professional Dark Mode UI
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    /* Colors - Core */
    --primary: #3B82F6;
    --primary-dark: #1E40AF;
    --primary-light: #60A5FA;
    --primary-glow: rgba(59, 130, 246, 0.15);

    --secondary: #0D9488;
    --secondary-dark: #0F766E;
    --secondary-light: #2DD4BF;

    /* Status Colors */
    --success: #059669;
    --success-light: #10B981;
    --success-bg: rgba(5, 150, 105, 0.12);

    --warning: #D97706;
    --warning-light: #F59E0B;
    --warning-bg: rgba(217, 119, 6, 0.12);

    --danger: #DC2626;
    --danger-light: #EF4444;
    --danger-bg: rgba(220, 38, 38, 0.12);

    --info: #0EA5E9;
    --info-light: #38BDF8;
    --info-bg: rgba(14, 165, 233, 0.12);

    /* Background Hierarchy */
    --bg-base: #0B1120;
    --bg-surface: #111827;
    --bg-elevated: #1E293B;
    --bg-hover: #273548;
    --bg-active: #334155;
    --bg-overlay: rgba(0, 0, 0, 0.6);

    /* Text Colors */
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-tertiary: #64748B;
    --text-disabled: #475569;

    /* Borders */
    --border-default: #1E293B;
    --border-light: #334155;
    --border-focus: var(--primary);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);

    /* Spacing */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --topbar-height: 64px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;

    /* Font */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary);
}

img {
    max-width: 100%;
    height: auto;
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-active);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ============================================
   LAYOUT - APP SHELL
   ============================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-base);
}

.app-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed);
}

.page-wrapper {
    padding: 24px;
    padding-top: calc(var(--topbar-height) + 24px);
    max-width: 1600px;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-default);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-base), width var(--transition-base);
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-default);
    min-height: 72px;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    color: white;
    flex-shrink: 0;
}

.sidebar-brand {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity var(--transition-fast);
}

.sidebar-brand h1 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.sidebar-brand p {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 400;
}

.sidebar.collapsed .sidebar-brand {
    opacity: 0;
    width: 0;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    padding: 8px 12px 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .nav-section-title {
    text-align: center;
    font-size: 0;
}

.sidebar.collapsed .nav-section-title::after {
    content: '—';
    font-size: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary-glow);
    color: var(--primary-light);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.nav-item .icon {
    flex-shrink: 0;
}

.nav-item-text {
    overflow: hidden;
    transition: opacity var(--transition-fast);
}

.sidebar.collapsed .nav-item-text {
    opacity: 0;
    width: 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
}

.sidebar.collapsed .nav-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    padding: 1px 4px;
    font-size: 9px;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-default);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.sidebar-user:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), #8B5CF6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
}

.user-info {
    overflow: hidden;
    white-space: nowrap;
}

.user-info .name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-info .role {
    font-size: 11px;
    color: var(--text-tertiary);
}

.sidebar.collapsed .user-info {
    opacity: 0;
    width: 0;
}

/* ============================================
   TOPBAR
   ============================================ */
.topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    height: var(--topbar-height);
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-default);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    transition: left var(--transition-base);
}

.sidebar-collapsed .topbar {
    left: var(--sidebar-collapsed);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-tertiary);
}

.breadcrumb a {
    color: var(--text-tertiary);
}

.breadcrumb a:hover {
    color: var(--primary-light);
}

.breadcrumb .separator {
    color: var(--text-disabled);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Notification Bell */
.notification-btn {
    position: relative;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
}

.notification-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.notification-count {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Notification Dropdown */
.notification-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 380px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 1010;
    display: none;
    overflow: hidden;
}

.notification-dropdown.show {
    display: block;
    animation: slideDown 200ms ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.notif-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-default);
}

.notif-header h3 {
    font-size: 14px;
    font-weight: 600;
}

.notif-mark-all {
    font-size: 12px;
    color: var(--primary-light);
    cursor: pointer;
    border: none;
    background: none;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.notif-mark-all:hover {
    background: var(--primary-glow);
}

.notif-list {
    max-height: 360px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-default);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.notif-item:hover {
    background: var(--bg-hover);
}

.notif-item.unread {
    background: rgba(59, 130, 246, 0.05);
}

.notif-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
}

.notif-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notif-content {
    flex: 1;
    min-width: 0;
}

.notif-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.notif-message {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notif-time {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.notif-footer {
    padding: 10px 16px;
    text-align: center;
    border-top: 1px solid var(--border-default);
}

.notif-footer a {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary-light);
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-base);
}

.card:hover {
    border-color: var(--border-light);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header h2,
.card-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 28px;
    margin-bottom: 36px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-base);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--stat-color, var(--primary));
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-light);
}

.stat-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stat-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.stat-card-icon.blue { background: linear-gradient(135deg, #3B82F6, #1D4ED8); }
.stat-card-icon.green { background: linear-gradient(135deg, #059669, #047857); }
.stat-card-icon.orange { background: linear-gradient(135deg, #D97706, #B45309); }
.stat-card-icon.red { background: linear-gradient(135deg, #DC2626, #B91C1C); }
.stat-card-icon.purple { background: linear-gradient(135deg, #7C3AED, #5B21B6); }
.stat-card-icon.teal { background: linear-gradient(135deg, #0D9488, #0F766E); }

.stat-card-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 4px;
}

.stat-card-sub {
    font-size: 12px;
    color: var(--text-tertiary);
}

.stat-card-sub .up { color: var(--success); }
.stat-card-sub .down { color: var(--danger); }

/* ============================================
   TABLES
   ============================================ */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead {
    background: var(--bg-elevated);
}

thead th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border-default);
    transition: background var(--transition-fast);
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg-hover);
}

tbody td {
    padding: 12px 16px;
    color: var(--text-primary);
    vertical-align: middle;
}

.table-actions {
    display: flex;
    gap: 4px;
}

.table-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
}

.table-empty .icon {
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.badge-primary { background: rgba(59, 130, 246, 0.15); color: #60A5FA; }
.badge-success { background: var(--success-bg); color: var(--success-light); }
.badge-warning { background: var(--warning-bg); color: var(--warning-light); }
.badge-danger { background: var(--danger-bg); color: var(--danger-light); }
.badge-info { background: var(--info-bg); color: var(--info-light); }
.badge-secondary { background: rgba(100, 116, 139, 0.15); color: var(--text-secondary); }
.badge-dark { background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); }

.badge-lg {
    padding: 5px 14px;
    font-size: 12px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 1px 3px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover { background: var(--primary-dark); color: white; }

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 1px 3px rgba(5, 150, 105, 0.3);
}
.btn-success:hover { background: #047857; color: white; }

.btn-warning {
    background: var(--warning);
    color: white;
    box-shadow: 0 1px 3px rgba(217, 119, 6, 0.3);
}
.btn-warning:hover { background: #B45309; color: white; }

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 1px 3px rgba(220, 38, 38, 0.3);
}
.btn-danger:hover { background: #B91C1C; color: white; }

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
}

.btn-icon {
    padding: 8px;
    width: 36px;
    height: 36px;
}

.btn-icon.btn-sm {
    width: 30px;
    height: 30px;
    padding: 5px;
}

.btn-block {
    width: 100%;
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-base);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 14px;
    transition: all var(--transition-fast);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control::placeholder {
    color: var(--text-disabled);
}

.form-control:disabled {
    background: var(--bg-elevated);
    color: var(--text-tertiary);
    cursor: not-allowed;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394A3B8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-help {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.form-error {
    font-size: 11px;
    color: var(--danger);
    margin-top: 4px;
}

.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .form-control {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group-append {
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-left: none;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: var(--text-secondary);
    font-size: 13px;
    display: flex;
    align-items: center;
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-bottom: 8px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-check label {
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-active);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-bar.progress-sm { height: 4px; }
.progress-bar.progress-lg { height: 14px; }

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 600ms ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.progress-fill span {
    font-size: 10px;
    font-weight: 600;
    color: white;
    padding-right: 6px;
    display: none;
}

.progress-lg .progress-fill span {
    display: inline;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    border: 1px solid;
    animation: fadeIn 300ms ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success { background: var(--success-bg); border-color: rgba(5, 150, 105, 0.2); color: var(--success-light); }
.alert-warning { background: var(--warning-bg); border-color: rgba(217, 119, 6, 0.2); color: var(--warning-light); }
.alert-danger { background: var(--danger-bg); border-color: rgba(220, 38, 38, 0.2); color: var(--danger-light); }
.alert-info { background: var(--info-bg); border-color: rgba(14, 165, 233, 0.2); color: var(--info-light); }

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
    padding: 0;
}

.alert-close:hover { opacity: 1; }

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 200ms ease;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlideUp 300ms ease;
}

@keyframes modalSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }

.modal-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-default);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ============================================
   TABS
   ============================================ */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border-default);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-item {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
}

.tab-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.tab-item.active {
    color: var(--primary-light);
    border-bottom-color: var(--primary);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}


/* ============================================
   UTILITIES
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-success { color: var(--success-light) !important; }
.text-warning { color: var(--warning-light) !important; }
.text-danger { color: var(--danger-light) !important; }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 20px; }
.text-bold { font-weight: 600; }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.gap-1 { gap: 6px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 18px; }
.gap-4 { gap: 24px; }
.gap-6 { gap: 32px; }

.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mt-4 { margin-top: 24px; }
.mt-6 { margin-top: 36px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.mb-4 { margin-bottom: 28px; }
.mb-6 { margin-bottom: 38px; }
.mr-2 { margin-right: 8px; }
.ml-auto { margin-left: auto; }

.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }

.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Divider */
.divider {
    border: none;
    border-top: 1px solid var(--border-default);
    margin: 16px 0;
}

/* Currency Display */
.currency {
    font-family: 'Inter', monospace;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.currency.positive { color: var(--success-light); }
.currency.negative { color: var(--danger-light); }

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header-info h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.page-header-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.page-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================================
   FILTERS BAR
   ============================================ */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-input {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 360px;
}

.search-input input {
    width: 100%;
    padding: 9px 14px 9px 38px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 13px;
    outline: none;
    transition: all var(--transition-fast);
}

.search-input input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-input .icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.filter-select {
    padding: 9px 32px 9px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 13px;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394A3B8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination-nav {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.pagination {
    display: flex;
    list-style: none;
    gap: 4px;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    transition: all var(--transition-fast);
    text-decoration: none;
}

.page-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.page-link.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.page-link.dots {
    border: none;
    background: none;
    cursor: default;
}

.pagination-info {
    text-align: center;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    max-width: 400px;
    animation: toastIn 300ms ease;
    font-size: 13px;
}

.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--danger); }
.toast.toast-warning { border-left: 3px solid var(--warning); }
.toast.toast-info { border-left: 3px solid var(--info); }

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 2px;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, transparent 70%);
    top: -100px;
    right: -100px;
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(13, 148, 136, 0.06) 0%, transparent 70%);
    bottom: -100px;
    left: -50px;
    pointer-events: none;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-xl);
    position: relative;
    z-index: 1;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 22px;
    color: white;
    margin: 0 auto 16px;
}

.login-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 13px;
}

.login-card .form-control {
    padding: 12px 16px;
    font-size: 14px;
}

.login-card .btn {
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    width: 100%;
    margin-top: 8px;
}

.login-demo {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-default);
}

.login-demo h4 {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
    text-align: center;
}

.demo-accounts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.demo-account {
    padding: 8px 10px;
    background: var(--bg-base);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.demo-account:hover {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.demo-account .role {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
}

.demo-account .email {
    font-size: 10px;
    color: var(--text-tertiary);
}

/* ============================================
   DASHBOARD SPECIFIC
   ============================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.dashboard-grid .card {
    height: fit-content;
}

.quick-list {
    list-style: none;
}

.quick-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
}

.quick-list li:last-child {
    border-bottom: none;
}

.quick-list .item-title {
    font-weight: 500;
    color: var(--text-primary);
}

.quick-list .item-sub {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* Chart container */
.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

/* ============================================
   WORKFLOW TIMELINE
   ============================================ */
.workflow-timeline {
    position: relative;
    padding-left: 28px;
}

.workflow-timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-default);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -22px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: var(--radius-full);
    border: 2px solid var(--border-light);
    background: var(--bg-base);
}

.timeline-dot.completed {
    background: var(--success);
    border-color: var(--success);
}

.timeline-dot.active {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.timeline-dot.warning {
    background: var(--warning);
    border-color: var(--warning);
}

.timeline-dot.late {
    background: var(--danger);
    border-color: var(--danger);
}

.timeline-content h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
}

.timeline-content p {
    font-size: 12px;
    color: var(--text-secondary);
}

.timeline-content .date {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    body {
        background: white;
        color: black;
    }

    .sidebar, .topbar, .page-header-actions,
    .filters-bar, .btn, .notification-btn,
    .sidebar-toggle, .no-print {
        display: none !important;
    }

    .app-content {
        margin-left: 0 !important;
    }

    .page-wrapper {
        padding: 0 !important;
        padding-top: 0 !important;
    }

    .card {
        border: 1px solid #ddd;
        box-shadow: none;
        break-inside: avoid;
    }

    table {
        border: 1px solid #ddd;
    }

    thead th {
        background: #f3f4f6;
        color: #111;
        border-bottom: 2px solid #ddd;
    }

    tbody td {
        color: #111;
        border-bottom: 1px solid #eee;
    }

    .badge {
        border: 1px solid #999;
        color: #111 !important;
        background: transparent !important;
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3, .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-grid > div,
    .dashboard-grid > section,
    .dashboard-grid > aside,
    .dashboard-grid > .card {
        grid-column: auto !important;
    }
}

@media (max-width: 768px) {
    .sidebar,
    .sidebar.collapsed {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
        z-index: 1100;
    }

    .sidebar.mobile-open,
    .sidebar.collapsed.mobile-open {
        transform: translateX(0);
    }

    /* Force text display on mobile sidebar even if collapsed */
    .sidebar.collapsed .nav-item-text,
    .sidebar.collapsed .user-info,
    .sidebar.collapsed .sidebar-brand {
        opacity: 1 !important;
        width: auto !important;
        display: block !important;
    }
    
    .sidebar.collapsed .nav-badge {
        position: static !important;
        margin-left: auto !important;
        padding: 2px 6px !important;
        font-size: 10px !important;
    }

    .app-content,
    .app-content.sidebar-collapsed {
        margin-left: 0 !important;
    }

    .topbar,
    .sidebar-collapsed .topbar {
        left: 0 !important;
    }

    .breadcrumb {
        display: none !important;
    }

    .page-wrapper {
        padding: 16px;
        padding-top: calc(var(--topbar-height) + 16px);
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }

    .filters-bar {
        flex-direction: column;
        align-items: stretch !important;
        gap: 12px;
    }

    .filters-bar > * {
        width: 100% !important;
        max-width: none !important;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .filters-bar {
        flex-direction: column;
    }

    .search-input {
        max-width: 100%;
    }

    .notification-dropdown {
        width: 320px;
        right: -60px;
    }

    .modal {
        margin: 10px;
    }

    table {
        font-size: 12px;
    }

    .table-container table {
        min-width: 800px !important;
    }

    .tabs {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar {
        display: none;
    }

    thead th, tbody td {
        padding: 8px 10px;
    }

    .login-card {
        padding: 24px;
    }
    
    .sidebar-close-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
}

/* Mobile overlay when sidebar is open */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 1050;
}

.sidebar-overlay.show {
    display: block;
}
