:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --panel: #ffffff;
    --panel-muted: #f8fafc;
    --text: #18202a;
    --muted: #667085;
    --line: #dde3ea;
    --shadow: 0 18px 45px rgba(24, 32, 42, 0.08);
    --accent: #2563eb;
    --active: #0f8f68;
    --pending: #b7791f;
    --blocked: #c2413d;
    --unknown: #64748b;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    letter-spacing: 0;
}

button,
input {
    font: inherit;
}

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    gap: 20px;
    align-items: stretch;
    min-height: 260px;
}

.hero-copy,
.query-panel,
.result-panel,
.devices-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.hero-copy {
    padding: 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 38px;
    line-height: 1.16;
}

h2 {
    font-size: 20px;
    line-height: 1.3;
}

.hero-note {
    max-width: 560px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.7;
}

.query-panel {
    padding: 24px;
    display: grid;
    gap: 16px;
}

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

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

.field input {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 14px;
    color: var(--text);
    background: var(--panel-muted);
    outline: none;
}

.field input:focus {
    border-color: var(--accent);
    background: #ffffff;
}

#submitButton {
    min-height: 46px;
    border: 0;
    border-radius: 8px;
    color: #ffffff;
    background: var(--text);
    font-weight: 800;
    cursor: pointer;
}

#submitButton:disabled {
    cursor: not-allowed;
    background: #9aa4b2;
}

.form-message {
    min-height: 22px;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.form-message.error {
    color: var(--blocked);
}

.form-message.success {
    color: var(--active);
}

.result-panel {
    margin-top: 20px;
    padding: 24px;
}

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

.section-heading.compact {
    align-items: center;
    margin-bottom: 14px;
}

.last-loaded,
.status-counts {
    color: var(--muted);
    font-size: 13px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
}

.metric-card {
    min-height: 104px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-muted);
}

.metric-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.metric-card strong {
    display: block;
    margin-top: 14px;
    font-size: 26px;
    line-height: 1.1;
    word-break: break-word;
}

.devices-panel {
    margin-top: 18px;
    padding: 20px;
    box-shadow: none;
}

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

.devices-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 920px;
}

.devices-table th,
.devices-table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 13px;
    white-space: nowrap;
}

.devices-table th {
    color: var(--muted);
    font-weight: 800;
    background: var(--panel-muted);
}

.status-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 68px;
    min-height: 26px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.status-active,
.status-authed,
.status-issued {
    color: #087052;
    background: #dff7eb;
}

.status-pending,
.status-missing {
    color: #935f12;
    background: #fff2cf;
}

.status-blocked {
    color: #a53631;
    background: #ffe2df;
}

.status-unknown {
    color: var(--unknown);
    background: #e8edf3;
}

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

.device-cards {
    display: none;
}

@media (max-width: 980px) {
    .hero-panel {
        grid-template-columns: 1fr;
    }

    .summary-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .page-shell {
        width: min(100% - 20px, 1180px);
        padding: 16px 0 32px;
    }

    .hero-copy,
    .query-panel,
    .result-panel,
    .devices-panel {
        padding: 18px;
    }

    h1 {
        font-size: 30px;
    }

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

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

    .table-wrap {
        display: none;
    }

    .device-cards {
        display: grid;
        gap: 12px;
    }

    .device-card {
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 14px;
        background: var(--panel-muted);
    }

    .device-card-head {
        display: flex;
        justify-content: space-between;
        gap: 10px;
        margin-bottom: 12px;
    }

    .device-card-title {
        min-width: 0;
        font-weight: 800;
        word-break: break-word;
    }

    .device-fields {
        display: grid;
        gap: 9px;
    }

    .device-field {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        color: var(--muted);
        font-size: 13px;
    }

    .device-field strong {
        color: var(--text);
        text-align: right;
        word-break: break-word;
    }
}

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