:root {
  color-scheme: light dark;
  --bg: #f7f5f2;
  --surface: #ffffff;
  --border: #e2ded8;
  --text: #2a2622;
  --text-muted: #78716a;
  --accent: #7c3a2d;
  --accent-hover: #612c22;
  --danger: #b3261e;
  --ok: #2e6b3e;
}

* { box-sizing: border-box; }

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

header.site {
  background: var(--accent);
  color: #fff;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

header.site .brand {
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  color: #fff;
}

header.site nav a {
  color: #f2e4de;
  text-decoration: none;
  margin-left: 1.2rem;
  font-size: 0.92rem;
}

header.site nav a:hover, header.site nav a.active { color: #fff; text-decoration: underline; }

header.site button.key {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.5);
  color: #fff;
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  margin-left: 1.2rem;
}

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

h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.6rem; }
h3 { font-size: 0.95rem; margin: 1rem 0 0.4rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }

a { color: var(--accent); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin-bottom: 0.8rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.filters select, .filters input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.88rem;
  background: var(--surface);
  color: var(--text);
}

.filters input[type="text"] { min-width: 180px; }

button, .btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.secondary:hover { background: #f2e4de; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.opp-list { list-style: none; margin: 0; padding: 0; }
.opp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}
.opp-row:last-child { border-bottom: none; }
.opp-row .title { font-weight: 600; }
.opp-row .title a { color: var(--text); text-decoration: none; }
.opp-row .title a:hover { color: var(--accent); }
.opp-row .meta { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.15rem; }
.opp-row .right { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-priority-DONT_MISS, .badge-priority-CRITICAL { background: #fbe0de; color: #8c1d15; }
.badge-priority-URGENT, .badge-priority-HIGH_PRIORITY { background: #fde6cc; color: #8a4b0b; }
.badge-priority-PREPARATION, .badge-priority-PROGRAMMABLE { background: #dbe6fb; color: #1e4a8c; }
.badge-priority-WATCH, .badge-priority-LOW_PRIORITY { background: #e7e3dd; color: #5c564d; }

.badge-status-DISCOVERED, .badge-status-VERIFYING { background: #e7e3dd; color: #5c564d; }
.badge-status-OPEN, .badge-status-SHORTLISTED { background: #dcefdf; color: #1f6b34; }
.badge-status-ACTION_REQUIRED, .badge-status-APPLIED { background: #fde6cc; color: #8a4b0b; }
.badge-status-ACCEPTED, .badge-status-COMPLETED { background: #cdeeda; color: #175c2d; }
.badge-status-REJECTED, .badge-status-EXPIRED, .badge-status-CANCELLED { background: #f3d9d7; color: #8c1d15; }
.badge-status-PRE_ALERT { background: #fcefc2; color: #7a5b00; }
.badge-status-ARCHIVED { background: #ece9e4; color: #78716a; }

.badge[class*="badge-category-"] { background: #efe7de; color: #5c4a36; }

.score { font-weight: 700; font-size: 1rem; }

.empty-state, .loading, .error-box {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
}
.error-box { color: var(--danger); background: #fbe0de; border-radius: 8px; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.8rem 1.5rem;
  margin-bottom: 0.5rem;
}
.field-grid .field label { display: block; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.02em; }
.field-grid .field .value { font-size: 0.95rem; }

.score-breakdown { display: flex; flex-direction: column; gap: 0.5rem; }
.score-item { display: flex; gap: 0.6rem; align-items: baseline; }
.score-item .label { min-width: 160px; font-size: 0.85rem; color: var(--text-muted); }
.score-item .points { font-weight: 700; min-width: 3.5em; }
.score-item .rationale { font-size: 0.85rem; }

textarea, input[type="text"], input[type="url"], input[type="password"] {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.92rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
textarea { min-height: 180px; resize: vertical; }
label.form-label { display: block; font-weight: 600; margin: 0.8rem 0 0.3rem; font-size: 0.88rem; }

.note-item, .list-item { padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.list-item:last-child, .note-item:last-child { border-bottom: none; }
.small { font-size: 0.8rem; color: var(--text-muted); }
.stack { display: flex; flex-direction: column; gap: 0.6rem; }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
