:root {
    color-scheme: light;
    --ink: #17202a;
    --muted: #667085;
    --line: #d8dee8;
    --surface: #ffffff;
    --background: #f4f6f9;
    --blue: #0866ff;
    --blue-dark: #0756d8;
    --green: #198754;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--background);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
    position: sticky;
    z-index: 10;
    top: 0;
    display: flex;
    align-items: center;
    gap: 24px;
    height: 64px;
    padding: 0 32px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 800;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 9px;
    color: white;
    background: var(--blue);
}

.product-name {
    padding-left: 24px;
    border-left: 1px solid var(--line);
    color: var(--muted);
}

.product-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-left: 18px;
    border-left: 1px solid var(--line);
}

.product-nav a {
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 750;
    text-decoration: none;
}

.product-nav a:hover,
.product-nav a.active {
    color: var(--blue);
    background: #edf4ff;
}

.database-link {
    margin-left: auto;
    color: var(--blue);
    font-weight: 700;
    text-decoration: none;
}

main {
    width: min(1440px, calc(100% - 48px));
    margin: 0 auto;
    padding: 54px 0 80px;
}

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

.hero-side {
    display: grid;
    width: min(560px, 100%);
    gap: 12px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.14em;
}

h1 {
    max-width: 720px;
    margin: 0;
    font-size: clamp(32px, 4vw, 54px);
    line-height: 1.02;
    letter-spacing: -0.045em;
}

.subtitle {
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 18px;
}

.stats-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.stats-panel div {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 8px 30px rgba(23, 32, 42, 0.05);
}

.stats-panel strong {
    display: block;
    font-size: 26px;
    letter-spacing: -0.04em;
}

.stats-panel span,
.result-summary span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.classification-panel {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 8px 30px rgba(23, 32, 42, 0.05);
}

.classification-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
}

.classification-head div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.classification-head span,
.classification-note {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.classification-head strong {
    font-size: 18px;
}

.run-status {
    flex: 0 0 auto;
    padding: 6px 9px;
    border-radius: 999px;
    color: #667085;
    background: #eef1f5;
    font-size: 11px;
    font-weight: 850;
}

.run-status.running {
    color: #8a5a00;
    background: #fff3cd;
}

.run-status.completed {
    color: var(--green);
    background: #e8f7ef;
}

.run-status.failed {
    color: #b42318;
    background: #fee4e2;
}

.classification-controls {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
}

.classification-controls input[type="number"] {
    height: 40px;
}

.classification-controls button {
    height: 40px;
}

.classification-controls button:disabled {
    border-color: #98a2b3;
    background: #98a2b3;
    cursor: wait;
}

.retry-field {
    display: flex;
    min-height: 40px;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.retry-field input {
    width: 18px;
    height: 18px;
}

.classification-note {
    margin: 0;
    line-height: 1.4;
}

.result-summary {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: -10px 0 20px;
}

.result-summary strong {
    font-size: 24px;
    letter-spacing: -0.04em;
}

.filters {
    display: grid;
    grid-template-columns: minmax(260px, 2fr) 1fr auto auto;
    gap: 14px;
    align-items: end;
    margin-bottom: 28px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 8px 30px rgba(23, 32, 42, 0.05);
}

label {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

label span {
    color: #475467;
    font-size: 12px;
    font-weight: 700;
}

input,
select,
button {
    height: 44px;
    border: 1px solid #cfd6e2;
    border-radius: 9px;
    background: white;
    color: var(--ink);
    font: inherit;
}

input,
select {
    width: 100%;
    padding: 0 13px;
}

input:focus,
select:focus {
    border-color: var(--blue);
    outline: 3px solid rgba(8, 102, 255, 0.12);
}

button {
    padding: 0 20px;
    border-color: var(--blue);
    color: white;
    background: var(--blue);
    font-weight: 750;
    cursor: pointer;
}

button:hover {
    background: var(--blue-dark);
}

.switch-field {
    align-items: start;
}

.switch-field input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.switch {
    position: relative;
    width: 56px;
    height: 32px;
    border-radius: 999px;
    background: #d9dee8;
    transition: background 0.15s ease;
}

.switch::after {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 6px rgba(23, 32, 42, 0.22);
    content: "";
    transition: transform 0.15s ease;
}

.switch-field input:checked + .switch {
    background: var(--blue);
}

.switch-field input:checked + .switch::after {
    transform: translateX(24px);
}

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

.ad-card {
    display: flex;
    position: relative;
    height: 620px;
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 3px 14px rgba(23, 32, 42, 0.04);
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 16px 16px 12px;
}

.page-avatar {
    display: grid;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    place-items: center;
    border-radius: 50%;
    color: var(--blue);
    background: #e8f0ff;
    font-weight: 850;
}

.page-info {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: 3px;
}

.page-info strong,
.page-info span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-info span,
.ad-id {
    color: var(--muted);
    font-size: 11px;
}

.status {
    padding: 5px 8px;
    border-radius: 999px;
    color: #667085;
    background: #eef1f5;
    font-size: 11px;
    font-weight: 800;
}

.status.active {
    color: var(--green);
    background: #e8f7ef;
}

.creative {
    display: flex;
    height: 314px;
    flex: 1;
    flex-direction: column;
    justify-content: space-between;
    border-top: 1px solid #edf0f4;
    border-bottom: 1px solid #edf0f4;
    background: #fafbfc;
}

.creative-frame {
    min-height: 0;
}

.creative-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px 0;
}

.creative-header div {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.creative-header strong,
.creative-header span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.creative-header strong {
    font-size: 13px;
}

.creative-header span {
    color: var(--muted);
    font-size: 11px;
}

.creative-avatar {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    border-radius: 50%;
    color: var(--blue);
    background: #e8f0ff;
    font-size: 13px;
    font-weight: 850;
}

.body-copy {
    display: -webkit-box;
    overflow: hidden;
    margin: 0;
    padding: 14px 18px 18px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 7;
    line-height: 1.52;
    white-space: pre-line;
}

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

.link-preview {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-height: 92px;
    padding: 14px 18px;
    border-top: 1px solid #e3e7ed;
    background: #f0f2f5;
}

.link-preview span {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}

.link-preview p {
    display: -webkit-box;
    overflow: hidden;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.facts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin: 0;
    padding: 14px 16px;
}

.facts div {
    min-width: 0;
}

.facts dt {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.facts dd {
    overflow: hidden;
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0 16px 12px;
}

.card-actions a,
.card-actions button,
.disabled-action {
    display: grid;
    min-height: 40px;
    place-items: center;
    padding: 10px;
    border-radius: 8px;
    color: white;
    background: var(--blue);
    font-size: 12px;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
}

.card-actions button {
    height: auto;
    cursor: pointer;
}

.card-actions a.secondary,
.card-actions button.secondary,
.disabled-action {
    border: 0;
    color: #344054;
    background: #edf0f4;
}

.disabled-action {
    color: #98a2b3;
    cursor: not-allowed;
}

.ad-id {
    padding: 0 16px 14px;
}

.creative-dialog {
    width: min(1040px, calc(100% - 32px));
    max-height: min(880px, calc(100% - 32px));
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 18px;
    color: var(--ink);
    background: var(--surface);
    box-shadow: 0 24px 90px rgba(23, 32, 42, 0.28);
}

.creative-dialog::backdrop {
    background: rgba(15, 23, 42, 0.54);
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--line);
}

.dialog-header div {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 4px;
}

.dialog-header span {
    color: var(--blue);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dialog-header strong {
    overflow: hidden;
    font-size: 20px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dialog-close {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    place-items: center;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--ink);
    background: white;
    font-size: 24px;
    line-height: 1;
}

.dialog-content {
    display: grid;
    gap: 14px;
    max-height: 740px;
    overflow: auto;
    padding: 18px;
    background: var(--background);
}

.snapshot-preview {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
}

.snapshot-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

.snapshot-preview-header div {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 4px;
}

.snapshot-preview-header span {
    color: var(--blue);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.snapshot-preview-header strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.snapshot-preview-header a {
    flex: 0 0 auto;
    padding: 9px 12px;
    border-radius: 9px;
    color: white;
    background: var(--blue);
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
}

.snapshot-preview iframe {
    display: block;
    width: 100%;
    height: 520px;
    border: 0;
    background: white;
}

.creative-detail {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
}

.creative-detail > p {
    margin: 10px 0 14px;
    line-height: 1.55;
    white-space: pre-line;
}

.detail-kicker {
    color: var(--blue);
    font-size: 12px;
    font-weight: 850;
}

.detail-preview {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
    padding: 14px;
    border-radius: 11px;
    background: #f0f2f5;
}

.detail-preview span {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
}

.detail-preview p {
    margin: 0;
    color: var(--muted);
}

.creative-detail dl {
    display: grid;
    gap: 10px;
    margin: 16px 0 0;
}

.creative-detail dt {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.creative-detail dd {
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 13px;
}

.creative-detail a {
    color: var(--blue);
    font-weight: 700;
}

.pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-top: 32px;
    color: var(--muted);
    text-align: center;
}

.pagination a {
    color: var(--blue);
    font-weight: 750;
    text-decoration: none;
}

.pagination a:last-child {
    text-align: right;
}

.empty {
    padding: 90px 24px;
    border: 1px dashed #c8d0dc;
    border-radius: 16px;
    background: white;
    text-align: center;
}

.empty div {
    color: var(--blue);
    font-size: 48px;
}

.empty h2 {
    margin-bottom: 8px;
}

.empty p {
    margin: 0;
    color: var(--muted);
}

.insights-hero {
    align-items: center;
}

.insight-explainer {
    display: flex;
    max-width: 360px;
    flex-direction: column;
    gap: 7px;
    padding: 18px;
    border: 1px solid #cfe0ff;
    border-radius: 16px;
    background: #edf4ff;
}

.insight-explainer strong {
    color: var(--blue-dark);
}

.insight-explainer span {
    color: #475467;
    font-size: 13px;
    line-height: 1.45;
}

.insight-filters {
    grid-template-columns:
        minmax(180px, 1.5fr)
        140px
        140px
        120px
        120px
        175px
        auto;
    gap: 10px;
}

.number-input {
    position: relative;
}

.number-input input {
    padding-right: 54px;
}

.number-input span {
    position: absolute;
    top: 14px;
    right: 13px;
    color: var(--muted);
    font-size: 12px;
}

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

.insight-card {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 18px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 8px 30px rgba(23, 32, 42, 0.05);
}

.insight-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.copy-kind {
    padding: 5px 8px;
    border-radius: 7px;
    color: var(--blue-dark);
    background: #edf4ff;
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
}

.fingerprint {
    color: #98a2b3;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
}

.insight-card blockquote {
    display: -webkit-box;
    min-height: 88px;
    margin: 0;
    overflow: hidden;
    color: #263242;
    font-size: 16px;
    line-height: 1.45;
    white-space: pre-line;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
}

.signal-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.signal-grid div {
    min-width: 0;
    padding: 10px 8px;
    border-radius: 10px;
    background: #f5f7fa;
}

.signal-grid strong,
.signal-grid span {
    display: block;
}

.signal-grid strong {
    font-size: 20px;
}

.signal-grid span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 750;
    text-transform: uppercase;
}

.active-meter {
    display: grid;
    gap: 7px;
}

.active-meter div {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 12px;
}

.active-meter strong {
    color: var(--green);
}

.active-meter progress {
    width: 100%;
    height: 7px;
    overflow: hidden;
    border: 0;
    border-radius: 999px;
    background: #e8edf3;
}

.active-meter progress::-webkit-progress-value {
    border-radius: 999px;
    background: var(--green);
}

.active-meter progress::-moz-progress-bar {
    border-radius: 999px;
    background: var(--green);
}

.insight-dates {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 7px 16px;
    color: var(--muted);
    font-size: 11px;
}

.insight-dates strong {
    color: #475467;
}

.insight-action {
    margin-top: auto;
    padding: 11px 14px;
    border: 1px solid #cfe0ff;
    border-radius: 9px;
    color: var(--blue);
    background: #f7faff;
    font-size: 13px;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
}

.insight-action:hover {
    color: white;
    background: var(--blue);
}

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

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

@media (max-width: 700px) {
    .topbar {
        padding: 0 16px;
    }

    .product-name {
        display: none;
    }

    .product-nav {
        margin-left: auto;
        padding-left: 0;
        border-left: 0;
    }

    main {
        width: min(100% - 24px, 1440px);
        padding-top: 32px;
    }

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

    .stats-panel {
        width: 100%;
        min-width: 0;
    }

    .hero-side {
        width: 100%;
    }

    .filters,
    .classification-controls,
    .grid,
    .insights-grid {
        grid-template-columns: 1fr;
    }

    .ad-card {
        height: 640px;
    }
}
