*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #f4f4f5;
    color: #111827;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.6;
}

/* ── Nav ─────────────────────────────────────────── */

nav {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0 2rem;
    height: 56px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: #111827;
    margin-right: auto;
    letter-spacing: -0.02em;
}

.logo span {
    color: #FF7B07;
}

nav a {
    color: #6b7280;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
}

nav a:hover {
    color: #111827;
}

/* ── Layout ──────────────────────────────────────── */

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9ca3af;
    margin-bottom: 1.25rem;
}

/* ── Cards ───────────────────────────────────────── */

.card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9ca3af;
}

/* ── Stat grid ───────────────────────────────────── */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 1rem;
}

.stat-item {
    background: #ffffff;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: #111827;
    line-height: 1;
}

.stat-value.creates  { color: #2563eb; }
.stat-value.updates  { color: #FF7B07; }
.stat-value.failed   { color: #dc2626; }

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9ca3af;
}

/* ── Badges ──────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.badge-running    { background: #fff7ed; color: #ea580c; }
.badge-completed  { background: #f0fdf4; color: #16a34a; }
.badge-failed     { background: #fef2f2; color: #dc2626; }
.badge-create     { background: #eff6ff; color: #2563eb; }
.badge-update     { background: #fff7ed; color: #ea580c; }
.badge-unchanged  { background: #f9fafb; color: #9ca3af; }

/* ── Buttons ─────────────────────────────────────── */

button, .btn {
    background-color: #FF7B07;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 0.6rem 1.4rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.15s;
}

button:hover:not(:disabled), .btn:hover {
    background-color: #e06a00;
}

button:disabled {
    background-color: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
}

/* ── Tables ──────────────────────────────────────── */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    table-layout: fixed;
}

th {
    text-align: left;
    padding: 0.6rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9ca3af;
    border-bottom: 1px solid #e5e7eb;
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
    vertical-align: top;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: #fafafa;
}

/* ── Logs table column widths ────────────────────── */

.logs-table th:nth-child(1) { width: 48px; }
.logs-table th:nth-child(2) { width: 130px; }
.logs-table th:nth-child(3) { width: 130px; }
.logs-table th:nth-child(4) { width: 100px; }
.logs-table th:nth-child(5),
.logs-table th:nth-child(6),
.logs-table th:nth-child(7),
.logs-table th:nth-child(8) { width: 80px; }

/* ── Preview table ───────────────────────────────── */

.preview-table th:nth-child(1) { width: 14%; }
.preview-table th:nth-child(2) { width: 18%; }
.preview-table th:nth-child(3) { width: 8%; }
/* 4th column (Changes) takes the remaining ~60% → render area ~50% of actual page width */

.preview-table-wrapper {
    max-height: 480px;
    overflow-y: auto;
    border-radius: 0 0 6px 6px;
    margin-top: 1rem;
}

.preview-table thead th {
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 1;
    box-shadow: 0 1px 0 #e5e7eb;
}

.record-key {
    font-family: ui-monospace, monospace;
    font-size: 0.8rem;
    color: #374151;
}

td.no-changes-msg {
    color: #9ca3af;
    font-style: italic;
    text-align: center;
    padding: 2rem 1rem;
}

/* ── Property change chips ───────────────────────── */

.prop-change {
    display: block;
    padding: 0.15rem 0;
    font-size: 0.8rem;
    color: #374151;
}

.prop-change + .prop-change {
    margin-top: 0.2rem;
}

.prop-change strong {
    font-weight: 600;
    color: #374151;
    margin-right: 0.4rem;
}

.old-val {
    color: #9ca3af;
    text-decoration: line-through;
    margin-right: 0.3rem;
}

.arrow {
    color: #d1d5db;
    margin-right: 0.3rem;
    font-size: 0.75rem;
}

.new-val {
    color: #111827;
    font-weight: 500;
}

/* ── File upload rows ────────────────────────────── */

.file-row {
    display: grid;
    grid-template-columns: 200px 1fr;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.file-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.file-row:first-child {
    padding-top: 0;
}

.file-row .label {
    margin-bottom: 0;
}

.file-row-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

input[type="file"] {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #374151;
    padding: 0.45rem 0.6rem;
    font-size: 0.875rem;
    width: 100%;
    cursor: pointer;
}

input[type="file"]:hover {
    border-color: #d1d5db;
}

input[type="file"]:focus {
    outline: 2px solid #FF7B07;
    outline-offset: 1px;
    border-color: transparent;
}

input[type="text"] {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #374151;
    padding: 0.45rem 0.6rem;
    font-size: 0.875rem;
    width: 100%;
}

input[type="text"]::placeholder {
    color: #d1d5db;
}

input[type="text"]:focus {
    outline: 2px solid #FF7B07;
    outline-offset: 1px;
    border-color: transparent;
}

/* ── File selected state ─────────────────────────── */

.file-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.filename {
    font-size: 0.875rem;
    color: #374151;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-status {
    font-size: 0.8rem;
    color: #9ca3af;
}

.btn-remove {
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    color: #9ca3af;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.btn-remove:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* ── Last sync card ──────────────────────────────── */

.last-run-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.last-run-time {
    font-size: 0.875rem;
    color: #6b7280;
}

/* ── Sync button ─────────────────────────────────── */

#sync-btn {
    margin-top: 0.25rem;
    min-width: 150px;
}

/* ── Preview results ─────────────────────────────── */

.preview-error-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #dc2626;
    margin-bottom: 0.5rem;
}

/* ── Sync progress bar ───────────────────────────── */

.progress-bar-track {
    width: 100%;
    height: 3px;
    background: #fde8cc;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 1rem;
}

.progress-bar {
    height: 100%;
    width: 40%;
    background: #FF7B07;
    border-radius: 2px;
    animation: progress-slide 1.4s ease-in-out infinite;
}

@keyframes progress-slide {
    0%   { transform: translateX(-150%); }
    100% { transform: translateX(400%); }
}

/* ── Sync result banner ──────────────────────────── */

.sync-result {
    margin-top: 1rem;
    padding: 0.9rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
}

.sync-result.success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.sync-result.failure {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fca5a5;
}

/* ── Preview actions ─────────────────────────────── */

.preview-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
    padding-top: 0.25rem;
}

.preview-note {
    font-size: 0.8rem;
    color: #9ca3af;
}

.preview-btns {
    display: flex;
    gap: 0.75rem;
}

.btn-secondary {
    background: none;
    border: 1px solid #e5e7eb;
    color: #6b7280;
}

.btn-secondary:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #374151;
}

#confirm-btn {
    background-color: #16a34a;
    min-width: 150px;
}

#confirm-btn:hover:not(:disabled) {
    background-color: #15803d;
}

/* ── Error detail (logs) ─────────────────────────── */

.error-detail summary {
    cursor: pointer;
    color: #dc2626;
    font-size: 0.8rem;
    font-weight: 500;
    list-style: none;
    user-select: none;
}

.error-detail summary::before {
    content: '▶ ';
    font-size: 0.6rem;
    transition: transform 0.15s;
    display: inline-block;
}

.error-detail[open] summary::before {
    transform: rotate(90deg);
}

.error-text {
    margin-top: 0.5rem;
    font-family: ui-monospace, monospace;
    font-size: 0.75rem;
    color: #374151;
    white-space: pre-wrap;
    word-break: break-all;
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 4px;
    padding: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
}
