:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #17212f;
    --muted: #5f6b7a;
    --border: #dfe5ef;
    --accent: #ff4b4b;
    --accent-dark: #d83a3a;
    --success: #e7f8ef;
    --success-text: #116a43;
    --warning: #fff4e5;
    --warning-text: #9a5b00;
    --error: #fdecec;
    --error-text: #a12626;
    --shadow: 0 10px 30px rgba(23, 33, 47, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Inter", sans-serif;
    background: var(--bg);
    color: var(--text);
}

.toast-container {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 1400;
    display: grid;
    gap: 10px;
    width: min(360px, calc(100vw - 24px));
}

.toast {
    border-radius: 14px;
    padding: 12px 14px;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.2);
    transform: translateY(-6px);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: linear-gradient(135deg, #047857 0%, #059669 100%);
}

.toast-error {
    background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 24px;
    background: linear-gradient(135deg, #101927 0%, #17212f 60%, #203047 100%);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 24px rgba(16, 25, 39, 0.18);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(255,255,255,0.18), rgba(255,255,255,0.08));
    border: 1px solid rgba(255,255,255,0.14);
    font-size: 1.2rem;
}

.topbar-subtitle {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.72);
}

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

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

.topbar-link,
.topbar-button {
    color: white;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    padding: 8px 14px;
    font: inherit;
    transition: all 0.18s ease;
    backdrop-filter: blur(6px);
}

.topbar-link:hover,
.topbar-button:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-1px);
}

.topbar-link.active {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.22);
}

.topbar-icon-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.topbar-button {
    cursor: pointer;
}

.topbar-user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px 8px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.topbar-user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.user-label {
    font-size: 0.74rem;
    color: rgba(255,255,255,0.7);
}

.user-badge {
    font-weight: 700;
}

.logout-form {
    margin: 0;
}

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

.sidebar {
    position: sticky;
    top: 24px;
    align-self: start;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 20px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}

.sidebar h2,
.content h1,
.panel h2,
.panel h3,
.panel h4 {
    margin-top: 0;
}

label {
    display: block;
    font-size: 0.92rem;
    font-weight: 600;
    margin: 12px 0 6px;
}

input[type="text"],
input[type="password"],
input[type="file"] {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
    font: inherit;
}

input[type="file"] {
    padding: 10px;
}

.primary-btn,
.download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 10px;
    padding: 12px 16px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease;
}

.primary-btn {
    width: 100%;
    margin-top: 16px;
}

.primary-btn:hover,
.download-btn:hover {
    background: var(--accent-dark);
}

.helper-link {
    display: inline-block;
    margin-top: 8px;
    color: #2563eb;
    text-decoration: none;
}

.config-card {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
}

.config-card .alert {
    margin-top: 10px;
    margin-bottom: 6px;
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 18px 0;
}

.sidebar-title {
    margin: 0;
    font-weight: 700;
}

.content {
    min-width: 0;
}

.hero,
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.hero-modern {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.08), transparent 24%),
        radial-gradient(circle at bottom left, rgba(255, 75, 75, 0.08), transparent 24%),
        linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    border: 1px solid #d9e3f2;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #eef4ff;
    color: #1d4ed8;
    font-size: 0.82rem;
    font-weight: 700;
}

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

.upload-panel-modern {
    border-style: dashed;
    border-width: 1.5px;
    background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%);
}

.upload-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.mini-status-pill {
    padding: 7px 12px;
    border-radius: 999px;
    background: #eaf8ef;
    color: #116a43;
    font-size: 0.82rem;
    font-weight: 700;
}

.message-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.alert {
    border-radius: 12px;
    padding: 12px 14px;
    font-weight: 500;
}

.alert.success {
    background: var(--success);
    color: var(--success-text);
}

.alert.warning {
    background: var(--warning);
    color: var(--warning-text);
}

.alert.error {
    background: var(--error);
    color: var(--error-text);
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.progress-bar {
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: #ecf1f8;
}

.progress-bar-lg {
    height: 14px;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff4b4b 0%, #ff8a65 100%);
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.status-queued {
    background: #eef2ff;
    color: #4338ca;
}

.status-running {
    background: #fff4e5;
    color: #9a5b00;
}

.status-completed {
    background: #eaf8ef;
    color: #116a43;
}

.status-failed {
    background: #fdecec;
    color: #a12626;
}

.job-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin: 14px 0 6px;
}

.job-rename-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 420px;
    flex-wrap: wrap;
}

.job-rename-form input {
    flex: 1 1 240px;
}

.job-action-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.job-inline-form {
    margin: 0;
}

.job-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #f5f8fc;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
}

.job-action-button:hover {
    background: #edf3fb;
    transform: translateY(-1px);
}

.secondary-button {
    background: #eef4ff;
    color: #1d4ed8;
    border-color: #c9d9ff;
}

.status-archived {
    background: #f3f4f6;
    color: #4b5563;
}

.archived-panel {
    border-style: dashed;
}

.danger-button {
    background: #b42318;
    color: white;
    border-color: #b42318;
}

.danger-button:hover {
    background: #971d13;
}

.job-action-button[disabled],
.danger-button[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

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

.stat-box {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
}

.stat-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

.job-search-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    font: inherit;
}

.job-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.job-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    text-decoration: none;
    color: inherit;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.job-list-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(23, 33, 47, 0.06);
}

.job-list-item.selected {
    border-color: #bfd6ff;
    box-shadow: inset 0 0 0 1px #c7dbff;
}

.job-list-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.small-text {
    font-size: 0.85rem;
}

details summary {
    cursor: pointer;
    font-weight: 700;
    margin-bottom: 14px;
}

.example-block {
    padding: 16px 0;
    border-top: 1px solid var(--border);
}

.example-block:first-of-type {
    border-top: 0;
    padding-top: 0;
}

.image-grid {
    display: grid;
    gap: 14px;
    margin: 12px 0 18px;
}

.image-grid.cols-1 {
    grid-template-columns: 1fr;
}

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

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

.image-card {
    margin: 0;
    padding: 12px;
    background: #fbfcfe;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.image-card img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 10px;
    background: white;
}

.image-card figcaption {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--muted);
}

.warning-panel {
    border-color: #f5d9ab;
    background: #fffdf8;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 16px;
}

.table-wrap-modern {
    border: 1px solid #dde6f2;
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
}

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

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

.results-table thead th {
    background: linear-gradient(180deg, #f8fbff 0%, #edf4ff 100%);
    position: sticky;
    top: 0;
    z-index: 1;
    font-size: 0.84rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #445468;
}

.results-table tbody tr:nth-child(even) {
    background: #fcfdff;
}

.results-table tbody tr[data-review-row] {
    cursor: pointer;
}

.results-table tbody tr:hover {
    background: #f5f9ff;
}

.results-table tbody tr.review-selected {
    background: #eaf2ff;
    box-shadow: inset 0 0 0 1px #b8ccf7;
}

.review-hint {
    margin: 6px 0 0;
}

.results-table-pane {
    min-width: 0;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(4px);
}

.modal-card {
    width: min(1180px, calc(100vw - 32px));
    max-height: calc(100vh - 40px);
    overflow: auto;
    background: #fff;
    border-radius: 18px;
    border: 1px solid var(--border);
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.22);
    padding: 20px;
}

.modal-header {
    position: sticky;
    top: 0;
    background: #fff;
    padding-bottom: 10px;
    margin-bottom: 10px;
    z-index: 1;
}

.modal-split-layout {
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.6fr);
    gap: 18px;
    align-items: start;
}

.modal-data-pane {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    padding: 14px;
    position: sticky;
    top: 0;
}

.modal-data-pane h4 {
    margin: 0 0 12px;
}

.data-preview-grid {
    display: grid;
    gap: 10px;
    margin: 0;
}

.data-preview-item {
    padding: 10px 12px;
    border: 1px solid #e6ebf3;
    border-radius: 12px;
    background: #fff;
}

.highlight-item {
    border-color: #bfd6ff;
    background: linear-gradient(180deg, #eef5ff 0%, #f8fbff 100%);
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.08);
}

.highlight-item dt {
    color: #1d4ed8;
}

.highlight-item dd {
    font-weight: 600;
}

.data-preview-item dt {
    margin: 0 0 4px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

.data-preview-item dd {
    margin: 0;
    font-size: 0.94rem;
    color: var(--text);
    word-break: break-word;
}

.data-field-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
}

.data-preview-item input,
.data-preview-item textarea {
    width: 100%;
    border: 1px solid #d6deeb;
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    color: var(--text);
    background: #fff;
}

.data-preview-item textarea {
    min-height: 88px;
    resize: vertical;
}

.data-preview-item input:focus,
.data-preview-item textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.row-edit-form {
    display: grid;
    gap: 12px;
}

.row-edit-intro {
    display: grid;
    gap: 6px;
}

.row-edit-intro .muted {
    margin: 0;
}

.row-edit-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
}

.row-save-feedback {
    font-size: 0.9rem;
    min-height: 1.2rem;
}

.row-save-feedback.success {
    color: #047857;
}

.row-save-feedback.error {
    color: #b91c1c;
}

.row-save-feedback.saving {
    color: #1d4ed8;
}

.modal-image-stack {
    gap: 12px;
}

.modal-content {
    padding-top: 4px;
}

.hidden-block {
    display: none;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 19, 31, 0.45);
    display: grid;
    place-items: center;
    z-index: 1000;
}

.loading-overlay.hidden {
    display: none;
}

.loading-card {
    background: white;
    padding: 28px;
    border-radius: 18px;
    width: min(420px, calc(100vw - 32px));
    text-align: center;
    box-shadow: var(--shadow);
}

.spinner {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 4px solid #e8edf5;
    border-top-color: var(--accent);
    margin: 0 auto 16px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

code {
    background: #f3f6fb;
    padding: 2px 6px;
    border-radius: 6px;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at top left, rgba(255, 75, 75, 0.08), transparent 28%),
        radial-gradient(circle at bottom right, rgba(37, 99, 235, 0.08), transparent 24%),
        var(--bg);
}

.auth-bg-orb {
    position: absolute;
    border-radius: 999px;
    filter: blur(18px);
    opacity: 0.55;
    pointer-events: none;
}

.auth-bg-orb-one {
    width: 220px;
    height: 220px;
    top: 50px;
    left: 60px;
    background: rgba(255, 75, 75, 0.16);
}

.auth-bg-orb-two {
    width: 260px;
    height: 260px;
    right: 40px;
    bottom: 40px;
    background: rgba(37, 99, 235, 0.14);
}

.auth-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(23, 33, 47, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(23, 33, 47, 0.03) 1px, transparent 1px);
    background-size: 24px 24px;
    mask-image: radial-gradient(circle at center, black 45%, transparent 85%);
    pointer-events: none;
}

.auth-shell {
    width: 100%;
    max-width: 460px;
    position: relative;
    z-index: 1;
}

.auth-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.auth-card-modern {
    overflow: hidden;
}

.auth-hero {
    margin: -28px -28px 20px;
    padding: 24px 28px 18px;
    background: linear-gradient(135deg, #101927 0%, #17212f 60%, #203047 100%);
    color: white;
}

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

.auth-brand-mark {
    width: 40px;
    height: 40px;
}

.auth-brand {
    font-weight: 700;
    color: white;
    margin-bottom: 2px;
}

.auth-subtitle {
    font-size: 0.82rem;
    color: rgba(255,255,255,0.72);
}

.auth-hero h1 {
    margin: 0 0 6px;
    font-size: 1.8rem;
}

.auth-hero .muted {
    color: rgba(255,255,255,0.78);
}

.auth-form {
    margin-top: 12px;
}

.small-note {
    margin-top: 16px;
    font-size: 0.92rem;
}

@media (max-width: 1100px) {
    .page-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        max-height: none;
    }
}

@media (max-width: 700px) {
    .topbar {
        padding: 14px;
        flex-direction: column;
        align-items: stretch;
    }

    .page-shell {
        padding: 14px;
    }

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

    .job-list-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .job-actions-bar,
    .job-rename-form,
    .job-action-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .modal-split-layout {
        grid-template-columns: 1fr;
    }

    .modal-data-pane {
        position: static;
    }

    .image-grid.cols-2,
    .image-grid.cols-3 {
        grid-template-columns: 1fr;
    }
}
