:root {
  --ink: #1a2233;
  --ink-soft: #57607a;
  --line: #dfe3ec;
  --bg: #f5f6fa;
  --card: #ffffff;
  --brand: #1e4d8c;
  --brand-dark: #163a68;
  --brand-soft: #eaf1fb;
  --accent: #0f9d6c;
  --danger: #c53838;
  --warn: #b8790a;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--brand-dark);
  color: white;
}
.topbar .brand { color: white; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.topbar .agency { opacity: .8; font-size: .9rem; }
.topbar .logout { margin-left: auto; color: white; opacity: .85; text-decoration: none; font-size: .9rem; }
.topbar .logout:hover { opacity: 1; text-decoration: underline; }

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

h1 { font-size: 1.6rem; margin: 0 0 6px; }
h2 { font-size: 1.25rem; margin: 0 0 12px; }
h3 { font-size: 1.05rem; margin: 0 0 8px; }
.subtitle { color: var(--ink-soft); margin: 0 0 24px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: white;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.secondary { background: white; color: var(--brand); }
.btn.secondary:hover { background: var(--brand-soft); }
.btn.ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn.danger { background: white; color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.actions-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* login */
.login-wrap { max-width: 380px; margin: 80px auto; }

/* region picker */
.region-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 700px) { .region-grid { grid-template-columns: 1fr; } }
.region-card {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  background: white;
  transition: border-color .15s, transform .1s;
}
.region-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.region-card.disabled { opacity: .5; cursor: not-allowed; }
.region-card .flag { font-size: 2rem; display: block; margin-bottom: 8px; }
.region-card strong { display: block; font-size: 1.05rem; margin-bottom: 4px; }
.region-card span.tag { color: var(--ink-soft); font-size: .85rem; }

/* dossier list */
.dossier-list { display: flex; flex-direction: column; gap: 10px; }
.dossier-row {
  display: flex; align-items: center; gap: 14px;
  background: white; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; text-decoration: none; color: var(--ink);
}
.dossier-row:hover { border-color: var(--brand); }
.dossier-row .pill {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .03em;
  padding: 3px 9px; border-radius: 20px; background: var(--brand-soft); color: var(--brand-dark);
}
.dossier-row .pill.final { background: #e4f6ec; color: var(--accent); }
.dossier-row .meta { color: var(--ink-soft); font-size: .85rem; }
.dossier-row .title { font-weight: 600; flex: 1; }

/* wizard */
.wizard-progress {
  display: flex; gap: 4px; margin-bottom: 22px; flex-wrap: wrap;
}
.wizard-progress .dot {
  flex: 1; min-width: 8px; height: 6px; border-radius: 4px; background: var(--line);
}
.wizard-progress .dot.done { background: var(--brand); }
.wizard-progress .dot.current { background: var(--accent); }
.step-counter { color: var(--ink-soft); font-size: .85rem; margin-bottom: 4px; }

.field { margin-bottom: 18px; }
.field > label.field-label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .help { color: var(--ink-soft); font-size: .85rem; margin-top: 4px; }
.field input[type=text], .field input[type=number], .field input[type=date], .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: .95rem; font-family: inherit; background: white; color: var(--ink);
}
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

.money-input { position: relative; }
.money-input input { padding-right: 40px; }
.money-input .suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-soft); }

.autocomplete { position: relative; }
.autocomplete-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px 0; list-style: none; max-height: 220px; overflow-y: auto;
  background: white; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
}
.autocomplete-list li { padding: 8px 12px; cursor: pointer; font-size: .9rem; }
.autocomplete-list li:hover { background: var(--bg, #f3f4f6); }
.autocomplete-hint { color: var(--ink-soft); font-size: .8rem; margin: 4px 0 0; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .two-col { grid-template-columns: 1fr; } }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .three-col { grid-template-columns: 1fr; } }

.choice-options { display: flex; flex-direction: column; gap: 8px; }
.choice-option {
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; cursor: pointer;
  background: white;
}
.choice-option.active { border-color: var(--brand); background: var(--brand-soft); }
.choice-option label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-weight: 600; }
.choice-option input[type=radio] { margin-top: 3px; }
.choice-suboptions { margin-top: 12px; padding-left: 26px; border-left: 2px solid var(--line); }

.bool-toggle { display: flex; gap: 8px; }
.bool-toggle-btn {
  min-width: 90px; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: white; cursor: pointer; font-size: .95rem; font-family: inherit; color: var(--ink);
}
.bool-toggle-btn.active { background: var(--brand); color: white; border-color: var(--brand); }

.repeat-list { display: flex; flex-direction: column; gap: 10px; }
.repeat-item { display: flex; gap: 8px; align-items: center; }
.repeat-item input { flex: 1; }

.party-card {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; background: #fbfcfe;
}
.party-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.party-type-toggle { display: flex; gap: 8px; margin-bottom: 14px; }
.party-type-toggle button {
  flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: white; cursor: pointer;
}
.party-type-toggle button.active { background: var(--brand); color: white; border-color: var(--brand); }

.upload-zone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px; text-align: center;
  background: white; color: var(--ink-soft); cursor: pointer;
}
.upload-zone:hover { border-color: var(--brand); }
.doc-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: white;
  border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px;
}
.doc-item .doc-icon { font-size: 1.3rem; }
.doc-item .doc-name { flex: 1; font-weight: 600; }
.doc-item .doc-type { color: var(--ink-soft); font-size: .82rem; }
.doc-item .status { font-size: .8rem; }
.doc-item .status.ok { color: var(--accent); }
.doc-item .status.pending { color: var(--warn); }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .9rem; }
.alert.error { background: #fdecec; color: var(--danger); border: 1px solid #f4c2c2; }
.alert.info { background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #cfe0f5; }
.alert.success { background: #e4f6ec; color: #0b6c4a; border: 1px solid #b9e6cf; }

.step-nav { display: flex; justify-content: space-between; margin-top: 26px; }

.summary-section { margin-bottom: 20px; }
.summary-section h3 { border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 10px; }
.summary-row { display: flex; gap: 8px; padding: 4px 0; font-size: .9rem; }
.summary-row .k { color: var(--ink-soft); min-width: 220px; }
.summary-row .v { font-weight: 600; }

table.simple { width: 100%; border-collapse: collapse; }
table.simple th, table.simple td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: .88rem; }

.badge-soon { display: inline-block; background: #efe7fb; color: #6236b3; font-size: .72rem; padding: 2px 8px; border-radius: 20px; margin-left: 6px; }
