:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1a2233;
  --muted: #66707f;
  --border: #e1e5eb;
  --accent: #1f5eff;
  --accent-hover: #1449cc;
  --green: #187a45;
  --green-bg: #e3f4ea;
  --amber: #8a6100;
  --amber-bg: #fdf3d7;
  --red: #9c2b2b;
  --red-bg: #fbe7e7;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c;
    --surface: #1b202b;
    --text: #e8ecf3;
    --muted: #93a0b4;
    --border: #2b3342;
    --accent: #5c8bff;
    --accent-hover: #7ba2ff;
    --green: #58c98a;
    --green-bg: #17331f;
    --amber: #e8c15a;
    --amber-bg: #34290d;
    --red: #ef8a8a;
    --red-bg: #3a1c1c;
  }
}

* { box-sizing: border-box; }

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

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

h1 { font-size: 1.2rem; margin: 0; }

.header-actions { display: flex; align-items: center; gap: 10px; }

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

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }

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

.warning {
  background: var(--amber-bg);
  color: var(--amber);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.stat .num { font-size: 1.6rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 0.8rem; }

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }

.tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
}
.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#search {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 240px;
}

.list { display: flex; flex-direction: column; gap: 10px; }

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

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card h3 { margin: 0 0 4px; font-size: 1rem; }

.badge {
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.relevant { background: var(--green-bg); color: var(--green); }
.badge.maybe { background: var(--amber-bg); color: var(--amber); }
.badge.not { background: var(--red-bg); color: var(--red); }
.badge.pending { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }

.card .meta { color: var(--muted); font-size: 0.83rem; margin-top: 2px; }
.card .reasoning { font-size: 0.88rem; margin-top: 8px; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
}

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  max-width: 720px;
  width: calc(100vw - 40px);
  padding: 24px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }

dialog h2 { margin-top: 0; }

label { display: block; margin-bottom: 14px; }
label > span { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
label small { font-weight: 400; color: var(--muted); }

textarea, dialog input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.9rem;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.detail h2 { margin: 0 0 6px; font-size: 1.15rem; }
.detail dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 0.9rem; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; }
.detail .section { margin-top: 14px; }
.detail .section h4 { margin: 0 0 6px; font-size: 0.9rem; }
.detail .desc { white-space: pre-wrap; font-size: 0.88rem; max-height: 300px; overflow-y: auto; }
.detail ul { margin: 6px 0; padding-left: 20px; font-size: 0.88rem; }
