:root {
  --ink: #1c2733;
  --muted: #5b6b7b;
  --line: #dde4ec;
  --bg: #f4f6f9;
  --card: #ffffff;
  --accent: #0f5d8f;
  --accent-soft: #e8f1f8;
  --danger: #b3261e;
  --warn: #9a6700;
  --ok: #2e7d4f;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.topbar { background: #12293d; color: #fff; }
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 14px 20px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: .3px; }
.brand-sub { font-size: 12.5px; color: #b8c9d8; margin-top: 2px; }
.topbar-right { font-size: 13px; color: #cfe0ee; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar-right a { color: #9fd0f5; text-decoration: none; }
.live { color: #7fe0a3; font-size: 12px; }
.live.off { color: #f0a9a4; }
.live.off::after { content: " — reconnecting"; }
.container { max-width: 1240px; margin: 0 auto; padding: 20px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 20px; margin-bottom: 18px;
}
h1 { font-size: 21px; margin: 0 0 6px; }
h2 { font-size: 16.5px; margin: 0 0 10px; }
h3 { font-size: 14.5px; margin: 22px 0 8px; }
.intro, .muted { color: var(--muted); font-size: 13px; }
.footnote { color: var(--muted); font-size: 12.5px; }
.banner { padding: 9px 12px; border-radius: 7px; margin: 10px 0; font-size: 13.5px; }
.banner.danger { background: #fbe4e2; color: var(--danger); }

input, select, textarea, button { font: inherit; }
input[type=text], input[type=password], input[type=search], input[type=date], input:not([type]), select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink);
}
textarea { resize: vertical; }
button { cursor: pointer; border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: 14px; }
button.primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
button.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.login-card { max-width: 380px; margin: 60px auto; }

/* summary tiles */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
  text-align: left; color: var(--ink); font-weight: 400;
}
.tile-btn:hover { border-color: var(--accent); }
.tile-n { font-size: 24px; font-weight: 700; }
.tile-l { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.bar { height: 6px; background: #e6ebf1; border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--ok); }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; }
.toolbar input[type=search] { flex: 1 1 240px; width: auto; }
.toolbar select { width: auto; max-width: 220px; }
.toolbar .spacer { flex: 1 1 0; }
.check { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }

/* sections */
.sec { padding: 16px 0 4px; overflow-x: auto; }
.sec h2 { padding: 0 20px; }
.count { font-weight: 500; font-size: 12.5px; color: var(--muted); margin-left: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted);
  padding: 8px 12px; border-bottom: 1px solid var(--line); background: #fafbfc;
}
th:first-child, td:first-child { padding-left: 20px; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
tr:last-child td { border-bottom: none; }
td:nth-child(2) { width: 150px; } td:nth-child(3) { width: 210px; } td:nth-child(4) { width: 150px; } td:nth-child(5) { width: 130px; }
a.title { color: var(--ink); font-weight: 600; text-decoration: none; }
a.title:hover { color: var(--accent); text-decoration: underline; }
tr.done a.title { color: var(--muted); font-weight: 500; }
tr.archived { opacity: .55; }
.detail { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.tags { margin-left: 8px; white-space: nowrap; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; margin-right: 4px; }
.pill.study { background: var(--accent-soft); color: var(--accent); }
.pill.grey { background: #eef1f5; color: var(--muted); }

select.status { padding: 5px 8px; border-radius: 20px; font-size: 12.5px; font-weight: 600; border-color: transparent; }
.st-not-started { background: #eef1f5; color: var(--muted); }
.st-open { background: #fbe4e2; color: var(--danger); }
.st-planned { background: #ede7f6; color: #5b3f9a; }
.st-draft { background: #fff3d6; color: var(--warn); }
.st-in-review { background: var(--accent-soft); color: var(--accent); }
.st-complete, .st-living { background: #eaf6ee; color: var(--ok); }
.st-retired { background: #eef1f5; color: var(--muted); text-decoration: line-through; }

/* drawer */
.drawer { position: fixed; inset: 0; background: rgba(18, 41, 61, .45); z-index: 20; display: flex; justify-content: flex-end; }
.drawer[hidden] { display: none; }
.drawer-panel { background: #fff; width: min(560px, 100%); height: 100%; overflow-y: auto; padding: 20px 22px 40px; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.drawer-head h2 { margin: 0; }
.drawer label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.drawer label input, .drawer label select, .drawer label textarea { margin-top: 4px; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.drawer-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#c-form textarea { margin-bottom: 8px; }
.comment { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; margin-top: 10px; font-size: 14px; white-space: pre-wrap; }
.event { font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }

@media (max-width: 640px) {
  .container { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .toolbar select { max-width: none; flex: 1 1 140px; }
}

/* home, admin */
a { color: var(--accent); }
.banner.ok { background: #eaf6ee; color: #1f5c39; }
.issued .cred { margin-top: 8px; font-size: 15px; }
code { background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px; font-size: 14px; user-select: all; }
.summary.home { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.tile-link { text-decoration: none; display: block; }
.tile-link:hover { border-color: var(--accent); }
.tile-h { font-weight: 700; font-size: 16px; color: var(--accent); }
.tile-unit { font-size: 13px; font-weight: 500; color: var(--muted); }
.stack label:not(.check) { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.stack label:not(.check) input, .stack label:not(.check) textarea { margin-top: 4px; font-weight: 400; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.access { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin: 4px 0 12px; }
.access-h { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.stack .check { color: var(--ink); margin-bottom: 10px; }
.person { border-top: 1px solid var(--line); padding: 10px 0; }
.person summary { cursor: pointer; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.person summary .right { margin-left: auto; }
.person.disabled summary b { color: var(--muted); text-decoration: line-through; }
.person form { padding: 14px 0 6px; }
button.danger { color: var(--danger); }
table.plain { min-width: 0; }
input:disabled { background: #f4f6f9; color: var(--muted); }
