:root {
  color-scheme: light;
  --bg: #f6f3ec;
  --surface: #ffffff;
  --surface-2: #fdfaf4;
  --ink: #17201f;
  --muted: #65706e;
  --line: #ded8cd;
  --teal: #0f766e;
  --teal-dark: #0c5f59;
  --amber: #d97706;
  --coral: #b4534b;
  --focus: #1d4ed8;
  --shadow: 0 16px 40px rgba(23, 32, 31, 0.08);
  --touch: 56px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), transparent 260px),
    var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 0 max(24px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.topbar h1,
.band-heading h2,
.quick-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(32px, 4vw, 54px);
  line-height: 0.95;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.language-toggle {
  display: inline-flex;
  min-height: var(--touch);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.language-toggle button {
  min-width: 70px;
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.language-toggle button[aria-pressed="true"] {
  background: var(--teal);
  color: #fff;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sync-panel {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--touch);
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.14);
}

.status-dot.ready {
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

.status-dot.error {
  background: var(--coral);
  box-shadow: 0 0 0 4px rgba(180, 83, 75, 0.14);
}

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

.side-panel,
.lead-form,
.form-band,
.details-band {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.side-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 16px;
  padding: 16px;
}

.lead-form {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.form-band,
.details-band {
  padding: 20px;
  box-shadow: none;
}

.band-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.band-heading h2,
.quick-panel h2 {
  font-size: 22px;
  line-height: 1.1;
}

.meter {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.meter-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.meter-copy strong {
  color: var(--ink);
}

.meter-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7e0d5;
}

.meter-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #f59e0b);
  transition: width 180ms ease;
}

.quick-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.field-grid {
  display: grid;
  gap: 16px;
}

.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field,
.control-group {
  display: grid;
  gap: 10px;
}

.field span,
.group-label,
.upload-box label {
  color: #2e3b39;
  font-size: 13px;
  font-weight: 800;
}

.field.required span::after,
.control-group.required .group-label::after {
  content: " *";
  color: var(--coral);
}

input,
textarea {
  width: 100%;
  border: 1px solid #cfc8bc;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

input {
  min-height: var(--touch);
  padding: 0 16px;
}

textarea {
  min-height: 112px;
  padding: 14px 16px;
  resize: vertical;
}

input:focus,
textarea:focus,
summary:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

input.invalid,
textarea.invalid {
  border-color: var(--coral);
  background: #fff7f5;
}

.invalid-group {
  border-color: var(--coral) !important;
  box-shadow: 0 0 0 3px rgba(180, 83, 75, 0.12);
}

.segmented,
.chip-row,
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.linked-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 8px;
  background: #f4fbf9;
}

.linked-panel[hidden] {
  display: none;
}

.segmented button,
.chip,
.tag,
.secondary-action,
.ghost-action,
.primary-action {
  min-height: var(--touch);
  border: 1px solid #cfc8bc;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}

.segmented button {
  flex: 1 1 160px;
  padding: 0 16px;
}

.segmented.compact button {
  flex-basis: 180px;
}

.chip,
.tag {
  padding: 0 16px;
  color: #344340;
}

.role-shortcuts {
  align-self: end;
}

.product-cloud .tag {
  flex: 1 1 190px;
}

.segmented button[aria-pressed="true"],
.chip.active,
.tag.active {
  border-color: var(--teal);
  background: #e5f3f1;
  color: var(--teal-dark);
}

.segmented button:active,
.chip:active,
.tag:active,
.secondary-action:active,
.ghost-action:active,
.primary-action:active {
  transform: translateY(1px);
}

.secondary-action,
.ghost-action,
.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
}

.secondary-action {
  border-color: rgba(15, 118, 110, 0.35);
  color: var(--teal-dark);
  background: #eef8f6;
}

.secondary-action .action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  line-height: 1;
}

.upload-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px dashed #bdb4a6;
  border-radius: 8px;
  background: #fffcf6;
}

.upload-box p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.file-input {
  max-width: 310px;
  min-height: auto;
  padding: 10px;
}

.details-band {
  overflow: hidden;
}

.details-band summary {
  display: flex;
  align-items: center;
  min-height: var(--touch);
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  outline: none;
}

.details-band[open] summary {
  margin-bottom: 14px;
}

.full-span {
  grid-column: 1 / -1;
}

.action-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.ghost-action {
  min-width: 110px;
  background: #fff;
}

.primary-action {
  min-width: 210px;
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.68;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 10;
  width: min(420px, calc(100% - 32px));
  min-height: 48px;
  padding: 13px 16px;
  border: 1px solid rgba(15, 118, 110, 0.32);
  border-radius: 8px;
  background: #f3fbf9;
  color: var(--teal-dark);
  box-shadow: var(--shadow);
  font-weight: 800;
  text-align: center;
  transform: translate(-50%, 120%);
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.toast.error {
  border-color: rgba(180, 83, 75, 0.35);
  background: #fff7f5;
  color: #8f3932;
}

.submit-frame,
.honeypot,
.hidden-field {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 900px) {
  .app-shell {
    width: calc(100% - 24px);
    padding-top: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .meter {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .two-up {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .upload-box,
  .action-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .file-input {
    max-width: none;
  }

  .ghost-action,
  .primary-action {
    width: 100%;
  }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .workspace {
    grid-template-columns: 280px minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
