:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #1d4ed8;
  --accent-soft: #e8efff;
  --good: #067647;
  --good-soft: #dcfae6;
  --warn: #b54708;
  --warn-soft: #fef0c7;
  --bad: #b42318;
  --bad-soft: #fee4e2;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 6px 12px;
}
button:hover { border-color: #c5cad3; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
button:disabled { opacity: .6; cursor: default; }

input[type=text], input[type=password], input[type=search], input[type=url], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

label { display: block; font-weight: 600; font-size: 13px; margin: 10px 0 4px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }

/* ---------- Khung trang ---------- */
header.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
header.top .inner {
  max-width: 920px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 18px;
}
header.top .brand { font-weight: 700; font-size: 17px; color: var(--text); }
header.top nav { display: flex; gap: 14px; flex: 1; }
header.top nav a { color: var(--muted); font-weight: 500; }
header.top nav a.active { color: var(--text); }
header.top .who { color: var(--muted); font-size: 13px; display: flex; gap: 10px; align-items: center; }

main { max-width: 920px; margin: 0 auto; padding: 16px; }

/* ---------- Tab và thanh công cụ ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { border-radius: 999px; padding: 5px 14px; }
.tabs button.active { background: var(--text); color: #fff; border-color: var(--text); }
.tabs .count { opacity: .7; margin-left: 4px; font-size: 13px; }

.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.toolbar select { max-width: 240px; }

.status-line { color: var(--muted); font-size: 13px; margin-bottom: 12px; }

/* ---------- Thẻ bài viết ---------- */
.article {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex; gap: 14px;
}
.article .body { flex: 1; min-width: 0; }
.article .meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.article h3 { font-size: 16px; margin: 4px 0 6px; line-height: 1.4; }
.article h3 a { color: var(--text); }
.article h3 a:hover { color: var(--accent); text-decoration: none; }
.article .summary { margin: 0; }
.article .snippet { margin: 0; color: var(--muted); }
.article img.thumb {
  width: 120px; height: 80px; object-fit: cover; border-radius: 6px; flex-shrink: 0; background: var(--line);
}
.article .dups { margin-top: 8px; font-size: 13px; }
.article .dups ul { margin: 6px 0 0; padding-left: 18px; }

.badge { display: inline-block; border-radius: 999px; padding: 0 8px; font-size: 12px; font-weight: 600; line-height: 20px; }
.score-hi { background: var(--good-soft); color: var(--good); }
.score-mid { background: var(--warn-soft); color: var(--warn); }
.score-lo { background: var(--line); color: var(--muted); }
.chip { background: var(--accent-soft); color: var(--accent); }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.more { display: block; margin: 16px auto; }

/* ---------- Trang cài đặt ---------- */
section.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 16px;
}
section.panel h2 { font-size: 17px; margin: 0 0 4px; }
section.panel > p.hint { margin: 0 0 12px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { margin-left: 4px; }
.ok { color: var(--good); }
.fail { color: var(--bad); }

.watch {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
  display: flex; gap: 12px; align-items: flex-start;
}
.watch .info { flex: 1; min-width: 0; }
.watch .kw { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.watch.off { opacity: .55; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.msg { font-size: 13px; }
.msg.error { color: var(--bad); }
.msg.success { color: var(--good); }

pre.report { background: var(--bg); border-radius: 8px; padding: 10px; font-size: 12px; white-space: pre-wrap; margin: 10px 0 0; }

/* ---------- Đăng nhập ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box {
  width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px 26px;
}
.login-box h1 { font-size: 20px; margin: 0 0 4px; }
.login-box p { color: var(--muted); margin: 0 0 14px; font-size: 14px; }
.login-box button { width: 100%; margin-top: 16px; padding: 9px; }

@media (max-width: 640px) {
  header.top .inner { gap: 12px; }
  header.top .who span { display: none; }
  .article img.thumb { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; }
  .toolbar select { max-width: none; }
}
