:root {
  --navy: #12315e;
  --navy-2: #1d4580;
  --orange: #e8822e;
  --orange-soft: #fff4e8;
  --ink: #1d2433;
  --muted: #5b6577;
  --line: #d9e0ea;
  --bg: #f4f6fa;
  --card: #ffffff;
  --ok: #1f7a4d;
  --ok-soft: #e7f5ee;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --warn-soft: #fff7e0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(18, 49, 94, .06), 0 4px 14px rgba(18, 49, 94, .06);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
a { color: var(--navy-2); }
h1, h2, h3 { color: var(--navy); line-height: 1.25; }
h1 { font-size: 1.6rem; margin: 0 0 .3rem; }
h2 { font-size: 1.2rem; margin: 1.4rem 0 .5rem; }
h3 { font-size: 1.02rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

/* ---------- page width: mobile first, grows on wide screens (one global place) ---------- */
.container { width: 100%; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
@media (min-width: 768px) { .container { padding-left: 24px; padding-right: 24px; } }
@media (min-width: 1280px) {
  .container { max-width: min(100%, 1680px); padding-left: clamp(1.5rem, 2.5vw, 3rem); padding-right: clamp(1.5rem, 2.5vw, 3rem); }
}
@media (min-width: 1920px) { .container { max-width: 1840px; } }
/* Deliberately narrow reading/form widths */
.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
.readable { max-width: 880px; }

main.container { padding-top: 24px; padding-bottom: 48px; outline: none; }

/* ---------- top bar ---------- */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.brand img { background: #fff; border-radius: 6px; padding: 2px; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a, .nav button { color: #dfe7f3; text-decoration: none; background: none; border: 0; font: inherit; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.nav a:hover, .nav button:hover, .nav a.active { background: rgba(255, 255, 255, .12); color: #fff; }
.nav .who { color: #b9c7dc; font-size: .875rem; padding: 0 6px; }

/* ---------- cards, buttons, forms ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--navy); background: var(--navy); color: #fff;
  font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 8px; cursor: pointer; text-decoration: none; min-height: 40px; }
.btn:hover { background: var(--navy-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--navy); }
.btn.secondary:hover { background: #eef3fa; }
.btn.accent { background: var(--orange); border-color: var(--orange); }
.btn.accent:hover { background: #d4711f; }
.btn.danger { background: #fff; color: var(--bad); border-color: #e4b4ae; }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: .875rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.btn-row.end { justify-content: flex-end; }

label { display: block; font-weight: 600; margin: 12px 0 4px; }
label .hint { font-weight: 400; color: var(--muted); font-size: .875rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], textarea, select {
  width: 100%; font: inherit; padding: 9px 11px; border: 1px solid #bfc9d8; border-radius: 8px; background: #fff; color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus, select:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid rgba(232, 130, 46, .45); outline-offset: 1px; }
.field-row { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .field-row.two { grid-template-columns: 1fr 1fr; } .field-row.three { grid-template-columns: 2fr 1fr auto; align-items: end; } }

.alert { border-radius: 8px; padding: 10px 14px; margin: 10px 0; border: 1px solid; }
.alert.error { background: var(--bad-soft); border-color: #f1b8b1; color: #7a1a12; }
.alert.ok { background: var(--ok-soft); border-color: #b5dfc8; color: #14532d; }
.alert.warn { background: var(--warn-soft); border-color: #f2d38a; color: #6b4a00; }
.alert.info { background: #eef3fa; border-color: #c9d6ea; color: var(--navy); }
.alert ul { margin: 4px 0 0; padding-left: 20px; }

.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #e8edf5; color: var(--navy); vertical-align: middle; }
.badge.locked { background: var(--ok-soft); color: var(--ok); }
.badge.draft { background: var(--warn-soft); color: #8a5a00; }
.badge.creep { background: var(--bad-soft); color: var(--bad); }

/* ---------- auth pages ---------- */
.auth-wrap { padding-top: 4vh; }
.auth-hero { text-align: center; margin-bottom: 18px; }
.auth-hero p { color: var(--muted); }

/* ---------- dashboard ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1280px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1920px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.grid > .card { margin-top: 0; }
.page-head form { margin-top: 0; }
.page-head form { flex-wrap: nowrap; width: 100%; max-width: 440px; }
.page-head form input { width: auto; flex: 1 1 auto; min-width: 0; }
.prd-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; }
.prd-card:hover { border-color: var(--navy-2); }
.prd-card h3 { margin: 0; }
.prd-card .killer { border-left: 3px solid var(--orange); padding-left: 10px; margin: 6px 0; }
.stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: .875rem; color: var(--muted); margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); }
.stats b { color: var(--ink); }
.empty { text-align: center; padding: 40px 20px; }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); margin-bottom: 16px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(5, 1fr); } }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.kpi .v { font-size: 1.5rem; font-weight: 700; color: var(--navy); }
.kpi .l { color: var(--muted); font-size: .85rem; }

/* ---------- PRD editor ---------- */
.editor { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .editor { grid-template-columns: 280px minmax(0, 1fr); } }
@media (min-width: 1500px) { .editor { grid-template-columns: 300px minmax(0, 1fr) 380px; } .editor .readable { max-width: none; } }
.steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; overflow-x: auto; }
@media (min-width: 1000px) { .steps { flex-direction: column; overflow: visible; } }
.steps a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); white-space: nowrap; border: 1px solid transparent; }
.steps a:hover { background: #fff; border-color: var(--line); }
.steps a.current { background: #fff; border-color: var(--navy); font-weight: 600; }
.steps .num { flex: 0 0 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; background: #e3e8f0; color: var(--navy); }
.steps .done .num { background: var(--ok); color: #fff; }
.steps .review .num { background: var(--orange); color: #fff; }
.q-title { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.q-step { color: var(--orange); font-weight: 700; }
.ask { font-size: 1.1rem; font-weight: 600; margin: 4px 0; }
.help { color: var(--muted); }
.ai-box { margin-top: 14px; background: var(--orange-soft); border: 1px solid #f3cfa6; border-radius: 8px; padding: 12px 14px; white-space: pre-wrap; }
.ai-box .btn-row { white-space: normal; }
.list-edit { display: grid; gap: 10px; }
.list-row { display: grid; gap: 8px; grid-template-columns: 1fr; background: #f9fafc; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
@media (min-width: 720px) { .list-row { grid-template-columns: 32px 1fr 1fr auto; align-items: center; } .list-row.single { grid-template-columns: 1fr auto; } }
.list-row .idx { font-weight: 700; color: var(--navy); }
.counter { font-size: .875rem; color: var(--muted); }
.counter.full { color: var(--bad); font-weight: 600; }
.saved { font-size: .85rem; color: var(--muted); }
.side-panel { display: none; }
@media (min-width: 1500px) { .side-panel { display: block; } .side-panel .card { position: sticky; top: 76px; } }

/* runway */
.runway { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); margin: 14px 0; }
@media (min-width: 900px) { .runway { grid-template-columns: repeat(4, 1fr); } }
.runway .kpi .v.big { color: var(--orange); }
.mini-runway .kpi { margin-bottom: 8px; }

/* review / PRD document */
.prd-doc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.prd-doc h1 { border-bottom: 4px solid var(--orange); padding-bottom: 6px; }
.prd-doc h2 { background: #eef3fa; border-left: 4px solid var(--navy); padding: 4px 10px; }
.prd-doc .pitch { color: var(--orange); font-weight: 600; font-size: 1.05rem; }
.prd-doc .rule { background: var(--orange-soft); border-left: 4px solid var(--orange); padding: 10px 14px; margin: 12px 0; }
table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; }
th, td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
th { background: var(--navy); color: #fff; font-weight: 600; }
tbody tr:nth-child(even) td { background: #f7f9fc; }
.table-wrap { overflow-x: auto; }
.lock-box { border: 2px dashed var(--orange); }
.change-form { display: grid; gap: 4px; }

/* admin */
.temp-pw { font-family: Consolas, monospace; font-size: 1.1rem; background: #fff; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); user-select: all; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px;
  transition: transform .2s, opacity .2s, visibility .2s; max-width: calc(100% - 32px); z-index: 50; opacity: 0; visibility: hidden; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }

/* ---------- print (Export PDF) ---------- */
@media print {
  @page { size: A4; margin: 15mm; }
  body { background: #fff; }
  .topbar, .no-print, .toast { display: none !important; }
  main.container { padding: 0; max-width: none; }
  .prd-doc { border: 0; padding: 0; }
  h2 { break-after: avoid; }
  tr { break-inside: avoid; }
  th { background: var(--navy) !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .prd-doc h2, .prd-doc .rule { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
