:root {
  --c-relevant: #dc2626;
  --c-relevant-bg: #fef2f2;
  --c-relevant-border: #fca5a5;
  --c-moderate: #d97706;
  --c-moderate-bg: #fffbeb;
  --c-moderate-border: #fcd34d;
  --c-none: #16a34a;
  --c-none-bg: #f0fdf4;
  --c-none-border: #86efac;
  --c-bg: #f8fafc;
  --c-surface: #ffffff;
  --c-border: #e2e8f0;
  --c-text: #0f172a;
  --c-muted: #64748b;
  --c-header: #0f172a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.5;
}

/* Header */
header {
  background: var(--c-header);
  color: #fff;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  background: #3b82f6;
  color: #fff;
  font-weight: 700;
  font-size: 1em;
  padding: 6px 10px;
  border-radius: 8px;
  letter-spacing: .04em;
}
.brand-title { font-weight: 600; font-size: 1.05em; }
.brand-sub { font-size: .75em; color: #94a3b8; margin-top: 1px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.sync-label { font-size: .75em; color: #94a3b8; }
.btn-sync {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .82em;
  font-weight: 500;
  transition: background .15s;
}
.btn-sync:hover { background: rgba(255,255,255,.18); }

/* Main */
main { max-width: 1200px; margin: 0 auto; padding: 28px 24px; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  border-left: 4px solid transparent;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.stat-relevant { border-left-color: var(--c-relevant); }
.stat-moderate { border-left-color: var(--c-moderate); }
.stat-none     { border-left-color: var(--c-none); }
.stat-week     { border-left-color: #3b82f6; }
.stat-num { font-size: 2em; font-weight: 700; line-height: 1.1; }
.stat-relevant .stat-num { color: var(--c-relevant); }
.stat-moderate .stat-num { color: var(--c-moderate); }
.stat-none .stat-num     { color: var(--c-none); }
.stat-week .stat-num     { color: #3b82f6; }
.stat-name { font-weight: 600; margin-top: 6px; font-size: .9em; }
.stat-hint { font-size: .75em; color: var(--c-muted); margin-top: 2px; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--c-border); padding-bottom: 0; }
.tab {
  background: none;
  border: none;
  padding: 8px 18px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  color: var(--c-muted);
  font-weight: 500;
  font-size: .85em;
  border-bottom: 2px solid transparent;
  transition: color .15s;
}
.tab:hover { color: var(--c-text); }
.tab.active { color: #3b82f6; border-bottom-color: #3b82f6; }

/* Filters */
.filters { display: flex; gap: 10px; margin-bottom: 18px; }
.filters select, .filters input {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: .85em;
  color: var(--c-text);
  outline: none;
}
.filters input { flex: 1; max-width: 280px; }
.filters select:focus, .filters input:focus { border-color: #3b82f6; }

/* Item cards */
.item-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  border-left: 4px solid transparent;
}
.item-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); transform: translateY(-1px); }
.item-card.rel-relevant { border-left-color: var(--c-relevant); }
.item-card.rel-moderate { border-left-color: var(--c-moderate); }
.item-card.rel-none     { border-left-color: var(--c-none); }
.item-card.rel-unknown  { border-left-color: #cbd5e1; }

.item-badge {
  flex-shrink: 0;
  font-size: .7em;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: 2px;
}
.badge-relevant { background: var(--c-relevant-bg); color: var(--c-relevant); border: 1px solid var(--c-relevant-border); }
.badge-moderate { background: var(--c-moderate-bg); color: var(--c-moderate); border: 1px solid var(--c-moderate-border); }
.badge-none     { background: var(--c-none-bg); color: var(--c-none); border: 1px solid var(--c-none-border); }
.badge-unknown  { background: #f1f5f9; color: var(--c-muted); border: 1px solid #e2e8f0; }

.item-content { flex: 1; min-width: 0; }
.item-title { font-weight: 600; font-size: .93em; margin-bottom: 4px; }
.item-meta { font-size: .75em; color: var(--c-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.item-reasoning { font-size: .8em; color: #475569; margin-top: 6px; font-style: italic; }
.item-action {
  font-size: .78em;
  background: var(--c-relevant-bg);
  color: var(--c-relevant);
  border-radius: 6px;
  padding: 4px 8px;
  margin-top: 6px;
  display: inline-block;
}

.loading { text-align: center; padding: 48px; color: var(--c-muted); font-size: .9em; }
.empty { text-align: center; padding: 48px; color: var(--c-muted); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.modal-box {
  position: relative;
  background: var(--c-surface);
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 680px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-sm { max-width: 420px; }
.modal-sm label { display: block; font-size: .8em; font-weight: 600; color: var(--c-muted); margin: 12px 0 4px; text-transform: uppercase; letter-spacing: .04em; }
.modal-sm input, .modal-sm select { width: 100%; padding: 8px 12px; border: 1px solid var(--c-border); border-radius: 8px; font-size: .9em; outline: none; }
.modal-sm input:focus, .modal-sm select:focus { border-color: #3b82f6; }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; font-size: 1.1em; cursor: pointer; color: var(--c-muted);
}
.modal-close:hover { color: var(--c-text); }
.modal-title { font-size: 1.05em; font-weight: 700; margin-bottom: 12px; }
.modal-section { margin-top: 16px; }
.modal-section h4 { font-size: .75em; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--c-muted); margin-bottom: 6px; }
.modal-section p { font-size: .88em; line-height: 1.6; color: #334155; }
.modal-body-text { font-size: .82em; color: #475569; line-height: 1.7; max-height: 280px; overflow-y: auto; background: #f8fafc; border-radius: 8px; padding: 12px; margin-top: 6px; white-space: pre-wrap; }

/* Keywords panel */
.kw-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.kw-toolbar h3 { font-size: 1em; font-weight: 600; }
.btn-add { background: #3b82f6; color: #fff; border: none; border-radius: 8px; padding: 7px 14px; cursor: pointer; font-size: .82em; font-weight: 600; }
.btn-add:hover { background: #2563eb; }
.btn-save { width: 100%; background: #3b82f6; color: #fff; border: none; border-radius: 8px; padding: 10px; cursor: pointer; font-size: .9em; font-weight: 600; margin-top: 18px; }
.btn-save:hover { background: #2563eb; }

.kw-table { width: 100%; border-collapse: collapse; }
.kw-table th { font-size: .72em; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--c-muted); padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--c-border); }
.kw-table td { padding: 9px 12px; border-bottom: 1px solid #f1f5f9; font-size: .85em; }
.kw-table tr:hover td { background: #f8fafc; }
.btn-del { background: none; border: none; color: #ef4444; cursor: pointer; font-size: .85em; padding: 2px 6px; border-radius: 4px; }
.btn-del:hover { background: #fef2f2; }

@media (max-width: 700px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  header { padding: 12px 16px; }
  main { padding: 16px; }
}
