:root {
  --ink: #17212f;
  --ink-soft: #485567;
  --muted: #8490a0;
  --line: #e7ebf0;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --accent: #315efb;
  --accent-dark: #2349d4;
  --accent-soft: #edf1ff;
  --sidebar: #111b2a;
  --sidebar-muted: #9aa6b7;
  --success: #15956b;
  --danger: #cf4343;
  --radius: 13px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f3f5f8;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: #f3f5f8; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 246px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; min-height: 680px; display: flex; flex-direction: column; padding: 25px 17px 16px; background: var(--sidebar); color: #fff; overflow: hidden; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 30px; }
.brand-mark { width: 35px; height: 35px; display: inline-grid; place-items: center; border-radius: 10px; background: #4267f8; color: #fff; font-size: 17px; font-weight: 800; letter-spacing: -.06em; flex: 0 0 auto; box-shadow: 0 5px 15px #315efb44; }
.brand-word { font-size: 12px; font-weight: 800; letter-spacing: .12em; line-height: 1.45; }
.brand-word small { display: block; margin-top: 2px; color: #8997aa; font-size: 8px; font-weight: 600; letter-spacing: .16em; }
.sidebar-label, .saved-heading, .eyebrow { font-size: 9px; font-weight: 800; letter-spacing: .14em; }
.sidebar-label { padding: 0 10px 11px; color: #748398; }
.section-nav { display: grid; gap: 4px; }
.nav-item { min-height: 43px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border-radius: 9px; color: #b7c1cf; font-size: 11px; font-weight: 550; transition: .18s ease; }
.nav-item:hover { color: #fff; background: #ffffff0b; }
.nav-item.active { background: #25344b; color: #fff; box-shadow: inset 2px 0 0 #6b8aff; }
.nav-index { width: 22px; color: #79889b; font-size: 9px; font-weight: 800; font-variant-numeric: tabular-nums; }
.nav-item.active .nav-index { color: #92aaff; }
.sidebar-divider { height: 1px; margin: 25px 4px 18px; background: #ffffff16; }
.saved-heading { display: flex; justify-content: space-between; align-items: center; padding: 0 8px 9px; color: #8492a6; }
.icon-button { width: 25px; height: 25px; border: 0; border-radius: 7px; background: #ffffff0b; color: #bcc7d6; cursor: pointer; font-size: 18px; }
.icon-button:hover { background: #ffffff19; color: #fff; }
.exports-list { display: grid; gap: 5px; overflow-y: auto; padding: 0 2px 10px; }
.empty-exports { padding: 10px 8px; color: #7e8ca0; font-size: 10px; line-height: 1.5; }
.export-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px; padding: 8px; border-radius: 8px; background: #ffffff09; }
.export-meta { min-width: 0; }
.export-name { display: block; overflow: hidden; color: #dbe2ec; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.export-date { display: block; margin-top: 3px; color: #8290a3; font-size: 9px; }
.export-actions { display: flex; gap: 4px; }
.export-actions a, .export-actions button { width: 23px; height: 23px; display: grid; place-items: center; border: 0; border-radius: 6px; color: #aebbd0; background: #ffffff0c; font-size: 12px; cursor: pointer; }
.export-actions a:hover, .export-actions button:hover { background: #ffffff20; color: white; }
.sidebar-bottom { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 15px 5px 0; border-top: 1px solid #ffffff16; }
.user-chip { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.user-avatar { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; color: #d7e1ff; background: #344b78; font-size: 11px; font-weight: 800; }
.user-chip b { display: block; color: #e4eaf2; font-size: 10px; }
.user-chip small { display: block; margin-top: 2px; color: #8594a8; font-size: 9px; }
.sidebar-bottom form { margin: 0; }
.logout-link { border: 0; background: transparent; cursor: pointer; color: #8f9eb1; font-size: 15px; padding: 5px; }
.logout-link:hover { color: #fff; }
.main-area { min-width: 0; min-height: 100vh; }
.topbar { min-height: 94px; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 17px 28px; border-bottom: 1px solid var(--line); background: #fff; }
.breadcrumb { margin-bottom: 7px; color: #9aa4b1; font-size: 8px; font-weight: 800; letter-spacing: .15em; }
.breadcrumb span { padding: 0 7px; color: #c3cad3; }
.topbar h1 { margin: 0; color: #1b2738; font-size: 20px; font-weight: 750; letter-spacing: -.035em; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; padding: 5px 8px; vertical-align: 3px; border: 1px solid #e6ebf1; border-radius: 6px; color: #778498; font-size: 9px; font-weight: 650; letter-spacing: 0; }
.status-pill i { width: 6px; height: 6px; border-radius: 50%; background: #8ba1ff; }
.top-actions { display: flex; align-items: end; gap: 10px; }
.filename-control { display: grid; gap: 5px; }
.filename-control label { color: #8490a0; font-size: 8px; font-weight: 800; letter-spacing: .12em; }
.filename-control input { width: 190px; height: 37px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; outline: none; color: var(--ink); background: #fff; font-size: 11px; }
.filename-control input:focus { border-color: #9eb0ff; box-shadow: 0 0 0 3px #315efb12; }
.btn { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 15px; border: 0; border-radius: 8px; font-size: 11px; font-weight: 750; cursor: pointer; transition: .18s ease; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 12px #315efb25; }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: wait; transform: none; }
.save-icon { font-size: 15px; font-weight: 500; }
.workspace { display: grid; grid-template-columns: minmax(390px, 48%) minmax(420px, 52%); min-height: calc(100vh - 94px); }
.editor-column { min-width: 0; padding: 25px 25px 70px 28px; overflow: visible; }
.editor-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 18px; }
.eyebrow { color: #8e9aab; }
.editor-heading h2 { margin: 5px 0 0; color: #202d3e; font-size: 19px; letter-spacing: -.035em; }
.completion-count { padding: 6px 9px; border: 1px solid #e5eaf0; border-radius: 7px; background: #fff; color: #788597; font-size: 9px; font-weight: 700; }
.form-section { margin-bottom: 13px; padding: 18px 18px 19px; scroll-margin-top: 18px; border: 1px solid #e9edf2; border-radius: var(--radius); background: #fff; box-shadow: 0 3px 12px #1e293b05; }
.section-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 17px; }
.section-number { width: 31px; height: 31px; display: grid; place-items: center; border: 1px solid #dfe6ff; border-radius: 9px; background: var(--accent-soft); color: #4565e9; font-size: 11px; font-weight: 800; }
.section-heading h3 { margin: 0; color: #263447; font-size: 13px; font-weight: 750; letter-spacing: -.01em; }
.section-heading p { margin: 3px 0 0; color: #8c97a6; font-size: 9px; }
.field-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.field-grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.field label { color: #5c6879; font-size: 9px; font-weight: 700; }
.field input, .field textarea { width: 100%; min-width: 0; border: 1px solid #e2e7ed; border-radius: 7px; outline: none; padding: 9px 10px; background: #fbfcfd; color: #273446; font-size: 10px; line-height: 1.5; transition: border-color .15s, box-shadow .15s, background .15s; }
.field input { height: 35px; }
.field textarea { min-height: 54px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: #b5bdc8; }
.field input:focus, .field textarea:focus { border-color: #9cb0ff; background: #fff; box-shadow: 0 0 0 3px #315efb10; }
.compact-grid { margin-top: 13px; }
.date-grid { gap: 10px; }
.declarations { padding-bottom: 12px; }
.question-list { display: grid; }
.question-row { padding: 12px 0; border-top: 1px solid #edf0f4; }
.question-row:first-child { border-top: 0; padding-top: 0; }
.question-text { display: grid; grid-template-columns: 19px 1fr; gap: 5px; color: #526071; font-size: 10px; font-weight: 600; line-height: 1.45; }
.question-text > span { color: #94a0af; font-size: 9px; font-weight: 800; }
.radio-options { display: flex; flex-wrap: wrap; gap: 7px; margin: 9px 0 0 24px; }
.radio-options label { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.radio-options input { position: absolute; opacity: 0; pointer-events: none; }
.radio-options label span { min-height: 27px; display: inline-flex; align-items: center; gap: 6px; padding: 0 9px; border: 1px solid #e3e8ee; border-radius: 6px; background: #fff; color: #7b8797; font-size: 9px; transition: .15s ease; }
.radio-options label b { color: #48576b; font-size: 9px; }
.radio-options input:checked + span { border-color: #a9b8ff; background: var(--accent-soft); color: #3154db; }
.radio-options input:checked + span b { color: #3154db; }
.radio-options input:focus-visible + span { outline: 2px solid #315efb; outline-offset: 2px; }
.preview-column { min-width: 0; display: flex; flex-direction: column; position: sticky; top: 0; height: calc(100vh - 0px); padding: 0; border-left: 1px solid #e4e8ee; background: #e9edf2; }
.preview-toolbar { min-height: 67px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 18px; background: #fff; border-bottom: 1px solid #e3e8ee; }
.preview-toolbar strong { display: block; margin-top: 4px; color: #293749; font-size: 11px; }
.preview-tools { display: flex; align-items: center; gap: 12px; }
.preview-state { display: inline-flex; align-items: center; gap: 6px; color: #8a95a3; font-size: 9px; white-space: nowrap; }
.preview-state i { width: 6px; height: 6px; border-radius: 50%; background: #97a3b3; }
.preview-state.is-updating i { background: #e6a33b; box-shadow: 0 0 0 3px #e6a33b24; }
.preview-state.is-ready i { background: var(--success); }
.open-original { color: #52647c; font-size: 9px; font-weight: 700; white-space: nowrap; }
.open-original:hover { color: var(--accent); }
.pdf-frame-wrap { flex: 1; min-height: 300px; padding: 13px; overflow: hidden; }
#pdf-preview { width: 100%; height: 100%; min-height: calc(100vh - 120px); display: block; border: 1px solid #d9dfe7; border-radius: 5px; background: white; box-shadow: 0 6px 20px #1c293a13; }
.preview-footer { min-height: 30px; display: flex; align-items: center; justify-content: space-between; padding: 0 17px; color: #8c98a7; font-size: 8px; }
.toast { position: fixed; z-index: 50; right: 23px; bottom: 22px; max-width: min(380px, calc(100vw - 36px)); padding: 12px 15px; border: 1px solid #dce3ec; border-radius: 9px; background: #fff; color: #39495d; box-shadow: 0 12px 35px #17212f20; font-size: 11px; line-height: 1.45; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: #f0caca; color: #a33232; }

/* Login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 25px; background: radial-gradient(circle at 50% 0%, #e6ebff 0, #f4f6fa 47%, #eef1f6 100%); }
.login-shell { width: min(100%, 380px); }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 24px; color: #29364b; font-size: 12px; font-weight: 850; letter-spacing: .17em; }
.login-card { padding: 31px; border: 1px solid #e7ebf1; border-radius: 16px; background: #fff; box-shadow: 0 18px 60px #22314a12; }
.login-card h1 { margin: 7px 0 24px; color: #202c3d; font-size: 25px; letter-spacing: -.045em; }
.login-card form { display: grid; gap: 8px; }
.login-card label { margin-top: 8px; color: #637083; font-size: 10px; font-weight: 750; }
.login-card input { height: 42px; padding: 0 12px; border: 1px solid #e0e6ed; border-radius: 8px; outline: none; background: #fbfcfd; color: var(--ink); font-size: 12px; }
.login-card input:focus { border-color: #9cb0ff; box-shadow: 0 0 0 3px #315efb10; }
.login-submit { width: 100%; margin-top: 18px; height: 43px; }
.login-submit span { font-size: 17px; font-weight: 400; }
.form-error { margin-top: 7px; color: var(--danger); font-size: 10px; }
.login-foot { margin-top: 17px; color: #9aa4b2; font-size: 9px; text-align: center; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 215px minmax(0, 1fr); }
  .workspace { grid-template-columns: minmax(360px, 1fr) minmax(350px, 1fr); }
  .editor-column { padding-left: 18px; padding-right: 18px; }
  .topbar { padding-left: 20px; padding-right: 20px; }
}
@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; top: auto; height: auto; min-height: 0; padding: 13px 14px; }
  .sidebar-brand { padding: 0 5px 12px; }
  .sidebar-label, .sidebar-divider, .saved-heading, .exports-list, .sidebar-bottom { display: none; }
  .section-nav { display: flex; overflow-x: auto; padding-bottom: 2px; }
  .nav-item { flex: 0 0 auto; min-height: 33px; padding: 0 9px; font-size: 9px; }
  .nav-index { display: none; }
  .main-area { min-height: auto; }
  .workspace { grid-template-columns: 1fr; }
  .preview-column { position: relative; top: auto; height: 78vh; min-height: 600px; order: -1; border-left: 0; border-bottom: 1px solid var(--line); }
  #pdf-preview { min-height: 0; }
  .editor-column { padding: 21px 16px 50px; }
}
@media (max-width: 620px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 16px; }
  .top-actions { width: 100%; align-items: end; }
  .filename-control { flex: 1; min-width: 0; }
  .filename-control input { width: 100%; }
  .topbar h1 { font-size: 18px; }
  .status-pill { display: none; }
  .workspace { min-height: 0; }
  .preview-column { height: 66vh; min-height: 470px; }
  .preview-toolbar { min-height: 59px; padding: 9px 12px; }
  .pdf-frame-wrap { padding: 8px; }
  .preview-footer { padding: 0 10px; }
  .field-grid.two-col { grid-template-columns: 1fr; }
  .form-section { padding: 15px 13px; }
  .editor-column { padding: 18px 10px 40px; }
  .question-text { font-size: 9px; }
}
.field-hint { display: block; margin-top: 5px; color: var(--muted, #8490a0); font-size: 9px; line-height: 1.45; }
