:root {
  --color-bg: #f7f6f3;
  --color-surface: #ffffff;
  --color-border: #e2e0da;
  --color-text: #26241f;
  --color-muted: #6f6b60;
  --color-primary: #c0392b;
  --color-primary-hover: #a5301f;
  --color-secondary: #eeece5;
  --color-secondary-hover: #e2dfd6;
  --color-success: #3d7a4d;
  --color-danger: #b23b3b;
  --color-sidebar-bg: #1e1c18;
  --color-sidebar-text: #d8d4c8;
  --color-sidebar-muted: #8a8579;
  --radius: 8px;
  --sidebar-width: 220px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-width: 960px; /* desktop-only tool, not designed for mobile */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

/* ── App shell / sidebar ───────────────────────────────────────── */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 12px 10px;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  margin-bottom: 2px;
}

.sidebar-link svg { flex-shrink: 0; opacity: 0.75; }

.sidebar-link:hover {
  background: rgba(255,255,255,0.06);
}

.sidebar-link.active {
  background: var(--color-primary);
  color: #fff;
}
.sidebar-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  font-size: 12.5px;
  color: var(--color-sidebar-muted);
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-logout {
  font-size: 12.5px;
  color: var(--color-sidebar-text);
  text-decoration: none;
}
.sidebar-logout:hover { color: #fff; }

.main-content {
  flex: 1;
  padding: 28px 36px;
  max-width: 1200px;
}

.page-header {
  margin-bottom: 20px;
}

.page-header h1 {
  margin: 4px 0 0;
  font-size: 22px;
}

.back-link {
  color: var(--color-muted);
  text-decoration: none;
  font-size: 13px;
}
.back-link:hover { color: var(--color-text); }

.empty-state {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 28px;
  color: var(--color-muted);
  font-size: 14px;
  line-height: 1.6;
}
.empty-state a { color: var(--color-primary); text-decoration: none; font-weight: 600; }
.empty-state a:hover { text-decoration: underline; }

.error-text {
  color: var(--color-danger);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-warning {
  background: #fdf2ef;
  border: 1px solid #f0c9bd;
  color: #a5432b;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── Login ─────────────────────────────────────────────────────── */

.login-page {
  min-width: 0; /* login page itself is fine at any width */
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 32px;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card h1 {
  margin: 0;
  font-size: 20px;
}

.login-subtitle {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--color-muted);
}

.login-card input {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
}

.login-card button {
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius);
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.login-card button:hover { background: var(--color-primary-hover); }

.login-card .error {
  color: var(--color-danger);
  font-size: 13px;
  min-height: 16px;
  margin: 0;
}

/* ── Scraper cards ─────────────────────────────────────────────── */

.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}

.card-head h2 {
  margin: 0;
  font-size: 16px;
}

.item-count {
  font-size: 12px;
  color: var(--color-muted);
}

.card-actions {
  display: flex;
  gap: 8px;
}

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

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:disabled { background: var(--color-secondary); color: var(--color-muted); cursor: not-allowed; }

.btn-secondary {
  background: var(--color-secondary);
  color: var(--color-text);
}
.btn-secondary:hover { background: var(--color-secondary-hover); }

.btn[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ── Log tail ──────────────────────────────────────────────────── */

.log-tail {
  margin-top: 14px;
  background: #1e1c18;
  color: #d8d4c8;
  border-radius: var(--radius);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.done-banner[hidden] {
  display: none;
}

.done-banner {
  margin-top: 14px;
  padding: 14px 16px;
  background: #eaf4ec;
  border: 1px solid #bfe0c6;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.done-banner-text {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-success);
}

/* ── Review table ──────────────────────────────────────────────── */

.review-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.review-status {
  font-size: 13px;
  color: var(--color-muted);
}

.review-status.success { color: var(--color-success); }
.review-status.error { color: var(--color-danger); }

.review-section {
  margin-bottom: 28px;
}

.review-section-heading {
  font-size: 15px;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--color-secondary);
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 600;
}

.review-section[data-section="new"] .count-badge {
  background: #e3f0e5;
  color: var(--color-success);
}

.review-section[data-section="changed"] .count-badge {
  background: #fbeee0;
  color: #a5652b;
}

.empty-row {
  color: var(--color-muted);
  font-style: italic;
  text-align: center;
  padding: 16px !important;
}

.diff-note {
  font-size: 10.5px;
  color: var(--color-danger);
  margin-top: 1px;
  padding-left: 6px;
  white-space: nowrap;
}

.review-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.review-table th, .review-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
  text-align: left;
}

.review-table th {
  background: var(--color-secondary);
  font-weight: 600;
}

.review-table tr.excluded {
  opacity: 0.4;
}

.review-table img.thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--color-secondary);
}

.review-table input[type="text"],
.review-table input[type="number"] {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.review-table input[type="text"]:focus,
.review-table input[type="number"]:focus {
  border-color: var(--color-border);
  background: var(--color-bg);
  outline: none;
}

.review-table input[type="number"] {
  width: 70px;
}