:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --border: #e5e7eb;
    --text: #111827;
    --text-soft: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --sidebar: #111827;
    --sidebar-soft: #1f2937;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background: var(--bg);
    color: var(--text);
}

button,
select,
textarea {
    font: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--sidebar);
    color: white;
    padding: 24px 18px;
}

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

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--primary);
    font-weight: 800;
    letter-spacing: 0.5px;
}

.brand h1 {
    margin: 0;
    font-size: 18px;
}

.brand p {
    margin: 2px 0 0;
    font-size: 12px;
    color: #9ca3af;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 24px;
}

.nav-item {
    width: 100%;
    border: 0;
    border-radius: 10px;
    padding: 12px 14px;
    text-align: left;
    background: transparent;
    color: #d1d5db;
    cursor: pointer;
    transition: 0.2s ease;
}

.nav-item:hover {
    background: var(--sidebar-soft);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 8px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-footer span {
    display: block;
    font-size: 11px;
    color: #9ca3af;
}

.sidebar-footer strong {
    display: block;
    margin-top: 4px;
    font-size: 13px;
}

.main-content {
    min-width: 0;
    padding: 24px 28px 48px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.topbar h2 {
    margin: 0;
    font-size: 24px;
}

.topbar p {
    margin: 4px 0 0;
    color: var(--text-soft);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: #ecfdf5;
    color: #166534;
    font-size: 13px;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
}

.page-section {
    display: none;
}

.page-section.active {
    display: block;
}

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

.section-header h3 {
    margin: 0;
    font-size: 22px;
}

.section-header p {
    margin: 5px 0 0;
    color: var(--text-soft);
}

select {
    min-width: 180px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: white;
    color: var(--text);
}

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

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.kpi-card span {
    display: block;
    font-size: 13px;
    color: var(--text-soft);
}

.kpi-card strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
    line-height: 1.1;
}

.kpi-card small {
    display: block;
    margin-top: 8px;
    color: var(--text-soft);
}

.small-value {
    font-size: 17px !important;
    line-height: 1.35 !important;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.panel h4 {
    margin: 0;
    font-size: 16px;
}

.panel p {
    color: var(--text-soft);
}

.panel-header p {
    margin: 4px 0 0;
    font-size: 13px;
}

.chart-wrap {
    position: relative;
    min-height: 320px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.filter-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.filter-card label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
}

.filter-card select {
    width: 100%;
}

.info-box {
    margin-top: 14px;
    padding: 16px;
    border-radius: 10px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    color: #374151;
    line-height: 1.6;
}

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

.ai-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

textarea {
    width: 100%;
    min-height: 150px;
    resize: vertical;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
}

textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.primary-button {
    margin-top: 14px;
    border: 0;
    border-radius: 9px;
    padding: 11px 18px;
    background: var(--primary);
    color: white;
    cursor: pointer;
    font-weight: 600;
}

.primary-button:hover {
    background: var(--primary-dark);
}

.suggested-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.suggestion {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 11px;
    background: white;
    color: #374151;
    cursor: pointer;
    font-size: 12px;
}

.suggestion:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.ai-response {
    min-height: 230px;
    margin-top: 12px;
    padding: 16px;
    border-radius: 10px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    white-space: pre-wrap;
    line-height: 1.6;
}

.architecture-flow {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    padding: 16px 0 24px;
}

.architecture-node {
    flex: 0 0 auto;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: white;
    box-shadow: var(--shadow);
    font-weight: 600;
}

.architecture-arrow {
    color: var(--text-soft);
    font-size: 20px;
}

.tech-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.tech-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.tech-card strong {
    display: block;
}

.tech-card span {
    display: block;
    margin-top: 6px;
    color: var(--text-soft);
    font-size: 13px;
}

@media (max-width: 1100px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-grid,
    .ai-layout {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 760px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

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

    .main-content {
        padding: 18px;
    }

    .topbar,
    .section-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .kpi-grid,
    .quality-kpis,
    .filter-grid,
    .tech-grid {
        grid-template-columns: 1fr;
    }
}