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

:root {
    --brand-primary: #0057D9;
    --brand-primary-hover: #0046B3;
    --brand-accent: #1572FE;
    --brand-cyan: #00D2FF;
    
    --bg-page: #F8FAFC;
    --bg-surface: #FFFFFF;
    --bg-surface-elevated: #FFFFFF;
    --bg-subtle: #F1F5F9;
    
    --border-color: #E2E8F0;
    --border-subtle: #F1F5F9;
    
    --text-main: #0F172A;
    --text-muted: #64748B;
    --text-light: #94A3B8;
    
    --status-success: #10B981;
    --status-warning: #F59E0B;
    --status-danger: #EF4444;
    --status-info: #0284C7;
    --status-purple: #8B5CF6;
    
    --font-sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --sidebar-width: 260px;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--brand-primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--brand-accent);
}

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

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

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background: #0A0F1D;
    color: #F8FAFC;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand img {
    height: 32px;
    width: auto;
}

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

.brand-title {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #FFFFFF;
    line-height: 1.1;
}

.brand-subtitle {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--brand-cyan);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

.nav-section-title {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748B;
    padding: 10px 12px 6px;
    font-weight: 700;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: #94A3B8;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
    transition: all 0.2s ease;
}

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

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

.nav-item.active {
    background: linear-gradient(135deg, rgba(0, 87, 217, 0.25), rgba(21, 114, 254, 0.15));
    color: #FFFFFF;
    border: 1px solid rgba(0, 87, 217, 0.4);
    box-shadow: 0 4px 12px rgba(0, 87, 217, 0.2);
}

.nav-item.active svg {
    color: var(--brand-cyan);
}

.sidebar-user {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

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

.user-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #F8FAFC;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.72rem;
    color: #64748B;
    text-transform: capitalize;
}

.user-logout {
    color: #94A3B8;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-logout:hover {
    color: #EF4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Main Content Area */
.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    height: 68px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

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

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.system-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--status-success);
}

.system-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--status-success);
    box-shadow: 0 0 6px var(--status-success);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

.content-body {
    padding: 32px;
    flex: 1;
}

/* Alert Messages */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    font-weight: 500;
}

.alert-success {
    background: #ECFDF5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.alert-error {
    background: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.alert-warning {
    background: #FFFBEB;
    color: #92400E;
    border: 1px solid #FDE68A;
}

.alert-info {
    background: #F0F9FF;
    color: #075985;
    border: 1px solid #BAE6FD;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none;
    font-family: var(--font-sans);
}

.btn-primary {
    background: var(--brand-primary);
    color: #FFFFFF;
    box-shadow: 0 2px 4px rgba(0, 87, 217, 0.2);
}

.btn-primary:hover {
    background: var(--brand-primary-hover);
    color: #FFFFFF;
    box-shadow: 0 4px 8px rgba(0, 87, 217, 0.3);
}

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

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

.btn-danger {
    background: #EF4444;
    color: #FFFFFF;
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.78rem;
}

/* Cards & Grid */
.grid {
    display: grid;
    gap: 24px;
}

.grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

@media (max-width: 1024px) {
    .grid-cols-4, .grid-cols-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .grid-cols-4, .grid-cols-3, .grid-cols-2 {
        grid-template-columns: 1fr;
    }
    .app-sidebar {
        display: none;
    }
    .app-main {
        margin-left: 0;
    }
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

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

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Metric / KPI Cards */
.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

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

.kpi-card.kpi-green::before { background: var(--status-success); }
.kpi-card.kpi-amber::before { background: var(--status-warning); }
.kpi-card.kpi-blue::before { background: var(--brand-accent); }
.kpi-card.kpi-purple::before { background: var(--status-purple); }

.kpi-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
    margin-bottom: 8px;
    font-family: var(--font-sans);
}

.kpi-sub {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* Tables */
.table-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

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

.table th,
.data-table th,
.table-container table th {
    background: var(--bg-subtle);
    padding: 12px 18px;
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

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

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

.table tbody tr:hover,
.data-table tbody tr:hover,
.table-container table tbody tr:hover {
    background-color: rgba(241, 245, 249, 0.5);
}

.table-responsive,
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.form-label {
    display: block;
    font-size: 0.825rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #FFFFFF;
    color: var(--text-main);
    font-family: var(--font-sans);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(21, 114, 254, 0.15);
}

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

/* Filters Bar */
.filter-bar {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.filter-input {
    flex: 1;
    min-width: 220px;
}

/* Auth Pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 10%, #0F172A 0%, #060913 100%);
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: 40px;
    color: #FFFFFF;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.auth-card .form-label {
    color: #E2E8F0;
}

.auth-card .form-control {
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
}

.auth-card .form-control:focus {
    border-color: var(--brand-cyan);
    box-shadow: 0 0 0 3px rgba(0, 210, 255, 0.2);
}
