
:root {
  --bg: #f4f7fb;
  --surface: rgba(255,255,255,.9);
  --surface-solid: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --success: #047857;
  --shadow: 0 18px 60px rgba(15,23,42,.08);
  --radius: 24px;
  --nav-h: 78px;
}
html[data-theme="dark"] {
  --bg: #070b16;
  --surface: rgba(17,24,39,.88);
  --surface-solid: #111827;
  --text: #f9fafb;
  --muted: #9ca3af;
  --line: #273244;
  --primary-soft: #1e1b4b;
  --shadow: 0 18px 60px rgba(0,0,0,.24);
}
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --bg: #070b16;
    --surface: rgba(17,24,39,.88);
    --surface-solid: #111827;
    --text: #f9fafb;
    --muted: #9ca3af;
    --line: #273244;
    --primary-soft: #1e1b4b;
    --shadow: 0 18px 60px rgba(0,0,0,.24);
  }
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 0%, rgba(79,70,229,.14), transparent 28rem),
    radial-gradient(circle at 100% 18%, rgba(124,58,237,.09), transparent 30rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
.topbar {
  height: 72px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1180px;
  margin: auto;
}
.brand { display: inline-flex; gap: 10px; align-items: center; font-weight: 800; letter-spacing: -.03em; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center;
  color: white; background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 8px 20px rgba(79,70,229,.28);
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-solid); border: 1px solid var(--line); font-weight: 800;
}
.page { max-width: 1100px; margin: auto; padding: 8px 24px 50px; }
h1,h2,h3,p { margin-top: 0; }
h1 { font-size: clamp(2rem, 5vw, 3.45rem); line-height: 1.02; letter-spacing: -.055em; margin-bottom: 12px; }
h2 { font-size: 1.45rem; letter-spacing: -.025em; margin-bottom: 6px; }
h3 { letter-spacing: -.02em; }
p { color: var(--muted); line-height: 1.55; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.eyebrow {
  text-transform: uppercase; font-size: .72rem; letter-spacing: .13em; font-weight: 850;
  color: var(--primary); margin-bottom: 10px;
}
.hero-card {
  min-height: 235px; padding: 34px; border-radius: 32px; color: white;
  background:
    radial-gradient(circle at 80% 10%, rgba(255,255,255,.2), transparent 17rem),
    linear-gradient(135deg, #111827, #312e81 72%, #6d28d9);
  display: flex; align-items: end; justify-content: space-between; gap: 20px; box-shadow: var(--shadow);
}
.hero-card h1 { max-width: 700px; }
.hero-card p { color: rgba(255,255,255,.75); max-width: 650px; margin-bottom: 0; }
.section { margin-top: 34px; }
.section-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 16px; }
.section-head p { margin-bottom: 0; }
.form-cards { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.form-card {
  position: relative; min-height: 190px; padding: 24px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: start;
  backdrop-filter: blur(18px);
}
.form-card:not(.disabled):hover { transform: translateY(-2px); transition: .18s ease; }
.form-card.disabled { opacity: .65; }
.form-card-icon {
  width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center;
  font-weight: 900; font-size: 1.35rem; background: var(--primary-soft); color: var(--primary);
}
.form-card h3 { margin: 12px 0 6px; font-size: 1.2rem; }
.form-card p { margin-bottom: 0; font-size: .95rem; }
.arrow { font-size: 1.5rem; opacity: .55; }
.badge {
  display: inline-flex; align-items: center; padding: 6px 9px; border-radius: 999px;
  font-size: .72rem; font-weight: 800; background: var(--primary-soft); color: var(--primary);
}
.badge.neutral { background: rgba(107,114,128,.12); color: var(--muted); }
.list { display: grid; gap: 10px; }
.list-item {
  padding: 15px 16px; border-radius: 18px; background: var(--surface);
  border: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 14px;
}
.list-main, .list-actions, .button-row { display: flex; align-items: center; gap: 10px; }
.list-main strong { display: block; margin-bottom: 4px; }
.list-main small { color: var(--muted); }
.doc-icon {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-size: .66rem; font-weight: 900; letter-spacing: .08em;
}
.icon-btn {
  width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-solid); color: var(--text); display: grid; place-items: center;
}
.icon-btn.danger { color: var(--danger); font-size: 1.3rem; }
.btn {
  min-height: 46px; padding: 0 17px; border-radius: 14px; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800;
}
.btn.primary { color: white; background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 10px 24px rgba(79,70,229,.22); }
.btn.secondary { color: var(--text); background: var(--surface-solid); border-color: var(--line); }
.btn.ghost { color: var(--text); background: transparent; border-color: var(--line); }
.btn.light { background: white; color: #111827; }
.btn.full { width: 100%; }
.danger-text { color: var(--danger) !important; }
.page-title { padding: 26px 0 18px; }
.page-title p { max-width: 700px; }
.panel {
  padding: 24px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(18px);
}
.form-stack { display: grid; gap: 15px; }
label { display: grid; gap: 7px; font-weight: 720; font-size: .9rem; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface-solid); color: var(--text);
  border-radius: 13px; padding: 13px 14px; outline: none; transition: .15s ease;
}
input, select { min-height: 48px; }
textarea { resize: vertical; min-height: 110px; }
input:focus, select:focus, textarea:focus { border-color: rgba(79,70,229,.72); box-shadow: 0 0 0 4px rgba(79,70,229,.1); }
input:disabled { opacity: .7; }
.settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.auth-wrap { min-height: calc(100vh - 130px); display: grid; place-items: center; }
.auth-card {
  width: min(440px,100%); padding: 34px; border-radius: 30px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(20px);
}
.auth-card h1 { font-size: 2.2rem; }
.auth-foot { text-align: center; margin: 20px 0 0; font-size: .92rem; }
.auth-foot a { color: var(--primary); font-weight: 800; }
.flash-stack { display: grid; gap: 9px; margin-bottom: 16px; }
.flash { padding: 13px 15px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-solid); font-weight: 700; }
.flash.success { color: var(--success); }
.flash.error { color: var(--danger); }
.bottom-nav {
  position: fixed; z-index: 30; bottom: max(10px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  width: min(560px, calc(100% - 24px)); height: 68px; padding: 6px; border-radius: 24px;
  background: rgba(17,24,39,.92); backdrop-filter: blur(24px); box-shadow: 0 18px 50px rgba(0,0,0,.26);
  display: grid; grid-template-columns: repeat(3,1fr); border: 1px solid rgba(255,255,255,.08);
}
.bottom-nav a {
  border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: #9ca3af; font-size: .72rem; font-weight: 720;
}
.bottom-nav a.active { background: rgba(255,255,255,.11); color: white; }
.bottom-nav svg {
  width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.template-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; }
.template-card {
  padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.template-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.template-card h3 { margin: 18px 0 6px; }
.template-card p { min-height: 42px; }
.template-card small { color: var(--muted); }
.template-actions { display: flex; gap: 9px; margin-top: 20px; }
.empty-state {
  min-height: 180px; padding: 26px; border: 1px dashed var(--line); border-radius: var(--radius);
  display: grid; place-items: center; text-align: center;
}
.empty-state.big { min-height: 350px; }
.empty-state p { max-width: 520px; }
.empty-icon { font-size: 2rem; color: var(--primary); }
.wizard-form { display: grid; gap: 16px; }
.form-section { position: relative; padding-top: 26px; }
.section-number {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 900; margin-bottom: 14px;
}
.section-copy p { margin-bottom: 20px; }
.fields { display: grid; gap: 15px; }
.fields.two { grid-template-columns: repeat(2,minmax(0,1fr)); }
.span-2 { grid-column: 1 / -1; }
.check {
  display: flex; align-items: flex-start; gap: 11px; padding: 13px 14px; border: 1px solid var(--line);
  border-radius: 14px; background: var(--surface-solid); cursor: pointer;
}
.check input { width: 19px; min-height: 19px; height: 19px; margin: 1px 0 0; padding: 0; accent-color: var(--primary); }
.check span { display: grid; gap: 3px; }
.check small { color: var(--muted); font-weight: 500; line-height: 1.4; }
.save-panel { display: grid; gap: 14px; }
.template-name { padding-top: 6px; }
.sticky-actions {
  position: sticky; bottom: calc(var(--nav-h) + 9px); z-index: 20; padding: 10px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
  backdrop-filter: blur(20px); display: flex; justify-content: flex-end; gap: 10px; box-shadow: var(--shadow);
}
.print-page { background: #d7dce5; color: #111827; padding: 20px; }
.print-toolbar {
  max-width: 900px; margin: 0 auto 14px; display: flex; justify-content: flex-end; gap: 8px;
}
.paper {
  width: 210mm; min-height: 297mm; margin: 0 auto; padding: 9mm 10mm 8mm;
  background: white; box-shadow: 0 20px 60px rgba(15,23,42,.18); color: #111827;
}
.print-header { display: flex; justify-content: space-between; gap: 14px; padding-bottom: 7px; border-bottom: 1.5px solid #111827; }
.print-kicker { font-size: 6.7pt; font-weight: 900; letter-spacing: .13em; color: #4f46e5; }
.print-header h1 { font-size: 14.5pt; line-height: 1.08; margin: 3px 0 2px; letter-spacing: -.035em; }
.print-header p { font-size: 7.2pt; line-height: 1.25; margin: 0; color: #4b5563; }
.print-badge { border: 1px solid #c7cbd3; padding: 5px 7px; border-radius: 7px; height: fit-content; font-weight: 900; font-size: 6.8pt; white-space: nowrap; }
.print-intro { padding: 6px 0 1px; }
.print-intro p { color: #111827; font-size: 7.55pt; margin: 0 0 2px; line-height: 1.26; }
.print-intro .en { color: #4b5563; font-size: 7.15pt; }
.print-section { margin-top: 6px; break-inside: avoid; page-break-inside: avoid; }
.print-section h2 { font-size: 8.4pt; line-height: 1.15; margin: 0 0 4px; padding-bottom: 2px; border-bottom: 1px solid #d1d5db; }
.print-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 3px 9px; }
.print-grid > div { display: grid; gap: 1px; min-height: 22px; align-content: start; }
.print-grid .wide { grid-column: span 2; }
.print-grid .full { grid-column: 1 / -1; }
.print-grid span { font-size: 5.8pt; line-height: 1.1; color: #6b7280; text-transform: uppercase; letter-spacing: .025em; }
.print-grid strong { font-size: 7.25pt; line-height: 1.18; overflow-wrap: anywhere; }
.consent-note { font-size: 6.7pt; line-height: 1.22; color: #111827; background: #f3f4f6; padding: 4px 6px; border-radius: 4px; margin: 4px 0 0; overflow-wrap: anywhere; }
.attachments { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 5px; font-size: 6.7pt; line-height: 1.18; }
.signature-section { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 14px; break-inside: avoid; page-break-inside: avoid; }
.signature-line { padding-top: 14px; }
.signature-line .line { border-top: 1px solid #111827; margin-bottom: 3px; }
.signature-line strong { display: block; font-size: 7pt; line-height: 1.15; }
.signature-line span { display: block; color: #6b7280; font-size: 5.8pt; line-height: 1.1; margin-top: 1px; }
.print-footer { margin-top: 8px; padding-top: 4px; border-top: 1px solid #d1d5db; color: #6b7280; font-size: 5.4pt; line-height: 1.18; }

@media (max-width: 760px) {
  .page { padding: 0 14px 36px; }
  .topbar { padding: 0 16px; height: 64px; }
  .hero-card { min-height: 245px; padding: 24px; border-radius: 26px; flex-direction: column; align-items: flex-start; justify-content: flex-end; }
  .hero-card h1 { font-size: 2.35rem; }
  .form-cards, .settings-grid, .template-grid { grid-template-columns: 1fr; }
  .form-card { min-height: auto; padding: 19px; }
  .list-item { align-items: flex-start; }
  .list-actions { flex-wrap: wrap; justify-content: flex-end; }
  .fields.two { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .panel { padding: 18px; border-radius: 20px; }
  .sticky-actions { bottom: calc(var(--nav-h) + 5px); }
  .sticky-actions .btn { flex: 1; }
  .auth-card { padding: 24px; border-radius: 24px; }
  .page-title h1 { font-size: 2.4rem; }
  .button-row { flex-wrap: wrap; }
  .print-page { padding: 0; overflow-x: auto; }
}
@media print {
  @page { size: A4 portrait; margin: 0; }
  html, body.print-page { width: 210mm; height: 297mm; margin: 0; padding: 0; background: white; }
  body.print-page { overflow: hidden; }
  .no-print { display: none !important; }
  .paper {
    width: 210mm; min-height: 0; height: 297mm; margin: 0; padding: 8mm 9mm 7mm;
    box-shadow: none; overflow: hidden;
  }
  .print-header, .print-intro, .print-section, .signature-section, .print-footer {
    break-inside: avoid; page-break-inside: avoid;
  }
}
