﻿:root {
    --bg-main: #101112;
    --bg-sidebar: #17191B;
    --bg-card: #1E2022;
    --bg-elevated: #27292C;
    --accent-gold: #F5B82E;
    --accent-orange: #FF8A24;
    --text-primary: #F4F4F5;
    --text-secondary: #92969D;
    --border-subtle: #303236;
    --status-success: #22C55E;
    --status-warning: #F59E0B;
    --status-error: #EF4444;
    --status-info: #3B82F6;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 14px;
    --sidebar-width: 248px;
    --sidebar-collapsed-width: 72px;
    --topbar-height: 60px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html, body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button, input, select, textarea {
    font-family: inherit;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 999px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: #44474D;
    }

/* ==================== APP SHELL ==================== */
.hapsis-shell {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-main);
}

.hapsis-main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.2s ease;
}

.hapsis-shell.sidebar-collapsed .hapsis-main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

.hapsis-content {
    flex: 1;
    padding: 24px 28px 40px;
    max-width: 1640px;
    width: 100%;
    margin: 0 auto;
}

/* ==================== SIDEBAR ==================== */
.hapsis-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width 0.2s ease, transform 0.22s ease;
}

.hapsis-shell.sidebar-collapsed .hapsis-sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
    height: var(--topbar-height);
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.brand-logo-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(245, 184, 46, 0.12);
    border: 1px solid rgba(245, 184, 46, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-gold);
    flex-shrink: 0;
}

.brand-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    white-space: nowrap;
}

.sidebar-collapse-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

    .sidebar-collapse-btn:hover {
        background-color: var(--bg-elevated);
        color: var(--text-primary);
        border-color: var(--border-subtle);
    }

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.nav-section-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    padding: 0 10px;
    margin-bottom: 6px;
    text-transform: uppercase;
    white-space: nowrap;
}

.hapsis-shell.sidebar-collapsed .nav-section-label {
    text-align: center;
    padding: 0;
    font-size: 9px;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 9px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13.5px;
    transition: background-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

    .nav-item:hover {
        background-color: var(--bg-elevated);
        color: var(--text-primary);
    }

    .nav-item.active {
        background-color: rgba(255, 138, 36, 0.12);
        color: var(--accent-orange);
        font-weight: 600;
    }

        .nav-item.active::before {
            content: '';
            position: absolute;
            left: -12px;
            top: 7px;
            bottom: 7px;
            width: 3px;
            border-radius: 0 3px 3px 0;
            background-color: var(--accent-orange);
        }

.hapsis-shell.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 10px;
}

.hapsis-shell.sidebar-collapsed .nav-item-text,
.hapsis-shell.sidebar-collapsed .brand-title,
.hapsis-shell.sidebar-collapsed .sidebar-footer-details {
    display: none;
}

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

.sidebar-engine-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.engine-badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-gold);
    flex-shrink: 0;
}

.sidebar-engine-title {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent-gold);
}

.sidebar-engine-sub {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* ==================== TOPBAR ==================== */
.hapsis-topbar {
    height: var(--topbar-height);
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 90;
}

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

.mobile-menu-btn {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.breadcrumb-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.breadcrumb-home {
    display: flex;
    align-items: center;
    color: var(--text-secondary);
}

    .breadcrumb-home:hover {
        color: var(--text-primary);
    }

.breadcrumb-current {
    color: var(--text-primary);
    font-weight: 500;
}

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

.topbar-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 11px;
    border-radius: 8px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    font-size: 12.5px;
    color: var(--text-primary);
    white-space: nowrap;
}

    .topbar-pill.mode-pill {
        color: var(--accent-gold);
        border-color: rgba(245, 184, 46, 0.28);
        background-color: rgba(245, 184, 46, 0.08);
        font-weight: 500;
    }

    .topbar-pill.mono {
        font-family: var(--font-mono);
        font-size: 12px;
        color: var(--text-secondary);
    }

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

    .status-dot.online {
        background-color: var(--status-success);
    }

    .status-dot.warning {
        background-color: var(--status-warning);
    }

    .status-dot.offline {
        background-color: var(--status-error);
    }

.user-menu-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 8px;
    border-left: 1px solid var(--border-subtle);
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--accent-gold);
    font-size: 11.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.user-name-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

/* ==================== PAGE HEADERS ==================== */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.page-title-block {
    border-left: 3px solid var(--accent-orange);
    padding-left: 14px;
}

.page-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--text-primary);
}

.page-subtitle {
    margin: 3px 0 0;
    font-size: 13.5px;
    color: var(--text-secondary);
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

/* ==================== CARDS & SURFACES ==================== */
.hapsis-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    transition: border-color 0.15s ease;
}

    .hapsis-card:hover {
        border-color: #3D4046;
    }

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

.hapsis-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

    .hapsis-card-title svg {
        color: var(--accent-gold);
    }

/* ==================== KPI GRID ==================== */
.kpi-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.kpi-grid-6 {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.kpi-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
}

    .kpi-card::before {
        content: '';
        position: absolute;
        left: 0;
        top: 12px;
        bottom: 12px;
        width: 3px;
        border-radius: 0 3px 3px 0;
        background-color: var(--accent-gold);
    }

    .kpi-card.accent-orange::before {
        background-color: var(--accent-orange);
    }

    .kpi-card.accent-success::before {
        background-color: var(--status-success);
    }

    .kpi-card.accent-info::before {
        background-color: var(--status-info);
    }

.kpi-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.kpi-label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
}

.kpi-icon-box {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-gold);
}

.kpi-card.accent-orange .kpi-icon-box {
    color: var(--accent-orange);
}

.kpi-card.accent-success .kpi-icon-box {
    color: var(--status-success);
}

.kpi-card.accent-info .kpi-icon-box {
    color: var(--status-info);
}

.kpi-bottom {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
}

.kpi-value {
    font-size: 24px;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.15;
}

.kpi-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ==================== BUTTONS & INPUTS ==================== */
.btn-hapsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 34px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-elevated);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

    .btn-hapsis:hover:not(:disabled) {
        border-color: #4A4D55;
        background-color: #2F3236;
    }

    .btn-hapsis:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

.btn-hapsis-primary {
    background-color: var(--accent-orange);
    border-color: var(--accent-orange);
    color: #101112;
    font-weight: 600;
}

    .btn-hapsis-primary:hover:not(:disabled) {
        background-color: #FF9B42;
        border-color: #FF9B42;
    }

.btn-hapsis-gold {
    background-color: rgba(245, 184, 46, 0.14);
    border-color: rgba(245, 184, 46, 0.4);
    color: var(--accent-gold);
}

    .btn-hapsis-gold:hover:not(:disabled) {
        background-color: rgba(245, 184, 46, 0.22);
    }

.btn-hapsis-danger {
    background-color: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
    color: var(--status-error);
}

    .btn-hapsis-danger:hover:not(:disabled) {
        background-color: rgba(239, 68, 68, 0.22);
    }

.btn-hapsis-sm {
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 7px;
}

.hapsis-input,
.hapsis-select,
.hapsis-textarea {
    width: 100%;
    background-color: var(--bg-main);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease;
}

    .hapsis-input:focus,
    .hapsis-select:focus,
    .hapsis-textarea:focus {
        border-color: var(--accent-orange);
    }

    .hapsis-input.mono,
    .hapsis-textarea.mono {
        font-family: var(--font-mono);
        font-size: 12.5px;
    }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ==================== BADGES ==================== */
.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-elevated);
    color: var(--text-secondary);
    white-space: nowrap;
}

.badge-success {
    background-color: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.3);
    color: var(--status-success);
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--status-warning);
}

.badge-error {
    background-color: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--status-error);
}

.badge-info {
    background-color: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--status-info);
}

.badge-gold {
    background-color: rgba(245, 184, 46, 0.12);
    border-color: rgba(245, 184, 46, 0.32);
    color: var(--accent-gold);
}

.badge-orange {
    background-color: rgba(255, 138, 36, 0.12);
    border-color: rgba(255, 138, 36, 0.32);
    color: var(--accent-orange);
}

/* ==================== DATA TABLES ==================== */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
}

.hapsis-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

    .hapsis-table th {
        padding: 11px 16px;
        font-size: 11.5px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-secondary);
        background-color: var(--bg-sidebar);
        border-bottom: 1px solid var(--border-subtle);
        white-space: nowrap;
    }

    .hapsis-table td {
        padding: 12px 16px;
        border-bottom: 1px solid var(--border-subtle);
        color: var(--text-primary);
        vertical-align: middle;
    }

    .hapsis-table tbody tr:last-child td {
        border-bottom: none;
    }

    .hapsis-table tbody tr:hover {
        background-color: rgba(39, 41, 44, 0.55);
    }

.mono-text {
    font-family: var(--font-mono);
    font-size: 12.5px;
}

/* ==================== PROGRESS BAR ==================== */
.progress-track {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background-color: var(--bg-main);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
    background-color: var(--accent-gold);
    transition: width 0.25s ease;
}

    .progress-fill.orange {
        background-color: var(--accent-orange);
    }

    .progress-fill.success {
        background-color: var(--status-success);
    }

    .progress-fill.error {
        background-color: var(--status-error);
    }

/* ==================== MODAL & TOAST ==================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal-box {
    width: 100%;
    max-width: 480px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
}

    .modal-box.modal-lg {
        max-width: 720px;
    }

.toast-stack {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1100;
    max-width: 380px;
}

.toast-card {
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-left: 3px solid var(--accent-gold);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
}

    .toast-card.success {
        border-left-color: var(--status-success);
    }

    .toast-card.error {
        border-left-color: var(--status-error);
    }

    .toast-card.warning {
        border-left-color: var(--status-warning);
    }

/* ==================== EMPTY / LOADING / ERROR ==================== */
.state-panel {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 42px 24px;
    text-align: center;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* ==================== AUTH / SETUP SHELL ==================== */
.auth-screen {
    min-height: 100vh;
    background-color: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 28px 30px;
}

    .auth-card.setup-card {
        max-width: 640px;
    }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1280px) {
    .kpi-grid-6 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

@media (max-width: 900px) {
    .hapsis-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

    .hapsis-shell.mobile-nav-open .hapsis-sidebar {
        transform: translateX(0);
    }

    .hapsis-main-wrapper {
        margin-left: 0 !important;
    }

    .mobile-menu-btn {
        display: inline-flex;
    }

    .hapsis-content {
        padding: 18px 16px 32px;
    }

    .hapsis-topbar {
        padding: 0 16px;
    }

    .kpi-grid-6,
    .kpi-grid-4 {
        grid-template-columns: 1fr;
    }
}
