:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #172033;
    --muted: #6c768a;
    --line: #e5e9f1;
    --primary: #5b5ce2;
    --primary-dark: #4849c8;
    --success: #159b67;
    --warning: #c78013;
    --danger: #d34e5b;
    --shadow: 0 12px 35px rgba(29, 40, 70, .07);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100%;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-dark);
}

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

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

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    white-space: nowrap;
}

.brand-mark,
.login-logo {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #696aee, #4d50c8);
    color: #fff;
    font-weight: 800;
}

.nav {
    display: flex;
    align-self: stretch;
    align-items: center;
    gap: 6px;
}

.nav a {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 14px;
    color: var(--muted);
    font-weight: 600;
    border-bottom: 2px solid transparent;
}

.nav a:hover,
.nav a.active {
    color: var(--text);
    border-bottom-color: var(--primary);
}

.logout-form {
    margin-left: auto;
}

.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 36px 28px 64px;
}

.container-login {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.page-heading h1 {
    margin: 0 0 7px;
    font-size: 30px;
    letter-spacing: -.03em;
}

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

.back-link {
    display: inline-block;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 600;
}

.sheet-link {
    display: inline-block;
    margin-top: 3px;
    font-size: 14px;
    font-weight: 600;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 17px;
    box-shadow: var(--shadow);
}

.padded-card {
    padding: 24px;
}

.padded-card h2 {
    margin: 0 0 16px;
    font-size: 18px;
}

.import-card {
    padding: 28px;
    min-height: 360px;
}

.dropzone {
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 2px dashed #cdd3e2;
    border-radius: 14px;
    background: var(--surface-soft);
    text-align: center;
    cursor: pointer;
    transition: .18s ease;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary);
    background: #f2f2ff;
}

.dropzone.loading {
    cursor: wait;
    pointer-events: none;
    border-color: var(--primary);
    background: #f2f2ff;
}

.dropzone-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    margin-bottom: 8px;
    border-radius: 16px;
    background: #e9e9ff;
    color: var(--primary);
    font-size: 28px;
    font-weight: 700;
}

.dropzone-spinner {
    width: 44px;
    height: 44px;
    margin-bottom: 10px;
    border: 4px solid #e5e6fb;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.dropzone strong {
    font-size: 18px;
}

.dropzone span:not(.dropzone-icon),
.dropzone small {
    color: var(--muted);
}

.analysis-strip {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 180px 100px auto;
    gap: 18px;
    align-items: center;
    padding: 18px;
    margin-bottom: 26px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface-soft);
}

.analysis-strip > div {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.analysis-strip strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.project-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.span-2 {
    grid-column: span 2;
}

label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #3d4659;
    font-size: 14px;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 13px;
    color: var(--text);
    background: #fff;
    border: 1px solid #dbe0ea;
    border-radius: 9px;
    outline: none;
    transition: .15s;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(91, 92, 226, .12);
}

textarea {
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
}

label small,
.field-group small {
    color: var(--muted);
    font-weight: 400;
}

.field-heading,
.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.field-heading {
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
}

.section-heading h2 {
    margin: 0 0 4px;
    font-size: 19px;
}

.section-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.text-button {
    padding: 0;
    color: var(--primary);
    background: none;
    border: 0;
    cursor: pointer;
    font-weight: 650;
}

.webhook-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.webhook-input-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.remove-webhook {
    width: 42px;
    color: var(--danger);
    background: #fff3f4;
    border: 0;
    border-radius: 9px;
    cursor: pointer;
    font-size: 18px;
}

.settings-section {
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.option-row {
    margin: 18px 0;
}

.check-label {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.check-label input,
.radio-option input {
    width: auto;
}

.url-fieldset {
    margin: 0;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.url-fieldset legend {
    padding: 0 8px;
    color: #3d4659;
    font-size: 14px;
    font-weight: 650;
}

.radio-option {
    flex-direction: row;
    align-items: center;
    gap: 9px;
    margin: 7px 0;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 9px;
    cursor: pointer;
    font-weight: 700;
    transition: .15s;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    color: #fff;
    background: var(--primary);
}

.button-primary:hover {
    color: #fff;
    background: var(--primary-dark);
}

.button:disabled {
    opacity: .55;
    cursor: wait;
    transform: none !important;
}

.button-secondary {
    color: #3f43b8;
    background: #ededff;
}

.button-ghost {
    color: #4d566a;
    background: #fff;
    border-color: var(--line);
}

.button-danger-soft {
    color: #b83f4c;
    background: #fff0f1;
}

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

.button-danger:hover {
    color: #fff;
    background: #b83f4c;
}

.button-small {
    min-height: 34px;
    padding: 7px 11px;
    font-size: 13px;
}

.button-full {
    width: 100%;
}

.alert {
    margin-bottom: 18px;
    padding: 13px 15px;
    border-radius: 10px;
    font-size: 14px;
}

.alert-error {
    color: #9e2e3a;
    background: #fff0f1;
    border: 1px solid #ffd8dc;
}

.alert-success {
    color: #08784c;
    background: #eaf9f2;
    border: 1px solid #c7f0df;
}

.missing-list {
    padding: 16px;
    color: #7b4d08;
    background: #fff8e8;
    border: 1px solid #f3dfad;
    border-radius: 10px;
}

.missing-list ul {
    margin: 9px 0 0;
    padding-left: 20px;
}

.progress-panel,
.success-panel {
    min-height: 360px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.progress-panel h2,
.success-panel h2 {
    margin: 20px 0 7px;
}

.progress-panel p,
.success-panel p {
    margin: 0 0 22px;
    color: var(--muted);
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid #e5e6fb;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

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

.progress-track {
    width: min(560px, 100%);
    height: 9px;
    overflow: hidden;
    background: #e9ecf3;
    border-radius: 99px;
}

.progress-track.large {
    width: 100%;
    height: 11px;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--primary), #8586f2);
    border-radius: inherit;
    transition: width .25s ease;
}

#progress-numbers {
    margin-top: 10px;
}

.success-mark {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    color: #fff;
    background: var(--success);
    border-radius: 50%;
    font-size: 30px;
    font-weight: 800;
}

.success-actions {
    display: flex;
    gap: 10px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.metric-card {
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 15px;
    box-shadow: 0 7px 24px rgba(29, 40, 70, .05);
}

.metric-card span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.metric-card strong {
    font-size: 27px;
    letter-spacing: -.03em;
}

.metric-card small {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.metric-card-attention strong {
    color: var(--danger);
}

.estimate-card strong {
    font-size: 22px;
}

.estimate-cell strong,
.estimate-cell small {
    display: block;
}

.estimate-cell small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.list-toolbar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(220px, 300px) auto;
    gap: 14px;
    align-items: end;
    padding: 18px;
    margin-bottom: 20px;
}

.list-toolbar small {
    grid-column: 1 / -1;
    color: var(--muted);
}

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

.table-card {
    overflow: hidden;
}

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

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

th,
td {
    padding: 15px 18px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

th {
    color: var(--muted);
    background: #fafbfc;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

td {
    font-size: 14px;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.project-name-cell {
    min-width: 270px;
}

.project-name-cell a {
    color: var(--text);
    font-weight: 700;
}

.mini-progress {
    height: 4px;
    margin-top: 8px;
    overflow: hidden;
    background: #eceef4;
    border-radius: 99px;
}

.mini-progress span {
    display: block;
    height: 100%;
    background: var(--primary);
}

.status {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 700;
}

.status-active,
.status-sent {
    color: #08784c;
    background: #e7f8f0;
}

.status-paused,
.status-retry {
    color: #9a650e;
    background: #fff5dc;
}

.status-completed {
    color: #4a4ebd;
    background: #ededff;
}

.status-failed {
    color: #ae3542;
    background: #ffebed;
}

.status-processing,
.status-pending {
    color: #3266a8;
    background: #eaf3ff;
}

.empty-state {
    padding: 58px 24px;
    text-align: center;
}

.empty-state h2 {
    margin: 0 0 7px;
}

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

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 15px 18px;
    border-top: 1px solid var(--line);
}

.pagination-info {
    color: var(--muted);
    font-size: 13px;
}

.pagination-pages {
    display: flex;
    gap: 6px;
}

.page-link {
    display: grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
}

.page-link:hover,
.page-link.active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.project-heading {
    align-items: center;
}

.progress-card {
    padding: 21px;
    margin-bottom: 20px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 11px;
}

.warning-text {
    margin: 12px 0 0;
    color: var(--warning);
    font-size: 13px;
}

.two-column {
    display: grid;
    grid-template-columns: .8fr 1.2fr;
    gap: 20px;
}

.inline-form {
    display: flex;
    gap: 9px;
}

.inline-form input {
    flex: 1;
}

.webhook-admin-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.webhook-admin-item {
    display: flex;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.webhook-edit-form {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 92px auto;
    gap: 8px;
}

.limit-input {
    min-width: 80px;
}

.add-webhook-details summary {
    color: var(--primary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
}

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

.danger-zone {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-top: 20px;
    border-color: #f3cbd0;
}

.danger-zone h2 {
    margin-bottom: 6px;
    color: #a93643;
}

.danger-zone p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.jobs-table .error-cell {
    max-width: 310px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.error-page {
    max-width: 640px;
    margin: 60px auto;
    text-align: center;
}

.login-card {
    width: min(410px, 100%);
    padding: 34px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.login-logo {
    width: 48px;
    height: 48px;
    margin-bottom: 18px;
}

.login-card h1 {
    margin: 0 0 4px;
}

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

.stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
}

.hidden {
    display: none !important;
}

@media (max-width: 880px) {
    .topbar {
        height: auto;
        padding: 12px 18px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .nav {
        order: 3;
        width: 100%;
        overflow-x: auto;
    }

    .nav a {
        min-height: 42px;
    }

    .container {
        padding: 26px 16px 50px;
    }

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

    .two-column {
        grid-template-columns: 1fr;
    }

    .analysis-strip {
        grid-template-columns: 1fr 1fr;
    }

    .analysis-strip .button {
        justify-self: start;
    }

    .list-toolbar {
        grid-template-columns: 1fr 1fr;
    }

    .toolbar-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 620px) {
    .brand span:last-child {
        display: none;
    }

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

    .span-2 {
        grid-column: span 1;
    }

    .analysis-strip {
        grid-template-columns: 1fr;
    }

    .list-toolbar {
        grid-template-columns: 1fr;
    }

    .toolbar-actions {
        grid-column: auto;
        flex-wrap: wrap;
    }

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

    .page-heading {
        flex-direction: column;
    }

    .webhook-admin-item {
        flex-direction: column;
    }

    .webhook-edit-form {
        grid-template-columns: 1fr;
    }

    .inline-form {
        flex-direction: column;
    }

    .danger-zone {
        align-items: stretch;
        flex-direction: column;
    }
}