:root {
  --bg: #0f1419;
  --card: #1a2332;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3d8bfd;
  --ok: #3ecf8e;
  --err: #f07178;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

h1 {
  font-weight: 600;
  font-size: 1.5rem;
  margin: 0 0 1rem;
}

.card {
  background: var(--card);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  border: 1px solid #2a3544;
}

.stats {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin: 0.75rem 0;
}

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

.stats strong {
  color: var(--text);
}

button,
.btn-file {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  margin-right: 0.5rem;
  margin-top: 0.35rem;
}

button:disabled,
.btn-file:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.secondary {
  background: #3d4f66;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th,
td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid #2a3544;
}

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

tr.valid td {
  border-left: 3px solid var(--ok);
}

tr.error td {
  border-left: 3px solid var(--err);
}

.logs {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
  background: #0b0f14;
  padding: 1rem;
  border-radius: 8px;
  max-height: 320px;
  overflow: auto;
  color: #c8d0da;
}

.loading {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}

input[type="password"],
input[type="text"] {
  width: 100%;
  max-width: 420px;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #2a3544;
  background: #0b0f14;
  color: var(--text);
}

label.small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.75rem;
}

.sync-result-card h2 {
  color: var(--text);
}

.sync-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1.25rem 0 0.35rem;
  color: var(--text);
}

.sync-section-title--err {
  color: var(--err);
}

.sync-section-desc {
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 48rem;
}

.sync-empty {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.sync-table--compact th,
.sync-table--compact td {
  padding: 0.35rem 0.45rem;
}

.sync-banner {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.sync-banner--err {
  background: rgba(240, 113, 120, 0.12);
  border: 1px solid var(--err);
  color: var(--text);
}

.sync-banner--warn {
  background: rgba(255, 180, 80, 0.1);
  border: 1px solid #c9a227;
  color: var(--text);
}

.sync-inline-list {
  margin: 0.25rem 0 0 1.1rem;
  padding: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.sync-summary {
  margin-bottom: 0.5rem;
}

.sync-help {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

.sync-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.sync-toolbar-hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.table-scroll {
  overflow-x: auto;
  max-height: min(70vh, 720px);
  overflow-y: auto;
  border: 1px solid #2a3544;
  border-radius: 8px;
}

.sync-table {
  font-size: 0.82rem;
}

.sync-table th.col-check,
.sync-table td.col-check {
  width: 4.5rem;
  text-align: center;
  vertical-align: middle;
}

.sync-table input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.sync-table input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.sync-issue {
  color: var(--err);
}

.sync-detail-row td {
  padding-top: 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #2a3544;
  font-size: 0.8rem;
}

.sync-details {
  margin: 0 0 0.35rem;
}

.sync-details summary {
  cursor: pointer;
  color: var(--accent);
  user-select: none;
}

.sync-detail-pre {
  margin: 0.35rem 0 0;
  padding: 0.5rem 0.65rem;
  background: #0b0f14;
  border-radius: 6px;
  white-space: pre-wrap;
  color: #c8d0da;
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
}

.sync-stderr-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.75rem 0 0.25rem;
}

.sync-stderr {
  margin: 0 0 0.75rem;
  padding: 0.65rem;
  background: #0b0f14;
  border-radius: 8px;
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  white-space: pre-wrap;
  color: #c8d0da;
  max-height: 160px;
  overflow: auto;
}

.sync-raw-details {
  margin-top: 0.75rem;
}

.sync-raw-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
}

.sync-raw-details .logs {
  margin-top: 0.5rem;
  max-height: 240px;
}

/* Page flow (Upload → Validation → Dry run → Changes → Failures → Selection → Run sync) */
.flow-main {
  max-width: 960px;
}

.flow-h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text);
  letter-spacing: 0.02em;
}

.flow-h2--err {
  color: var(--err);
}

.flow-lead {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 40rem;
}

.flow-status {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.flow-muted {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.5rem 0 0.75rem;
}

.flow-muted-tight {
  margin: 0.25rem 0 0.75rem;
}

.flow-ok-msg {
  margin: 0;
  color: var(--ok);
  font-size: 0.9rem;
}

.flow-section-desc {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 44rem;
}

.flow-alert {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
}

.flow-alert--err {
  background: rgba(240, 113, 120, 0.12);
  border: 1px solid var(--err);
}

.flow-alert-list {
  margin: 0.5rem 0 0 1.1rem;
  padding: 0;
}

.flow-alert-list li {
  margin: 0.25rem 0;
}

.flow-table-wrap {
  margin-top: 0.35rem;
}

.flow-card--accent {
  border-color: rgba(61, 139, 253, 0.35);
  background: linear-gradient(165deg, rgba(61, 139, 253, 0.06) 0%, var(--card) 48%);
}

.flow-placeholder {
  border-style: dashed;
  border-color: #3d4f66;
  background: rgba(15, 20, 25, 0.5);
}

.flow-card--run {
  border-color: rgba(62, 207, 142, 0.35);
}

.flow-run-actions {
  margin-top: 0.5rem;
}

.flow-sync-summary {
  margin-top: 0;
}

.flow-toolbar {
  margin-bottom: 0.65rem;
}

main.flow-main code {
  font-size: 0.85em;
  background: #0b0f14;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.flow-selection-search {
  margin-bottom: 0.85rem;
}

.flow-selection-search label.small {
  margin-top: 0;
}

.flow-search-input {
  display: block;
  width: 100%;
  max-width: 28rem;
  margin-top: 0.35rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #2a3544;
  background: #0b0f14;
  color: var(--text);
  font-size: 0.95rem;
}

.flow-search-input::placeholder {
  color: var(--muted);
}

.flow-search-meta {
  display: inline-block;
  margin-left: 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.flow-search-empty {
  margin: 0.5rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

/* Live sync toast */
.flow-toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  max-width: min(26rem, calc(100vw - 2.5rem));
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid #2a3544;
  background: var(--card);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-size: 0.92rem;
  line-height: 1.4;
  animation: flow-toast-in 0.22s ease-out;
}

@keyframes flow-toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.flow-toast--ok {
  border-color: rgba(62, 207, 142, 0.45);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(62, 207, 142, 0.12);
}

.flow-toast--ok .flow-toast__text {
  color: var(--text);
}

.flow-toast--err {
  border-color: rgba(240, 113, 120, 0.45);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(240, 113, 120, 0.12);
}

.flow-toast__text {
  flex: 1;
  min-width: 0;
}

.flow-toast__close {
  flex-shrink: 0;
  margin: 0;
  padding: 0 0.35rem;
  line-height: 1;
  font-size: 1.35rem;
  font-weight: 400;
  background: transparent;
  color: var(--muted);
  opacity: 0.85;
}

.flow-toast__close:hover:not(:disabled) {
  color: var(--text);
  opacity: 1;
}

.flow-toast__close:disabled {
  opacity: 0.35;
}
