* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #15171a;
    --muted: #73777f;
    --line: #e6e8eb;
    --accent: #1677ff;
    --danger: #d93025;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;

    background: var(--bg);
    color: var(--text);
}

button,
input,
select {
    font: inherit;
}

.hidden {
    display: none !important;
}


/* LOGIN */

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

.login-card {
    width: 100%;
    max-width: 390px;
    background: var(--card);
    border-radius: 18px;
    padding: 30px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .08);
}

.login-logo {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.5px;
}

.login-subtitle {
    margin-top: 5px;
    margin-bottom: 26px;
    color: var(--muted);
}

.login-card label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 16px;
}

.login-card input {
    width: 100%;
    height: 46px;
    margin-top: 6px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    outline: none;
    background: #fff;
}

.login-card input:focus {
    border-color: var(--accent);
}

.login-card button {
    width: 100%;
    height: 46px;
    border: 0;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.error {
    min-height: 20px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--danger);
}


/* APPLICATION */

.app {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 22px 18px 50px;
}

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

.brand {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -.5px;
}

.page-title {
    margin-top: 3px;
    color: var(--muted);
    font-size: 15px;
}

.report-date {
    padding-top: 4px;
    font-size: 14px;
    color: var(--muted);
    white-space: nowrap;
}


/* SUMMARY */

.summary {
    display: flex;
    gap: 30px;
    padding: 15px 17px;
    background: var(--card);
    border-radius: 14px;
    margin-bottom: 12px;
}

.summary div {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.summary strong {
    font-size: 20px;
}

.summary span {
    font-size: 13px;
    color: var(--muted);
}


/* FILTERS */

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

.search-wrap {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.search-wrap input,
.filters select {
    width: 100%;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--card);
    outline: none;
}

.search-wrap input {
    padding: 0 13px 0 38px;
}

.filters select {
    padding: 0 11px;
}


/* CLIENT */

.client {
    margin-bottom: 18px;
}

.client-name {
    padding: 0 4px 7px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .7px;
    color: #62666d;
    text-transform: uppercase;
}

.accounts {
    display: grid;
    gap: 8px;
}

.account {
    background: var(--card);
    border-radius: 14px;
    padding: 15px 16px;
    border: 1px solid rgba(0, 0, 0, .025);
}

.account-name {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 14px;
}

.metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 25px;
    row-gap: 10px;
}

.metric {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.metric-label {
    color: var(--muted);
    font-size: 13px;
}

.metric-value {
    font-size: 14px;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

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


/* MOBILE */

@media (max-width: 600px) {

    .app {
        padding: 18px 12px 40px;
    }

    .brand {
        font-size: 20px;
    }

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

    .summary {
        gap: 18px;
        justify-content: space-between;
    }

    .summary div {
        flex-direction: column;
        gap: 1px;
    }

    .account {
        padding: 14px;
    }

    .metrics {
        column-gap: 16px;
    }

    .metric-label {
        font-size: 12px;
    }

    .metric-value {
        font-size: 13px;
    }
}


/* =========================================================
   MANUAL REFRESH
   ========================================================= */

.refresh-panel {
    padding: 0 16px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.refresh-button {
    flex: 0 0 auto;
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.refresh-button:disabled {
    opacity: 0.6;
    cursor: default;
}

.refresh-status {
    font-size: 12px;
    line-height: 1.3;
    opacity: 0.65;
}

@media (max-width: 520px) {
    .refresh-panel {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .refresh-button {
        width: 100%;
    }
}


/* =========================================================
   CLIENT ANALYTICS
   ========================================================= */

.client-open {
    width: 100%;
    border: 0;
    background: transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    text-align: left;
}

.client-arrow {
    font-size: 20px;
    line-height: 12px;
    color: var(--accent);
}


.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
}

.back-button {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--accent);
    font-weight: 700;
    cursor: pointer;
}


.analytics-title-block {
    margin-bottom: 16px;
}

.analytics-client-name {
    font-size: 27px;
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -.6px;
}

.analytics-subtitle {
    margin-top: 5px;
    font-size: 13px;
    color: var(--muted);
}


.analytics-summary {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 24px;
}

.analytics-metric {
    background: var(--card);
    border-radius: 13px;
    padding: 14px;
    min-width: 0;
}

.analytics-metric-label {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 5px;
}

.analytics-metric-value {
    font-size: 17px;
    line-height: 1.2;
    font-weight: 800;
    word-break: break-word;
}


.analytics-section {
    margin-top: 25px;
}

.analytics-section-title {
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 10px;
}


.analytics-card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}


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

.history-header .analytics-section-title {
    margin-bottom: 0;
}


.period-switch {
    display: flex;
    background: #e9ebee;
    padding: 3px;
    border-radius: 10px;
}

.period-button {
    border: 0;
    background: transparent;
    padding: 6px 10px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.period-button.active {
    background: var(--card);
    color: var(--text);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
}


.history-card {
    background: var(--card);
    border-radius: 14px;
    padding: 15px;
    margin-bottom: 8px;
}

.history-card-title {
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 13px;
}

.history-row {
    display: grid;
    grid-template-columns: 82px 1fr 90px;
    gap: 10px;
    align-items: center;
    min-height: 29px;
}

.history-date {
    color: var(--muted);
    font-size: 12px;
}

.history-bar-wrap {
    height: 7px;
    border-radius: 20px;
    background: #eef0f3;
    overflow: hidden;
}

.history-bar {
    height: 100%;
    border-radius: 20px;
    background: var(--accent);
}

.history-value {
    text-align: right;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.history-empty {
    background: var(--card);
    padding: 25px;
    border-radius: 14px;
    text-align: center;
    color: var(--muted);
}


.analytics-accounts {
    display: grid;
    gap: 8px;
}

.analytics-account {
    background: var(--card);
    border-radius: 14px;
    padding: 15px 16px;
}

.analytics-account-name {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 14px;
}

.analytics-account-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 25px;
    row-gap: 10px;
}


@media (max-width: 600px) {

    .analytics-summary {
        grid-template-columns: 1fr 1fr;
    }

    .analytics-summary .analytics-metric:first-child {
        grid-column: span 1;
    }

    .analytics-card-grid {
        grid-template-columns: 1fr 1fr;
    }

    .analytics-client-name {
        font-size: 24px;
    }

    .history-row {
        grid-template-columns: 72px 1fr 76px;
        gap: 7px;
    }

    .history-date {
        font-size: 11px;
    }

    .history-value {
        font-size: 11px;
    }

    .analytics-account-grid {
        column-gap: 15px;
    }
}


/* =========================================================
   ACCOUNT ANALYTICS
   ========================================================= */

.account-open {
    cursor: pointer;
    transition:
        transform .12s ease,
        box-shadow .12s ease;
}

.account-open:active {
    transform: scale(.992);
}

.account-open:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.analytics-account-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 14px;
}

.analytics-account-title .analytics-account-name {
    margin-bottom: 0;
}

.account-arrow {
    flex: 0 0 auto;
    color: var(--accent);
    font-size: 24px;
    line-height: 1;
    font-weight: 500;
}

.account-client-name {
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
}


@media (hover: hover) {

    .account-open:hover {
        box-shadow: 0 4px 18px rgba(0, 0, 0, .06);
    }
}


@media (max-width: 600px) {

    #account-analytics .analytics-card-grid {
        grid-template-columns: 1fr 1fr;
    }

    #account-analytics .analytics-summary {
        grid-template-columns: 1fr 1fr;
    }
}
