:root {
  --bg: #f4f7f8;
  --panel: #ffffff;
  --panel-soft: #eef4f2;
  --ink: #17211f;
  --muted: #66736f;
  --line: #d9e2df;
  --green: #147b63;
  --green-dark: #0e5d4b;
  --yellow: #f0b429;
  --red: #c83e4d;
  --blue: #2f6fbd;
  --shadow: 0 18px 50px rgba(24, 42, 37, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #eaf1ef;
}

.auth-panel {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-brand {
  color: var(--ink);
  margin-bottom: 28px;
}

.auth-brand span {
  color: var(--muted);
}

.auth-panel h1 {
  font-size: 27px;
  margin-bottom: 8px;
}

.auth-submit {
  width: 100%;
  margin-top: 18px;
}

.auth-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.auth-message {
  min-height: 20px;
  margin-top: 14px;
  color: var(--red);
  font-size: 13px;
}

.sync-status,
.user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  background: #edf3f1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sync-status.synced {
  background: #e3f4ed;
  color: var(--green-dark);
}

.sync-status.error {
  background: #ffe1e5;
  color: #942333;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: #102420;
  color: white;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #f0b429;
  color: #102420;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #aec1bc;
  font-size: 13px;
  margin-top: 3px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  color: #d9e8e4;
  background: transparent;
  border-radius: 8px;
  padding: 12px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-icon {
  width: 22px;
  text-align: center;
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-note strong,
.sidebar-note span {
  display: block;
}

.sidebar-note span {
  color: #c0d1cd;
  font-size: 13px;
  line-height: 1.45;
  margin-top: 6px;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-head,
.section-row,
.wizard-head,
.form-footer,
.topbar-actions,
.generate-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 32px;
}

h2 {
  margin-bottom: 7px;
  font-size: 24px;
}

h3 {
  margin-bottom: 10px;
  font-size: 20px;
}

h4 {
  margin-bottom: 0;
  font-size: 16px;
}

.muted,
.section-head p {
  color: var(--muted);
  line-height: 1.5;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.primary-button,
.secondary-button,
.ghost-button {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
  white-space: nowrap;
}

.primary-button {
  background: var(--green);
  color: white;
}

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button {
  background: #e0eee9;
  color: var(--green-dark);
}

.ghost-button {
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-button input {
  display: none;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.onboarding-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
  margin-bottom: 22px;
}

.onboarding-strip div {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 58px;
  padding: 10px 12px;
  background: white;
}

.onboarding-strip strong {
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--green);
  color: white;
}

.onboarding-strip span {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.project-card {
  position: relative;
  min-height: 220px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 32px rgba(24, 42, 37, 0.07);
  display: grid;
  align-content: space-between;
  gap: 16px;
}

.project-card.add-card {
  border: 2px dashed #aac9c0;
  background: #f8fbfa;
  place-items: center;
  text-align: center;
}

.add-plus {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-size: 34px;
  line-height: 1;
}

.card-logo {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel-soft);
}

.project-card h3 {
  margin-bottom: 6px;
  line-height: 1.25;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.danger-button {
  color: var(--red);
  border-color: #efb0b8;
}

.danger-button:hover {
  background: #fff6f7;
}

.chip,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: #edf3f1;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.status-pill.warning {
  background: #fff2c7;
  color: #7a5200;
}

.status-pill.error {
  background: #ffe1e5;
  color: #942333;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.wizard-panel,
.inspector {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.wizard-panel {
  padding: 22px;
}

.inspector {
  position: sticky;
  top: 28px;
  padding: 18px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 22px 0;
}

.step-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 54px;
  background: #f9fbfa;
  color: var(--muted);
  padding: 9px;
  text-align: left;
}

.step-button strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.step-button.active {
  border-color: var(--green);
  background: #e8f5f0;
}

.step-card {
  display: grid;
  gap: 18px;
}

.step-section {
  min-height: 420px;
}

.hidden {
  display: none !important;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #2b3835;
  font-size: 13px;
  font-weight: 800;
}

.field-hint {
  margin-top: -2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.field-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.field-state,
.required-badge,
.origin-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  width: fit-content;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 900;
}

.required-badge {
  background: #fff2c7;
  color: #7a5200;
}

.field-state.filled {
  background: #e3f4ed;
  color: var(--green-dark);
}

.field-state.missing {
  background: #ffe1e5;
  color: #942333;
}

.field-state.optional {
  background: #edf3f1;
  color: var(--muted);
}

.origin-badge {
  background: #e7f0fb;
  color: #245b98;
}

.field-hint.warning {
  color: #8a5b00;
}

.field-hint.error {
  color: var(--red);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(20, 123, 99, 0.12);
}

.subsection {
  margin-top: 22px;
}

.subtabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f0f5f3;
  margin-bottom: 16px;
}

.subtab {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.subtab.active {
  background: white;
  color: var(--green-dark);
  box-shadow: 0 5px 18px rgba(24, 42, 37, 0.1);
}

.people-tab-panel {
  display: grid;
  gap: 16px;
}

.source-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: stretch;
}

.source-controls,
.source-status,
.source-mapper {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 14px;
}

.source-textarea {
  margin-top: 14px;
}

.source-textarea textarea {
  min-height: 150px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.source-status {
  display: grid;
  align-content: start;
  gap: 10px;
}

.source-progress {
  border: 1px solid #b8d3ca;
  border-radius: 8px;
  background: #f4fbf8;
  padding: 14px;
  margin-top: 16px;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.progress-head strong,
.progress-head span {
  display: block;
}

.progress-head span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: #dce9e5;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--green);
  transition: width 0.2s ease;
}

.progress-log {
  display: grid;
  gap: 6px;
  max-height: 160px;
  overflow: auto;
  margin-top: 12px;
  color: #31403c;
  font-size: 13px;
}

.progress-log div {
  border-left: 3px solid var(--line);
  padding-left: 8px;
}

.progress-log .error {
  color: var(--red);
  border-left-color: var(--red);
}

.status-line {
  border-left: 4px solid var(--green);
  border-radius: 0 8px 8px 0;
  background: white;
  padding: 10px 12px;
  line-height: 1.45;
}

.status-line.warning {
  border-color: var(--yellow);
}

.status-line.error {
  border-color: var(--red);
}

.source-mapper {
  margin-top: 16px;
}

.raw-records {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  margin-top: 12px;
}

.raw-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 14px 0 10px;
}

.raw-toolbar input {
  min-width: 220px;
  flex: 1;
}

.filter-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  padding: 0 10px;
  font-weight: 800;
}

.filter-button.active {
  border-color: var(--green);
  background: #e8f5f0;
  color: var(--green-dark);
}

.dry-run-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  border: 0;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 28px 90px rgba(16, 36, 32, 0.3);
  color: var(--ink);
}

.dry-run-dialog::backdrop {
  background: rgba(12, 28, 25, 0.55);
}

.dialog-head,
.dry-run-modes {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.dry-run-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.dry-run-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f9f7;
  padding: 12px;
}

.dry-run-summary strong,
.dry-run-summary span {
  display: block;
}

.dry-run-summary strong {
  font-size: 24px;
}

.dry-run-summary span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.dry-run-modes {
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 18px;
}

.raw-record {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.mini-copy {
  margin: 4px 0 0;
  font-size: 13px;
}

.stack-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.entity-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 14px;
}

.entity-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.icon-button {
  border: 0;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  background: #f2e3e6;
  color: var(--red);
  font-weight: 900;
}

.offer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.checks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: white;
  font-weight: 700;
}

.checks .guided-check {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
}

.checks .guided-check .field-hint {
  grid-column: 1 / -1;
  margin-top: 3px;
  font-weight: 600;
}

.checks input {
  width: auto;
}

.import-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid #b8d3ca;
  border-radius: 8px;
  background: #eef8f4;
  padding: 14px;
  margin-bottom: 18px;
}

.import-box span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.table-import {
  border: 1px solid #b8d3ca;
  border-radius: 8px;
  background: #fbfdfc;
  padding: 14px;
}

.mapper-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.mapper-grid label {
  min-width: 0;
}

.table-preview {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 260px;
  background: white;
}

.table-preview table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-size: 13px;
}

.table-preview th,
.table-preview td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.table-preview th {
  position: sticky;
  top: 0;
  background: #eef4f2;
  z-index: 1;
}

.import-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.doctor-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.doctor-preview img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  background: #dfe8e5;
}

.doctor-preview-body {
  padding: 14px;
}

.doctor-preview-body h4 {
  margin-bottom: 6px;
}

.price {
  font-weight: 900;
  color: var(--green-dark);
}

.validation-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.validation-tile {
  border-radius: 8px;
  padding: 14px;
  background: #edf3f1;
}

.validation-tile strong {
  display: block;
  font-size: 28px;
}

.validation-list {
  display: grid;
  gap: 8px;
}

.validation-item {
  border-radius: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  background: white;
}

.validation-item.error {
  border-color: #efb0b8;
  background: #fff6f7;
}

.validation-item.warning {
  border-color: #efd37b;
  background: #fffaf0;
}

.generate-layout {
  display: grid;
  gap: 14px;
}

.generate-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #f8fbfa;
}

.generate-card strong,
.generate-card span {
  display: block;
}

.generate-card span {
  color: var(--muted);
  margin: 6px 0 14px;
}

.compare-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: white;
}

.compare-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.compare-item {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdfc;
}

.compare-badge {
  display: inline-flex;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 8px;
  color: white;
  font-size: 12px;
  font-weight: 900;
}

.compare-badge.added {
  background: var(--green);
}

.compare-badge.removed {
  background: var(--red);
}

.compare-badge.changed {
  background: var(--blue);
}

.compare-item strong,
.compare-item span {
  display: block;
}

.compare-item span {
  color: var(--muted);
  margin-top: 3px;
  font-size: 13px;
}

.xml-output {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101c1a;
  color: #e6fff7;
  padding: 14px;
  font-size: 12px;
  line-height: 1.55;
}

.tips-box {
  display: grid;
  gap: 10px;
}

.readiness-box {
  display: grid;
  gap: 9px;
  margin-bottom: 20px;
}

.readiness-track {
  height: 9px;
  border-radius: 999px;
  background: #dce9e5;
  overflow: hidden;
}

.readiness-track span {
  display: block;
  height: 100%;
  background: var(--green);
}

.readiness-items {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.validation-jump {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
  color: var(--ink);
  text-align: left;
}

.validation-jump.error {
  border-color: #efb0b8;
  background: #fff6f7;
}

.validation-jump.warning {
  border-color: #efd37b;
  background: #fffaf0;
}

.validation-jump small {
  display: block;
  color: var(--muted);
  margin-top: 5px;
}

.tip {
  border-left: 4px solid var(--green);
  padding: 10px 12px;
  border-radius: 0 8px 8px 0;
  background: #f2f7f5;
  color: #31403c;
  line-height: 1.45;
}

.metric-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 18px;
}

.metric-list div {
  border-radius: 8px;
  background: #f0f5f3;
  padding: 10px;
  text-align: center;
}

.metric-list span,
.metric-list small {
  display: block;
}

.metric-list span {
  font-weight: 900;
  font-size: 22px;
}

.metric-list small {
  color: var(--muted);
  font-size: 12px;
}

.docs-view {
  max-width: 980px;
}

.docs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.docs-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 18px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 13px 15px;
  border-radius: 8px;
  background: #102420;
  color: white;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .source-layout {
    grid-template-columns: 1fr;
  }

  .inspector {
    position: static;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .main {
    padding: 18px;
  }

  .topbar,
  .section-head,
  .wizard-head,
  .import-box {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-grid,
  .offer-grid,
  .checks,
  .docs-grid,
  .validation-summary,
  .mapper-grid,
  .steps {
    grid-template-columns: 1fr;
  }

  .onboarding-strip {
    grid-template-columns: 1fr;
  }

  .dry-run-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
