/* Neutral palette only: grays / slate / off-white, one muted blue-gray
   accent. No orange, brown, light green, or violet (see SPEC.md). */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --fg: #1c1f24;
  --fg-muted: #5b626c;
  --accent: #454b54;
  --accent-hover: #2f343b;
  --border: #dde1e6;
  --error: #9c3b3b;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(20, 22, 25, 0.06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  line-height: 1.55; -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 0.7rem 1.75rem; background: var(--accent); color: #f2f3f5;
}
.topbar .brand { font-weight: 700; font-size: 1rem; color: #ffffff; }
.topbar nav { display: flex; align-items: center; }
.topbar .whoami { margin-right: 1rem; color: #cfd2d7; font-size: 0.85rem; }

.content { max-width: 720px; margin: 0 auto; padding: 2rem 1.75rem 3rem; }

h1 { margin: 0 0 1rem; font-size: 1.4rem; font-weight: 700; letter-spacing: -0.01em; }

.muted { color: var(--fg-muted); }

.login-box {
  max-width: 340px; margin: 3rem auto; padding: 1.75rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.login-box h1 { text-align: center; }

form label { display: block; margin: 0.85rem 0 0.3rem; font-size: 0.9rem; color: var(--fg-muted); }
form input {
  width: 100%; padding: 0.5rem 0.6rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 1rem; background: var(--surface); color: var(--fg);
}
form button {
  margin-top: 1.25rem; width: 100%; padding: 0.55rem 0.8rem;
  border: none; border-radius: var(--radius); background: var(--accent);
  color: #ffffff; font-size: 1rem; font-weight: 600; cursor: pointer;
}
form button:hover { background: var(--accent-hover); }

.link-button {
  background: none; border: none; color: #cfd2d7; cursor: pointer;
  font-size: 0.9rem; padding: 0; text-decoration: underline;
}
.inline-form { display: inline; }

.error {
  color: var(--error); background: #f6e9e9; border: 1px solid #e3c6c6;
  border-radius: var(--radius); padding: 0.5rem 0.75rem; font-size: 0.9rem;
}

/* ---------- Phase 1: research management ---------- */
.topbar .brand { text-decoration: none; }

.page-head {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.page-head h1 { margin: 0; }
.page-head .button { margin-left: auto; }

h2 { font-size: 1.05rem; font-weight: 650; margin: 0 0 0.75rem; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem; margin-bottom: 1.25rem;
}

a.button {
  display: inline-block; padding: 0.45rem 0.9rem; border-radius: var(--radius);
  background: var(--accent); color: #ffffff; text-decoration: none;
  font-weight: 600; font-size: 0.95rem;
}
a.button:hover { background: var(--accent-hover); }

/* tables: never fixed-width; horizontal scroll on small screens */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--fg-muted); font-weight: 600; font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.small { font-size: 0.85rem; }
code { background: #eceef1; padding: 0.1rem 0.35rem; border-radius: 4px; }
.join-code { font-size: 1.3rem; letter-spacing: 0.12em; }

.badge {
  display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; border: 1px solid var(--border);
  background: #eceef1; color: var(--fg-muted);
}
.badge-running { background: #e3ebe6; color: #2e5941; border-color: #c8d8cd; }
.badge-draft { background: #eceef1; color: #5b626c; }
.badge-stopped { background: #f0e7e7; color: #7c4a4a; border-color: #ddc9c9; }
.badge-finished { background: #e7eaf0; color: #3f4d63; border-color: #ccd4e0; }

.sort-row a { color: var(--fg-muted); }
.sort-row a.active-sort { color: var(--fg); font-weight: 600; text-decoration: none; }

form select, form textarea {
  width: 100%; padding: 0.5rem 0.6rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 1rem; background: var(--surface);
  color: var(--fg); font-family: inherit;
}
form fieldset {
  border: 1px dashed var(--border); border-radius: var(--radius);
  margin: 0.85rem 0 0; padding: 0.25rem 0.75rem 0.75rem;
}
.field-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.field-row > span { flex: 1 1 130px; }
.checkbox-label {
  display: inline-flex !important; align-items: center; gap: 0.4rem;
  margin: 0.5rem 0.75rem 0 0; color: var(--fg);
}
.checkbox-label input { width: auto; }
.days-row { display: flex; flex-wrap: wrap; gap: 0.15rem 0.5rem; }

.add-box { margin-top: 0.9rem; }
.add-box > summary {
  cursor: pointer; color: var(--accent); font-weight: 600; font-size: 0.95rem;
}
.add-box[open] > summary { margin-bottom: 0.5rem; }
.add-box form button[type="submit"] { width: auto; padding: 0.5rem 1.1rem; }

.status-actions {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  margin: 0.75rem 0;
}
.status-actions button { margin-top: 0; width: auto; padding: 0.45rem 0.9rem; }
.extend-form { display: inline-flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.extend-form input[type="date"] { width: auto; }

button.danger { background: #8a5050; }
button.danger:hover { background: #714040; }
button.mini {
  margin: 0; width: auto; padding: 0.15rem 0.5rem; font-size: 0.9rem;
  background: #eceef1; color: var(--fg); border: 1px solid var(--border);
}
button.mini:hover { background: var(--border); }
button.mini.danger { color: #7c4a4a; }
button.mini:disabled { opacity: 0.35; cursor: default; }
.actions-cell form { margin-right: 0.15rem; }

.join-row { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
.qr { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }

.preview-list { columns: 2 220px; margin: 0.5rem 0 0; padding-left: 1.2rem; }
.preview-list li { margin-bottom: 0.15rem; }

.form-narrow { max-width: 480px; }
