:root {
    color-scheme: light;
    font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
    color: #172033;
    background: #f7f8fb;
    font-synthesis: none;
    --surface: #ffffff;
    --line: #e8ebf1;
    --muted: #697386;
    --blue: #2563eb;
    --purple: #7c3aed;
    --shadow: 0 10px 35px rgba(23, 32, 51, 0.06);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    background: #f7f8fb;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

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

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    padding: 12px clamp(20px, 5vw, 72px);
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.brand-mark,
.login-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: #ffffff;
    background: #172033;
    border-radius: 13px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 15px;
}

.brand small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.topbar-actions,
.connection-status,
.chart-legend,
.chart-legend span {
    display: flex;
    align-items: center;
}

.topbar-actions {
    gap: 12px;
}

.connection-status {
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
}

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

.connection-status.is-online .status-dot {
    background: #16a34a;
    box-shadow: 0 0 0 4px #dcfce7;
}

.secondary-button,
.text-button,
.range-picker button {
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #465065;
}

.secondary-button {
    min-height: 38px;
    padding: 0 14px;
    background: #ffffff;
    border: 1px solid #dce1ea;
    font-size: 13px;
    font-weight: 650;
}

.secondary-button:hover,
.secondary-button:focus-visible {
    border-color: #aeb7c7;
}

.text-button {
    padding: 8px;
    color: var(--muted);
}

.main-content {
    width: min(1420px, calc(100% - 40px));
    margin: 0 auto;
    padding: 52px 0 72px;
}

.hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px;
    margin-bottom: 28px;
}

.eyebrow,
.panel-kicker {
    margin: 0 0 8px;
    color: var(--blue);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.14em;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 12px;
    font-size: clamp(30px, 4vw, 44px);
    letter-spacing: -0.045em;
}

.hero-description {
    max-width: 620px;
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.65;
}

.range-picker {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: #eceff4;
    border-radius: 12px;
}

.range-picker button {
    padding: 9px 13px;
    white-space: nowrap;
    font-size: 13px;
}

.range-picker button.is-active {
    color: #172033;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(23, 32, 51, 0.12);
    font-weight: 700;
}

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

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

.metric-card {
    position: relative;
    min-height: 190px;
    padding: 24px;
}

.metric-icon {
    position: absolute;
    top: 22px;
    right: 22px;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    font-weight: 800;
}

.metric-icon-blue { color: #2563eb; background: #eff6ff; }
.metric-icon-purple { color: #7c3aed; background: #f5f3ff; }
.metric-icon-green { color: #15803d; background: #f0fdf4; }
.metric-icon-orange { color: #c2410c; background: #fff7ed; }

.metric-card p {
    margin-bottom: 20px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}

.metric-card strong {
    display: block;
    margin-bottom: 12px;
    font-size: clamp(30px, 4vw, 38px);
    letter-spacing: -0.04em;
}

.metric-card small {
    color: #8a93a3;
}

.metric-card small span {
    color: #475267;
    font-weight: 700;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 0.8fr);
    gap: 18px;
    margin-top: 18px;
}

.panel {
    padding: 26px;
}

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

.panel-heading h2 {
    margin: 0;
    font-size: 20px;
    letter-spacing: -0.025em;
}

.panel-kicker {
    margin-bottom: 6px;
    color: #8992a2;
}

.chart-legend {
    gap: 16px;
    color: var(--muted);
    font-size: 12px;
}

.chart-legend span {
    gap: 6px;
}

.chart-legend i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.legend-open { background: var(--blue); }
.legend-draw { background: var(--purple); }

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

#trendChart {
    display: block;
    width: 100%;
    min-height: 300px;
    overflow: visible;
}

.empty-state {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--muted);
}

.period-list {
    margin: 0;
}

.period-list div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 17px 0;
    border-bottom: 1px solid var(--line);
}

.period-list dt {
    color: var(--muted);
    font-size: 13px;
}

.period-list dd {
    margin: 0;
    font-size: 18px;
    font-weight: 750;
}

.privacy-note {
    margin: 24px 0 0;
    padding: 15px;
    color: #526078;
    background: #f8fafc;
    border: 1px solid #e8edf3;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.65;
}

.privacy-note span {
    color: #16a34a;
    font-weight: 800;
}

.table-panel {
    margin-top: 18px;
}

.updated-at {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th,
td {
    padding: 15px 14px;
    border-bottom: 1px solid var(--line);
}

th {
    color: #7a8495;
    background: #fafbfc;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.04em;
}

td {
    color: #455066;
    font-size: 13px;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.login-view {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 76px);
    padding: 40px 20px;
    background: #f7f8fb;
}

.login-card {
    width: min(100%, 430px);
    padding: 42px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 22px 70px rgba(23, 32, 51, 0.09);
}

.login-mark {
    width: 50px;
    height: 50px;
    margin-bottom: 30px;
}

.login-card h1 {
    margin-bottom: 12px;
    font-size: 30px;
}

.login-card > p:not(.eyebrow) {
    margin-bottom: 28px;
    color: var(--muted);
    line-height: 1.65;
}

.login-card label {
    display: block;
    margin-bottom: 9px;
    font-size: 13px;
    font-weight: 700;
}

.login-card input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1px solid #dce1ea;
    border-radius: 11px;
    outline: 0;
}

.login-card input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px #dbeafe;
}

.primary-button {
    width: 100%;
    min-height: 48px;
    margin-top: 18px;
    color: #ffffff;
    background: #172033;
    border: 0;
    border-radius: 11px;
    font-weight: 750;
}

.primary-button:hover,
.primary-button:focus-visible {
    background: #29344a;
}

.form-error {
    margin: 10px 0 0;
    color: #b91c1c;
    font-size: 12px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

button:focus-visible,
a:focus-visible {
    outline: 3px solid #bfdbfe;
    outline-offset: 2px;
}

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

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

@media (max-width: 680px) {
    .topbar {
        padding-inline: 18px;
    }

    .connection-status {
        display: none;
    }

    .topbar-actions {
        gap: 7px;
    }

    .secondary-button {
        padding-inline: 12px;
    }

    .text-button {
        display: inline-flex;
        align-items: center;
        min-height: 38px;
        padding-inline: 7px;
    }

    .main-content {
        width: min(100% - 28px, 1420px);
        padding-top: 34px;
    }

    .hero {
        align-items: stretch;
        flex-direction: column;
    }

    .range-picker {
        overflow-x: auto;
    }

    .range-picker button {
        flex: 1;
    }

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

    .metric-card {
        min-height: 165px;
    }

    .panel {
        padding: 20px;
    }

    .panel-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .chart-legend {
        align-self: flex-start;
    }

    .login-card {
        padding: 30px 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}
