:root {
    /* Color Palette */
    --primary: #6366F1;
    --primary-hover: #4F46E5;
    --primary-light: rgba(99, 102, 241, 0.2);
    --secondary: #818CF8;
    --accent: #A5B4FC;
    
    --bg-base: #0F172A;
    --bg-surface: #1E293B;
    --bg-surface-hover: #334155;
    --border: #334155;
    
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    
    --success: #10B981;
    --success-light: rgba(16, 185, 129, 0.2);
    --warning: #F59E0B;
    --danger: #EF4444;
    
    /* Layout */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --sidebar-width: 250px;
    
    /* Fonts */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

/* Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-grow { flex-grow: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: 1rem; }
.w-10 { width: 2.5rem; }
.h-full { height: 100%; }
.text-right { text-align: right; }
.text-sm { font-size: 0.875rem; }
.text-slate-400 { color: #94a3b8; }
.font-medium { font-weight: 500; }
.border-b { border-bottom: 1px solid var(--border); }
.border-t { border-top: 1px solid var(--border); }
.pb-4 { padding-bottom: 1rem; }
.pt-4 { padding-top: 1rem; }
.hidden { display: none !important; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.relative { position: relative; }
.max-w-3xl { max-width: 48rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 1024px) {
    .col-span-2 { grid-column: span 2 / span 2; }
}

.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-accent { color: var(--accent); }

/* Glassmorphism effect */
.glassmorphism {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.025em;
}

.sidebar-nav {
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.nav-item:hover {
    color: var(--text-main);
    background-color: rgba(255,255,255,0.03);
}

.nav-item.active {
    color: var(--primary);
    background-color: var(--primary-light);
    border-right: 3px solid var(--primary);
}

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

.period-selector label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-base);
    min-width: 0;
}

.top-bar {
    height: 4.5rem;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    z-index: 10;
}

.view-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.header-right {
    display: flex;
    gap: 1rem;
}

/* View Container Container */
.view-pane {
    display: none;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.view-pane.active {
    display: block;
}

.view-pane.flex {
    display: flex;
}

.scrollable {
    overflow-y: auto;
    height: calc(100vh - 4.5rem);
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: inherit;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-outline {
    background-color: transparent;
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background-color: var(--bg-surface-hover);
}

.btn-danger {
    background-color: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}
.btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover { color: var(--text-main); }
.btn-icon.danger:hover { color: var(--danger); }

/* Inputs */
.input-field, .input-select {
    width: 100%;
    background-color: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.625rem 0.75rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.input-field:focus, .input-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.input-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.kpi-card {
    padding: 1.5rem;
    border-radius: var(--radius-md);
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.kpi-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.kpi-icon {
    padding: 0.5rem;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    display: flex;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    font-family: "SF Mono", monospace;
    letter-spacing: -0.025em;
}

.kpi-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.trend {
    font-weight: 600;
}
.trend.up { color: var(--success); }
.trend.down { color: var(--danger); }

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* Panels */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}
@media (min-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.panel {
    border-radius: var(--radius-md);
    overflow: hidden;
}

.panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.panel-body {
    padding: 1.5rem;
}

/* Tables */
.table-container {
    padding: 0;
}

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

.data-table th, .data-table td {
    padding: 0.875rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    background: rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 5;
}

.data-table tbody tr {
    transition: background 0.2s;
}

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

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box svg {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
}

.search-box input {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.4rem 1rem 0.4rem 2.25rem;
    color: var(--text-main);
    font-size: 0.875rem;
    width: 200px;
    transition: width 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    width: 250px;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.empty-state .empty-icon {
    display: inline-flex;
    margin-bottom: 1rem;
    color: var(--border);
}
.empty-state h3 {
    color: var(--text-main);
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

/* Settings Form */
.form-section-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.tier-row {
    display: grid;
    grid-template-columns: auto 1fr 1fr auto;
    gap: 1rem;
    align-items: end;
    padding: 1rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

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

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-md);
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}
.btn-close:hover { color: var(--text-main); }

.modal-body {
    padding: 1.5rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--success);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    font-weight: 500;
    font-size: 0.875rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
}
.toast.error { background: var(--danger); }
.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}
