* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: #1d2733;
    background: #f4f6f8;
}

a {
    color: #0f6b63;
    text-decoration: none;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 24px;
    background: #ffffff;
    border-bottom: 1px solid #dfe5eb;
}

.topbar h1 {
    margin: 0;
    font-size: 20px;
}

.topbar nav {
    display: flex;
    gap: 14px;
    font-weight: 700;
}

.layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 20px;
    padding: 20px;
}

.test-layout {
    padding: 20px;
}

.panel,
.content,
.login-box {
    background: #ffffff;
    border: 1px solid #dfe5eb;
    border-radius: 8px;
}

.panel {
    padding: 18px;
}

.panel-title h2,
.saved-filters h3 {
    margin: 0 0 6px;
    font-size: 18px;
}

.panel-title p {
    margin: 0 0 18px;
    color: #667382;
    line-height: 1.4;
}

hr {
    margin: 20px 0;
    border: 0;
    border-top: 1px solid #e7edf2;
}

.muted,
.token-box small,
.site-list small {
    color: #667382;
}

.site-form {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.token-box {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
    padding: 12px;
    border: 1px solid #bfe2dc;
    border-radius: 8px;
    background: #eefaf7;
}

.token-box code {
    display: block;
    overflow-x: auto;
    padding: 10px;
    border-radius: 6px;
    background: #ffffff;
    color: #0f4f49;
    font-size: 13px;
}

.site-selector {
    display: grid;
    grid-template-columns: 140px minmax(220px, 360px);
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.site-selector label {
    font-weight: 700;
}

.report-filters {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(180px, 1fr) minmax(180px, 1fr);
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
}

.report-filters label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}

.report-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.condition-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.condition-row input {
    grid-column: span 2;
}

.condition-row .remove {
    grid-column: span 2;
    background: #fff2f0;
    color: #a12b1f;
}

input,
select,
button,
.button {
    width: 100%;
    min-height: 40px;
    border: 1px solid #cbd5df;
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #0f6b63;
    border-color: #0f6b63;
    color: #ffffff;
    cursor: pointer;
    font-weight: 700;
}

.button.secondary {
    background: #eef3f2;
    border-color: #d7e4e2;
    color: #0f4f49;
}

.actions,
.save-filter {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 12px;
}

.save-filter {
    padding-top: 16px;
    border-top: 1px solid #e7edf2;
}

.saved-filters {
    margin-top: 18px;
}

.saved-filter {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 0;
    border-top: 1px solid #edf1f5;
}

.saved-filter .delete {
    color: #a12b1f;
    font-size: 13px;
}

.content {
    min-width: 0;
    padding: 18px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stats div {
    padding: 14px;
    background: #f7faf9;
    border: 1px solid #dfeae8;
    border-radius: 8px;
}

.stats strong {
    display: block;
    font-size: 21px;
}

.stats span {
    color: #667382;
    font-size: 13px;
}

.top-products {
    margin-bottom: 18px;
}

.section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.section-title h2 {
    margin: 0;
    font-size: 18px;
}

.section-title span {
    color: #667382;
    font-size: 13px;
}

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

.table-wrap.compact table {
    min-width: 420px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

th,
td {
    padding: 11px 10px;
    border-bottom: 1px solid #e8eef3;
    text-align: left;
    vertical-align: top;
}

th {
    font-size: 13px;
    color: #526170;
    background: #f8fafb;
}

.badge {
    display: inline-block;
    padding: 4px 7px;
    border-radius: 999px;
    background: #e8f4f2;
    color: #0f5c55;
    font-size: 12px;
    font-weight: 700;
}

.empty {
    text-align: center;
    color: #667382;
}

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

.login-box {
    width: min(420px, 100%);
    padding: 24px;
}

.login-box h1 {
    margin: 0 0 20px;
}

.login-box label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

.login-box button {
    margin-top: 12px;
}

.test-form {
    display: grid;
    gap: 10px;
    max-width: 920px;
}

.test-form label,
.result-box label {
    font-weight: 700;
}

textarea {
    width: 100%;
    min-height: 360px;
    border: 1px solid #cbd5df;
    border-radius: 6px;
    padding: 10px;
    font: 14px/1.5 Consolas, Monaco, monospace;
}

.result-box {
    margin-top: 18px;
    max-width: 920px;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #dfe5eb;
}

.result-box.success {
    border-color: #bfe2dc;
    background: #eefaf7;
}

.result-box.failure {
    border-color: #f0c4bd;
    background: #fff5f3;
}

.result-box pre {
    overflow-x: auto;
    min-height: 80px;
    padding: 12px;
    border-radius: 6px;
    background: #ffffff;
    white-space: pre-wrap;
}

.error {
    padding: 10px;
    border-radius: 6px;
    background: #fff2f0;
    color: #a12b1f;
}

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

    .stats {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

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

@media (max-width: 560px) {
    .topbar,
    .topbar nav {
        align-items: flex-start;
        flex-direction: column;
    }

    .layout {
        padding: 12px;
    }

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

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