:root {
    --sidebar-width: 220px;
    --top-bar-height: 48px;
    --color-primary: #1a56db;
    --color-primary-hover: #1e40af;
    --color-success: #059669;
    --color-warning: #d97706;
    --color-danger: #dc2626;
    --color-bg: #f8fafc;
    --color-sidebar-bg: #1e293b;
    --color-sidebar-text: #e2e8f0;
    --color-card-bg: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg);
}

.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    padding: 1rem 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.brand {
    padding: 0 1rem 1rem;
    font-weight: 700;
    font-size: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 0.5rem;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 0.5rem;
}

.nav-link {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--color-sidebar-text);
    text-decoration: none;
    border-radius: var(--radius);
    transition: background 0.15s;
}

.nav-link:hover { background: rgba(255,255,255,0.1); }
.nav-link.active { background: var(--color-primary); color: #fff; }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.top-bar {
    height: var(--top-bar-height);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 1.5rem;
    background: var(--color-card-bg);
    border-bottom: 1px solid var(--color-border);
}

.user-name {
    font-size: 13px;
    color: var(--color-text-muted);
}

.page-content {
    padding: 1.5rem;
    flex: 1;
}

/* Cards */
.card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.card h3 {
    font-size: 13px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.card .value {
    font-size: 24px;
    font-weight: 700;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

th, td {
    padding: 0.625rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th {
    background: #f1f5f9;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-success { background: var(--color-success); color: #fff; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
}
.btn-outline:hover:not(:disabled) { background: #f1f5f9; }
.btn-sm { padding: 0.325rem 0.625rem; font-size: 12px; }

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.375rem;
    font-size: 13px;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
}

select.form-control { appearance: auto; }

/* Status badges */
.badge {
    display: inline-flex;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* Gauges */
.gauge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gauge-bar {
    flex: 1;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.gauge-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.gauge-fill.green { background: var(--color-success); }
.gauge-fill.amber { background: var(--color-warning); }
.gauge-fill.red { background: var(--color-danger); }

/* Dialogs */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.dialog {
    background: var(--color-card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    min-width: 400px;
    max-width: 560px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.dialog h3 { margin-bottom: 1rem; }
.dialog-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1.25rem; }

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 13px;
}

.alert-error { background: #fee2e2; border: 1px solid #fecaca; color: #991b1b; }
.alert-warning { background: #fef3c7; border: 1px solid #fde68a; color: #92400e; }
.alert-success { background: #dcfce7; border: 1px solid #bbf7d0; color: #166534; }
.alert-info { background: #dbeafe; border: 1px solid #bfdbfe; color: #1e40af; }

/* Page headers */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 700;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
    transition: color 0.15s, border-color 0.15s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

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

/* Loading */
.loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-muted);
    padding: 2rem;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Wizard steps */
.wizard-steps {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.wizard-step {
    flex: 1;
    padding: 0.5rem;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius);
    background: #f1f5f9;
    color: var(--color-text-muted);
}

.wizard-step.active { background: var(--color-primary); color: #fff; }
.wizard-step.completed { background: var(--color-success); color: #fff; }

/* Toggle switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    top: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--color-primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }
