:root {
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--card);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  width: 100%;
  max-width: 360px;
}

.card h1 {
  margin: 0 0 1.5rem 0;
  font-size: 1.25rem;
}

form label {
  display: block;
  margin-bottom: 1rem;
}

form label span {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
}

input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

button {
  background: var(--accent);
  color: white;
  border: 0;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.95rem;
  cursor: pointer;
}
button:hover { filter: brightness(0.95); }

.error { color: var(--err); margin: 0.5rem 0 0 0; font-size: 0.875rem; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 1.125rem; }
.topbar-right { display: flex; gap: 0.75rem; align-items: center; }
.topbar-right span { color: var(--muted); font-size: 0.875rem; }

main { padding: 1.5rem; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  vertical-align: top;
}

th { background: #f9fafb; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }

.muted { color: var(--muted); font-size: 0.875rem; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  background: var(--border);
  color: var(--text);
}
.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.warn { background: #fef3c7; color: var(--warn); }
.badge.err { background: #fee2e2; color: var(--err); }

.banner {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  border: 1px solid transparent;
}
.banner-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.banner-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.banner-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

.section-actions {
  display: flex;
  gap: 0.5rem;
}

/* Inactive rows: muted, slightly desaturated. */
tr.inactive {
  background: #fafafa;
  color: var(--muted);
}
tr.inactive td a { color: var(--muted); }
.badge.muted { background: var(--border); color: var(--muted); }

td.actions {
  white-space: nowrap;
}
td.actions button {
  padding: 0.25rem 0.6rem;
  font-size: 0.8125rem;
  margin-left: 0.25rem;
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}
td.actions button:hover { background: #f3f4f6; }
td.actions .btn-toggle { color: var(--warn); }
tr.inactive td.actions .btn-toggle { color: var(--ok); }
td.actions .btn-move { color: var(--accent); }
td.actions .btn-scrape { color: var(--ok); }
td.actions .btn-llm { color: #7c3aed; }  /* purple, distinct from the other actions */

/* Combined Label/URL column. Label on top, URL below with an open-in-new-tab button. */
td.label-url { min-width: 240px; }
td.label-url .label-line {
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
}
td.label-url .url-line {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.8125rem;
  word-break: break-all;
}
td.label-url .url-line .url-text { flex: 1; }
td.label-url .btn-open-url {
  flex: 0 0 auto;
  padding: 0 0.4rem;
  height: 1.4rem;
  line-height: 1.4rem;
  font-size: 0.875rem;
  background: white;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 3px;
}
td.label-url .btn-open-url:hover { background: #f3f4f6; }
tr.inactive td.label-url .label-line { color: var(--muted); }

/* Article count cell in dashboard linking to articles.html */
.article-count-link {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px dashed var(--border);
}
.article-count-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ─── Articles page ──────────────────────────────────────────────────────── */

.topbar-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.875rem;
}
.topbar-link:hover { text-decoration: underline; }

.article-header {
  margin-bottom: 1rem;
}
.article-header h2 {
  margin: 0 0 0.25rem 0;
}

.article-toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 1rem;
}
.article-toolbar label.inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  margin: 0;
}
.article-toolbar select {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.875rem;
}

.article-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.article-card {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 1rem;
  padding: 0.9rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.article-card.depublished {
  background: #fafafa;
  opacity: 0.85;
}

.article-thumb {
  width: 100px;
  height: 75px;
  object-fit: cover;
  border-radius: 4px;
  background: #f3f4f6;
  border: 1px solid var(--border);
}
.article-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.2rem;
}

.article-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.article-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}
.article-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
}
.article-position {
  flex: 0 0 auto;
  color: var(--muted);
  font-family: monospace;
  font-size: 0.8rem;
}

.article-teaser {
  margin: 0;
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.75rem;
  margin-top: 0.2rem;
}

.article-actions {
  margin-top: 0.3rem;
}
.article-actions .btn-open-url {
  padding: 0.25rem 0.7rem;
  font-size: 0.8125rem;
  background: white;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}
.article-actions .btn-open-url:hover {
  background: #f3f4f6;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}
.pagination button {
  padding: 0.4rem 1rem;
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.pagination button:hover:not([disabled]) { background: #f3f4f6; }
.pagination button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
td.actions button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
td.actions button[disabled]:hover { background: white; }

.small { font-size: 0.75rem; }

.move-advanced {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fafafa;
}
.move-advanced summary {
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--muted);
}
.move-advanced[open] summary { margin-bottom: 0.5rem; }
.move-advanced p { margin: 0.25rem 0 0.75rem 0; }

/* Dialog form layout. */
dialog {
  border: 0;
  border-radius: 8px;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog h3 { margin: 0 0 1rem 0; font-size: 1.05rem; }
dialog form label { display: block; margin-bottom: 0.9rem; }
dialog form label.inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}
dialog form label.inline span { display: inline; color: var(--text); font-size: 0.9rem; }
dialog form select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
  background: white;
}
dialog form input[type="url"] { width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 4px; font-size: 1rem; }
dialog form input[disabled] { background: #f3f4f6; color: var(--muted); }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}
.dialog-actions button[type="button"] { background: white; color: var(--text); border: 1px solid var(--border); }
.dialog-actions button[type="button"]:hover { background: #f3f4f6; }

.card-footer {
  margin-top: 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  font-family: var(--font-source-code-pro, monospace);
}

.version-tag {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.7rem;
  font-family: monospace;
  background: #f9fafb;
}
