:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --panel: #ffffff;
    --text: #172026;
    --muted: #5e6b74;
    --line: #d8e0e5;
    --accent: #176b87;
    --accentSoft: #e7f1f4;
    --locked: #8a4b12;
    --ready: #246b3d;
    --blocked: #9d2222;
    --warningText: #7a3f00;
    --shadow: 0 10px 26px rgba(23, 32, 38, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Segoe UI, Arial, sans-serif;
    font-size: 14px;
    overflow-x: hidden;
}

body::selection {
    background: #c9e5ee;
}

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

.topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    justify-content: space-between;
    align-items: start;
    gap: 24px;
    padding: 18px 28px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    min-width: 0;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 1px 0 rgba(216, 224, 229, 0.5);
}

.brand-block {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.brand-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    flex: 0 0 auto;
    box-shadow: var(--shadow);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    width: max-content;
    max-width: 100%;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 3px;
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.app-nav a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 6px;
    color: var(--muted);
    transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.app-nav a:hover,
.app-nav a.active {
    background: var(--accentSoft);
    color: var(--accent);
}

.app-nav a:hover {
    transform: translateY(-1px);
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 22px;
}

h2 {
    font-size: 16px;
    margin-bottom: 14px;
}

h3 {
    margin: 0;
    font-size: 15px;
}

p {
    color: var(--muted);
    margin-top: 4px;
    overflow-wrap: anywhere;
}

.layout {
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: 24px;
    min-width: 0;
    animation: page-in 180ms ease-out both;
}

.layout.dashboard-layout {
    max-width: none;
    padding-left: 18px;
    padding-right: 18px;
}

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

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
    min-width: 0;
    overflow: hidden;
    transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.panel:hover {
    border-color: #c7d3da;
}

.stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

.stats strong {
    display: block;
    font-size: 26px;
}

.stats span,
dt {
    color: var(--muted);
}

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

th,
td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
    word-break: break-word;
}

th {
    color: var(--muted);
    font-weight: 600;
}

.table-panel {
    padding: 0;
}

.table-panel h2 {
    padding: 16px 16px 0;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

.table-scroll table {
    min-width: 1320px;
}

.dashboard-layout .table-scroll table {
    min-width: 980px;
}

.jobs-table th:nth-child(1),
.jobs-table td:nth-child(1) {
    width: 190px;
}

.jobs-table th:nth-child(2),
.jobs-table td:nth-child(2),
.jobs-table th:nth-child(3),
.jobs-table td:nth-child(3) {
    width: 220px;
}

.jobs-table th:nth-child(4),
.jobs-table td:nth-child(4) {
    width: 210px;
}

.jobs-table th:nth-child(5),
.jobs-table td:nth-child(5),
.jobs-table th:nth-child(6),
.jobs-table td:nth-child(6),
.jobs-table th:nth-child(7),
.jobs-table td:nth-child(7) {
    width: 190px;
}

.jobs-table th:nth-child(8),
.jobs-table td:nth-child(8) {
    width: 170px;
}

.jobs-panel {
    padding: 0;
}

.jobs-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.bulk-run-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.select-all-row {
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

.bulk-run-result {
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
    background: #f9fbfc;
}

.bulk-run-result ul {
    margin: 8px 0 0;
    padding-left: 18px;
    color: var(--muted);
}

.jobs-panel-head h2 {
    margin: 0;
}

.jobs-panel-head p {
    max-width: 560px;
    text-align: right;
}

.jobs-list {
    display: grid;
}

.job-row {
    display: grid;
    grid-template-columns: minmax(160px, 0.7fr) minmax(260px, 1.15fr) minmax(420px, 1.75fr) minmax(130px, 0.45fr);
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    min-width: 0;
}

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

.job-main,
.job-endpoints,
.job-status-grid,
.job-row-actions {
    min-width: 0;
}

.job-main {
    display: grid;
    align-content: start;
    gap: 6px;
}

.job-title {
    font-size: 15px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.job-select-row {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    font-weight: 400;
}

.job-select-row input {
    width: auto;
    margin-top: 3px;
}

.job-label {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

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

.job-endpoints > div,
.job-status-grid > div {
    display: grid;
    align-content: start;
    gap: 6px;
    min-width: 0;
}

.job-endpoints strong {
    font-weight: 500;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.job-status-grid {
    display: grid;
    grid-template-columns: minmax(170px, 1.05fr) repeat(3, minmax(120px, 0.8fr));
    gap: 14px;
    min-width: 0;
}

.job-status-grid .inline-notes {
    margin-top: 2px;
}

.job-row-actions {
    display: grid;
    align-content: start;
    gap: 8px;
}

.job-row-actions .actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.job-row-actions .actions a {
    gap: 6px;
    white-space: nowrap;
}

.job-row-actions button {
    min-height: 28px;
    padding: 0;
    background: transparent;
    color: var(--accent);
    box-shadow: none;
    justify-content: flex-start;
}

.job-row-actions .job-toggle {
    background: #4f6069;
    color: #fff;
    padding: 4px 10px;
}

.job-row-actions .job-toggle:focus-visible {
    outline: 2px solid #176b87;
    outline-offset: 2px;
}

.job-row-actions button:hover {
    box-shadow: none;
}

.empty-state {
    padding: 18px;
}

.filter-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.dashboard-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    position: sticky;
    top: 84px;
    z-index: 10;
}

.tab-button {
    background: transparent;
    color: var(--muted);
    border: 1px solid transparent;
    box-shadow: none;
}

.tab-button:hover {
    box-shadow: none;
}

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

.dashboard-tab-panel[hidden] {
    display: none;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 16px;
}

.button.disabled,
button.disabled {
    opacity: 0.52;
    pointer-events: none;
    box-shadow: none;
    transform: none;
}

.summary-chips {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.summary-chip {
    display: grid;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
    background: #fbfcfd;
}

.summary-chip strong {
    font-size: 24px;
}

.summary-chip span {
    color: var(--muted);
}

.run-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.55fr);
    gap: 18px;
    align-items: start;
}

.run-hero h2 {
    margin-bottom: 6px;
    font-size: 22px;
}

.run-hero dl {
    grid-template-columns: 90px minmax(0, 1fr);
    gap: 7px 12px;
}

.scheduler-panel {
    padding: 0;
}

.scheduler-panel .stats {
    border-bottom: 1px solid var(--line);
    margin: 0;
    padding: 14px 18px;
}

.scheduler-decisions {
    display: grid;
}

.scheduler-decision {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr) max-content;
    gap: 14px;
    align-items: start;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
}

.scheduler-decision:last-child {
    border-bottom: 0;
}

.scheduler-decision a {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.action-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.button.compact {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 14px;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid currentColor;
}

.pill.locked {
    color: var(--locked);
}

.pill.ready {
    color: var(--ready);
}

.pill.warning {
    color: var(--warningText);
}

.pill.blocked {
    color: var(--blocked);
}

.pill.success {
    color: var(--ready);
}

.pill.failed {
    color: var(--blocked);
}

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

.pill.running {
    color: var(--accent);
}

.pill.queued {
    color: var(--accent);
}

.pill.complete {
    color: var(--ready);
}

.pill.cancelled,
.pill.blocked {
    color: var(--warningText);
}

.progress {
    display: grid;
    gap: 6px;
    min-width: 140px;
}

.progress.large {
    min-width: 0;
}

.progress-bar {
    width: 100%;
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: #e4ebef;
}

.progress-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 220ms ease;
}

.progress-meta {
    display: grid;
    gap: 2px;
}

.progress-meta small,
.cell-note {
    color: var(--muted);
    font-size: 12px;
}

.inline-notes,
.health-list {
    margin: 8px 0 0;
    padding-left: 18px;
    color: var(--muted);
}

.inline-notes {
    font-size: 12px;
}

.button,
button {
    appearance: none;
    border: 0;
    background: var(--accent);
    color: #fff;
    border-radius: 5px;
    padding: 9px 14px;
    font: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.button:hover,
button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.button.secondary {
    background: #4f6069;
}

button.secondary {
    background: #4f6069;
}

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

.header-actions {
    justify-content: flex-end;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--muted);
    background: #fbfcfd;
}

td .actions {
    align-items: flex-start;
}

.jobs-table td .actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.actions a {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
}

.icon {
    width: 17px;
    height: 17px;
    display: inline-block;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.brand-mark .icon {
    width: 21px;
    height: 21px;
}

.floating-run-action {
    width: 100%;
    max-width: 1320px;
    margin: 14px auto 0;
    padding: 0 24px;
    display: flex;
    justify-content: flex-end;
    animation: page-in 180ms ease-out both;
}

dl {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px 16px;
    margin: 0;
}

dd {
    margin: 0;
    overflow-wrap: anywhere;
    min-width: 0;
}

pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    background: #f1f4f6;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 12px;
    max-width: 100%;
    overflow-x: auto;
}

.form {
    display: grid;
    gap: 14px;
    max-width: 820px;
}

.auth-layout {
    min-height: 100vh;
    display: grid;
    align-items: center;
    justify-items: center;
}

.auth-card {
    width: min(420px, 100%);
}

.form-section {
    display: grid;
    gap: 14px;
    border-top: 1px solid var(--line);
    padding-top: 16px;
}

.form-section h2 {
    margin: 0;
    font-size: 18px;
}

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

.check-row input[type="checkbox"] {
    width: auto;
}

.danger-option {
    color: var(--blocked);
}

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

.endpoint-section {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 16px;
}

.source-section {
    border-left: 4px solid var(--ready);
}

.destination-section {
    border-left: 4px solid var(--accent);
}

.endpoint-summary {
    grid-column: 1 / -1;
}

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

.endpoint-card {
    display: grid;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 14px;
    min-width: 0;
}

.sync-context {
    display: grid;
    gap: 14px;
}

.sync-context-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.sync-context-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr);
    align-items: stretch;
    gap: 12px;
}

.sync-endpoint-card {
    display: grid;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 14px;
    min-width: 0;
    background: #fbfcfd;
}

.sync-endpoint-card h3 {
    font-size: 16px;
}

.sync-endpoint-card dl {
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 7px 12px;
}

.sync-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.sync-arrow .icon {
    width: 24px;
    height: 24px;
}

.sync-policy-strip {
    border-top: 1px solid var(--line);
    padding-top: 12px;
    grid-template-columns: repeat(3, max-content minmax(0, 1fr));
    gap: 8px 12px;
}

.direction-summary {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

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

.inline-fields {
    display: grid;
    grid-template-columns: minmax(90px, 0.45fr) minmax(130px, 0.55fr);
    gap: 10px;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 9px 10px;
    font: inherit;
    min-width: 0;
}

.error {
    color: #9d2222;
}

.warning {
    color: #7a3f00;
    background: #fff7e8;
    border-color: #f0c36b;
}

.info {
    color: #155e75;
    background: #ecfeff;
    border-color: #67e8f9;
}

.tree {
    max-height: 520px;
    overflow: auto;
}

.tree-list {
    list-style: none;
    margin: 0;
    padding-left: 24px;
}

.tree > .tree-list {
    padding-left: 0;
}

.tree-node {
    margin: 0;
}

.tree-row {
    display: grid;
    grid-template-columns: 22px 20px minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    min-height: 28px;
}

.tree-list[hidden] {
    display: none;
}

.tree-row input[type="checkbox"] {
    margin: 0;
    justify-self: center;
}

.tree-label {
    min-width: 0;
    overflow-wrap: anywhere;
}

.tree-toggle {
    width: 22px;
    height: 22px;
    padding: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text);
    justify-self: center;
    line-height: 1;
}

.tree-spacer {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
}

.full-row {
    grid-column: 1 / -1;
}

@keyframes page-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        transition-duration: 1ms !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 1280px) {
    .job-row {
        grid-template-columns: minmax(150px, 0.65fr) minmax(260px, 1.1fr) minmax(0, 1.5fr);
    }

    .job-row-actions {
        grid-column: 1 / -1;
    }

    .job-row-actions .actions {
        grid-template-columns: repeat(4, max-content);
    }
}

@media (max-width: 1080px) {
    .job-row {
        grid-template-columns: minmax(180px, 0.75fr) minmax(0, 1.25fr);
    }

    .job-status-grid,
    .job-row-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 920px) {
    .jobs-panel-head,
    .job-row,
    .job-endpoints,
    .job-status-grid,
    .run-hero,
    .scheduler-decision {
        grid-template-columns: 1fr;
    }

    .jobs-panel-head {
        display: grid;
    }

    .jobs-panel-head p {
        text-align: left;
    }
}

@media (max-width: 820px) {
    .topbar,
    .layout.two,
    .endpoint-cards,
    .sync-context-grid,
    .grid,
    .stats {
        grid-template-columns: 1fr;
    }

    .sync-arrow {
        justify-content: flex-start;
        min-height: 20px;
    }

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

    .topbar {
        display: grid;
        padding: 18px 16px;
    }

    .header-actions {
        justify-content: flex-start;
    }

    .layout {
        padding: 16px;
    }

    .floating-run-action {
        padding: 0 16px;
        justify-content: flex-start;
    }

    dl {
        grid-template-columns: 1fr;
        gap: 4px 0;
    }

    .panel {
        padding: 14px;
    }

    .table-panel {
        padding: 0;
    }

    .button,
    button {
        width: max-content;
        max-width: 100%;
        white-space: normal;
    }

    .job-row-actions .actions {
        grid-template-columns: repeat(2, max-content);
    }
}

.plan-proceed {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
    background: white;
}
