:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --panel: #ffffff;
    --surface: #ffffff;
    --surface-soft: #fbfcfd;
    --surface-muted: #f8fafb;
    --surface-alt: #eef2f5;
    --ink: #172026;
    --muted: #65727d;
    --line: #dce3e8;
    --accent: #1f6feb;
    --accent-strong: #185abc;
    --danger: #b42318;
    --success: #16704b;
    --warning: #9a4d00;
    --badge-success-bg: #e8f5ef;
    --badge-muted-bg: #eef2f5;
    --badge-warning-bg: #fff1d6;
    --badge-danger-bg: #fef0ef;
    --sidebar-bg: #15232d;
    --sidebar-ink: #eef5f8;
    --sidebar-muted: #adc0ca;
    --sidebar-nav: #cddae0;
    --overlay: rgba(15, 28, 36, 0.55);
    --log-bg: #101820;
    --log-ink: #d8e3ea;
    --shadow: 0 18px 40px rgba(20, 36, 48, 0.12);
    --shadow-soft: 0 1px 2px rgba(20, 36, 48, 0.04);
    --shadow-panel: 0 10px 24px rgba(20, 36, 48, 0.06);
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f151a;
    --panel: #151d23;
    --surface: #182229;
    --surface-soft: #1b252d;
    --surface-muted: #11191f;
    --surface-alt: #22303a;
    --ink: #e8eef2;
    --muted: #98a8b3;
    --line: #2c3a45;
    --accent: #65a3ff;
    --accent-strong: #8bbaff;
    --danger: #ff7b72;
    --success: #62d394;
    --warning: #ffbd66;
    --badge-success-bg: rgba(98, 211, 148, 0.14);
    --badge-muted-bg: #24313a;
    --badge-warning-bg: rgba(255, 189, 102, 0.16);
    --badge-danger-bg: rgba(255, 123, 114, 0.14);
    --sidebar-bg: #0b1116;
    --sidebar-ink: #eef5f8;
    --sidebar-muted: #8fa2ad;
    --sidebar-nav: #bac8d0;
    --overlay: rgba(2, 8, 12, 0.72);
    --log-bg: #081017;
    --log-ink: #d8e3ea;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-panel: 0 10px 24px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--bg);
    display: grid;
    grid-template-columns: 260px 1fr;
}

body.auth-locked {
    display: block;
}

body.auth-locked .sidebar,
body.auth-locked .shell {
    display: none;
}

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

.auth-card {
    display: grid;
    gap: 16px;
    width: min(440px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 26px;
}

.auth-card p {
    margin: 8px 0 0;
    color: var(--muted);
}

button,
input,
select,
textarea {
    font: inherit;
}

.sidebar {
    min-height: 100vh;
    padding: 24px 18px;
    background: var(--sidebar-bg);
    color: var(--sidebar-ink);
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 34px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #2fb178;
    font-weight: 800;
}

.brand strong,
.brand span {
    display: block;
}

.brand span {
    color: var(--sidebar-muted);
    font-size: 13px;
}

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

.nav-item {
    border: 0;
    border-radius: 8px;
    color: var(--sidebar-nav);
    background: transparent;
    padding: 12px 14px;
    text-align: left;
    cursor: pointer;
}

.nav-item.active,
.nav-item:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.account-box {
    display: grid;
    gap: 10px;
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.account-box span {
    overflow: hidden;
    color: var(--sidebar-muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-box .ghost {
    color: var(--sidebar-ink);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.16);
}

.shell {
    width: min(1440px, 100%);
    padding: 30px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 22px;
}

.topbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.theme-toggle {
    white-space: nowrap;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: 34px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(140px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

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

.stats article {
    padding: 18px;
}

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

.stats strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
}

.dashboard-view {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
}

.dashboard-hero {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(360px, 1.5fr);
    gap: 22px;
    align-items: stretch;
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow-panel);
}

.dashboard-hero h2 {
    margin: 4px 0 0;
    font-size: 28px;
}

.dashboard-hero-metrics,
.dashboard-grid,
.performance-grid,
.metric-row {
    display: grid;
    gap: 16px;
}

.dashboard-hero-metrics {
    grid-template-columns: repeat(3, minmax(170px, 1fr));
}

.dashboard-hero-metrics article,
.dash-card,
.metric-row > div {
    min-height: 118px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.dashboard-hero-metrics span,
.dash-card span,
.metric-row span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.dashboard-hero-metrics strong,
.dash-card strong,
.metric-row strong {
    display: block;
    margin-top: 12px;
    font-size: 30px;
    line-height: 1.08;
}

.dashboard-grid {
    grid-template-columns: repeat(4, minmax(190px, 1fr));
}

.dash-card small {
    display: block;
    margin-top: 10px;
    line-height: 1.35;
    color: var(--muted);
}

.dash-card.warning strong {
    color: var(--ink);
}

.dash-card.danger strong {
    color: var(--ink);
}

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

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

.metric-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 12px 20px 8px;
}

.chart-panel {
    display: grid;
    overflow: visible;
}

.scrape-chart {
    min-height: 290px;
    padding: 34px 20px 8px;
    overflow: visible;
}

.line-chart {
    width: 100%;
    height: 270px;
    overflow: visible;
}

.chart-grid-lines line {
    stroke: var(--line);
    stroke-width: 1;
}

.line-area {
    fill: url(#scrapeAreaGradient);
}

.line-stroke {
    fill: none;
    stroke: var(--accent);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 4;
}

.chart-hover-point circle {
    fill: var(--panel);
    stroke: var(--accent);
    stroke-width: 3;
}

.chart-hover-line {
    opacity: 0;
    stroke: var(--accent);
    stroke-dasharray: 4 6;
    stroke-width: 1.5;
}

.chart-tooltip {
    display: grid;
    gap: 2px;
    opacity: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: var(--panel);
    box-shadow: var(--shadow-panel);
    padding: 8px 10px;
    pointer-events: none;
}

.chart-tooltip span,
.chart-tooltip small {
    color: var(--muted);
    font-size: 11px;
}

.chart-hover-point:hover .chart-tooltip,
.chart-hover-point:hover .chart-hover-line {
    opacity: 1;
}

.chart-labels text {
    fill: var(--muted);
    font-size: 11px;
    text-anchor: middle;
}

.chart-legend {
    display: flex;
    gap: 16px;
    padding: 0 20px 18px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.chart-legend i {
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.legend-done {
    background: var(--accent);
}

.legend-failed {
    background: var(--danger);
}

.dashboard-list {
    display: grid;
    gap: 10px;
    padding: 16px 20px 20px;
}

.dashboard-list-item {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    text-align: left;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

button.dashboard-list-item:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.dashboard-list-item small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

.user-performance-table {
    display: grid;
    gap: 8px;
    padding: 16px 20px 20px;
}

.user-performance-head,
.user-performance-row {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) minmax(120px, 0.8fr) minmax(120px, 0.8fr);
    gap: 12px;
    align-items: center;
}

.user-performance-head {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.user-performance-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 13px 14px;
}

.user-performance-row span {
    color: var(--muted);
    font-weight: 700;
}

.activity-list .dashboard-list-item {
    align-items: flex-start;
}

.activity-list .dashboard-list-item > span:last-child {
    max-width: 280px;
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-table th,
.activity-table td {
    vertical-align: top;
}

.activity-table td:nth-child(4) {
    max-width: 520px;
    white-space: normal;
}

.panel {
    overflow: hidden;
    box-shadow: var(--shadow-panel);
}

.toolbar,
.pagination {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: end;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

.pagination {
    align-items: center;
    border-top: 1px solid var(--line);
    border-bottom: 0;
}

.search {
    flex: 1;
}

label span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: var(--surface);
    padding: 11px 12px;
    outline: none;
}

textarea {
    min-height: 112px;
    resize: vertical;
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 13px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.primary,
.ghost,
.danger,
.icon-button {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 11px 14px;
    cursor: pointer;
    font-weight: 700;
}

.primary {
    color: #ffffff;
    background: var(--accent);
}

.primary:hover {
    background: var(--accent-strong);
}

.ghost {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
}

.danger {
    color: #ffffff;
    background: var(--danger);
}

.icon-button {
    width: 38px;
    height: 38px;
    padding: 0;
    background: var(--surface-alt);
    font-size: 24px;
    line-height: 1;
}

.table-wrap {
    position: relative;
    min-height: 280px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0;
    background: var(--surface-soft);
}

td {
    font-size: 14px;
}

.product-title {
    display: grid;
    gap: 4px;
    min-width: 260px;
}

.product-title strong {
    max-width: 520px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-title span {
    color: var(--muted);
    font-size: 12px;
    max-width: 520px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-link {
    color: var(--accent);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.source-link:hover {
    text-decoration: underline;
}

.field-link {
    display: block;
    margin: 6px 0 8px;
    font-size: 12px;
    line-height: 1.35;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    color: var(--success);
    background: var(--badge-success-bg);
    font-size: 12px;
    font-weight: 700;
}

.badge.muted {
    color: var(--muted);
    background: var(--badge-muted-bg);
}

.badge.warning {
    color: var(--warning);
    background: var(--badge-warning-bg);
}

.badge.danger-badge {
    color: var(--danger);
    background: var(--badge-danger-bg);
}

.price-stack {
    display: grid;
    gap: 2px;
}

.price-stack small {
    color: var(--muted);
    font-size: 12px;
}

.row-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.empty {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    min-height: 280px;
    padding: 30px;
    color: var(--muted);
    text-align: center;
}

.empty strong {
    color: var(--ink);
}

dialog {
    width: min(980px, calc(100vw - 28px));
    max-height: calc(100vh - 28px);
    border: 0;
    border-radius: 8px;
    padding: 0;
    box-shadow: var(--shadow);
    margin: 14px auto auto;
}

dialog::backdrop {
    background: var(--overlay);
}

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

.editor footer,
.review-dialog footer {
    border-top: 1px solid var(--line);
    border-bottom: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-content: start;
    padding: 20px;
}

.form-grid label {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 12px;
}

.form-grid label span {
    text-transform: uppercase;
}

.form-grid input,
.form-grid textarea {
    margin-top: 4px;
    background: var(--surface);
}

input[readonly] {
    color: var(--muted);
    background: var(--surface-muted);
    cursor: default;
}

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

.checkbox-field {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 14px;
}

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

.form-message {
    flex: 1;
    color: var(--muted);
    font-size: 13px;
}

#reviewDialog {
    width: min(1320px, calc(100vw - 28px));
    overflow: hidden;
}

#editorDialog {
    width: min(1320px, calc(100vw - 28px));
    overflow: hidden;
}

#previewDialog {
    width: min(1180px, calc(100vw - 28px));
    overflow: hidden;
}

.review-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    padding: 16px;
}

.review-card {
    display: grid;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 16px;
}

.review-card h3 {
    margin: 10px 0 6px;
    font-size: 17px;
    line-height: 1.3;
}

.review-card p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.review-card dl {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 0;
}

.review-card dt,
.review-field span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.review-card dd {
    margin: 4px 0 0;
    font-weight: 700;
}

.review-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.review-data,
.asset-pane {
    min-width: 0;
    padding: 20px;
}

.review-dialog,
.editor,
.preview-dialog {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 28px);
    min-height: 0;
    background: var(--panel);
    color: var(--ink);
}

.review-dialog header,
.review-dialog footer,
.editor header,
.editor footer,
.preview-dialog header {
    flex: 0 0 auto;
}

.editor-layout {
    flex: 1 1 auto;
}

.editor.no-assets .editor-layout {
    grid-template-columns: 1fr;
}

.review-data {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-content: start;
}

.review-field {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface-soft);
}

.editor-tab {
    display: none;
}

.editor-tab.active {
    display: grid;
    gap: 14px;
}

.review-field:nth-child(6),
.review-field:nth-child(7),
.review-field:nth-child(8),
.review-field:nth-child(9) {
    grid-column: 1 / -1;
}

.review-field p {
    margin: 8px 0 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.45;
}

.asset-pane {
    display: grid;
    gap: 22px;
    border-left: 1px solid var(--line);
    background: var(--surface-muted);
    align-content: start;
}

.asset-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.asset-head h3 {
    margin: 0;
    font-size: 16px;
}

.upload-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 9px 11px;
    color: var(--ink);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    flex: 0 0 auto;
}

.upload-button input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

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

.image-tile {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 3;
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface);
}

.image-tile img {
    width: 100%;
    height: 100%;
    max-height: 240px;
    object-fit: contain;
    display: block;
    padding: 8px;
}

.image-tile span {
    position: absolute;
    left: 8px;
    top: 8px;
    border-radius: 999px;
    background: rgba(21, 35, 45, 0.82);
    color: #ffffff;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
}

.asset-empty {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.asset-delete {
    position: absolute;
    right: 8px;
    top: 8px;
    z-index: 2;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 8px;
    color: #ffffff;
    background: var(--danger);
    cursor: pointer;
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
}

.pdf-list {
    display: grid;
    gap: 8px;
}

.pdf-row {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 34px;
    gap: 8px;
}

.pdf-item {
    display: grid;
    gap: 4px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 11px 12px;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}

.list-delete {
    position: static;
    align-self: stretch;
    width: 34px;
    height: auto;
}

.pdf-item span {
    color: var(--muted);
    font-size: 12px;
}

.pdf-item strong {
    overflow-wrap: anywhere;
}

.pdf-preview-shell {
    display: grid;
    flex: 1 1 auto;
    min-height: 0;
    background: var(--surface-alt);
}

.pdf-preview-shell object,
.pdf-preview-shell embed {
    width: 100%;
    height: min(76vh, 820px);
    border: 0;
    background: var(--surface-alt);
}

.pdf-fallback {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 14px 18px;
    border-top: 1px solid var(--line);
    background: var(--surface);
}

.pdf-fallback p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.pdf-fallback a {
    text-decoration: none;
}

.scraper-form {
    display: flex;
    gap: 14px;
    align-items: end;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

.scraper-form .search {
    flex: 1;
}

.scraper-layout {
    display: grid;
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    min-height: 480px;
}

.scraper-layout > section {
    min-width: 0;
    padding: 16px;
}

.scraper-layout > section + section {
    border-left: 1px solid var(--line);
}

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

.section-head h3 {
    margin: 0;
    font-size: 16px;
}

.panel > .section-head {
    padding: 18px 20px 8px;
    margin-bottom: 0;
}

.panel > .section-head h3 {
    line-height: 1.25;
}

.panel > .section-head .form-message {
    margin-left: 4px;
}

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

.counter {
    display: inline-flex;
    min-width: 22px;
    height: 22px;
    margin-left: 6px;
    padding: 0 7px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--danger);
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
}

.job-list {
    display: grid;
    gap: 8px;
    max-height: 380px;
    overflow: auto;
    padding-right: 4px;
}

.job-item {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr);
    gap: 6px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 10px;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}

.job-item.active,
.job-item:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.1);
}

.job-item strong {
    display: block;
    overflow-wrap: anywhere;
    line-height: 1.35;
    max-height: 38px;
    overflow: hidden;
}

.job-item small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.job-status {
    width: 8px;
    min-height: 100%;
    border-radius: 999px;
    background: var(--muted);
}

.job-status.done {
    background: var(--success);
}

.job-status.failed {
    background: var(--danger);
}

.job-status.running {
    background: #d88a00;
}

.job-status.existing {
    background: var(--accent);
}

.job-main {
    min-width: 0;
}

.job-detail {
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-muted);
    color: var(--muted);
    overflow-wrap: anywhere;
    font-size: 13px;
}

.job-detail a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
}

.scraper-log {
    min-height: 420px;
    max-height: 62vh;
    margin: 0;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--log-bg);
    color: var(--log-ink);
    padding: 14px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 13px;
    line-height: 1.45;
}

#jobHistoryDialog {
    width: min(1180px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
    padding: 0;
    border: 0;
    border-radius: 10px;
}

.history-dialog {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px);
    background: var(--panel);
}

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

.history-dialog h2 {
    margin: 0;
    font-size: 22px;
}

.history-layout {
    display: grid;
    grid-template-columns: minmax(320px, 460px) minmax(0, 1fr);
    min-height: 560px;
    overflow: hidden;
}

.history-layout > section {
    min-width: 0;
    padding: 16px;
    overflow: auto;
}

.history-layout > section + section {
    border-left: 1px solid var(--line);
}

.history-list {
    display: grid;
    align-content: start;
    gap: 8px;
}

.history-item {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 10px;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}

.history-item.active,
.history-item:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.1);
}

.history-main {
    min-width: 0;
}

.history-main strong {
    display: block;
    overflow-wrap: anywhere;
    line-height: 1.35;
    max-height: 38px;
    overflow: hidden;
}

.history-main small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

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

.retry-button,
.delete-job-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--accent) 14%, var(--surface));
    color: var(--accent);
    font-weight: 800;
    font-size: 13px;
    white-space: nowrap;
}

.delete-job-button {
    background: var(--badge-danger-bg);
    color: var(--danger);
}

.history-log {
    min-height: 440px;
}

.review-main {
    min-width: 0;
    padding: 20px;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.tab-button {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    padding: 9px 11px;
    cursor: pointer;
    font-weight: 700;
    transition: 0.15s ease;
}

.tab-button.active {
    border-color: var(--accent);
    color: #ffffff;
    background: var(--accent);
}

.review-tab {
    display: none;
}

.review-tab.active {
    display: grid;
    gap: 14px;
}

.review-main .review-data {
    padding: 0;
}

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

.structured-row {
    display: grid;
    grid-template-columns: minmax(160px, 0.8fr) auto minmax(220px, 1fr) auto;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 10px;
    box-shadow: var(--shadow-soft);
}

.structured-row.feature-row {
    grid-template-columns: minmax(220px, 1fr) auto;
}

.structured-row > span {
    color: var(--muted);
    font-weight: 800;
}

.switch-label {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.switch-label input {
    width: 18px;
    height: 18px;
}

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

.settings-form {
    display: grid;
    gap: 14px;
    padding: 16px;
}

.api-settings {
    margin-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.api-url-preview {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.api-url-preview span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.api-url-preview code {
    display: block;
    overflow-x: auto;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    white-space: nowrap;
}

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

.link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    text-decoration: none;
}

.api-log-preview {
    display: grid;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 12px;
}

.api-log-head,
.api-log-row {
    display: grid;
    grid-template-columns: 120px 160px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}

.api-log-head {
    grid-template-columns: minmax(0, 1fr) auto;
    color: var(--text);
}

.api-log-head span,
.api-log-row span,
.api-log-row small {
    color: var(--muted);
}

.api-log-list {
    display: grid;
    gap: 6px;
}

.api-log-row {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 8px 10px;
}

.api-log-row small {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-admin {
    border-top: 1px solid var(--line);
}

.user-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 16px;
}

.user-active,
.permission-grid,
.user-actions {
    grid-column: 1 / -1;
}

.permission-grid {
    display: grid;
    gap: 10px;
}

.permission-matrix {
    display: grid;
    gap: 8px;
}

.permission-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) repeat(3, minmax(120px, 150px));
    gap: 8px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 10px;
}

.permission-toggle {
    display: grid;
    gap: 5px;
}

.permission-toggle span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.permission-toggle select {
    min-height: 38px;
}

.permission-item {
    display: flex;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 12px;
}

.permission-item input {
    width: 18px;
    height: 18px;
}

.permission-item strong {
    display: block;
}

.permission-item span {
    margin: 2px 0 0;
    font-size: 12px;
    font-weight: 500;
    text-transform: none;
}

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

.user-actions .form-message {
    margin-right: auto;
}

.user-list {
    display: grid;
    gap: 8px;
}

.user-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 12px;
}

.user-row strong,
.user-row small {
    display: block;
}

.user-row small {
    margin-top: 3px;
    color: var(--muted);
}

.user-row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.worker-mode {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
    font-size: 14px;
}

.worker-form {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.worker-form .search {
    flex: 1;
}

.worker-token {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.worker-token p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.worker-token textarea {
    width: 100%;
    min-height: 82px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    color: var(--text);
    background: var(--panel);
}

.worker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}

.worker-card {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.worker-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.worker-card-head small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.worker-card dl {
    display: grid;
    gap: 8px;
    margin: 0;
}

.worker-card dl div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    font-size: 13px;
}

.worker-card dt {
    color: var(--muted);
}

.worker-card dd {
    margin: 0;
    text-align: right;
}

.worker-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.category-builder {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 16px;
}

.category-tree {
    display: grid;
    gap: 10px;
}

.menu-node {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    overflow: hidden;
}

.menu-row {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) 28px;
    gap: 10px;
    align-items: center;
    min-height: 46px;
    padding: 8px 10px;
}

.parent-row {
    background: var(--surface-muted);
    border-bottom: 1px solid var(--line);
}

.menu-children {
    display: grid;
    background: var(--surface);
}

.child-row {
    grid-template-columns: 26px 28px minmax(0, 1fr) 28px;
    margin-left: 18px;
    border-bottom: 1px solid var(--line);
}

.child-row:last-child {
    border-bottom: 0;
}

.muted-row {
    grid-template-columns: 26px minmax(0, 1fr);
    color: var(--muted);
}

.tree-elbow {
    width: 18px;
    height: 24px;
    border-left: 2px solid var(--line);
    border-bottom: 2px solid var(--line);
    justify-self: center;
    align-self: start;
}

.drag-handle {
    color: var(--muted);
    cursor: grab;
    font-weight: 900;
    letter-spacing: 0;
}

.icon-mini {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 999px;
    color: var(--muted);
    background: var(--surface-alt);
    cursor: pointer;
    font-weight: 900;
}

.danger-mini {
    color: var(--danger);
    background: var(--badge-danger-bg);
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    max-width: 380px;
    border-radius: 8px;
    color: #ffffff;
    background: var(--sidebar-bg);
    box-shadow: var(--shadow);
    padding: 13px 15px;
    font-weight: 700;
}

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

    .sidebar {
        min-height: auto;
    }

    .stats,
    .dashboard-hero,
    .dashboard-hero-metrics,
    .dashboard-grid,
    .performance-grid,
    .admin-dashboard-grid,
    .metric-row,
    .user-performance-head,
    .user-performance-row,
    .form-grid,
    .review-layout,
    .review-data,
    .scraper-layout,
    .history-layout,
    .structured-row,
    .structured-row.feature-row,
    .assignment-grid,
    .category-builder {
        grid-template-columns: 1fr;
    }

    .child-row {
        margin-left: 6px;
    }

    .topbar,
    .toolbar,
    .editor header,
    .editor footer,
    .review-dialog header,
    .review-dialog footer {
        align-items: stretch;
        flex-direction: column;
    }

    .asset-pane {
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    .scraper-form {
        align-items: stretch;
        flex-direction: column;
    }

    .scraper-layout > section + section {
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    .history-layout {
        min-height: 0;
        overflow: auto;
    }

    .history-layout > section + section {
        border-left: 0;
        border-top: 1px solid var(--line);
    }
}
