* {
    box-sizing: border-box;
}

:root {
    --bg: #f3f5f7;
    --card: #ffffff;
    --text: #111827;
    --muted: #64748b;
    --line: #e2e8f0;
    --green: #0b8f48;
    --green-soft: #e8f7ef;
    --red: #c62828;
    --red-soft: #feecec;
    --orange: #d97706;
    --orange-soft: #fff5df;
    --shadow: 0 10px 30px rgba(15, 23, 42, .06);
}

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

a {
    color: inherit;
}

.container {
    width: min(1500px, calc(100% - 36px));
    margin: 0 auto;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

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

.brand span {
    color: var(--green);
}

.userbox {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--muted);
    font-size: 14px;
}

.logout {
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: #fff;
}

main {
    padding: 26px 0 50px;
}

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

.hero h1 {
    font-size: 27px;
    margin: 0 0 4px;
}

.hero p {
    margin: 0;
    color: var(--muted);
}

.source-status {
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 700;
    background: var(--orange-soft);
    color: var(--orange);
    text-align: right;
}

.source-status.ok {
    background: var(--green-soft);
    color: var(--green);
}

.source-status.error {
    background: var(--red-soft);
    color: var(--red);
}

.source-status small {
    display: block;
    margin-top: 3px;
    font-weight: 500;
    color: var(--muted);
}

.filters {
    display: grid;
    grid-template-columns: repeat(5, minmax(140px, 1fr));
    gap: 12px;
    padding: 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}

.field label {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 6px;
}

.field select,
.field input {
    width: 100%;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0 11px;
    background: #fff;
    color: var(--text);
}

.filter-button {
    align-self: end;
    height: 42px;
    border: 0;
    border-radius: 10px;
    background: var(--green);
    color: white;
    font-weight: 700;
    cursor: pointer;
}

.cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}

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

.card-label {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 800;
}

.card-value {
    font-size: 28px;
    line-height: 1.15;
    font-weight: 800;
    margin-top: 8px;
}

.card-sub {
    color: var(--muted);
    font-size: 12px;
    margin-top: 5px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--shadow);
    min-width: 0;
}

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

.panel-header h2 {
    margin: 0;
    font-size: 17px;
}

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

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

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    padding: 11px 9px;
    text-align: left;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--line);
}

td {
    padding: 12px 9px;
    border-bottom: 1px solid #eef2f7;
    white-space: nowrap;
}

td.customer {
    white-space: normal;
    min-width: 220px;
}

.amount {
    font-weight: 750;
}

.empty {
    text-align: center;
    padding: 28px;
    color: var(--muted);
}

.rank-number {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--green-soft);
    color: var(--green);
    border-radius: 50%;
    font-weight: 800;
    font-size: 12px;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

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

.login-card h1 {
    margin: 0 0 5px;
}

.login-card > p {
    margin: 0 0 26px;
    color: var(--muted);
}

.login-card input {
    width: 100%;
    height: 46px;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 0 13px;
}

.login-card button {
    width: 100%;
    height: 46px;
    border: 0;
    border-radius: 11px;
    background: var(--green);
    color: white;
    font-weight: 800;
    cursor: pointer;
}

.login-error {
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 14px;
    background: var(--red-soft);
    color: var(--red);
    font-size: 13px;
}

@media (max-width: 1000px) {
    .filters {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .grid-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 620px) {
    .container {
        width: min(100% - 20px, 1500px);
    }

    .hero {
        flex-direction: column;
    }

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

    .userbox span {
        display: none;
    }

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

.target-panel {
    margin-bottom: 18px;
}

.target-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 16px;
}

.target-stat {
    min-width: 0;
}

.target-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.target-value {
    margin-top: 5px;
    font-size: 22px;
    font-weight: 800;
}

.progress-track {
    height: 14px;
    border-radius: 999px;
    background: #e8edf2;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--green);
    transition: width .3s ease;
}

.progress-caption {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 7px;
    font-size: 12px;
    color: var(--muted);
}

.compliance {
    font-weight: 800;
}

.compliance.good {
    color: var(--green);
}

.compliance.pending {
    color: var(--orange);
}

@media (max-width: 850px) {
    .target-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 520px) {
    .target-grid {
        grid-template-columns: 1fr;
    }
}
