:root {
  --bg: #F5F4F0;
  --card: #FFFFFF;
  --ink: #16212E;
  --muted: #6B7380;
  --line: #E6E3DC;
  --navy: #1F3A5F;
  --navy-2: #2C5282;
  --coral: #E07A5F;
  --green: #2F855A;
  --green-soft: #E3F2E9;
  --amber: #B7791F;
  --amber-soft: #FBF0DC;
  --red: #C53030;
  --grey-soft: #EFEDE8;
  --shadow: 0 1px 2px rgba(22, 33, 46, .04), 0 8px 24px -12px rgba(22, 33, 46, .16);
  --r: 16px;
  --sans: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--navy-2); }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
h2 { font-size: 17px; margin-bottom: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.err { color: var(--red); margin: 0; font-size: 14px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 10px; cursor: pointer; text-decoration: none; color: var(--ink); font-weight: 500; font-size: 14px; transition: background .15s, border-color .15s, transform .1s; white-space: nowrap; }
.btn:hover { border-color: #CFCAC0; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: var(--navy-2); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.04); }
.btn.icon { padding: 8px 11px; font-size: 18px; line-height: 1; }
.btn.wide { width: 100%; justify-content: center; padding: 12px; }
.btn.danger { color: var(--red); }

/* gate */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 80% -10%, #DCE6F2, transparent), radial-gradient(800px 500px at -10% 110%, #F8DED6, transparent), var(--bg); }
.gate-card { width: min(380px, 100%); background: var(--card); border-radius: 22px; padding: 32px 28px; box-shadow: var(--shadow); display: grid; gap: 12px; text-align: center; }
.gate-card h1 { font-size: 26px; }
.gate-card p { margin: 0 0 6px; }
.gate-card input { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; outline: none; background: #FBFAF8; }
.gate-card input:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(44, 82, 130, .15); }
.logo { width: 52px; height: 52px; border-radius: 15px; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 24px; margin: 0 auto 4px; position: relative; }
.logo::after { content: ""; position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--coral); right: -3px; bottom: -3px; border: 2px solid var(--card); }
.logo.sm { width: 36px; height: 36px; font-size: 17px; border-radius: 11px; margin: 0; }
.logo.sm::after { width: 9px; height: 9px; }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 12px max(20px, calc((100vw - 1120px) / 2)); background: rgba(245, 244, 240, .85); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 10px; align-items: center; }
.brand b { display: block; line-height: 1.1; }
.brand small { color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 2px; background: var(--grey-soft); padding: 3px; border-radius: 12px; margin: 0 auto; }
.tabs button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 500; color: var(--muted); font-size: 14px; }
.tabs button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.top-actions { position: relative; display: flex; gap: 4px; }
.menu { position: absolute; right: 0; top: 44px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 180px; display: grid; }
.menu button { border: 0; background: none; text-align: left; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--grey-soft); }

main { max-width: 1120px; margin: 0 auto; padding: 24px 20px 80px; }

/* hero */
.hero { display: flex; gap: 24px; align-items: center; justify-content: space-between; background: linear-gradient(135deg, #1F3A5F 0%, #2C5282 60%, #3B6AA0 100%); color: #fff; border-radius: 22px; padding: 28px 30px; margin-bottom: 24px; position: relative; overflow: hidden; box-shadow: 0 20px 40px -24px rgba(31, 58, 95, .6); }
.hero::before { content: ""; position: absolute; width: 340px; height: 340px; border-radius: 50%; background: radial-gradient(circle, rgba(224, 122, 95, .35), transparent 70%); right: -80px; top: -140px; }
.hero > * { position: relative; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 11px; font-weight: 600; opacity: .7; margin: 0 0 6px; }
.hero h1 { font-size: clamp(22px, 3.2vw, 30px); line-height: 1.15; }
.hero .muted { color: rgba(255,255,255,.78); margin: 8px 0 14px; max-width: 60ch; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); padding: 5px 11px; border-radius: 999px; font-size: 13px; }
.chip b { font-weight: 600; }
.chip.warn { background: rgba(224, 122, 95, .3); border-color: rgba(224, 122, 95, .6); }
.ring-wrap { position: relative; width: 120px; height: 120px; flex: none; }
.ring { width: 120px; height: 120px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: rgba(255,255,255,.15); }
.ring .bar { stroke: #fff; stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1); }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-label b { font-size: 26px; line-height: 1; }
.ring-label small { opacity: .75; font-size: 12px; }

/* toolbar */
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; }
.seg { display: flex; gap: 2px; background: var(--grey-soft); padding: 3px; border-radius: 10px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 500; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
#search { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 12px; min-width: 240px; outline: none; }
#search:focus { border-color: var(--navy-2); }

/* sections + doc cards */
.section { margin-bottom: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.section-head h2 { margin: 0; font-size: 19px; }
.section-head .count { color: var(--muted); font-size: 13px; font-weight: 500; }
.section > p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; align-items: start; }
.doc { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s, transform .15s; position: relative; }
.doc.drag { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(44, 82, 130, .18), var(--shadow); transform: translateY(-2px); }
.doc.is-ready { border-color: #BFE0CC; }
.doc.is-na { opacity: .6; }
.doc-top { display: flex; gap: 12px; align-items: flex-start; }
.check { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #CFCAC0; background: none; cursor: pointer; display: grid; place-items: center; color: #fff; font-size: 14px; margin-top: 1px; transition: all .15s; }
.check:hover { border-color: var(--green); }
.doc.is-ready .check { background: var(--green); border-color: var(--green); }
.doc.is-na .check { background: #CFCAC0; border-color: #CFCAC0; }
.doc-title { flex: 1; min-width: 0; }
.doc-title h3 { font-size: 15px; font-weight: 600; line-height: 1.3; }
.doc-title p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; margin-top: 6px; letter-spacing: .02em; }
.tag.required { background: #FDE8E4; color: #B5452B; }
.tag.strong { background: var(--amber-soft); color: var(--amber); }
.tag.helpful { background: #E8EEF6; color: var(--navy-2); }
.tag.if { background: var(--grey-soft); color: var(--muted); }
.doc-more { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px 6px; border-radius: 6px; font-size: 18px; line-height: 1; }
.doc-more:hover { background: var(--grey-soft); }
.files { display: grid; gap: 6px; }
.file { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; background: #FAF9F6; border: 1px solid var(--line); }
.thumb { width: 38px; height: 38px; border-radius: 7px; flex: none; background: var(--grey-soft) center/cover no-repeat; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--muted); cursor: pointer; border: 0; }
.thumb.pdf { background-color: #FDE8E4; color: #B5452B; }
.file-name { flex: 1; min-width: 0; cursor: pointer; }
.file-name b { display: block; font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name small { color: var(--muted); font-size: 11px; }
.file .x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; padding: 4px 6px; border-radius: 6px; }
.file .x:hover { background: #FDE8E4; color: var(--red); }
.drop { border: 1.5px dashed #D3CEC4; border-radius: 12px; padding: 12px; text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; transition: all .15s; background: #FCFBF9; }
.drop:hover { border-color: var(--navy-2); color: var(--navy-2); background: #F3F6FA; }
.drop b { color: var(--navy-2); font-weight: 600; }
.progress { height: 4px; background: var(--grey-soft); border-radius: 4px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--navy-2); width: 0; transition: width .2s; }
.note { width: 100%; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 6px 8px; font-size: 13px; resize: vertical; min-height: 32px; color: var(--ink); }
.note:hover { background: #FAF9F6; }
.note:focus { outline: none; border-color: var(--line); background: #FAF9F6; }
.doc-menu { position: absolute; right: 12px; top: 40px; z-index: 5; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: grid; min-width: 200px; }
.doc-menu button { border: 0; background: none; text-align: left; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.doc-menu button:hover { background: var(--grey-soft); }
.add-doc { border: 1.5px dashed #D3CEC4; border-radius: var(--r); background: transparent; display: grid; place-content: center; gap: 4px; min-height: 120px; color: var(--muted); cursor: pointer; font-weight: 500; transition: all .15s; text-align: center; }
.add-doc:hover { border-color: var(--navy-2); color: var(--navy-2); }
.add-doc span { font-size: 24px; line-height: 1; }
.empty { color: var(--muted); padding: 30px; text-align: center; }

/* cards & plan */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1.3fr; gap: 18px; }
.grid2 .card { margin: 0; }
.grid2 + .card { margin-top: 18px; }
.date-row { display: flex; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.date-row:last-child { border: 0; }
.date-badge { width: 52px; flex: none; text-align: center; border-radius: 12px; background: var(--grey-soft); padding: 6px 0; }
.date-badge small { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .06em; }
.date-badge b { font-size: 19px; line-height: 1.1; }
.date-row.hot .date-badge { background: #FDE8E4; }
.date-row.hot .date-badge small { color: #B5452B; }
.date-row.past { opacity: .5; }
.date-row div p { margin: 0; font-weight: 500; }
.date-row div span { color: var(--muted); font-size: 13px; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { display: flex; gap: 12px; padding: 10px 0; position: relative; }
.steps li:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 40px; bottom: -4px; width: 2px; background: var(--line); }
.steps li.done:not(:last-child)::before { background: #BFE0CC; }
.steps .check { width: 28px; height: 28px; }
.steps li.done .check { background: var(--green); border-color: var(--green); }
.steps p { margin: 0; font-weight: 500; }
.steps li.done p { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.25); }
.steps span { color: var(--muted); font-size: 13px; }
.tips ul { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
.tips li::marker { color: var(--coral); }

/* form */
.form h2 { margin-top: 10px; }
.form h2:first-child { margin-top: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 16px; margin-bottom: 18px; }
.fields .span2 { grid-column: 1 / -1; }
.fields label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }
.fields input, .fields textarea { border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #FBFAF8; outline: none; color: var(--ink); font-size: 15px; resize: vertical; }
.fields input:focus, .fields textarea:focus { border-color: var(--navy-2); background: #fff; box-shadow: 0 0 0 3px rgba(44, 82, 130, .12); }

/* letter */
.letter-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
.letter-head h2 { margin-bottom: 4px; }
.letter-head p { margin: 0; max-width: 60ch; }
.letter { font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.6; background: #FFFEFC; border: 1px solid var(--line); border-radius: 12px; padding: 48px 56px; max-width: 800px; margin: 0 auto; outline: none; white-space: pre-wrap; min-height: 600px; }
.letter:focus { border-color: var(--navy-2); }

/* viewer */
.viewer { position: fixed; inset: 0; z-index: 50; background: rgba(15, 20, 28, .88); display: flex; flex-direction: column; backdrop-filter: blur(4px); }
.viewer-bar { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; color: #fff; gap: 12px; }
.viewer-bar b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-bar .btn { color: #fff; border-color: rgba(255,255,255,.25); }
.viewer-body { flex: 1; display: grid; place-items: center; padding: 0 18px 18px; min-height: 0; }
.viewer-body img { max-width: 100%; max-height: 100%; border-radius: 8px; object-fit: contain; }
.viewer-body iframe { width: min(1000px, 100%); height: 100%; border: 0; border-radius: 8px; background: #fff; }
.viewer-body .nopreview { color: #fff; text-align: center; }

.drop-hint { position: fixed; inset: 0; z-index: 40; pointer-events: none; display: grid; place-items: end center; padding: 24px; }
.drop-hint div { background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow); font-weight: 500; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px; z-index: 60; box-shadow: var(--shadow); font-size: 14px; max-width: calc(100% - 32px); }

@media (max-width: 860px) {
  .top { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .tabs { order: 3; width: 100%; margin: 0; }
  .tabs button { flex: 1; padding: 7px 4px; }
  .top-actions { margin-left: auto; }
  #zip span { display: none; }
  main { padding: 16px 14px 60px; }
  .hero { padding: 22px; border-radius: 18px; }
  .ring-wrap, .ring { width: 92px; height: 92px; }
  .ring-label b { font-size: 21px; }
  .grid2 { grid-template-columns: 1fr; }
  .docs { grid-template-columns: 1fr; }
  #search { min-width: 0; flex: 1; }
  .letter { padding: 24px 20px; }
}
@media (max-width: 520px) {
  .hero { flex-direction: column-reverse; align-items: flex-start; }
}

@media print {
  body * { visibility: hidden; }
  .letter, .letter * { visibility: visible; }
  .letter { position: absolute; left: 0; top: 0; border: 0; padding: 0; max-width: none; margin: 0; background: #fff; font-size: 12pt; min-height: 0; }
  @page { margin: 22mm; }
}
