:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --line: #e7e8ec;
    --line-soft: #f0f1f4;
    --ink: #1d2230;
    --muted: #6b7280;
    --faint: #9aa1ad;
    --accent: #6b4ee6;
    --accent-soft: #f3f0ff;
    --green: #1f9d57;
    --green-soft: #e8f7ee;
    --red: #d4503b;
    --amber: #8a5a00;
    --amber-soft: #fff7e6;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(20, 24, 40, .06), 0 8px 24px rgba(20, 24, 40, .04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, Segoe UI, Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

#app { max-width: 880px; margin: 0 auto; padding: 24px 18px 80px; }

/* ---------- screens ---------- */
.screen { display: none; animation: fade .18s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.center-card { text-align: center; padding: 12vh 1rem; color: var(--muted); }
.center-card.glass {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 3rem 2rem; margin-top: 8vh;
}
.big-icon { width: 40px; height: 40px; color: var(--accent); margin-bottom: .5rem; }
.spinner {
    width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent);
    border-radius: 50%; margin: 0 auto 1rem; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- header ---------- */
.topbar {
    display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
}
.topbar h1 { font-size: 20px; margin: 0; flex: 1; }
.topbar .sub { font-size: 13px; color: var(--muted); margin-top: 2px; font-weight: 400; }
.crumb {
    display: inline-flex; align-items: center; gap: 6px; background: var(--card);
    border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer;
    font-size: 13px; font-weight: 500; color: var(--ink); text-decoration: none;
}
.crumb:hover { border-color: var(--accent); color: var(--accent); }
.crumb i { width: 16px; height: 16px; }

/* ---------- cards ---------- */
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 16px;
}
.card h2 { font-size: 16px; margin: 0 0 4px; }
.card .desc { color: var(--muted); font-size: 13px; margin: 0 0 14px; line-height: 1.5; }

/* ---------- home hub ---------- */
.hello { font-size: 24px; font-weight: 700; margin: 0 0 2px; }
.hello-sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }

.task {
    display: flex; align-items: center; gap: 16px; background: var(--card);
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px 20px; margin-bottom: 14px; cursor: pointer; transition: border-color .15s;
}
.task:hover { border-color: var(--accent); }
.task .tnum {
    width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent);
    display: grid; place-items: center; font-weight: 700; flex-shrink: 0;
}
.task .tbody { flex: 1; min-width: 0; }
.task .tbody h3 { margin: 0 0 3px; font-size: 15px; }
.task .tbody p { margin: 0; font-size: 13px; color: var(--muted); }
.task .tstate { text-align: right; flex-shrink: 0; display: flex; align-items: center; gap: 10px; }
.task .chev { color: var(--faint); width: 20px; height: 20px; }

.pill {
    font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}
.pill.todo { background: #fdecea; color: var(--red); }
.pill.partial { background: var(--amber-soft); color: var(--amber); }
.pill.done { background: var(--green-soft); color: var(--green); }

.bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }

.done-banner {
    background: var(--green-soft); border: 1px solid #bfe6cd; color: var(--green);
    border-radius: var(--radius); padding: 18px 20px; text-align: center; margin-bottom: 16px;
}
.done-banner h2 { margin: 0 0 4px; color: var(--green); }
.done-banner p { margin: 0; font-size: 13.5px; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid var(--line); background: var(--card); color: var(--ink);
    border-radius: 10px; padding: 10px 16px; font-size: 14px; font-weight: 600;
    cursor: pointer; font-family: inherit; text-decoration: none; transition: all .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn i { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- narrative ---------- */
.narrative-prompt h3 { margin: 0 0 6px; font-size: 15px; color: var(--accent); }
.narrative-prompt p { margin: 0 0 4px; font-size: 13.5px; line-height: 1.55; color: var(--ink); }
.narrative-prompt .it { color: var(--muted); font-style: italic; font-size: 13px; }
.prev-ref {
    background: #fafbfc; border: 1px solid var(--line); border-left: 3px solid var(--faint);
    border-radius: 10px; padding: 12px 14px; margin: 14px 0; font-size: 13px;
}
.prev-ref .lab { font-size: 11px; font-weight: 700; letter-spacing: .4px; color: var(--faint); margin-bottom: 6px; }
.prev-ref p { margin: 0; font-style: italic; color: #444b58; line-height: 1.55; }
textarea.narrative {
    width: 100%; min-height: 150px; padding: 14px; border: 1px solid var(--line); border-radius: 10px;
    font-family: inherit; font-size: 14px; line-height: 1.55; resize: vertical; color: var(--ink);
    background: #fff; outline: none;
}
textarea.narrative:focus { border-color: var(--accent); }
.req-mark { color: var(--red); font-weight: 700; }
.field-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); margin-top: 6px; }

/* ---------- criteria rows ---------- */
.crit {
    padding: 16px 0; border-bottom: 1px solid var(--line-soft);
}
.crit:last-child { border-bottom: 0; }
.crit h4 { margin: 0 0 3px; font-size: 14px; }
.crit .cd { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.crit .cd.it { font-style: italic; color: var(--faint); margin-top: 2px; }
.scale { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.scale button {
    width: 38px; height: 38px; border: 1px solid var(--line); background: #fff; border-radius: 9px;
    font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; font-family: inherit;
    transition: all .1s;
}
.scale button:hover { border-color: var(--accent); color: var(--accent); }
.scale button.sel { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- team: summary strip ---------- */
.strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 16px; }
.chip {
    display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--card);
    border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
    white-space: nowrap; color: var(--ink);
}
.chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.chip.partial .dot { background: var(--amber); }
.chip.done .dot { background: var(--green); }

.nav-between { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; }

/* ---------- team: desktop grid ---------- */
.viewtoggle { display: flex; gap: 6px; }
.viewtoggle .tg {
    border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 6px 12px;
    font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--muted);
}
.viewtoggle .tg.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.gridwrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table.grid { border-collapse: collapse; width: 100%; font-size: 13px; }
table.grid th, table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); text-align: center; }
table.grid th.crit-col, table.grid td.crit-col { text-align: left; position: sticky; left: 0; background: var(--card); min-width: 190px; }
table.grid thead th { background: #fafbfc; font-size: 11px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); }
table.grid select {
    width: 54px; padding: 5px; border: 1px solid var(--line); border-radius: 7px; font-family: inherit;
    font-size: 13px; background: #fff; color: var(--muted);
}
table.grid select.rated { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.grid-note { font-size: 12px; color: var(--muted); margin: 10px 2px 0; }

/* ---------- toast ---------- */
.toast {
    position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 13.5px;
    font-weight: 500; opacity: 0; pointer-events: none; transition: all .2s; z-index: 100;
    display: flex; align-items: center; gap: 8px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.saved { background: var(--green); }
.toast.error { background: var(--red); }

.hint { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.hint i { width: 14px; height: 14px; }
.saved-ind { font-size: 12.5px; color: var(--green); display: inline-flex; align-items: center; gap: 5px; opacity: 0; transition: opacity .2s; }
.saved-ind.show { opacity: 1; }
.saved-ind i { width: 14px; height: 14px; }

/* ---------- admin tables ---------- */
table.adm { border-collapse: collapse; width: 100%; font-size: 13px; }
table.adm th { background: #fafbfc; padding: 9px 11px; font-size: 11px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); border-bottom: 1px solid var(--line); text-align: center; }
table.adm td { padding: 9px 11px; border-bottom: 1px solid var(--line-soft); }
table.adm tbody tr:hover { background: #fafbff; }
table.adm tr.row-warn td { background: #fffdf7; }

@media (max-width: 640px) {
    #app { padding: 16px 12px 70px; }
    .hello { font-size: 20px; }
    .scale button { width: 34px; height: 34px; }
}
