:root {
    --bg: #eef3fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --line: #dbe3f1;
    --text: #162033;
    --muted: #7a869f;
    --primary: #2457d6;
    --primary-dark: #173d9c;
    --navy: #141c34;
    --teal: #2da8ff;
    --purple: #5c7cff;
    --green-soft: #dff7e5;
    --cyan-soft: #e0f2ff;
    --red-soft: #fde0df;
    --blue-soft: #ddeaff;
    --shadow: 0 12px 36px rgba(15, 23, 42, 0.08);
    --radius-xl: 22px;
    --radius-lg: 16px;
    --radius-md: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: "Inter", "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

.page-shell {
    min-height: 100vh;
}

.login-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: min(100%, 360px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 32px;
}

.login-card-head {
    margin-bottom: 20px;
    text-align: center;
}

.login-card-head p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.stack-form { display: grid; gap: 18px; }

label {
    display: grid;
    gap: 8px;
}

label span {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #ffffff;
    padding: 13px 14px;
    font: inherit;
    color: var(--text);
}

input::placeholder,
textarea::placeholder { color: #98a3b8; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: rgba(36, 87, 214, 0.55);
    box-shadow: 0 0 0 4px rgba(36, 87, 214, 0.12);
}

button {
    border: 0;
    border-radius: var(--radius-md);
    padding: 14px 16px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 140ms ease, opacity 140ms ease;
}

button:hover { transform: translateY(-1px); }

.primary-button {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #ffffff;
}

.secondary-button {
    background: linear-gradient(135deg, var(--primary), var(--teal));
    color: #ffffff;
}

.dashboard-shell {
    min-height: 100vh;
}

.app-topbar {
    height: 72px;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 18px;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 28px;
}

.brand-word {
    font-size: 1.95rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.03em;
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-tab {
    background: transparent;
    color: #516079;
    padding: 10px 12px;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    font-weight: 500;
}

.nav-tab.is-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.app-userbar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    display: grid;
    gap: 2px;
    text-align: right;
}

.user-chip strong {
    font-size: 0.92rem;
}

.user-chip span {
    font-size: 0.82rem;
    color: var(--muted);
}

.ghost-button {
    background: #f3f6fb;
    color: var(--navy);
}

.dashboard-page {
    width: min(1360px, calc(100% - 28px));
    margin: 0 auto;
    padding: 18px 0 28px;
    display: grid;
    gap: 18px;
}

.filters-panel,
.section-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.filters-panel {
    padding: 14px 16px 16px;
}

.subnav-tabs {
    display: flex;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid #edf2fa;
    margin-bottom: 14px;
    overflow: auto;
}

.subnav-tab {
    background: transparent;
    color: #66758e;
    padding: 10px 14px;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    white-space: nowrap;
}

.subnav-tab.is-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.filter-box {
    gap: 6px;
}

.filter-box span {
    font-size: 0.72rem;
}

.metrics-section,
.chart-section,
.summary-section,
.recent-section {
    padding: 14px;
}

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

.section-head h2 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
}

.section-head p {
    margin: 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.metric-box {
    border: 1px solid #edf2fa;
    border-radius: 16px;
    padding: 16px;
    background: #fbfcff;
    text-align: center;
    display: grid;
    gap: 8px;
}

.metric-box span,
.metric-box small {
    color: #71819b;
}

.metric-box strong {
    font-size: 1.05rem;
    font-weight: 800;
}

.metric-green strong { color: #22c55e; }
.metric-cyan strong { color: #0f7ae5; }
.metric-red strong { color: #ef4444; }
.metric-blue strong { color: #3b82f6; }

.overview-grid {
    display: grid;
    grid-template-columns: 1.4fr 0.8fr;
    gap: 18px;
}

.section-actions {
    display: flex;
    gap: 8px;
}

.mini-pill {
    background: #eef3fb;
    color: #66758e;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
}

.mini-pill.is-active {
    background: #dfe7f6;
    color: var(--navy);
}

.chart-placeholder {
    border: 1px solid #edf2fa;
    border-radius: 16px;
    padding: 18px;
    min-height: 260px;
    display: flex;
    align-items: end;
}

.chart-bars {
    width: 100%;
    height: 200px;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    align-items: end;
    gap: 12px;
}

.chart-bar-column {
    display: grid;
    justify-items: center;
    gap: 8px;
}

.chart-bar {
    width: 100%;
    max-width: 54px;
    border-radius: 12px 12px 4px 4px;
    background: linear-gradient(180deg, rgba(45, 168, 255, 0.9), rgba(36, 87, 214, 0.92));
    min-height: 10px;
}

.chart-label,
.chart-value {
    font-size: 0.76rem;
    color: #7a869f;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.summary-card {
    border-radius: 16px;
    padding: 20px 14px;
    text-align: center;
}

.summary-card strong {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 6px;
}

.summary-card span {
    color: #6b7280;
    font-size: 0.86rem;
}

.summary-green { background: var(--green-soft); color: #22a45a; }
.summary-cyan { background: var(--cyan-soft); color: #0f7ae5; }
.summary-red { background: var(--red-soft); color: #ef4444; }
.summary-blue { background: var(--blue-soft); color: #3b82f6; }

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

.field-grid.compact {
    grid-template-columns: 1fr;
}

.products-list {
    display: grid;
    gap: 10px;
}

.product-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    border-radius: 14px;
    background: var(--surface-soft);
    border: 1px solid #edf2fa;
}

.product-item strong {
    display: block;
    margin-bottom: 4px;
}

.product-item span {
    color: var(--muted);
    font-size: 0.84rem;
}

.product-item b {
    color: var(--navy);
}

.empty-state {
    padding: 28px;
    text-align: center;
    color: var(--muted);
    border: 1px dashed #d8e0ee;
    border-radius: 14px;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    max-width: 320px;
    padding: 14px 16px;
    border-radius: 14px;
    background: #111827;
    color: white;
    box-shadow: var(--shadow);
}

.toast.error { background: #7f1d1d; }

@media (max-width: 1280px) {
    .filters-grid,
    .metrics-grid,
    .overview-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    .app-topbar {
        height: auto;
        flex-direction: column;
        align-items: flex-start;
        padding: 14px;
    }

    .app-brand,
    .app-nav,
    .app-userbar {
        width: 100%;
        flex-wrap: wrap;
    }

    .dashboard-page {
        width: min(100% - 16px, 1360px);
    }

    .summary-cards,
    .field-grid {
        grid-template-columns: 1fr;
    }
}
