:root {
  --bg: #f6f1ea;
  --panel: rgba(255, 255, 255, 0.82);
  --card: #ffffff;
  --text: #1f1b18;
  --muted: #6f665f;
  --line: #e8ddd1;
  --brand: #d36b2d;
  --brand-dark: #b7561c;
  --brand-soft: #f8e1d1;
  --success: #1f7a52;
  --shadow: 0 14px 40px rgba(42, 30, 18, 0.1);
  --radius-xl: 26px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, #fff8f1 0, #fff8f1 20%, transparent 40%),
    linear-gradient(180deg, #f9f4ee 0%, #f3ece4 100%);
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 18px 48px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(120, 84, 52, 0.08);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.wizard-shell {
  padding: 18px;
}

.wizard {
  background: linear-gradient(180deg, #ffffff 0%, #fff9f4 100%);
  border: 1px solid rgba(211, 107, 45, 0.1);
  border-radius: 22px;
  padding: 20px;
  min-height: 560px;
  display: flex;
  flex-direction: column;
}

.success-layout {
  min-height: 320px;
  justify-content: center;
}

.wizard-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.wizard-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.wizard-logo {
  width: 124px;
  height: auto;
  display: block;
  margin-bottom: 10px;
}

.wizard-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
}

.step-pill {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.progress {
  width: 100%;
  height: 10px;
  background: #efe3d8;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 24px;
}

.progress > div {
  height: 100%;
  width: 16%;
  background: linear-gradient(90deg, var(--brand) 0%, #eb9a61 100%);
  border-radius: inherit;
  transition: width 0.28s ease;
}

.question,
.result-screen,
.lead-screen {
  display: none;
  flex: 1;
  flex-direction: column;
}

.question.active,
.result-screen.active,
.lead-screen.active {
  display: flex;
}

.inline-error {
  background: #fff0ef;
  color: #842029;
  border: 1px solid #f4c2c0;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 700;
}

.question-label {
  color: var(--brand-dark);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

h2 {
  font-size: clamp(26px, 4vw, 34px);
  line-height: 1.08;
  letter-spacing: -0.04em;
  margin: 0 0 18px;
  max-width: 16ch;
}

.options {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

button,
.link-button {
  border: 0;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.option,
.btn-primary,
.btn-secondary,
.next,
.link-button {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.option:hover,
.btn-primary:hover,
.btn-secondary:hover,
.next:hover,
.link-button:hover {
  transform: translateY(-1px);
}

.option {
  padding: 16px;
  text-align: left;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 700;
  color: var(--text);
}

.option.selected {
  border-color: rgba(211, 107, 45, 0.45);
  background: #fff3ea;
  box-shadow: 0 8px 20px rgba(211, 107, 45, 0.12);
}

.wizard-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.ghost {
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  padding: 10px 6px;
}

.next {
  background: var(--text);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 800;
  opacity: 0.45;
  pointer-events: none;
}

.next.ready {
  opacity: 1;
  pointer-events: auto;
}

.result-badge {
  display: inline-flex;
  align-self: flex-start;
  border-radius: 999px;
  padding: 8px 12px;
  background: #edf8f2;
  color: var(--success);
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 14px;
}

.result-card,
.lead-card,
.success-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
}

.result-card p,
.lead-card p,
.success-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.lead-card h3,
.success-card h3,
.result-card h3 {
  margin: 0 0 8px;
  font-size: 24px;
  letter-spacing: -0.03em;
}

.lead-card p {
  margin-bottom: 16px;
}

.field-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
  margin-top: 16px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #fff;
  font: inherit;
  color: var(--text);
}

.btn-primary,
.link-button {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  padding: 15px 20px;
  border-radius: 14px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(211, 107, 45, 0.25);
}

.btn-secondary {
  background: #fff;
  color: var(--text);
  padding: 15px 20px;
  border-radius: 14px;
  border: 1px solid var(--line);
  font-weight: 700;
}

.cta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.admin-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 18px 60px;
}

.admin-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 100% 0%, rgba(211, 107, 45, 0.09), transparent 30%);
  z-index: -1;
}

.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.admin-topbar h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: -0.03em;
}

.admin-topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.leads-brand {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.brand-logo {
  width: 110px;
  height: auto;
  display: block;
}

.admin-headline {
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--brand-dark);
}

.admin-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.period-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.period-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.period-select {
  min-width: 180px;
  padding: 9px 12px;
  border-radius: 999px;
  font-weight: 700;
}

.admin-link {
  display: inline-flex;
}

.admin-panel {
  padding: 18px;
  margin-bottom: 14px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}

.admin-stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.admin-stat-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
}

.admin-stat-value {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.03em;
  margin-top: 4px;
}

.leads-table-wrap {
  padding: 8px;
  overflow: auto;
}

.leads-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 980px;
}

.leads-table thead th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fffaf6;
  position: sticky;
  top: 0;
  z-index: 1;
}

.leads-table tbody tr {
  background: #fff;
}

.leads-table tbody tr:nth-child(even) {
  background: #fffdfb;
}

.leads-table tbody td {
  padding: 12px;
  vertical-align: top;
  border-bottom: 1px solid #efe5db;
}

.lead-cell-main {
  min-width: 220px;
}

.lead-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.lead-meta {
  color: var(--muted);
  font-size: 13px;
}

.table-form {
  margin: 0;
}

.table-form.stack {
  display: grid;
  gap: 8px;
}

.table-select,
.table-note {
  width: 100%;
  border: 1px solid #e2d4c6;
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
}

.status-select[data-status="Ny"] {
  border-color: #bdd1ff;
  background: #eef3ff;
  color: #2b4fb0;
}

.status-select[data-status="Plukket"] {
  border-color: #f0d59d;
  background: #fff4df;
  color: #8a5a0b;
}

.status-select[data-status="Kontaktet"] {
  border-color: #bde7d2;
  background: #edf8f2;
  color: #1f7a52;
}

.status-select[data-status="I prosess"] {
  border-color: #efd8a7;
  background: #fff7e9;
  color: #925c00;
}

.status-select[data-status="Ferdig"] {
  border-color: #b8e9d0;
  background: #e8f9f0;
  color: #11663f;
}

.status-select[data-status="Tap"] {
  border-color: #f0b8b8;
  background: #ffe9e9;
  color: #9f2f2f;
}

.table-select:focus,
.table-note:focus {
  outline: none;
  border-color: rgba(211, 107, 45, 0.6);
  box-shadow: 0 0 0 3px rgba(211, 107, 45, 0.12);
}

.table-note {
  resize: vertical;
  min-height: 84px;
}

.table-actions-stack {
  display: grid;
  gap: 6px;
}

.chip-btn {
  border: 1px solid #dbc7b6;
  background: #fff;
  color: #4c3523;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.chip-btn-brand {
  border-color: rgba(211, 107, 45, 0.45);
  background: #fff3ea;
  color: #8f4518;
}

.chip-btn-danger {
  border-color: rgba(176, 43, 43, 0.4);
  background: #ffecec;
  color: #9c2e2e;
}

.admin-panel h2,
.admin-panel h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

.admin-form-grid {
  display: grid;
  gap: 10px;
}

.admin-form-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  margin-top: 10px;
}

.admin-form-row .full {
  grid-column: 1 / span 2;
}

.admin-form-row textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  font: inherit;
}

.admin-form-row select,
.admin-form-grid select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  background: #fff;
}

.lead-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.lead-header h2 {
  margin: 0 0 4px;
  font-size: 24px;
}

.lead-header p {
  margin: 0;
  color: var(--muted);
}

.lead-status-pill {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.lead-status-pill.status-ny {
  background: #eef3ff;
  color: #2b4fb0;
}

.lead-status-pill.status-plukket {
  background: #fff4df;
  color: #8a5a0b;
}

.lead-status-pill.status-kontaktet {
  background: #edf8f2;
  color: #1f7a52;
}

.lead-status-pill.status-i-prosess {
  background: #fff7e9;
  color: #925c00;
}

.lead-status-pill.status-ferdig {
  background: #e8f9f0;
  color: #11663f;
}

.lead-status-pill.status-tap {
  background: #ffe9e9;
  color: #9f2f2f;
}

.admin-stat-value.status-ny {
  color: #2b4fb0;
}

.admin-stat-value.status-plukket {
  color: #8a5a0b;
}

.admin-stat-value.status-kontaktet {
  color: #1f7a52;
}

.admin-stat-value.status-i-prosess {
  color: #925c00;
}

.admin-stat-value.status-ferdig {
  color: #11663f;
}

.admin-stat-value.status-tap {
  color: #9f2f2f;
}

.lead-main-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 14px;
  margin-top: 10px;
}

.lead-actions-col {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.lead-meta-line {
  color: var(--muted);
  margin-bottom: 8px;
}

.inline-form {
  margin-top: 10px;
}

.notes-list {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.notes-list h3 {
  margin: 0 0 10px;
}

.note-item {
  background: #fff8f2;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
}


.note-history-static {
  min-width: 220px;
}

.note-history-list {
  margin-top: 8px;
}

.note-empty {
  color: var(--muted);
  font-size: 13px;
}

.note-edit-form {
  margin-top: 6px;
}

.note-actions {
  display: flex;
  gap: 8px;
}

.note-delete-form {
  margin-top: 8px;
}

.lead-modal {
  position: fixed;
  inset: 0;
  background: rgba(27, 17, 10, 0.48);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 30;
}

.lead-modal.open {
  display: flex;
}

.lead-modal-dialog {
  width: min(1080px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 20px;
  border: 1px solid #e6d9cb;
  box-shadow: 0 20px 60px rgba(32, 20, 12, 0.28);
  padding: 16px;
}

.lead-modal-close {
  border: 1px solid #dbc7b6;
  background: #fff;
  color: #4c3523;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
}

.lead-modal-body {
  margin-top: 8px;
}

.lead-modal-head h2 {
  margin: 8px 0 6px;
  font-size: 30px;
  letter-spacing: -0.03em;
}

.lead-modal-head p {
  margin: 0;
  color: var(--muted);
}

.lead-modal-topbox {
  background: #fff9f4;
  border: 1px solid #ecdccf;
  border-radius: 16px;
  padding: 12px;
  margin-top: 12px;
}

.modal-grid-form {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.modal-grid-form input,
.modal-grid-form select {
  width: 100%;
  border: 1px solid #e2d4c6;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.modal-save-btn {
  white-space: nowrap;
}

.lead-modal-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #efe4d8;
}

.lead-modal-section h3 {
  margin: 0 0 10px;
}

.answers-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}

.answer-item {
  background: #fffaf7;
  border: 1px solid #ebddd0;
  border-radius: 12px;
  padding: 10px;
}

.answer-key {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.answer-value {
  font-weight: 700;
}

body.modal-open {
  overflow: hidden;
}

.note-item .meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.admin-form-row-compact {
  grid-template-columns: 1fr 1fr auto;
}

.admin-form-row-note {
  grid-template-columns: 1fr auto;
}

.admin-form-row-note .full {
  grid-column: 1;
}

.admin-notice,
.admin-error {
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-weight: 700;
}

.admin-notice {
  background: #edf8f2;
  color: #1f7a52;
  border: 1px solid #bee4d0;
}

.admin-error {
  background: #fff0ef;
  color: #842029;
  border: 1px solid #f4c2c0;
}

.admin-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1024px) {
  .admin-shell {
    padding: 16px 12px 28px;
  }

  .admin-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-brand {
    flex-direction: column;
    align-items: flex-start;
  }

  .admin-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .period-form {
    width: auto;
    flex-wrap: wrap;
  }

  .period-select {
    min-width: 0;
    width: 100%;
  }

  .modal-grid-form {
    grid-template-columns: 1fr 1fr;
  }

  .modal-save-btn {
    grid-column: 1 / span 2;
    width: 100%;
  }

  .admin-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .leads-table-wrap {
    padding: 0;
    overflow: visible;
    border-radius: 18px;
  }

  .leads-table {
    min-width: 0;
    border-collapse: collapse;
  }

  .leads-table thead {
    display: none;
  }

  .leads-table tbody,
  .leads-table tr,
  .leads-table td {
    display: block;
    width: 100%;
  }

  .leads-table tbody tr {
    padding: 12px;
    margin: 0 0 10px;
    background: #fff;
    border: 1px solid #e8ddd1;
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(47, 30, 15, 0.06);
  }

  .leads-table tbody td {
    border-bottom: 0;
    padding: 8px 0;
  }

  .leads-table tbody td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 4px;
    font-weight: 800;
  }

  .lead-cell-main {
    min-width: 0;
    padding-bottom: 10px;
    border-bottom: 1px dashed #eadccd;
    margin-bottom: 4px;
  }

  .table-actions-stack {
    grid-template-columns: 1fr;
  }

  .chip-btn,
  .table-select,
  .table-note {
    width: 100%;
  }

  .note-history {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .field-grid {
    grid-template-columns: 1fr;
  }

  .wizard-shell {
    padding: 12px;
  }

  .wizard {
    padding: 16px;
    min-height: 520px;
  }

  .admin-form-row {
    grid-template-columns: 1fr;
  }

  .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-topbar h1 {
    font-size: 28px;
  }

  .btn-primary,
  .btn-secondary {
    padding: 12px 14px;
  }

  .lead-modal {
    padding: 8px;
  }

  .lead-modal-dialog {
    border-radius: 14px;
    padding: 10px;
    max-height: 95vh;
  }

  .modal-grid-form {
    grid-template-columns: 1fr;
  }

  .modal-save-btn {
    grid-column: auto;
  }

  .admin-form-row .full {
    grid-column: auto;
  }
}
