:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --border: #e3e6ea;
  --text: #1b1f24; --muted: #667085; --accent: #2d6cdf; --accent-soft: #e8f0fd; --accent-text: #1d4fb0;
  --ok: #1a7f4b; --ok-soft: #e3f5ea; --warn: #b4540a; --warn-soft: #fdf0e3; --danger: #c0392b; --danger-soft: #fdeaea;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --surface: #1a1f26; --surface-2: #222933; --border: #2d3540;
    --text: #e8ebf0; --muted: #98a2b3; --accent: #5b8def; --accent-soft: #1d2a44; --accent-text: #9dbcf7;
    --ok: #4ccb86; --ok-soft: #14301f; --warn: #f0a04b; --warn-soft: #3a2812; --danger: #f07167; --danger-soft: #3a1b18;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5; color: var(--text); background: var(--bg); }
body.modal-open { overflow: hidden; }
h1 { font-size: 1.5rem; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
p { margin: 0 0 10px; }
a { color: var(--accent-text); }
.link { color: var(--accent-text); text-decoration: none; }
.link:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: var(--mono); font-size: .9em; }
.empty { padding: 18px 0; text-align: center; }
[hidden] { display: none !important; }

.container { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.page { padding: 20px 0 60px; display: flex; flex-direction: column; gap: 16px; }
.page.narrow { max-width: 560px; }
.page.wide { max-width: 1100px; }
.section-head { margin-top: 8px; }
.section-head p { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > input[type=text] { flex: 1; min-width: 200px; }
.row-end { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-block; position: relative; }
.brand-mark::after { content: ''; position: absolute; left: 6px; top: 4px; width: 6px; height: 10px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav-link { padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-text); }
.topbar-right { margin-left: auto; }
.announcement { padding: 10px 16px; background: var(--warn-soft); color: var(--text); border-bottom: 1px solid var(--border); }
#announcement { background: var(--warn-soft); }
.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.subnav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; }
.subnav a.active { background: var(--accent-soft); color: var(--accent-text); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card-flush { padding: 0; overflow: hidden; }
.hero h1 { font-size: 1.35rem; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.alias-pill { padding: 4px 10px; border-radius: 999px; background: var(--surface-2); font-size: .85rem; white-space: nowrap; }
.next-step { margin-top: 16px; padding: 14px; border-radius: 10px; background: var(--accent-soft); }
.next-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--accent-text); font-weight: 700; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.next-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.next-text { font-size: 1.1rem; font-weight: 600; }
.nudge { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.hint { display: block; color: var(--muted); font-size: .875rem; margin-top: 2px; }
.label-strong { font-weight: 600; display: block; margin-bottom: 2px; }

/* Milestones */
.ms { padding: 12px 16px; }
.ms-current { border-color: var(--accent); }
.ms-done { opacity: .8; }
.ms-head { display: flex; justify-content: space-between; align-items: center; width: 100%; gap: 10px; background: none; border: 0; padding: 4px 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.ms-title { display: flex; align-items: center; gap: 10px; font-weight: 600; flex-wrap: wrap; }
.ms-num { width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; font-weight: 700; flex-shrink: 0; }
.ms-current .ms-num { background: var(--accent); color: #fff; }
.ms-meta { display: flex; gap: 10px; align-items: center; white-space: nowrap; }
.chev { color: var(--muted); }
.ms-desc { margin: 8px 0 4px; }
.items { list-style: none; margin: 10px 0 0; padding: 0; }
.items li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--border); }
.items li input[type=checkbox] { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }
.items li label { cursor: pointer; flex: 1; }
.items li.done .item-label { text-decoration: line-through; color: var(--muted); }
.items.ro li { padding: 6px 0; }
.tick { width: 22px; text-align: center; color: var(--ok); font-weight: 700; }
.ms-details summary { cursor: pointer; padding: 8px 0; font-weight: 600; }

/* Progress bars */
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 8px 0; }
.bar-sm { height: 6px; margin: 6px 0; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }

/* Chips & alerts */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.chip-accent { background: var(--accent-soft); color: var(--accent-text); }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip-btn { border: 1px solid var(--border); background: var(--surface); cursor: pointer; font: inherit; font-size: .8rem; color: var(--text); }
.chip-btn:hover { background: var(--surface-2); }
.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-size: .95rem; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }

/* Forms */
label { display: block; font-weight: 600; font-size: .9rem; margin: 10px 0 4px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; margin: 14px 0; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop { display: block; position: relative; padding: 22px; border: 2px dashed var(--border); border-radius: 10px; text-align: center; cursor: pointer; margin-bottom: 10px; font-weight: 400; }
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.step { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.step:last-of-type { border-bottom: 0; }
.step > div { flex: 1; min-width: 0; }
.step label:first-child { margin-top: 0; }
.step-num { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; margin-top: 2px; }
.notice ul { padding-left: 20px; }
.notice li { margin-bottom: 6px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn.danger { color: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: .85rem; }
.btn-block { width: 100%; margin-top: 16px; }

/* Auth */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.auth-brand h1 { margin: 0; }

/* Log */
.log-list { display: flex; flex-direction: column; gap: 10px; }
.log-entry { padding: 12px 16px; }
.log-meta { display: flex; justify-content: space-between; align-items: center; }
.log-body { white-space: pre-wrap; margin: 4px 0 0; }
.log-entry-sm { padding: 8px 0; border-top: 1px solid var(--border); }
.log-entry-sm p { white-space: pre-wrap; margin: 2px 0 0; }

/* Board */
.table-wrap { overflow-x: auto; }
.board, .tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.board th, .board td, .tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.board th, .tbl th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); }
.board th:not(:first-child):not(:last-child), .board td:not(:first-child):not(:last-child) { text-align: center; }
.board tr.me { background: var(--accent-soft); }
.board td.alias { font-weight: 600; white-space: nowrap; }
.board td.alias .chip { margin-left: 6px; }
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); vertical-align: middle; }
.dot-part { background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); border-color: var(--accent); }
.dot-full { background: var(--ok); border-color: var(--ok); }
.legend .dot { margin: 0 2px 0 6px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; }
.stat-label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-num { font-size: 1.6rem; font-weight: 700; }
.tbl.clickable tbody tr { cursor: pointer; }
.tbl.clickable tbody tr:hover { background: var(--surface-2); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

/* Feedback */
.sub { padding: 12px 16px; }
.sub-head { display: flex; justify-content: space-between; align-items: center; width: 100%; gap: 10px; background: none; border: 0; padding: 4px 0; font: inherit; color: inherit; cursor: pointer; text-align: left; flex-wrap: wrap; }
.sub-head > div:last-child { display: flex; gap: 8px; align-items: center; }
.sub-q { margin: 4px 0 0; }
.sub-body { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.sub-details summary { cursor: pointer; padding: 8px 0; }
.md h3 { font-size: 1rem; margin: 14px 0 6px; }
.md ul, .md ol { padding-left: 22px; }
.md p { margin: 6px 0; }
.pre { white-space: pre-wrap; font-family: var(--mono); font-size: .85rem; background: var(--surface-2); padding: 10px; border-radius: 8px; max-height: 300px; overflow: auto; }

/* Admin milestone editor */
.ms-edit { display: grid; grid-template-columns: 30px 1fr 160px auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.items-edit { list-style: none; padding: 0; margin: 12px 0 0; }
.items-edit li, .items-edit-add { display: grid; grid-template-columns: 1.3fr 1fr auto auto; gap: 8px; align-items: center; padding: 4px 0; }
.items-edit-add { grid-template-columns: 1.3fr 1fr auto; margin-top: 8px; border-top: 1px solid var(--border); padding-top: 10px; }
@media (max-width: 700px) { .ms-edit, .items-edit li, .items-edit-add { grid-template-columns: 1fr; } }

/* Modal, toasts, spinner */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; padding: 18px; }
.modal-wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-head h2 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; width: min(92vw, 420px); }
.toast { padding: 10px 14px; border-radius: 10px; background: var(--text); color: var(--bg); opacity: 0; transform: translateY(8px); transition: all .25s; font-size: .95rem; text-align: center; }
.toast.show { opacity: 1; transform: none; }
.toast-error { background: var(--danger); color: #fff; }
.toast-success { background: var(--ok); color: #fff; }
.boot-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--muted); }
.spinner { width: 20px; height: 20px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  .topbar-inner { gap: 10px; }
  .brand-text { display: none; }
  .nav { gap: 0; }
  .nav-link { padding: 6px 8px; font-size: .92rem; }
  .next-row { flex-direction: column; align-items: stretch; }
  .hero-top { flex-direction: column; }
}
