:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --ink: #18202a;
    --muted: #657282;
    --line: #dce2e8;
    --teal: #087568;
    --teal-dark: #075d54;
    --amber: #9a6700;
    --amber-bg: #fff6d8;
    --red: #b42318;
    --red-bg: #fff0ee;
    --green-bg: #e7f6ef;
    --shadow: 0 10px 28px rgba(31, 41, 55, 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;
}

button,
input,
select {
    font: inherit;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 24px clamp(16px, 4vw, 40px);
    border-bottom: 1px solid var(--line);
    background: #ffffff;
}

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

.eyebrow {
    margin: 0 0 4px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 0;
    font-size: 1.85rem;
    line-height: 1.15;
}

h2 {
    margin-bottom: 6px;
    font-size: 1.05rem;
}

h3 {
    margin-bottom: 10px;
    font-size: 0.86rem;
    color: #3a4654;
}

.small {
    font-size: 0.8rem;
}

.layout {
    display: grid;
    gap: 18px;
    width: min(1500px, 100%);
    margin: 0 auto;
    padding: 20px clamp(14px, 3vw, 32px) 40px;
}

.control-band {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 0 6px;
}

.toolbar-form,
.dataset-controls {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}

.field {
    display: grid;
    gap: 6px;
    min-width: min(280px, 100%);
}

.field span {
    color: #3f4b59;
    font-size: 0.78rem;
    font-weight: 700;
}

input,
select {
    height: 38px;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
    color: var(--ink);
    padding: 0 10px;
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(8, 117, 104, 0.14);
}

button {
    height: 38px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0 16px;
    cursor: pointer;
    font-weight: 700;
}

.secondary-button {
    border-color: var(--line);
    background: #ffffff;
    color: var(--ink);
}

.secondary-button:hover {
    border-color: #b9c3ce;
    background: #f9fafb;
}

.status-pill,
.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
}

.status-neutral {
    background: #eef2f6;
    color: #394654;
}

.status-ok {
    background: var(--green-bg);
    color: var(--teal-dark);
}

.status-error {
    background: var(--red-bg);
    color: var(--red);
}

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

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

.metric-card {
    display: grid;
    gap: 8px;
    min-height: 88px;
    align-content: start;
    padding: 14px;
}

.metric-label {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.metric-card strong {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
    font-size: 1.25rem;
    line-height: 1.25;
}

.metric-card .fingerprint-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
}

.accent-error {
    border-left: 4px solid var(--red);
}

.accent-warning {
    border-left: 4px solid var(--amber);
}

.panel {
    min-width: 0;
    overflow: hidden;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 58px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
    margin: 0;
}

.dataset-heading {
    align-items: end;
}

.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    padding: 16px;
}

.pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 30px;
}

.pill {
    border: 1px solid var(--line);
    background: #f8fafc;
    color: #354050;
}

.table-wrap {
    width: 100%;
    overflow: auto;
}

.operation-log-wrap {
    max-height: 520px;
}

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

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
    font-size: 0.84rem;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f9fafb;
    color: #4a5565;
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
}

td {
    max-width: 360px;
    color: #263241;
    overflow-wrap: anywhere;
}

tbody tr:hover {
    background: #f9fbfb;
}

.empty-row td {
    color: var(--muted);
    text-align: center;
}

.change-cell {
    min-width: 220px;
}

.change-diff {
    display: grid;
    grid-template-columns: minmax(70px, 0.8fr) minmax(70px, 1fr) auto minmax(70px, 1fr);
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.change-diff:last-child {
    margin-bottom: 0;
}

.change-field {
    color: #354050;
    font-weight: 800;
}

.change-value {
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 3px 6px;
    background: #f8fafc;
    overflow-wrap: anywhere;
}

.from-value {
    background: var(--red-bg);
    color: #7a2118;
}

.to-value {
    background: var(--green-bg);
    color: var(--teal-dark);
}

.change-arrow {
    color: var(--muted);
    font-weight: 800;
}

.database-field {
    min-width: min(360px, 100%);
}

.compact-field {
    min-width: 170px;
}

.limit-field {
    width: 94px;
    min-width: 94px;
}

@media (max-width: 980px) {
    .topbar,
    .control-band,
    .panel-heading,
    .dataset-heading {
        align-items: stretch;
        flex-direction: column;
    }

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

    .toolbar-form,
    .dataset-controls,
    .dataset-controls .field,
    .database-field {
        width: 100%;
    }

    .limit-field {
        width: 100%;
    }
}
