:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-muted: #eef3f8;
    --line: #dfe5ec;
    --text: #172033;
    --muted: #657389;
    --nav: #203040;
    --blue: #2563eb;
    --red: #dc2626;
    --green: #16a34a;
    --amber: #d97706;
}

* {
    box-sizing: border-box;
}

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

a {
    color: inherit;
}

.crm-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.crm-sidebar {
    background: var(--nav);
    color: #ffffff;
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}

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

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #ffffff;
    color: var(--nav);
    font-weight: 800;
}

.brand-name {
    font-size: 18px;
    font-weight: 800;
}

.brand-caption {
    color: #b8c4d2;
    font-size: 12px;
    margin-top: 2px;
}

.side-nav {
    display: grid;
    gap: 6px;
    margin-top: 24px;
}

.side-nav a {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 0 14px;
    border-radius: 8px;
    color: #d8e1ec;
    text-decoration: none;
    font-weight: 650;
}

.side-nav a:hover,
.side-nav a.active {
    background: #ffffff;
    color: var(--nav);
}

.crm-main {
    min-width: 0;
    padding: 24px;
}

.topbar {
    min-height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(21, 32, 48, 0.06);
}

.topbar h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
}

.topbar p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.lang-switch {
    display: flex;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-muted);
}

.lang-switch a {
    min-width: 34px;
    padding: 7px 8px;
    border-radius: 6px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
}

.lang-switch a.active {
    background: #ffffff;
    color: var(--blue);
    box-shadow: 0 1px 4px rgba(21, 32, 48, 0.08);
}

.user-card {
    display: grid;
    gap: 2px;
    min-width: 170px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.user-card strong {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card span {
    color: var(--muted);
    font-size: 12px;
}

.logout-link,
.quick-actions a,
.panel-header a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
    text-decoration: none;
    font-weight: 750;
    font-size: 13px;
}

.logout-link {
    background: #fee2e2;
    border-color: #fecaca;
    color: #991b1b;
}

.dashboard {
    margin-top: 22px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.eyebrow {
    display: inline-block;
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.page-heading h2 {
    margin: 5px 0 0;
    font-size: 28px;
}

.page-heading p {
    margin: 6px 0 0;
    color: var(--muted);
}

.quick-actions {
    display: flex;
    gap: 10px;
}

.quick-actions a:first-child {
    background: var(--blue);
    border-color: var(--blue);
    color: #ffffff;
}

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

.kpi-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(21, 32, 48, 0.05);
}

.kpi-card {
    display: grid;
    gap: 8px;
    padding: 18px;
    text-decoration: none;
    border-left-width: 5px;
}

.kpi-card span,
.kpi-card small {
    color: var(--muted);
}

.kpi-card span {
    font-size: 13px;
    font-weight: 750;
}

.kpi-card strong {
    font-size: 34px;
    line-height: 1;
}

.accent-red { border-left-color: var(--red); }
.accent-blue { border-left-color: var(--blue); }
.accent-green { border-left-color: var(--green); }
.accent-amber { border-left-color: var(--amber); }

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

.panel {
    padding: 18px;
}

.panel-wide {
    grid-column: span 2;
}

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

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

.panel-header a {
    min-height: 32px;
    color: var(--blue);
}

.metric-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.metric-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 0;
    border-bottom: 1px solid #edf1f5;
    color: var(--muted);
}

.metric-list li:last-child {
    border-bottom: 0;
}

.metric-list b {
    color: var(--text);
}

.metric-list .danger { color: var(--red); }
.metric-list .info { color: var(--blue); }
.metric-list .success { color: var(--green); }
.metric-list .warning { color: var(--amber); }

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

.two-columns h4 {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
}

.system-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
    padding: 12px;
    border-radius: 8px;
    background: var(--surface-muted);
}

.system-status span {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--green);
    font-weight: 800;
}

.system-status i {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--green);
}

.system-status b {
    padding: 4px 8px;
    border-radius: 6px;
    background: #ffffff;
}

.site-footer {
    padding: 28px 0 8px;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

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

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

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

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

    .topbar,
    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar-actions,
    .quick-actions {
        justify-content: flex-start;
    }

    .kpi-grid,
    .content-grid,
    .two-columns {
        grid-template-columns: 1fr;
    }

    .panel-wide {
        grid-column: auto;
    }
}
