:root {
  --blue: #2864f0;
  --blue-2: #1f54d8;
  --blue-soft: #edf4ff;
  --ink: #10192c;
  --text: #26344b;
  --muted: #75839b;
  --line: #dde5f1;
  --panel: #ffffff;
  --bg: #f6f8fc;
  --success: #19a974;
  --warning: #f0a51a;
  --danger: #dc4b55;
  --shadow-sm: 0 1px 2px rgba(21, 39, 74, .06), 0 5px 18px rgba(30, 52, 92, .06);
  --shadow-md: 0 16px 50px rgba(30, 52, 92, .12);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.app-shell { display: grid; grid-template-columns: 292px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; border-bottom: 1px solid #edf1f7; }
.logo { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #3777ff, #1f52df); box-shadow: 0 8px 18px rgba(40,100,240,.25); }
.logo svg { width: 22px; height: 22px; }
.brand strong { display: block; font-size: 16px; color: var(--ink); }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.sidebar-main { padding: 14px 12px; overflow: auto; flex: 1; }
.primary-btn, .ghost-btn, .dark-btn, .soft-btn { border: 0; border-radius: 11px; padding: 11px 15px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: .18s ease; }
.primary-btn { color: #fff; background: var(--blue); box-shadow: 0 8px 18px rgba(40,100,240,.18); }
.primary-btn:hover { background: var(--blue-2); transform: translateY(-1px); }
.primary-btn:disabled { opacity: .48; cursor: not-allowed; transform: none; }
.ghost-btn { background: #fff; color: var(--text); border: 1px solid var(--line); }
.ghost-btn:hover { border-color: #bfcbe0; background: #f9fbff; }
.soft-btn { color: var(--blue-2); background: var(--blue-soft); }
.dark-btn { color: #fff; background: #111b31; }
.full { width: 100%; }
.side-title { display: flex; justify-content: space-between; align-items: center; margin: 17px 2px 8px; font-size: 11px; color: #718099; font-weight: 800; letter-spacing: .06em; }
.search-box { position: relative; margin-bottom: 8px; }
.search-box input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 10px 34px; outline: none; background: #fbfcff; }
.search-box svg { position: absolute; left: 11px; top: 11px; width: 16px; color: #8a98ad; }
.doc-list { display: grid; gap: 7px; }
.doc-entry { display: grid; grid-template-columns: minmax(0, 1fr) 34px; gap: 5px; align-items: stretch; }
.doc-card { width: 100%; min-width: 0; border: 1px solid transparent; border-radius: 12px; padding: 11px; background: #fff; text-align: left; transition: .18s; }
.doc-card:hover { background: #f8faff; border-color: #d8e3f6; }
.doc-card.active { background: #eef4ff; border-color: #adcbff; box-shadow: 0 4px 12px rgba(40,100,240,.1); }
.doc-card strong { display: block; color: #1e3358; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.doc-delete { border: 1px solid transparent; border-radius: 10px; background: transparent; color: #9aa6b8; display: grid; place-items: center; transition: .18s; }
.doc-delete:hover { color: var(--danger); background: #fff1f2; border-color: #ffd1d5; }
.empty-side { padding: 25px 12px; text-align: center; color: var(--muted); font-size: 12px; }
.sidebar-footer { border-top: 1px solid var(--line); padding: 12px; background: #fbfcff; }
.user-line { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.avatar { width: 31px; height: 31px; border-radius: 50%; display: grid; place-items: center; background: #e9eff9; color: #28476f; font-weight: 800; font-size: 12px; }
.user-line strong { display: block; color: var(--ink); font-size: 12px; }
.user-line small { display: block; color: var(--muted); font-size: 10px; }
.plan-badge { margin-left: auto; background: #ffd75a; color: #604500; font-size: 9px; font-weight: 900; padding: 4px 7px; border-radius: 6px; text-transform: uppercase; }
.credit-line { display: flex; justify-content: space-between; align-items: end; margin-top: 10px; }
.credit-line small { color: var(--muted); display: block; font-size: 9px; text-transform: uppercase; font-weight: 800; }
.credit-line strong { color: var(--blue); display: block; font-size: 17px; margin-top: 2px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 68px; background: rgba(255,255,255,.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 15; }
.breadcrumb { display: flex; align-items: center; gap: 8px; min-width: 0; }
.breadcrumb span { color: var(--muted); font-size: 12px; }
.breadcrumb strong { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 9px; }
.status-dot { display: inline-flex; align-items: center; gap: 7px; color: var(--success); font-size: 12px; font-weight: 700; }
.status-dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.content { flex: 1; padding: 34px; }
.content-inner { max-width: 1120px; margin: 0 auto; }
.hero { text-align: center; padding: 18px 0 28px; }
.eyebrow { display: inline-flex; align-items: center; gap: 7px; background: var(--blue-soft); color: var(--blue-2); border-radius: 999px; padding: 7px 11px; font-size: 11px; font-weight: 800; letter-spacing: .03em; }
.hero h1 { margin: 15px 0 9px; font-size: clamp(28px, 4vw, 44px); line-height: 1.13; letter-spacing: -.035em; color: var(--ink); }
.hero p { max-width: 700px; margin: 0 auto; color: var(--muted); line-height: 1.65; }
.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.type-card { border: 1px solid var(--line); border-radius: 17px; background: #fff; padding: 22px; text-align: left; box-shadow: var(--shadow-sm); transition: .2s; position: relative; overflow: hidden; }
.type-card::after { content: ''; position: absolute; width: 120px; height: 120px; border-radius: 50%; background: var(--blue-soft); right: -55px; top: -55px; opacity: .6; }
.type-card:hover { transform: translateY(-3px); border-color: #a9c7ff; box-shadow: 0 14px 34px rgba(30, 76, 160, .12); }
.type-card.active { border: 2px solid var(--blue); padding: 21px; background: linear-gradient(145deg, #fff, #f4f8ff); }
.type-icon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); margin-bottom: 18px; position: relative; z-index: 1; }
.type-icon svg { width: 23px; height: 23px; }
.type-card h3 { margin: 0 0 8px; color: var(--ink); font-size: 17px; }
.type-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; min-height: 62px; }
.type-card .link { color: var(--blue); font-weight: 800; font-size: 12px; margin-top: 16px; display: inline-flex; gap: 5px; }

.stepper { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 15px 22px; display: grid; grid-template-columns: 1fr 70px 1fr 70px 1fr; align-items: center; box-shadow: var(--shadow-sm); margin-bottom: 24px; }
.step { display: flex; align-items: center; gap: 9px; color: #9aa6b8; font-size: 12px; font-weight: 800; justify-content: center; }
.step-num { width: 25px; height: 25px; border-radius: 50%; display: grid; place-items: center; background: #edf1f7; color: #75839b; }
.step.active { color: var(--blue); }
.step.active .step-num { color: #fff; background: var(--blue); box-shadow: 0 5px 12px rgba(40,100,240,.25); }
.step.done { color: var(--success); }
.step.done .step-num { color: #fff; background: var(--success); }
.step-line { height: 1px; background: #e6ebf3; }

.form-shell { max-width: 790px; margin: 0 auto; }
.form-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-sm); padding: 25px; }
.form-header { text-align: center; margin-bottom: 22px; }
.form-header .eyebrow { padding: 5px 9px; }
.form-header h2 { margin: 10px 0 5px; color: var(--ink); font-size: 22px; }
.form-header p { margin: 0; color: var(--muted); font-size: 13px; }
.field { margin-bottom: 19px; }
.field label { display: block; color: #43516a; font-size: 12px; font-weight: 800; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .02em; }
.field label .required { color: var(--danger); }
.input, .textarea, .select { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; background: #fbfcff; color: var(--ink); outline: none; transition: .18s; }
.textarea { min-height: 104px; resize: vertical; line-height: 1.55; }
.input:focus, .textarea:focus, .select:focus { border-color: #85adff; box-shadow: 0 0 0 4px rgba(40,100,240,.09); background: #fff; }
.topic-layout { display: grid; grid-template-columns: 1fr 235px; gap: 15px; }
.ai-box { border: 1px solid #cedcf4; border-radius: 13px; background: linear-gradient(145deg, #f8fbff, #eff5ff); padding: 15px; }
.ai-box strong { display: flex; align-items: center; gap: 7px; color: #2a3d5c; font-size: 12px; }
.ai-box p { color: var(--muted); font-size: 11px; line-height: 1.45; margin: 7px 0 12px; }
.switch-line { display: flex; align-items: start; gap: 8px; margin-bottom: 11px; }
.switch-line input { width: 17px; height: 17px; accent-color: var(--blue); }
.switch-line span { font-size: 11px; color: #495972; line-height: 1.35; }
.switch-line small { display: block; color: var(--muted); margin-top: 2px; }
.length-panel { border: 1px solid #d9e4f3; border-radius: 15px; padding: 16px; background: #fbfdff; }
.section-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.section-label strong { color: #43516a; font-size: 12px; text-transform: uppercase; }
.section-label small { color: var(--muted); }
.length-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.length-card { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 13px 11px; text-align: left; min-height: 96px; transition: .18s; }
.length-card:hover { border-color: #a9c7ff; }
.length-card.active { border: 2px solid var(--blue); padding: 12px 10px; background: var(--blue-soft); }
.length-card strong { display: block; color: var(--ink); font-size: 13px; }
.length-card span { display: inline-block; margin-top: 4px; color: var(--blue); font-weight: 800; font-size: 12px; }
.length-card small { display: block; margin-top: 7px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.page-estimate-note { margin: 10px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.custom-row { display: grid; grid-template-columns: 150px 140px 1fr; align-items: center; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed #dbe3ef; }
.custom-row label { margin: 0; font-size: 11px; font-weight: 800; }
.custom-row .input { padding: 10px 12px; }
.custom-row small { color: var(--muted); }
.accordion { border: 1px solid var(--line); border-radius: 13px; margin-top: 17px; overflow: hidden; }
.accordion-head { width: 100%; border: 0; background: #fbfcff; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; font-weight: 800; color: #43516a; font-size: 12px; }
.accordion-body { padding: 17px; border-top: 1px solid var(--line); display: none; }
.accordion.open .accordion-body { display: block; }
.form-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
.cost-box { color: var(--muted); font-size: 12px; }
.cost-box strong { color: var(--ink); }
.generate-btn { padding: 14px 21px; min-width: 220px; }
.info-banner { margin-top: 16px; border: 1px solid #cfe0ff; background: #f3f7ff; border-radius: 12px; padding: 12px 14px; color: #4a6185; font-size: 12px; line-height: 1.55; }

.progress-card { max-width: 760px; margin: 55px auto; background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-md); padding: 31px; text-align: center; }
.progress-orb { width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #3979ff, #1e51da); position: relative; box-shadow: 0 13px 30px rgba(40,100,240,.3); }
.progress-orb::after { content: ''; position: absolute; inset: -8px; border-radius: 50%; border: 2px solid #d9e7ff; border-top-color: var(--blue); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-card h2 { color: var(--ink); margin: 0 0 7px; }
.progress-card > p { color: var(--muted); margin: 0; }
.progress-track { height: 10px; background: #eaf0f8; border-radius: 999px; margin: 24px 0 9px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #3779ff, #255ee7); border-radius: inherit; transition: width .5s ease; }
.progress-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.pipeline { margin-top: 25px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.pipeline-item { border: 1px solid var(--line); border-radius: 11px; padding: 11px 8px; color: #8995a8; font-size: 11px; font-weight: 700; }
.pipeline-item.active { color: var(--blue); border-color: #a9c7ff; background: var(--blue-soft); }
.pipeline-item.done { color: var(--success); border-color: #bce8d8; background: #f0fbf7; }
.demo-note { margin-top: 18px; color: #8b6500; background: #fff8df; border: 1px solid #f0d988; border-radius: 10px; padding: 10px; font-size: 12px; }

.document-layout { display: grid; grid-template-columns: minmax(0, 900px) 280px; justify-content: center; gap: 24px; align-items: start; }
.document-paper { background: #fff; border: 1px solid var(--line); border-radius: 17px; box-shadow: var(--shadow-sm); padding: 56px 68px; min-height: 800px; }
.document-title { text-align: center; border-bottom: 1px solid #e9edf4; padding-bottom: 24px; margin-bottom: 30px; }
.document-title .badge { display: inline-block; color: var(--blue); background: var(--blue-soft); border-radius: 999px; padding: 6px 10px; font-size: 10px; font-weight: 900; text-transform: uppercase; }
.document-title h1 { color: var(--ink); font-family: Arial, Helvetica, sans-serif; font-size: 29px; line-height: 1.35; margin: 14px 0 8px; }
.document-title p { margin: 0; color: var(--muted); font: 12px/1.5 Arial, Helvetica, sans-serif; }
.prose { font-family: Arial, Helvetica, sans-serif; color: #182235; font-size: 15.5px; line-height: 1.72; }
.prose h2 { font-size: 21px; line-height: 1.4; margin: 31px 0 12px; color: #101a2e; }
.prose h3 { font-size: 17.5px; line-height: 1.45; margin: 23px 0 9px; color: #1d2d4b; }
.prose p { margin: 0 0 12px; text-align: justify; text-indent: 1.35em; }
.prose h2 + p, .prose h3 + p, .prose ul + p, .prose ol + p { text-indent: 0; }
.prose ul, .prose ol { padding-left: 26px; margin: 8px 0 15px; }
.prose li { margin-bottom: 7px; text-align: justify; }
.doc-tools { position: sticky; top: 88px; display: grid; gap: 13px; }
.tool-card { background: #fff; border: 1px solid var(--line); border-radius: 15px; padding: 16px; box-shadow: var(--shadow-sm); }
.tool-card h3 { margin: 0 0 12px; color: var(--ink); font-size: 14px; }
.tool-list { display: grid; gap: 9px; }
.download-word-btn { min-height: 48px; font-size: 14px; box-shadow: 0 10px 22px rgba(40, 100, 240, .2); }
.tool-help { margin: 11px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.meta-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; padding: 7px 0; border-bottom: 1px dashed #e8edf4; }
.meta-row:last-child { border-bottom: 0; }
.meta-row span { color: var(--muted); }
.meta-row strong { color: var(--text); text-align: right; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(8,17,34,.55); z-index: 100; display: grid; place-items: center; padding: 20px; backdrop-filter: blur(3px); }
.modal { width: min(760px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: 18px; box-shadow: 0 28px 90px rgba(5,13,28,.3); }
.modal.wide { width: min(1180px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 21px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.modal-head h2 { margin: 0; color: var(--ink); font-size: 18px; }
.icon-btn { width: 36px; height: 36px; border: 0; border-radius: 9px; background: #f2f5f9; color: #64738a; font-size: 20px; }
.modal-body { padding: 21px; }
.topic-options { display: grid; gap: 10px; }
.topic-option { width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 13px; padding: 14px; transition: .18s; }
.topic-option:hover { border-color: #8fb4ff; background: #f7faff; transform: translateY(-1px); }
.topic-option strong { display: block; color: var(--ink); line-height: 1.4; }
.topic-option p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.admin-shell { display: grid; grid-template-columns: 225px 1fr; min-height: 680px; }
.admin-nav { background: #f7f9fc; border-right: 1px solid var(--line); padding: 18px 12px; }
.admin-nav button { width: 100%; border: 0; background: transparent; border-radius: 10px; padding: 11px 12px; color: #516078; font-weight: 700; text-align: left; margin-bottom: 3px; }
.admin-nav button.active { background: var(--blue); color: #fff; box-shadow: 0 8px 18px rgba(40,100,240,.2); }
.admin-content { padding: 25px; overflow: auto; max-height: 75vh; }
.admin-title { margin: 0 0 5px; color: var(--ink); font-size: 20px; }
.admin-subtitle { margin: 0 0 22px; color: var(--muted); font-size: 12px; }
.admin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.admin-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: #fff; }
.admin-card h3 { margin: 0 0 14px; color: var(--ink); font-size: 14px; }
.package-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.package-card { border: 1px solid var(--line); border-radius: 14px; padding: 15px; }
.check-row { display: flex; gap: 16px; align-items: center; margin-top: 10px; font-size: 12px; }
.check-row input { accent-color: var(--blue); }
.admin-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 19px; padding-top: 16px; border-top: 1px solid var(--line); }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { text-align: left; background: #f5f7fb; color: #53627a; padding: 10px; }
.data-table td { padding: 10px; border-bottom: 1px solid #edf0f5; vertical-align: top; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.badge-ok, .badge-warn, .badge-muted { display: inline-block; padding: 4px 7px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.badge-ok { background: #eaf9f3; color: #16865e; }
.badge-warn { background: #fff6dc; color: #a17100; }
.badge-muted { background: #eef2f7; color: #69778c; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 200; background: #111b31; color: #fff; border-radius: 11px; padding: 12px 15px; box-shadow: var(--shadow-md); font-size: 13px; max-width: 360px; animation: toastIn .22s ease; }
.toast.error { background: #9f2732; }
.toast.success { background: #127c58; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }
.loading { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 235px 1fr; }
  .content { padding: 24px; }
  .topic-layout { grid-template-columns: 1fr; }
  .length-grid { grid-template-columns: repeat(2, 1fr); }
  .document-layout { grid-template-columns: 1fr; }
  .doc-tools { position: static; grid-template-columns: repeat(2, 1fr); }
  .document-paper { padding: 40px; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; border-right: 0; }
  .sidebar-main { display: none; }
  .sidebar-footer { display: none; }
  .brand { padding: 11px 15px; }
  .logo { width: 34px; height: 34px; }
  .topbar { top: 57px; height: 56px; padding: 0 15px; }
  .top-actions .status-dot { display: none; }
  .content { padding: 18px 13px 28px; }
  .hero { padding-top: 8px; }
  .hero h1 { font-size: 29px; }
  .type-grid { grid-template-columns: 1fr; }
  .type-card p { min-height: auto; }
  .stepper { grid-template-columns: 1fr 24px 1fr 24px 1fr; padding: 12px 7px; }
  .step { font-size: 0; gap: 0; }
  .step-num { font-size: 11px; }
  .form-card { padding: 17px; }
  .topic-layout { display: block; }
  .ai-box { margin-top: 13px; }
  .length-grid { grid-template-columns: 1fr 1fr; }
  .custom-row { grid-template-columns: 1fr 1fr; }
  .custom-row small { grid-column: 1/-1; }
  .form-actions { align-items: stretch; flex-direction: column; gap: 12px; }
  .generate-btn { width: 100%; }
  .progress-card { margin: 20px auto; padding: 22px 16px; }
  .pipeline { grid-template-columns: 1fr 1fr; }
  .document-paper { padding: 27px 20px; }
  .document-title h1 { font-size: 23px; }
  .doc-tools { grid-template-columns: 1fr; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-nav { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-nav button { width: auto; white-space: nowrap; }
  .admin-grid, .package-grid { grid-template-columns: 1fr; }
}
