/* App styles (brief 198: visual design pass). No inline styles anywhere: the Content-Security-Policy
   allows stylesheets from this site only, so every look lives here.
   Design tokens: one type scale, one spacing scale, a calm navy-blue accent on cool grey surfaces. */
:root {
  --fg: #172033; --muted: #556074; --faint: #8a93a3; --line: #dde2ea; --line-strong: #c4ccd8;
  --bg: #f4f6f9; --surface: #ffffff; --surface-alt: #f8fafc;
  --accent: #1f4f9c; --accent-hover: #183f7e; --accent-soft: #e8eef8; --accent-ink: #163a73;
  --success: #1a7f37; --success-soft: #e7f5ec; --warn: #8a5a00; --warn-soft: #fff6e0; --warn-line: #ecd28f;
  --danger: #b42318; --danger-soft: #fdecea; --danger-line: #f1b5ae;
  --focus: 0 0 0 3px rgba(31, 79, 156, .32);
  --radius: 8px; --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(23, 32, 51, .06), 0 1px 3px rgba(23, 32, 51, .05);
  --shadow-lg: 0 4px 16px rgba(23, 32, 51, .08);
  /* type scale (1.2 ratio from 16px) */
  --fs-xs: .78rem; --fs-sm: .875rem; --fs-md: 1rem; --fs-lg: 1.125rem; --fs-xl: 1.35rem; --fs-2xl: 1.7rem; --fs-3xl: 2.25rem;
  /* spacing scale */
  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2rem; --s7: 3rem;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: var(--fs-md)/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
       color: var(--fg); background: var(--bg); }
h1, h2, h3 { line-height: 1.25; color: var(--fg); letter-spacing: -.01em; }
h1 { font-size: var(--fs-2xl); margin: 0 0 var(--s4); }
h2 { font-size: var(--fs-xl); margin: var(--s6) 0 var(--s3); }
h3 { font-size: var(--fs-lg); margin: var(--s5) 0 var(--s2); }
p { margin: 0 0 var(--s4); }
a { color: var(--accent); text-underline-offset: .15em; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
code { font-size: .85em; background: var(--surface-alt); border: 1px solid var(--line); border-radius: 4px; padding: 0 .3em; }

/* ---- top bar ---- */
.topbar { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); align-items: center; justify-content: space-between;
          padding: var(--s3) var(--s5); background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar nav { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2); align-items: center; }
.topbar nav a, .topbar nav button.link { padding: .35rem .6rem; border-radius: 6px; color: var(--muted); text-decoration: none; font-size: var(--fs-sm); font-weight: 500; }
.topbar nav a:hover, .topbar nav button.link:hover { color: var(--fg); background: var(--bg); }
.topbar nav a[aria-current="page"] { color: var(--accent-ink); background: var(--accent-soft); }
.topbar .nav-account { display: flex; flex-wrap: wrap; gap: var(--s1); align-items: center; padding-left: var(--s2); margin-left: var(--s1); border-left: 1px solid var(--line); }
.topbar nav a.nav-cta { color: #fff; background: var(--accent); }
.topbar nav a.nav-cta:hover { color: #fff; background: var(--accent-hover); }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 750; font-size: 1.1rem; letter-spacing: -.01em; text-decoration: none; color: var(--fg); }
.brand::before { content: ""; width: 1.6rem; height: 1.6rem; border-radius: 7px; flex: none;
  /* a simple roof-line mark, drawn with gradients (no image request) */
  background: linear-gradient(135deg, transparent 47%, #fff 47%, #fff 57%, transparent 57%) left 0 top 0 / 50% 100% no-repeat,
              linear-gradient(225deg, transparent 47%, #fff 47%, #fff 57%, transparent 57%) right 0 top 0 / 50% 100% no-repeat,
              var(--accent); }
.brand:hover { color: var(--fg); }
.team-switch { display: inline-flex; flex-wrap: wrap; gap: var(--s1); }

/* ---- page frame ---- */
main { max-width: 60rem; margin: 0 auto; padding: var(--s6) var(--s5) var(--s7); }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s5); }
.page-head h1 { margin: 0; }
.page-head .hint { font-size: var(--fs-md); font-weight: 400; }
.card, .plan, fieldset.template-picker, .send-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card { padding: var(--s5); margin: 0 0 var(--s5); }

/* ---- buttons ---- */
button, a.button-link, .button-link { display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 2.5rem; padding: .5rem 1rem; font: inherit; font-size: var(--fs-sm); font-weight: 600; line-height: 1.2;
  border: 1px solid var(--accent); border-radius: var(--radius); background: var(--accent); color: #fff;
  text-decoration: none; cursor: pointer; transition: background-color .12s, border-color .12s, color .12s; }
button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:disabled, button[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
a.button-link, .button-link { background: var(--surface); color: var(--accent); border-color: var(--line-strong); }
a.button-link:hover, .button-link:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
a.button-link.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
a.button-link.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
button.secondary { background: var(--surface); color: var(--accent); border-color: var(--line-strong); }
button.secondary:hover { background: var(--accent-soft); border-color: var(--accent); }
button.danger { background: var(--surface); color: var(--danger); border-color: var(--danger-line); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
button.link { display: inline; min-height: 0; background: none; border: none; color: var(--accent); padding: 0; font-weight: 500; text-decoration: underline; text-underline-offset: .15em; }
button.link:hover { background: none; color: var(--accent-hover); }
form.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin: 0 0 var(--s4); }

/* ---- forms ---- */
label { font-weight: 500; }
input, select, textarea { font: inherit; color: var(--fg); padding: .5rem .65rem; min-height: 2.5rem; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius); transition: border-color .12s, box-shadow .12s; }
textarea { min-height: 0; line-height: 1.45; }
input:hover, select:hover, textarea:hover { border-color: #9aa5b6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input[type=checkbox], input[type=radio] { min-height: 0; width: 1.1rem; height: 1.1rem; padding: 0; accent-color: var(--accent); vertical-align: -.15em; margin: 0 .35rem 0 0; }
input[readonly] { background: var(--surface-alt); }
input.wide, textarea.wide, .wide { width: 100%; max-width: 36rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s4) var(--s5); margin: 0 0 var(--s5); background: var(--surface); }
legend { font-weight: 650; padding: 0 var(--s2); }

/* ---- tables ---- */
table { border-collapse: separate; border-spacing: 0; width: 100%; margin: var(--s2) 0 var(--s5); background: var(--surface);
        border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-alt); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fbfcfe; }
tr.not-included td { color: var(--faint); }

/* ---- status pills ---- */
.status { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: var(--fs-xs); font-weight: 650; line-height: 1.5;
          background: #eef0f4; color: #3d4757; white-space: nowrap; }
.status-draft { background: #eef0f4; color: #3d4757; }
.status-sent { background: var(--accent-soft); color: var(--accent-ink); }
.status-accepted { background: var(--success-soft); color: #145c29; }
.status-declined, .status-not-delivered { background: var(--danger-soft); color: #8f1c13; }
.status-void, .status-expired { background: #f1f1f1; color: #555; }

/* ---- messages and notices ---- */
.messages { list-style: none; padding: 0; margin: 0 0 var(--s5); }
.messages li { padding: .7rem 1rem; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid #c9d6ee; margin-bottom: var(--s2); }
.messages li.success { background: var(--success-soft); border-color: #b5dcc1; }
.messages li.error { background: var(--danger-soft); border-color: var(--danger-line); }
.form-error { padding: .7rem 1rem; border-radius: var(--radius); background: var(--danger-soft); border: 1px solid var(--danger-line); }
.hint { color: var(--muted); font-size: var(--fs-sm); }
.notice { padding: .8rem 1rem; background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: var(--radius); }
.notice > :last-child { margin-bottom: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- step indicator on the main path (new, fill in, preview, send) ---- */
.steps-bar { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); list-style: none; margin: 0; padding: 0; font-size: var(--fs-sm); color: var(--muted); counter-reset: step; }
.steps-bar li { display: inline-flex; align-items: center; gap: .4rem; counter-increment: step; }
.steps-bar li::before { content: counter(step); display: inline-flex; align-items: center; justify-content: center; width: 1.45rem; height: 1.45rem;
  border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); font-size: var(--fs-xs); font-weight: 700; color: var(--muted); }
.steps-bar li.done::before { content: "\2713"; background: var(--success-soft); border-color: #b5dcc1; color: var(--success); }
.steps-bar li[aria-current="step"] { color: var(--fg); font-weight: 650; }
.steps-bar li[aria-current="step"]::before { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- new proposal: template cards ---- */
fieldset.template-picker { padding: var(--s4); }
fieldset.template-picker legend { font-size: var(--fs-lg); }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--s3); margin-top: var(--s2); }
.template-card { position: relative; display: block; padding: var(--s3) var(--s4) var(--s3) 2.6rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; transition: border-color .12s, box-shadow .12s, background-color .12s; }
.template-card:hover { border-color: var(--accent); }
.template-card input[type=radio] { position: absolute; left: var(--s4); top: 1rem; }
.template-card strong { display: block; margin-bottom: .2rem; }
.template-card .hint { display: block; font-size: var(--fs-xs); line-height: 1.45; }
.template-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.template-card:has(input:focus-visible) { box-shadow: var(--focus); }
.new-proposal-foot { display: flex; flex-wrap: wrap; gap: var(--s4); align-items: end; justify-content: space-between; margin: 0 0 var(--s4); }
.new-proposal-foot p { margin: 0; flex: 1 1 18rem; }
.new-proposal-foot button { min-width: 12rem; min-height: 2.9rem; font-size: var(--fs-md); }

/* ---- send page ---- */
.send-card { padding: var(--s5); margin-bottom: var(--s5); }
.send-card table { box-shadow: none; }
.send-card table input, .send-card table select { width: 100%; }
.send-blocked .problems { margin: var(--s2) 0 var(--s3); }
.send-blocked .problems li { margin-bottom: .3rem; }
.client-links { list-style: none; padding: 0; }
.client-links li { padding: var(--s4); margin-bottom: var(--s3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.client-links input { width: 100%; max-width: 34rem; margin: var(--s2) var(--s2) var(--s2) 0; }

/* ---- detail page ---- */
.timeline { list-style: none; padding: 0; margin: 0 0 var(--s5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.timeline li { padding: .55rem .9rem; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: none; }
.timeline .hint { display: inline-block; min-width: 13rem; }
.delete-form { margin-top: var(--s5); padding: var(--s4); border: 1px solid var(--danger-line); border-radius: var(--radius-lg); background: #fffafa; }
.delete-form input { margin: var(--s2) var(--s2) var(--s2) 0; }
section.export { margin-top: var(--s6); }

/* Free proposal generator (brief 047) */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.generator-form fieldset { margin: 0 0 var(--s4); }
.generator-items input { width: 100%; box-sizing: border-box; }
.generator-form input:not([type=checkbox]):not([type=radio]), .generator-form textarea, .generator-form select { width: 100%; max-width: 36rem; }
/* Public site pages (brief 048) */
.site-footer { max-width: 60rem; margin: 0 auto; padding: var(--s5) var(--s5) var(--s6); border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); margin-bottom: var(--s2); }
.site-footer nav a { color: var(--muted); }
.lead { font-size: var(--fs-lg); color: var(--muted); max-width: 40rem; }
.hero { padding: var(--s5) 0 var(--s4); }
.hero h1 { font-size: var(--fs-3xl); line-height: 1.15; margin-bottom: var(--s3); max-width: 40rem; }
.hero .button-link { min-height: 2.9rem; padding: .65rem 1.25rem; font-size: var(--fs-md); margin: 0 var(--s2) var(--s2) 0; }
main > section:not(.hero):not(.export) { margin-bottom: var(--s6); }
.steps { padding-left: 1.3rem; }
.steps li { margin-bottom: var(--s2); }
.columns { columns: 2 14rem; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: var(--s4); margin: var(--s4) 0 var(--s6); }
.plan { padding: var(--s5); }
.plan.popular { border: 2px solid var(--accent); box-shadow: var(--shadow-lg); }
.plan h2 { margin: var(--s1) 0; }
.plan ul { padding-left: 1.1rem; }
.price strong { font-size: var(--fs-2xl); }
.badge { display: inline-block; margin: 0; padding: .1rem .55rem; border-radius: 999px; background: var(--accent); color: #fff; font-size: var(--fs-xs); font-weight: 650; }
.draft-banner { padding: .7rem 1rem; background: var(--danger-soft); border: 1px solid var(--danger-line); border-radius: var(--radius); }
.legal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s5) var(--s6); }
.legal h2 { margin-top: 1.75rem; }
/* Brief 227: the team's images */
.image-grid { list-style: none; padding: 0; margin: 0 0 var(--s5); display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s3); }
.image-card { margin: 0; padding: var(--s3); display: flex; flex-direction: column; gap: var(--s2); }
.image-card img { display: block; width: 100%; height: 120px; object-fit: cover; border-radius: var(--radius); background: var(--line); }
.image-card p { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 640px) {
  :root { --fs-2xl: 1.45rem; --fs-3xl: 1.8rem; }
  main { padding: var(--s5) var(--s4) var(--s6); }
  .topbar { padding: var(--s2) var(--s4); }
  .topbar .nav-account { border-left: none; padding-left: 0; margin-left: 0; }
  .legal { padding: var(--s4); }
  /* tables become stacked rows on a phone */
  /* headers stay for screen readers (visually hidden); each cell shows its label */
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border-bottom: 1px solid var(--line); padding: var(--s2) 0; }
  table.stack tbody tr:last-child { border-bottom: none; }
  table.stack td { border-bottom: none; padding: .2rem .9rem; }
  table.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
  .new-proposal-foot button { width: 100%; }
}
