:root {
    color-scheme: light;
    --bg: #f5f7f6;
    --panel: #ffffff;
    --panel-soft: #eef4f1;
    --ink: #16201d;
    --muted: #63706c;
    --line: #d9e1dd;
    --accent: #0f766e;
    --accent-strong: #0b5f59;
    --blue: #2563eb;
    --amber: #b45309;
    --danger: #b42318;
    --shadow: 0 16px 45px rgba(24, 35, 32, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background: var(--bg);
}

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

.login-brand {
    display: grid;
    gap: 8px;
    margin-bottom: 22px;
}

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

.brand-text {
    font-size: 20px;
    font-weight: 900;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.login-form {
    display: grid;
    gap: 12px;
}

.login-form label {
    margin-bottom: 0;
}

.login-submit {
    width: 100%;
    min-height: 44px;
    margin-top: 2px;
}

.form-row,
.login-footer {
    display: flex;
    justify-content: flex-end;
    font-size: 14px;
}

.login-footer {
    justify-content: center;
    margin-top: 16px;
}

.form-row a,
.login-footer a {
    color: var(--accent-strong);
    font-weight: 800;
    text-decoration: none;
}

.login-error,
.login-success {
    margin-bottom: 14px;
    padding: 11px 12px;
    border-radius: 8px;
    font-weight: 700;
}

.login-error {
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: var(--danger);
}

.login-success {
    border: 1px solid #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

button,
input,
select {
    font: inherit;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px clamp(16px, 4vw, 44px);
    background: rgba(245, 247, 246, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.eyebrow,
.app-header h1,
.panel-heading h2,
.results-heading p {
    margin: 0;
}

.eyebrow {
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.app-header h1 {
    margin-top: 4px;
    font-size: clamp(22px, 4vw, 34px);
    line-height: 1.05;
}

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

.user-pill {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.button,
.ghost-button,
.icon-button {
    border: 1px solid var(--line);
    border-radius: 8px;
    min-height: 40px;
    cursor: pointer;
    background: var(--panel);
    color: var(--ink);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    text-decoration: none;
    font-weight: 800;
}

.button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.button.secondary {
    color: var(--accent-strong);
}

.ghost-button {
    padding: 0 10px;
    color: var(--muted);
}

.icon-button {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
}

.app-shell {
    width: min(1500px, calc(100% - 32px));
    margin: 24px auto 48px;
}

.notice {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    padding: 14px 16px;
    border: 1px solid #f1c27d;
    border-radius: 8px;
    background: #fff7ed;
    color: #78350f;
}

.notice.info {
    border-color: #b6d7ff;
    background: #eff6ff;
    color: #1e3a8a;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.metric-card,
.filter-panel,
.results-panel,
.insight-grid > article {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric-card {
    min-height: 118px;
    padding: 16px;
}

.metric-card span,
label span,
.result-kicker,
.detail-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.metric-card strong {
    display: block;
    margin: 8px 0 4px;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1;
}

.metric-card small {
    color: var(--muted);
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.filter-panel,
.results-panel,
.insight-grid > article {
    padding: 16px;
}

.filter-panel {
    position: sticky;
    top: 102px;
}

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

.panel-heading h2 {
    font-size: 18px;
}

label {
    display: grid;
    gap: 7px;
    margin-bottom: 12px;
}

input,
select {
    width: 100%;
    min-height: 42px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    outline: none;
}

input:focus,
select:focus,
button:focus-visible,
.button:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.check-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 2px;
}

.check-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    margin: 0;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font-weight: 700;
}

.check-grid input {
    width: 16px;
    min-height: 16px;
}

.results-heading {
    align-items: flex-start;
}

.results-heading p {
    color: var(--muted);
    font-size: 13px;
}

.pager {
    display: flex;
    align-items: center;
    gap: 8px;
}

#pageLabel {
    min-width: 34px;
    text-align: center;
    color: var(--muted);
    font-weight: 800;
}

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

.result-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    width: 100%;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    text-align: left;
    cursor: pointer;
}

.result-row:hover {
    border-color: #9cc7c0;
    background: #fbfefd;
}

.result-main h3 {
    margin: 2px 0 5px;
    font-size: 17px;
    line-height: 1.25;
}

.result-main p {
    margin: 0;
    color: var(--muted);
    line-height: 1.35;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--panel-soft);
    color: #275049;
    font-size: 12px;
    font-weight: 800;
}

.tag.blue {
    background: #e8f0ff;
    color: #1d4ed8;
}

.tag.amber {
    background: #fff4df;
    color: var(--amber);
}

.result-side {
    display: grid;
    align-content: start;
    justify-items: end;
    gap: 5px;
    min-width: 94px;
}

.rating {
    font-size: 18px;
    font-weight: 900;
}

.muted {
    color: var(--muted);
}

.empty-state {
    padding: 30px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    text-align: center;
}

.insight-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;
    gap: 16px;
    margin-top: 16px;
}

.rank-list,
.import-list {
    display: grid;
    gap: 8px;
}

.rank-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    text-align: left;
}

.rank-row span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.import-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.import-row div {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.import-row strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.import-row span,
.import-row small {
    color: var(--muted);
}

dialog {
    width: min(900px, calc(100% - 28px));
    max-height: min(760px, calc(100vh - 36px));
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 25px 70px rgba(20, 32, 29, 0.24);
}

dialog::backdrop {
    background: rgba(10, 20, 18, 0.42);
}

.dialog-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.dialog-head h2,
.dialog-head p {
    margin: 0;
}

.dialog-head h2 {
    font-size: 22px;
}

.dialog-head p {
    margin-top: 5px;
    color: var(--muted);
}

.dialog-body {
    display: grid;
    gap: 14px;
    padding: 18px;
    overflow: auto;
}

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

.detail-item {
    display: grid;
    gap: 4px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow-wrap: anywhere;
}

.detail-item a {
    color: var(--blue);
}

.wide {
    grid-column: 1 / -1;
}

@media (max-width: 1100px) {
    .metric-grid {
        grid-template-columns: repeat(3, 1fr);
    }

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

    .filter-panel {
        position: static;
    }
}

@media (max-width: 700px) {
    .app-header {
        align-items: flex-start;
        flex-direction: column;
        position: static;
    }

    .header-actions {
        width: 100%;
        justify-content: stretch;
    }

    .button {
        flex: 1 1 130px;
    }

    .app-shell {
        width: min(100% - 20px, 1500px);
        margin-top: 14px;
    }

    .metric-grid,
    .two-col,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .result-row {
        grid-template-columns: 1fr;
    }

    .result-side {
        justify-items: start;
        grid-template-columns: repeat(2, max-content);
        min-width: 0;
    }
}
