:root {
    --bg: #06111b;
    --bg-soft: #0d1c29;
    --bg-panel: #112638;
    --surface: rgba(255, 255, 255, 0.98);
    --surface-soft: rgba(17, 38, 56, 0.06);
    --surface-strong: rgba(255, 255, 255, 0.92);
    --line: #d8e3ed;
    --line-soft: rgba(216, 227, 237, 0.7);
    --text: #122033;
    --text-soft: #607085;
    --text-muted: #7d8da1;
    --primary: #0f766e;
    --primary-strong: #115e59;
    --accent: #0ea5e9;
    --accent-soft: rgba(14, 165, 233, 0.14);
    --success: #15803d;
    --warning: #c26a11;
    --error: #c53030;
    --shadow-lg: 0 30px 80px rgba(4, 14, 26, 0.22);
    --shadow-md: 0 18px 40px rgba(10, 22, 38, 0.12);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Manrope", system-ui, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.22), transparent 22%),
        radial-gradient(circle at right 20%, rgba(14, 165, 233, 0.22), transparent 18%),
        linear-gradient(135deg, var(--bg), #0a1725 38%, #11253c 100%);
}

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

.login-shell,
.dashboard-shell {
    min-height: 100vh;
}

.login-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.login-card,
.dashboard-header,
.filters-card,
.workspace-card,
.table-card,
.chart-card,
.modal-card {
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 18px;
}

.eyebrow {
    background: rgba(17, 94, 89, 0.09);
    color: var(--primary-strong);
}

.login-card h2,
.dashboard-header h1,
.workspace-header h2 {
    font-family: "Space Grotesk", "Manrope", sans-serif;
    letter-spacing: -0.03em;
}

.login-card {
    align-self: center;
    width: 100%;
    max-width: 440px;
    background: rgba(255, 255, 255, 0.98);
    padding: 34px 34px 30px;
    border: 1px solid rgba(255, 255, 255, 0.55);
}

.login-card h2 {
    margin: 0 0 20px;
    font-size: 34px;
    line-height: 1.02;
}

.field-group {
    display: grid;
    gap: 14px;
}

.field-group label {
    font-size: 13px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 0.02em;
}

.field-group input,
.filters-grid input,
.filters-grid select {
    width: 100%;
    min-height: 54px;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px 16px;
    background: #fff;
    color: var(--text);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.field-group input::placeholder,
.filters-grid input::placeholder {
    color: #94a3b8;
}

.field-group input:focus,
.filters-grid input:focus,
.filters-grid select:focus {
    outline: none;
    border-color: rgba(15, 118, 110, 0.54);
    box-shadow: 0 0 0 5px rgba(15, 118, 110, 0.12);
    transform: translateY(-1px);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.table-action,
.section-tab,
.view-tab {
    border: none;
    cursor: pointer;
    font-weight: 800;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.table-action:hover,
.section-tab:hover,
.view-tab:hover {
    transform: translateY(-1px);
}

.primary-btn {
    width: 100%;
    margin-top: 18px;
    min-height: 56px;
    border-radius: 16px;
    padding: 14px 20px;
    color: white;
    background: linear-gradient(135deg, var(--primary-strong), var(--accent));
    box-shadow: 0 18px 32px rgba(15, 118, 110, 0.22);
}

.secondary-btn,
.ghost-btn {
    border-radius: 14px;
    min-height: 46px;
    padding: 11px 16px;
}

.secondary-btn {
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--accent));
}

.ghost-btn {
    background: #edf4f9;
    color: var(--text);
}

.login-error {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(197, 48, 48, 0.1);
    color: var(--error);
    display: none;
}

.login-error.show {
    display: block;
}

.dashboard-shell {
    display: none;
    padding: 24px;
}

.dashboard-wrap {
    max-width: 1600px;
    margin: 0 auto;
    display: grid;
    gap: 18px;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    padding: 28px 30px;
    background: var(--surface);
}

.dashboard-header h1 {
    margin: 0;
    font-size: 34px;
}

.dashboard-header p {
    margin: 10px 0 0;
    color: var(--text-soft);
}

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

.header-user {
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 13px;
    color: var(--text-soft);
    background: var(--surface-soft);
}

.filters-card,
.workspace-card,
.table-card,
.chart-card,
.modal-card {
    background: var(--surface);
}

.filters-card {
    padding: 24px 26px;
}

.filters-title {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 18px;
}

.filters-title h2,
.table-header h2,
.chart-card h3,
.workspace-header h2 {
    margin: 0;
}

.filters-title p,
.workspace-header p,
.table-header p {
    margin: 8px 0 0;
    color: var(--text-soft);
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.filters-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.workspace-card {
    padding: 24px 26px 26px;
}

.workspace-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 20px;
}

.section-tabs,
.view-tabs {
    display: inline-flex;
    gap: 10px;
    padding: 6px;
    background: #eef4f8;
    border-radius: 999px;
}

.section-tab,
.view-tab {
    padding: 11px 18px;
    border-radius: 999px;
    background: transparent;
    color: var(--text-soft);
}

.section-tab.active,
.view-tab.active {
    background: linear-gradient(135deg, var(--primary-strong), var(--accent));
    color: white;
    box-shadow: 0 10px 20px rgba(15, 118, 110, 0.18);
}

.section-panel {
    display: grid;
    gap: 18px;
}

.stats-grid,
.charts-grid {
    display: grid;
    gap: 16px;
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stat-card {
    padding: 22px 22px 24px;
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 250, 253, 0.98));
    border: 1px solid rgba(216, 227, 237, 0.85);
    box-shadow: var(--shadow-md);
    border-top: 5px solid var(--primary);
}

.stat-card.success { border-top-color: var(--success); }
.stat-card.warning { border-top-color: var(--warning); }
.stat-card.error { border-top-color: var(--error); }

.stat-label {
    margin-bottom: 10px;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stat-value {
    font-family: "Space Grotesk", "Manrope", sans-serif;
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.04em;
}

.charts-grid {
    grid-template-columns: repeat(2, minmax(320px, 1fr));
}

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

.chart-card {
    padding: 22px;
    border: 1px solid rgba(216, 227, 237, 0.8);
}

.chart-card h3 {
    margin-bottom: 16px;
}

.chart-card canvas {
    width: 100% !important;
    height: 290px !important;
}

.chart-empty {
    display: none;
    min-height: 280px;
    border: 1px dashed var(--line);
    border-radius: 18px;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
    background: #f7fafc;
    font-weight: 800;
}

.table-card {
    padding: 22px 24px;
    border: 1px solid rgba(216, 227, 237, 0.8);
}

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

.table-wrap {
    overflow-x: auto;
    border: 1px solid rgba(216, 227, 237, 0.9);
    border-radius: 18px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    padding: 14px 14px;
    border-bottom: 1px solid #eef3f7;
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f8fbfd;
}

th {
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.status-badge,
.stage-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-success {
    background: rgba(21, 128, 61, 0.12);
    color: var(--success);
}

.status-warning {
    background: rgba(194, 106, 17, 0.12);
    color: var(--warning);
}

.status-error {
    background: rgba(197, 48, 48, 0.12);
    color: var(--error);
}

.status-in_progress,
.status-unknown {
    background: rgba(96, 112, 133, 0.12);
    color: var(--text-soft);
}

.stage-badge {
    background: rgba(15, 118, 110, 0.12);
    color: var(--primary-strong);
}

.table-action {
    padding: 10px 12px;
    border-radius: 12px;
    background: #e6f7f5;
    color: var(--primary-strong);
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
}

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

.empty-row {
    text-align: center;
    color: var(--text-soft);
    padding: 34px 12px;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 40;
    padding: 32px;
    overflow-y: auto;
    background: rgba(4, 14, 26, 0.65);
}

.modal-card {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

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

.modal-close {
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: #eef4f8;
    cursor: pointer;
    font-size: 18px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

pre {
    overflow-x: auto;
    padding: 16px;
    border-radius: 16px;
    white-space: pre-wrap;
    word-break: break-word;
    background: #08111f;
    color: #d8e8ff;
    font-size: 12px;
}

.steps-list {
    display: grid;
    gap: 12px;
}

.step-card {
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--line);
}

.step-header,
.step-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-bottom: 10px;
}

.step-meta {
    color: var(--text-soft);
    font-size: 13px;
}

.detail-table {
    width: 100%;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 50;
    min-width: 280px;
    max-width: 460px;
    padding: 14px 16px;
    border-radius: 16px;
    color: white;
    font-weight: 800;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: linear-gradient(135deg, #15803d, #22c55e);
}

.toast-error {
    background: linear-gradient(135deg, #b91c1c, #ef4444);
}

code {
    font-family: "SFMono-Regular", ui-monospace, "Cascadia Mono", monospace;
    font-size: 0.93em;
}

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

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

@media (max-width: 900px) {
    .dashboard-shell,
    .login-shell {
        padding: 14px;
    }

    .dashboard-header,
    .filters-card,
    .workspace-card,
    .table-card,
    .modal-card,
    .login-card {
        padding: 18px;
        border-radius: 22px;
    }

    .dashboard-header,
    .workspace-header,
    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions,
    .section-tabs,
    .view-tabs {
        width: 100%;
    }

    .section-tabs,
    .view-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

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

    .page-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .modal {
        padding: 14px;
    }
}

@media (max-width: 640px) {
    .login-card h2,
    .dashboard-header h1 {
        font-size: 28px;
    }

    .stat-value {
        font-size: 28px;
    }

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