:root {
    --background: #f8fafc;
    --foreground: #0f172a;
    --card: #ffffff;
    --card-foreground: #0f172a;
    --muted: #f1f5f9;
    --muted-foreground: #64748b;
    --border: #e2e8f0;
    --primary: #0f172a;
    --primary-foreground: #f8fafc;
    --warning: #92400e;
    --warning-background: #fffbeb;
    --success: #047857;
    --radius: 0.75rem;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--foreground);
    background: var(--background);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--background); color: var(--foreground); }
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; }
.topbar {
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    min-height: 4.5rem;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(12px);
}

.brand { align-items: center; display: flex; gap: 0.75rem; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.2; }
.brand small, .operator-copy small { color: var(--muted-foreground); font-size: 0.75rem; }
.brand-logo { display: block; height: 2.5rem; object-fit: contain; width: auto; }
.brand-logo-large { height: auto; max-width: 100%; width: 12rem; }
.primary-nav { align-items: center; display: flex; gap: 0.25rem; margin-right: auto; margin-left: 2rem; }
.primary-nav a { border-radius: 0.45rem; color: var(--muted-foreground); font-size: 0.85rem; font-weight: 600; padding: 0.5rem 0.75rem; }
.primary-nav a:hover { background: var(--muted); color: var(--foreground); }
.primary-nav a.active { background: var(--muted); color: var(--foreground); }

.operator-menu, .operator-copy { align-items: center; display: flex; }
.operator-menu { gap: 1rem; }
.operator-copy { align-items: flex-end; flex-direction: column; }
.operator-copy span { font-size: 0.875rem; font-weight: 600; }

.page-container { margin: 0 auto; max-width: 86rem; padding: 3rem 2rem 5rem; }
.page-heading { align-items: flex-start; display: flex; justify-content: space-between; margin-bottom: 2rem; gap: 2rem; }
.page-heading h1, .auth-intro h1 { font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -0.04em; margin: 0; }
.page-description { color: var(--muted-foreground); font-size: 1rem; line-height: 1.7; margin: 0.75rem 0 0; max-width: 45rem; }
.eyebrow { color: var(--muted-foreground); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; margin: 0 0 0.65rem; text-transform: uppercase; }

.summary-grid { display: grid; gap: 1rem; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 1rem; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03); }
.card-header { padding: 1.4rem 1.4rem 0; }
.card-header h2 { font-size: 1rem; letter-spacing: -0.01em; margin: 0; }
.card-header p { color: var(--muted-foreground); font-size: 0.875rem; line-height: 1.5; margin: 0.4rem 0 0; }
.card-content { padding: 1.4rem; }

.status-line { align-items: flex-start; display: flex; gap: 0.8rem; }
.status-line > div { display: flex; flex-direction: column; gap: 0.2rem; }
.status-line strong { font-size: 0.9rem; }
.status-line small { color: var(--muted-foreground); line-height: 1.5; }
.status-dot { border-radius: 999px; flex: 0 0 auto; height: 0.65rem; margin-top: 0.25rem; width: 0.65rem; }
.status-ready { background: #10b981; box-shadow: 0 0 0 4px #d1fae5; }
.status-pending { background: #f59e0b; box-shadow: 0 0 0 4px #fef3c7; }
.status-error { background: #ef4444; box-shadow: 0 0 0 4px #fee2e2; }
.status-muted { background: #94a3b8; box-shadow: 0 0 0 4px #e2e8f0; }

.badge { border: 1px solid var(--border); border-radius: 999px; display: inline-flex; font-size: 0.75rem; font-weight: 600; padding: 0.35rem 0.65rem; white-space: nowrap; }
.badge-warning { background: var(--warning-background); border-color: #fde68a; color: var(--warning); }
.badge-neutral { background: var(--muted); color: var(--muted-foreground); }
.badge-success { background: #ecfdf5; border-color: #a7f3d0; color: var(--success); }
.badge-error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

.flow-list { display: grid; gap: 0; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.flow-list > div { display: flex; gap: 0.75rem; padding: 0.3rem 1.25rem; }
.flow-list > div:first-child { padding-left: 0; }
.flow-list > div + div { border-left: 1px solid var(--border); }
.flow-list span { align-items: center; background: var(--muted); border-radius: 999px; display: flex; flex: 0 0 auto; font-size: 0.75rem; font-weight: 700; height: 1.75rem; justify-content: center; width: 1.75rem; }
.flow-list p { display: flex; flex-direction: column; gap: 0.25rem; margin: 0; }
.flow-list strong { font-size: 0.875rem; }
.flow-list small { color: var(--muted-foreground); line-height: 1.45; }

.button { border: 0; border-radius: 0.5rem; cursor: pointer; font-size: 0.875rem; font-weight: 600; min-height: 2.4rem; padding: 0.55rem 0.9rem; }
.button-primary { background: var(--primary); color: var(--primary-foreground); }
.button-primary:hover { background: #1e293b; }
.button-secondary { background: white; border: 1px solid var(--border); color: var(--foreground); }
.button-secondary:hover { background: var(--muted); }
.button-danger { background: #b91c1c; color: white; }
.button-danger:hover { background: #991b1b; }
.button:disabled { cursor: wait; opacity: 0.6; }
.button-ghost { background: transparent; color: var(--muted-foreground); }
.button-ghost:hover { background: var(--muted); color: var(--foreground); }
.button-full { margin-top: 0.4rem; width: 100%; }

.auth-body { background: #f1f5f9; }
.auth-shell { align-items: center; display: grid; gap: clamp(3rem, 8vw, 8rem); grid-template-columns: minmax(0, 1fr) minmax(20rem, 28rem); margin: 0 auto; max-width: 70rem; min-height: 100vh; padding: 3rem 2rem; }
.auth-intro > p:last-child { color: var(--muted-foreground); line-height: 1.7; max-width: 32rem; }
.auth-intro .eyebrow { margin-top: 2rem; }
.login-card { box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08); }
.login-card .card-header { padding: 2rem 2rem 0; }
.login-card .card-header h2 { font-size: 1.5rem; }
.login-card .card-content { padding: 2rem; }
.login-form { display: flex; flex-direction: column; gap: 0.55rem; }
.login-form label { font-size: 0.85rem; font-weight: 600; margin-top: 0.55rem; }
.input { background: white; border: 1px solid var(--border); border-radius: 0.5rem; color: var(--foreground); min-height: 2.65rem; outline: none; padding: 0.55rem 0.75rem; width: 100%; }
.input:focus { border-color: #94a3b8; box-shadow: 0 0 0 3px #e2e8f0; }
.validation-message, .field-validation { color: #b91c1c; font-size: 0.8rem; line-height: 1.4; }
.validation-message:empty, .field-validation:empty { display: none; }
.validation-message ul { list-style: none; margin: 0; padding: 0; }

.heading-actions { align-items: center; display: flex; gap: 0.75rem; }
.empty-state { color: var(--muted-foreground); font-size: 0.9rem; margin: 0; }
.live-data-meta { color: var(--muted-foreground); display: flex; flex-wrap: wrap; font-size: 0.78rem; gap: 0.5rem 1.25rem; margin-bottom: 1rem; }
.table-scroll { overflow-x: auto; }
.data-table { border-collapse: collapse; font-size: 0.8rem; min-width: 100%; white-space: nowrap; }
.data-table th { background: var(--muted); color: var(--muted-foreground); font-size: 0.7rem; letter-spacing: 0.04em; text-align: left; text-transform: uppercase; }
.data-table th, .data-table td { border-bottom: 1px solid var(--border); max-width: 16rem; overflow: hidden; padding: 0.7rem 0.8rem; text-overflow: ellipsis; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.table-note { color: var(--muted-foreground); font-size: 0.75rem; margin: 0.8rem 0 0; }
.configuration-card { margin-top: 1rem; }
.configuration-fields { display: grid; gap: 1rem; grid-template-columns: 2fr 1fr 1fr; }
.configuration-fields label { display: flex; flex-direction: column; gap: 0.45rem; }
.configuration-fields label span { font-size: 0.8rem; font-weight: 600; }
.configuration-fields .input:disabled { background: var(--muted); color: var(--muted-foreground); }
.configuration-errors { background: #fef2f2; border: 1px solid #fecaca; border-radius: 0.5rem; color: #991b1b; margin-bottom: 1rem; padding: 0.75rem 1rem; }
.configuration-errors p { font-size: 0.82rem; margin: 0; }
.configuration-errors p + p { margin-top: 0.35rem; }
.configuration-table td { vertical-align: middle; }
.inline-status { align-items: center; display: inline-flex; font-size: 0.78rem; gap: 0.55rem; }
.inline-status .status-dot { margin-top: 0; }
.comparison-controls { align-items: end; display: grid; gap: 1rem; grid-template-columns: minmax(15rem, 2fr) repeat(2, minmax(9rem, 1fr)) auto auto; }
.comparison-controls label, .result-toolbar label { display: flex; flex-direction: column; gap: 0.45rem; }
.comparison-controls label span, .result-toolbar label span { font-size: 0.8rem; font-weight: 600; }
.comparison-controls .checkbox-field { align-items: center; flex-direction: row; min-height: 2.6rem; }
.checkbox-field input { height: 1rem; width: 1rem; }
.comparison-error { margin: 1rem 0 0; }
.comparison-warnings { background: var(--warning-background); border: 1px solid #fde68a; border-radius: 0.5rem; color: var(--warning); margin-bottom: 1rem; padding: 0.75rem 1rem; }
.comparison-warnings p { font-size: 0.82rem; margin: 0; }
.snapshot-summary { display: grid; gap: 0.75rem; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom: 1.25rem; }
.snapshot-summary > div { background: var(--muted); border-radius: 0.55rem; display: flex; flex-direction: column; padding: 0.8rem; }
.snapshot-summary strong { font-size: 1.2rem; }
.snapshot-summary span { color: var(--muted-foreground); font-size: 0.72rem; margin-top: 0.15rem; }
.result-toolbar { align-items: end; display: grid; gap: 1rem; grid-template-columns: minmax(15rem, 2fr) minmax(11rem, 1fr); margin-bottom: 1rem; }
.comparison-table { min-width: 104rem; }
.stock-table { min-width: 82rem; }
.comparison-table .column-groups th { background: #e2e8f0; color: var(--foreground); text-align: center; }
.mutation-copy { display: block; margin-top: 0.35rem; }
.sync-action-cell { text-align: center; }
.sync-button { align-items: center; background: var(--primary); border: 0; border-radius: 999px; color: white; cursor: pointer; display: inline-flex; height: 2.1rem; justify-content: center; padding: 0; transition: opacity 0.15s ease, transform 0.15s ease; width: 2.1rem; }
.sync-button:hover:not(:disabled) { transform: rotate(18deg); }
.sync-button:disabled { background: #cbd5e1; color: #64748b; cursor: not-allowed; opacity: 0.7; }
.sync-button svg { fill: none; height: 1.05rem; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; width: 1.05rem; }
.sync-spinner { animation: sync-spin 0.8s linear infinite; border: 2px solid rgba(255, 255, 255, 0.45); border-radius: 999px; border-top-color: white; height: 0.9rem; width: 0.9rem; }
.sync-result { border: 1px solid var(--border); border-radius: 0.5rem; margin-top: 1rem; padding: 0.75rem 1rem; }
.sync-result p { margin: 0; }
.sync-result details { margin-top: 0.65rem; }
.sync-result summary { cursor: pointer; font-size: 0.78rem; font-weight: 600; }
.sync-result pre { background: rgba(15, 23, 42, 0.06); border-radius: 0.35rem; margin: 0.5rem 0 0; max-height: 12rem; overflow: auto; padding: 0.65rem; white-space: pre-wrap; }
.sync-result.success { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.sync-result.warning { background: var(--warning-background); border-color: #fde68a; color: var(--warning); }
.sync-result.error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.sync-result.neutral { background: var(--muted); color: var(--muted-foreground); }
.dialog-backdrop { align-items: center; background: rgba(15, 23, 42, 0.58); display: flex; inset: 0; justify-content: center; padding: 1rem; position: fixed; z-index: 1000; }
.sync-dialog { background: var(--background); border: 1px solid var(--border); border-radius: 0.75rem; box-shadow: 0 24px 80px rgba(15, 23, 42, 0.3); max-height: calc(100vh - 2rem); max-width: 42rem; overflow: auto; width: 100%; }
.dialog-header { align-items: flex-start; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; padding: 1.35rem 1.5rem 1.1rem; }
.dialog-header h2 { font-size: 1.25rem; margin: 0.15rem 0 0.3rem; }
.dialog-header p:last-child { color: var(--muted-foreground); font-size: 0.85rem; margin: 0; }
.dialog-close { background: transparent; border: 0; border-radius: 0.35rem; color: var(--muted-foreground); cursor: pointer; font-size: 1.5rem; line-height: 1; padding: 0.2rem 0.4rem; }
.dialog-close:hover:not(:disabled) { background: var(--muted); color: var(--foreground); }
.dialog-body { padding: 1.25rem 1.5rem; }
.dialog-footer { border-top: 1px solid var(--border); display: flex; gap: 0.65rem; justify-content: flex-end; padding: 1rem 1.5rem; }
.sync-identifiers { display: grid; gap: 0.75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1rem; }
.sync-identifiers > div { background: var(--muted); border-radius: 0.5rem; display: flex; flex-direction: column; padding: 0.7rem 0.85rem; }
.sync-identifiers span { color: var(--muted-foreground); font-size: 0.72rem; }
.sync-change-list { border: 1px solid var(--border); border-radius: 0.55rem; overflow: hidden; }
.sync-change-row { align-items: center; display: grid; gap: 0.75rem; grid-template-columns: minmax(6rem, 1fr) minmax(5rem, 1fr) auto minmax(5rem, 1fr); padding: 0.75rem 0.9rem; }
.sync-change-row + .sync-change-row { border-top: 1px solid var(--border); }
.sync-change-row > span:first-child { font-size: 0.8rem; font-weight: 600; }
.sync-change-row del { color: var(--muted-foreground); }
.sync-arrow { color: var(--muted-foreground); }
.sync-empty-state { background: var(--muted); border-radius: 0.55rem; padding: 1rem; }
.sync-empty-state p { color: var(--muted-foreground); font-size: 0.82rem; margin: 0.25rem 0 0; }
.sync-publication-note { background: var(--muted); border-radius: 0.5rem; display: flex; flex-direction: column; gap: 0.2rem; margin-top: 1rem; padding: 0.75rem 0.9rem; }
.sync-publication-note span { color: var(--muted-foreground); font-size: 0.75rem; }
.payload-preview { margin-top: 0.85rem; }
.payload-preview summary { cursor: pointer; font-size: 0.78rem; font-weight: 600; }
.payload-preview pre { background: #0f172a; border-radius: 0.45rem; color: #e2e8f0; margin: 0.5rem 0 0; overflow: auto; padding: 0.8rem; white-space: pre-wrap; }
@keyframes sync-spin { to { transform: rotate(360deg); } }
.pagination { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }
.jobs-table { min-width: 78rem; }
.job-key { color: var(--muted-foreground); display: block; font-size: 0.68rem; margin-top: 0.25rem; }
.job-actions { align-items: center; display: flex; gap: 0.4rem; }
.execute-now { align-items: center; display: inline-flex; gap: 0.4rem; white-space: nowrap; }
.execute-now svg { fill: currentColor; height: 0.85rem; width: 0.85rem; }
.job-delete { color: #b91c1c; }
.jobs-empty { align-items: center; display: flex; flex-direction: column; padding: 2.5rem; text-align: center; }
.jobs-empty p { color: var(--muted-foreground); margin: 0.5rem 0 0; }
.job-message { border: 1px solid; border-radius: 0.5rem; font-size: 0.85rem; margin: 0 0 1rem; padding: 0.75rem 1rem; }
.job-message.success { background: #ecfdf5; border-color: #a7f3d0; color: var(--success); }
.job-message.error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.job-dialog { max-width: 38rem; }
.history-dialog { max-width: 58rem; }
.delete-dialog { max-width: 32rem; }
.job-form { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.job-form > label { display: flex; flex-direction: column; gap: 0.4rem; }
.job-form > label > span, .job-work legend { font-size: 0.8rem; font-weight: 600; }
.job-form small { color: var(--muted-foreground); font-size: 0.72rem; line-height: 1.4; }
.job-work { border: 1px solid var(--border); border-radius: 0.5rem; display: flex; gap: 1rem; margin: 0; padding: 0.65rem 0.8rem; }
.job-work label { align-items: center; display: flex; font-size: 0.82rem; gap: 0.35rem; }
.job-work small { flex-basis: 100%; }
.job-work { flex-wrap: wrap; }
.history-list { display: flex; flex-direction: column; gap: 0.75rem; }
.history-list article { border: 1px solid var(--border); border-radius: 0.55rem; padding: 0.9rem; }
.history-list article > div:first-child { align-items: center; display: flex; flex-wrap: wrap; gap: 0.65rem; }
.history-list article span { color: var(--muted-foreground); font-size: 0.76rem; }
.history-counts { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; margin-top: 0.65rem; }
.history-actions { align-items: center; display: flex; margin-top: 0.75rem; }
.history-actions span { color: var(--muted-foreground); font-size: 0.72rem; }
.history-list article p { color: #b91c1c; font-size: 0.8rem; margin: 0.65rem 0 0; }
.execution-heading-meta { align-items: center; color: var(--muted-foreground); display: flex; flex-wrap: wrap; font-size: 0.78rem; gap: 0.6rem 1rem; margin-bottom: 1rem; }
.execution-summary { margin-bottom: 0; }
.execution-results-table { min-width: 100rem; }
.dashboard-executions-table { min-width: 78rem; }
.execution-results-table td:last-child { max-width: 32rem; white-space: normal; }
.outcome-badge { align-items: center; border: 1px solid; border-radius: 999px; display: inline-flex; font-size: 0.74rem; font-weight: 700; gap: 0.35rem; padding: 0.35rem 0.65rem; }
.outcome-badge svg { fill: none; height: 0.9rem; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.5; width: 0.9rem; }
.outcome-success { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.outcome-neutral { background: var(--muted); border-color: var(--border); color: var(--muted-foreground); }
.outcome-error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.outcome-details { display: flex; flex-direction: column; gap: 0.45rem; }
.outcome-details details summary { color: var(--muted-foreground); cursor: pointer; font-size: 0.72rem; font-weight: 600; }
.outcome-details pre { background: var(--muted); border-radius: 0.4rem; color: var(--foreground); font-size: 0.7rem; margin: 0.4rem 0 0; max-height: 10rem; overflow: auto; padding: 0.6rem; white-space: pre-wrap; }

@media (max-width: 900px) {
    .summary-grid, .flow-list { grid-template-columns: 1fr; }
    .flow-list > div { padding: 1rem 0; }
    .flow-list > div + div { border-left: 0; border-top: 1px solid var(--border); }
    .auth-shell { grid-template-columns: 1fr; max-width: 34rem; }
    .auth-intro { display: none; }
    .configuration-fields { grid-template-columns: 1fr; }
    .comparison-controls, .result-toolbar { grid-template-columns: 1fr; }
    .snapshot-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .job-form { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .topbar { padding: 0 1rem; }
    .page-container { padding: 2rem 1rem 4rem; }
    .page-heading { flex-direction: column; }
    .heading-actions { width: 100%; }
    .primary-nav { margin-left: 0.75rem; }
    .primary-nav a { padding: 0.45rem 0.5rem; }
    .operator-copy { display: none; }
}
