:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1d2330;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --good: #16a34a;
  --mid: #d97706;
  --bad: #dc2626;
}

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

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
nav a { margin-left: 18px; text-decoration: none; color: var(--accent); font-weight: 500; }

main { max-width: 880px; margin: 0 auto; padding: 26px 22px 60px; }
h1 { margin-top: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.callout {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 20px;
}
.callout.warn { background: #fffbeb; border-color: #fde68a; }

/* Cards / listings grid */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s, transform .15s;
}
.card:hover { box-shadow: 0 6px 18px rgba(0,0,0,.08); transform: translateY(-2px); }
.card h3 { margin: 8px 0 4px; font-size: 1.05rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.meta { color: var(--muted); margin: 4px 0; font-size: 0.92rem; }

.badge {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 20px; background: #eef2ff; color: #4338ca;
}
.badge-realestate { background: #fee2e2; color: #b91c1c; }
.badge-domain { background: #dcfce7; color: #15803d; }
.badge-manual { background: #f3f4f6; color: #4b5563; }

/* Scores */
.score {
  font-weight: 700; font-size: 1.15rem; display: inline-flex; flex-direction: column;
  align-items: center; line-height: 1; padding: 6px 10px; border-radius: 10px;
}
.score small { font-weight: 500; font-size: 0.6rem; color: var(--muted); margin-top: 2px; }
.score-good { color: var(--good); background: #f0fdf4; }
.score-mid  { color: var(--mid);  background: #fffbeb; }
.score-bad  { color: var(--bad);  background: #fef2f2; }

.score-big {
  font-size: 2.6rem; font-weight: 800; display: flex; flex-direction: column;
  align-items: center; padding: 14px 22px; border-radius: 14px; line-height: 1;
}
.score-big small { font-size: 0.7rem; font-weight: 600; color: var(--muted); margin-top: 4px; }

/* Forms */
form button {
  background: var(--accent); color: #fff; border: 0; padding: 9px 16px;
  border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 0.95rem;
}
form button:hover { filter: brightness(1.05); }
button.danger { background: var(--bad); }
button.small { padding: 4px 10px; font-size: 0.82rem; }
input, select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; width: 100%; background: #fff;
}

.url-bar { display: flex; gap: 10px; margin-bottom: 20px; }
.url-bar input { flex: 1; }
.url-bar button { white-space: nowrap; }

.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; background: var(--card); padding: 20px; border-radius: 12px; border: 1px solid var(--line); }
.grid-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.grid-form .full { grid-column: 1 / -1; }

.pref-form { background: var(--card); padding: 20px; border-radius: 12px; border: 1px solid var(--line); }
.pref-row { display: flex; gap: 14px; align-items: flex-end; margin-bottom: 14px; }
.pref-row label { display: flex; flex-direction: column; gap: 4px; flex: 1; font-size: 0.85rem; color: var(--muted); }
.pref-row label.w { flex: 0 0 90px; }
.pref-row label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.pref-row label.check input { width: auto; }

/* Detail page */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.detail-head h1 { margin: 6px 0; }
.desc { background: var(--card); padding: 16px; border-radius: 10px; border: 1px solid var(--line); white-space: pre-wrap; }

.person-score { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.person-score-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.flags { margin: 6px 0; }
.flag { display: inline-block; background: #fef2f2; color: var(--bad); padding: 2px 8px; border-radius: 6px; font-size: 0.8rem; margin-right: 6px; }

.breakdown { width: 100%; border-collapse: collapse; }
.breakdown td { padding: 5px 8px; font-size: 0.9rem; border-top: 1px solid var(--line); vertical-align: middle; }
.breakdown td.w { color: var(--muted); white-space: nowrap; }
.breakdown td.note { font-size: 0.82rem; }
.breakdown td.bar { width: 120px; }
.breakdown td.bar span { display: block; height: 8px; background: var(--accent); border-radius: 4px; min-width: 2px; }

.people { list-style: none; padding: 0; }
.people li { display: flex; justify-content: space-between; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; }
.row-actions { display: flex; gap: 14px; align-items: center; }

.danger-form { margin-top: 30px; }

/* Status filter tabs */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.filters a {
  text-decoration: none; color: var(--muted); font-size: 0.9rem; font-weight: 500;
  padding: 5px 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--card);
}
.filters a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Status badges (pipeline) */
.status { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.status-new { background: #eef2ff; color: #4338ca; }
.status-to_inspect { background: #fef9c3; color: #854d0e; }
.status-inspected { background: #dbeafe; color: #1e40af; }
.status-applied { background: #dcfce7; color: #15803d; }
.status-rejected { background: #f3f4f6; color: #6b7280; }

.card-foot { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; flex-wrap: wrap; }
.tally { font-size: 0.85rem; }

.status-bar { display: flex; align-items: center; gap: 10px; margin: 16px 0; }
.status-bar select { width: auto; }

/* Per-person reaction (vote + note) */
.reaction { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.reaction input[name="note"] { flex: 1; }
.votes { display: flex; gap: 4px; }
.votes label {
  cursor: pointer; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-size: 0.95rem; user-select: none;
}
.votes label input { display: none; }
.votes label.on.vote-up { background: #f0fdf4; border-color: var(--good); }
.votes label.on.vote-down { background: #fef2f2; border-color: var(--bad); }
.votes label.on.vote-none { background: #f3f4f6; }
.commute-hint { align-self: flex-end; padding-bottom: 8px; }

/* Auth */
nav { display: flex; align-items: center; gap: 16px; }
.whoami { color: var(--muted); font-size: 0.9rem; }
.logout-form { margin: 0; }
button.linkish { background: none; color: var(--accent); padding: 0; font-weight: 500; }
.auth-card { max-width: 360px; margin: 40px auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin: 18px 0; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.you-badge { background: var(--accent); color: #fff; font-size: 0.7rem; padding: 1px 7px; border-radius: 20px; margin-left: 4px; }
.reaction.readonly { justify-content: flex-start; }
.vote-tag { font-size: 1rem; }

/* Mobile setup page */
.msetup { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; }
.msetup h2 { margin-top: 0; font-size: 1.1rem; }
.msetup ol, .msetup ul { padding-left: 20px; }
.msetup li { margin: 6px 0; }
.token { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; background: #f8fafc; margin-bottom: 10px; }
.code { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 0.8rem; white-space: pre-wrap; word-break: break-all; }
.bookmarklet { display: inline-block; background: var(--accent); color: #fff; padding: 8px 16px; border-radius: 8px; text-decoration: none; font-weight: 600; }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 0.88em; }

/* Responsive: stack the header nav on narrow screens */
@media (max-width: 640px) {
  header { flex-direction: column; align-items: flex-start; gap: 8px; }
  nav { flex-wrap: wrap; gap: 12px; }
  .grid-form { grid-template-columns: 1fr; }
  .pref-row { flex-wrap: wrap; }
  .pref-row label.w { flex: 1 0 90px; }
  .detail-head { flex-direction: column; }
  .url-bar { flex-direction: column; }
  .reaction { flex-wrap: wrap; }
}
