:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --panel: #ffffff;
  --ink: #18201d;
  --muted: #68736d;
  --line: #dbe1dc;
  --accent: #1f6f68;
  --accent-2: #a94736;
  --soft: #e7f0ed;
  --warn: #fff2ce;
  --danger: #ffe5de;
  --shadow: 0 18px 42px rgba(30, 40, 36, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a { color: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(25px, 4vw, 36px); letter-spacing: 0; }
h2 { font-size: 20px; letter-spacing: 0; }
h3 { font-size: 17px; letter-spacing: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 44px);
  background: rgba(245, 246, 242, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar a {
  text-decoration: none;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.brand > span {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.top-actions form {
  margin: 0;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 20px clamp(14px, 3vw, 28px) 48px;
}

.page.narrow {
  width: min(680px, 100%);
}

.hero-summary,
.section-shell,
.panel,
.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-summary {
  display: grid;
  grid-template-columns: minmax(220px, .7fr) minmax(0, 1.3fr);
  gap: 18px;
  align-items: start;
  padding: 20px;
  margin-bottom: 16px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.status-grid > div {
  min-height: 74px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.status-grid span,
label span,
.section-head span,
small,
dt,
time {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.status-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 19px;
  overflow-wrap: anywhere;
}

.section-shell,
.panel {
  padding: 18px;
  margin-bottom: 16px;
}

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

.project-list,
.event-list {
  display: grid;
  gap: 10px;
}

.project-card {
  display: grid;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  background: #fbfcfa;
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.project-card:hover,
.project-card:focus-visible {
  border-color: rgba(31, 111, 104, .42);
  box-shadow: 0 12px 28px rgba(31, 111, 104, .11);
  transform: translateY(-1px);
  outline: 0;
}

.project-card-main {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.project-card p,
.event-row p,
dd {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.project-card p {
  margin-top: 5px;
  font-size: 13px;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.project-meta span {
  min-height: 28px;
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: #31534f;
  font-size: 12px;
  font-weight: 700;
}

.event-row {
  display: grid;
  grid-template-columns: 180px 160px 1fr;
  gap: 12px;
  align-items: start;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.event-row:last-child { border-bottom: 0; }
.event-row strong { font-size: 13px; }
.event-row p { font-size: 12px; }

.detail-page {
  width: min(1080px, 100%);
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.detail-title {
  display: grid;
  gap: 10px;
}

.detail-title p {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.detail-actions form,
.actions form {
  margin: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.info-panel {
  min-height: 100%;
}

.kv-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.kv-list > div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.kv-list > div:first-child {
  padding-top: 0;
  border-top: 0;
}

dt {
  font-weight: 800;
}

dd {
  margin: 0;
  font-size: 14px;
}

.break-link {
  color: var(--accent);
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
}

input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fbfcfa;
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  font: inherit;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 6px;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

button.ghost {
  color: var(--accent);
  background: var(--soft);
}

.button.ghost {
  color: var(--accent);
  background: var(--soft);
}

button.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
  white-space: nowrap;
}

.notice {
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid #bbd7d2;
  border-radius: 8px;
  background: #edf7f4;
  color: #174f4b;
}

.notice.error {
  border-color: #e0b6ad;
  background: #fff0ed;
  color: #8f2d1c;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  background: #fafbf8;
}

td {
  font-size: 14px;
  overflow-wrap: anywhere;
}

tr:last-child td { border-bottom: 0; }

.pill,
.status {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  background: #eef1ef;
}

.status.active,
.status.verified {
  color: #176149;
  background: #dff2ea;
}

.status.needs_review,
.status.ready_to_add,
.status.draft {
  color: #8a5400;
  background: var(--warn);
}

.status.fetch_failed {
  color: #943320;
  background: var(--danger);
}

.empty,
.empty-panel {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.empty-panel {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.decision {
  padding: 24px;
}

.decision h1 {
  margin: 8px 0 12px;
}

.decision p {
  color: var(--muted);
  line-height: 1.7;
}

.decision-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0 14px;
}

.decision-actions form {
  margin: 0;
}

.back-link {
  color: var(--accent);
  font-weight: 800;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-panel {
  padding: 24px;
}

@media (max-width: 860px) {
  .hero-summary,
  .detail-hero,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-actions {
    justify-content: stretch;
  }

  .detail-actions form,
  .detail-actions button {
    width: 100%;
  }

  .event-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
  }

  .topbar form {
    flex: 0 0 auto;
  }

  .status-grid,
  .project-card-main,
  .kv-list > div,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .project-card-main {
    display: grid;
  }

  .section-shell,
  .panel,
  .hero-summary,
  .detail-hero {
    padding: 14px;
  }

  button {
    padding-inline: 12px;
  }
}
