:root {
    --bg-page: #f7f8fa;
    --bg-soft: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #fbfcfd;
    --surface-3: #f8fafc;
    --line: #e5e7eb;
    --line-strong: #d8dee6;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #155a99;
    --primary-soft: #eef5fb;
    --primary-dark: #0f3f6d;
    --accent: #f29a00;
    --accent-soft: #fff7eb;
    --success: #067647;
    --success-soft: #ecfdf3;
    --error: #b42318;
    --error-soft: #fef3f2;
    --warning: #b54708;
    --warning-soft: #fff7ed;
    --shadow-sm: 0 8px 20px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 18px 40px rgba(15, 23, 42, 0.06);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --maxw: 1280px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: Inter, Arial, sans-serif;
    color: var(--text);
    background: linear-gradient(180deg, #fbfcfd 0%, #f6f8fb 100%);
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select { font: inherit; }
.site-shell { min-height: 100vh; }
.wrap { width: min(var(--maxw), calc(100% - 32px)); margin: 0 auto; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}
.topbar-inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 24px;
    align-items: center;
    padding: 14px 0;
}
.brandmark {
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: 18px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}
.brandmark img { height: 38px; }
.topbar-copy {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
    max-width: 760px;
}
.top-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.top-links a {
    padding: 10px 14px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--text);
    transition: .2s ease;
}
.top-links a:hover {
    border-color: rgba(21, 90, 153, 0.24);
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.hero { padding: 32px 0 24px; }
.hero-grid,
.hero-grid-wide {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, .85fr);
    gap: 24px;
    align-items: stretch;
}
.hero-copy,
.hero-card,
.card,
.auth-card {
    border-radius: var(--radius-xl);
    background: var(--surface);
    border: 1px solid rgba(15, 23, 42, 0.06);
    box-shadow: var(--shadow-md);
}
.hero-copy {
    padding: 42px;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at right bottom, rgba(242, 154, 0, 0.10), transparent 24%),
        linear-gradient(180deg, #ffffff 0%, #f7fafc 100%);
}
.hero-copy::after {
    content: "";
    position: absolute;
    inset: auto -40px -46px auto;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(21, 90, 153, 0.08), transparent 70%);
}
.hero-copy-compact { padding: 36px; }
.hero-card {
    padding: 20px;
    display: grid;
    gap: 14px;
    align-content: start;
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
}
.hero-stack-card .metric { min-height: 110px; }

.eyebrow,
.section-kicker,
.section-kicker-light {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.eyebrow,
.section-kicker {
    color: var(--primary);
    background: var(--primary-soft);
    border: 1px solid rgba(21, 90, 153, 0.12);
    margin-bottom: 16px;
}
.section-kicker-light {
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid rgba(242, 154, 0, 0.14);
    margin-bottom: 16px;
}

h1 {
    margin: 0 0 14px;
    font-size: clamp(2.4rem, 5vw, 4rem);
    line-height: 1.02;
    letter-spacing: -0.04em;
    max-width: 760px;
}
.lead {
    margin: 0;
    max-width: 760px;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.8;
}
.hero-actions,
.form-actions,
.selection-actions,
.table-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.hero-actions { margin-top: 26px; }
.form-actions,
.table-actions { margin-top: 18px; }
.hero-points {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 22px;
}
.hero-points span {
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--surface-3);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 14px;
}
.metric {
    padding: 18px;
    border-radius: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
}
.metric strong {
    display: block;
    font-size: 1.85rem;
    color: var(--primary-dark);
    margin-bottom: 4px;
}
.metric span { color: var(--muted); }
.metric-accent {
    background: linear-gradient(180deg, #fffdf8 0%, #fff7ea 100%);
    border-color: rgba(242, 154, 0, 0.18);
}

.auth-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    padding-bottom: 44px;
}
.span-all { grid-column: 1 / -1; }
.card,
.auth-card { padding: 28px; }
.auth-form { display: grid; gap: 14px; }
.portal-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.85fr);
    gap: 24px;
    align-items: start;
    padding-bottom: 44px;
}
.portal-main,
.portal-sidebar {
    min-width: 0;
}
.portal-main {
    display: grid;
    gap: 20px;
}
.portal-sidebar {
    display: grid;
    gap: 20px;
    align-content: start;
}
.portal-sidebar .card {
    width: 100%;
}
.card-dark {
    background: linear-gradient(180deg, #ffffff 0%, #f9fbfd 100%);
    color: var(--text);
    border: 1px solid rgba(15, 23, 42, 0.06);
}
.card-dark .muted { color: var(--muted); }

.card-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.card-head > .muted {
    max-width: 320px;
    text-align: right;
}
.card h2,
.auth-card h2 {
    margin: 0 0 6px;
    font-size: 1.85rem;
    letter-spacing: -0.03em;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }

.panel {
    padding: 22px;
    border-radius: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
}
.panel h3 { margin-top: 0; }
.panel-tint { background: linear-gradient(180deg, #ffffff 0%, #fafcfe 100%); }
.panel-accent { background: linear-gradient(180deg, #ffffff 0%, #fffaf1 100%); }

.form-grid,
.enterprise-form-grid,
.detail-grid,
.stats-grid {
    display: grid;
    gap: 18px;
}
.form-grid,
.enterprise-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail-grid,
.stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 18px;
}
.detail-box,
.stat {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-2);
}
.detail-box span,
.stat span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}
.detail-box strong,
.stat strong {
    display: block;
    font-size: 1.2rem;
    margin: 4px 0 8px;
}

label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
}
input[type=text],
input[type=password],
input[type=email],
select {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    transition: .2s ease;
}
input:focus,
select:focus {
    outline: none;
    border-color: rgba(21, 90, 153, 0.4);
    box-shadow: 0 0 0 4px rgba(21, 90, 153, 0.08);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-weight: 700;
    cursor: pointer;
    transition: .2s ease;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
    background: #fff;
    color: var(--text);
    border-color: var(--line);
}
.btn-secondary:hover,
.btn-ghost:hover {
    background: var(--primary-soft);
    border-color: rgba(21, 90, 153, 0.18);
    color: var(--primary-dark);
}
.btn-ghost {
    background: #fff;
    color: var(--primary-dark);
    border-color: var(--line);
}
.btn-full { width: 100%; }

.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.selection-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    margin-bottom: 14px;
}
.selection-meta { display: grid; gap: 4px; }
.progress-card {
    padding: 16px 18px;
    border-radius: 16px;
    background: var(--surface-3);
    border: 1px solid var(--line);
    margin-bottom: 16px;
}
.progress-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.progress-bar {
    height: 10px;
    background: #e8eef5;
    border-radius: 999px;
    overflow: hidden;
}
.progress-bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #3f80bf);
    border-radius: 999px;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
}
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
}
th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid #eef2f6;
    text-align: left;
    vertical-align: top;
}
th {
    background: #fafbfc;
    font-size: 12px;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #718096;
}

.pill,
.status {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.pill-directory,
.status-running {
    background: var(--primary-soft);
    color: var(--primary);
}
.pill-file,
.status-completed,
.status-completed_with_errors {
    background: var(--success-soft);
    color: var(--success);
}
.status-failed {
    background: var(--error-soft);
    color: var(--error);
}

.alert {
    padding: 14px 16px;
    border-radius: 16px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert-success {
    background: var(--success-soft);
    color: var(--success);
    border-color: #b7efd0;
}
.alert-error {
    background: var(--error-soft);
    color: var(--error);
    border-color: #f7c4c0;
}
.alert-warning {
    background: var(--warning-soft);
    color: var(--warning);
    border-color: #fcd8bd;
}

.job-list,
.log-list { display: grid; gap: 12px; }
.job-item,
.log {
    display: grid;
    gap: 6px;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #fff;
}
.job-item strong { display: block; }
.job-item span { color: var(--muted); }
.log span {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.log-success span { color: var(--success); }
.log-error span { color: var(--error); }
.log-info span { color: var(--primary); }

.check-list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 10px;
}
.admin-inline-form {
    display: grid;
    gap: 8px;
    min-width: 260px;
}

.accounts-table-wrap {
    overflow-x: auto;
}
.accounts-table {
    min-width: 0;
    table-layout: fixed;
}
.accounts-table th:nth-child(1) { width: 24%; }
.accounts-table th:nth-child(2) { width: 24%; }
.accounts-table th:nth-child(3) { width: 14%; }
.accounts-table th:nth-child(4) { width: 14%; }
.accounts-table th:nth-child(5) { width: 24%; }
.accounts-table td:last-child,
.accounts-table th:last-child {
    min-width: 280px;
}
.account-primary strong,
.account-login {
    font-size: 1.02rem;
    line-height: 1.35;
}
.account-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}
.admin-inline-form-compact {
    min-width: 0;
    width: 100%;
    gap: 10px;
}
.admin-inline-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.admin-inline-row-submit {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}
.admin-inline-form-compact input,
.admin-inline-form-compact select {
    width: 100%;
}
.admin-inline-form-compact .btn {
    white-space: nowrap;
}
.compact-hero { padding-bottom: 20px; }
.portal-sidebar .card:first-child {
    position: sticky;
    top: 92px;
}
.enterprise-form-grid {
    align-items: start;
}
.enterprise-form-grid .panel {
    min-width: 0;
}
.table-wrap,
.job-list,
.log-list {
    min-width: 0;
}
.portal-main .card,
.portal-sidebar .card {
    overflow: hidden;
}
code {
    padding: 4px 8px;
    border-radius: 10px;
    background: var(--surface-3);
    border: 1px solid var(--line);
}

@media (max-width: 980px) {
    .topbar-inner,
    .hero-grid,
    .hero-grid-wide,
    .auth-grid,
    .portal-layout,
    .form-grid,
    .enterprise-form-grid,
    .stats-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .topbar-copy { display: none; }
    .card-head-stack-mobile,
    .selection-toolbar,
    .card-head {
        flex-direction: column;
        align-items: flex-start;
    }
    .card-head > .muted {
        max-width: none;
        text-align: left;
    }
    .portal-sidebar .card:first-child {
        position: static;
    }
    table { min-width: 640px; }
    .accounts-table { min-width: 860px; }
    .admin-inline-row,
    .admin-inline-row-submit { grid-template-columns: 1fr; }
}
.progress-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
    color: var(--muted);
    font-size: 14px;
}
.progress-card-lg {
    padding: 20px;
}
.job-action-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 18px 0 6px;
}
.mini-progress {
    margin-top: 10px;
    height: 8px;
    background: var(--bg-soft);
    border-radius: 999px;
    overflow: hidden;
}
.mini-progress span,
.progress-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary) 0%, #3b82f6 100%);
}
.job-item-rich {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: start;
}
.stats-grid-jobs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.log-list {
    display: grid;
    gap: 10px;
}
.log {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: start;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-2);
}
.log span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--bg-soft);
    color: var(--primary-dark);
}
.log p {
    margin: 6px 0 0;
    color: var(--text);
}
.log-success span { background: var(--success-soft); color: var(--success); }
.log-error span { background: var(--error-soft); color: var(--error); }
.log-info span { background: var(--primary-soft); color: var(--primary); }
.status-queued,
.status-running,
.status-paused,
.status-completed,
.status-completed_with_errors,
.status-failed {
    white-space: nowrap;
}
.status-queued { background: var(--bg-soft); color: var(--primary-dark); }
.status-running { background: var(--primary-soft); color: var(--primary-dark); }
.status-paused { background: var(--warning-soft); color: var(--warning); }
.status-completed { background: var(--success-soft); color: var(--success); }
.status-completed_with_errors { background: var(--accent-soft); color: var(--warning); }
.status-failed { background: var(--error-soft); color: var(--error); }
.card-head-inline-gap { margin-top: 24px; }
@media (max-width: 1024px) {
    .stats-grid-jobs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 720px) {
    .progress-meta,
    .job-action-row {
        flex-direction: column;
        align-items: stretch;
    }
    .stats-grid-jobs {
        grid-template-columns: 1fr;
    }
    .job-item-rich {
        grid-template-columns: 1fr;
    }
}
