:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #637083;
  --line: #dfe4ea;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --warn: #b45309;
  --good: #15803d;
  --bad: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.sidebar {
  background: #111827;
  color: #f9fafb;
  padding: 22px 18px;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
}

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

.nav a,
.nav button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  background: transparent;
  color: #d1d5db;
  text-align: left;
  cursor: pointer;
}

.nav a:hover,
.nav button:hover {
  background: #1f2937;
  color: #ffffff;
}

.content {
  padding: 28px;
}

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

.topbar h1 {
  margin: 0;
  font-size: 28px;
}

.muted {
  color: var(--muted);
}

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

.stats {
  grid-template-columns: repeat(5, minmax(140px, 1fr));
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

.table th {
  background: #f1f5f9;
  color: #334155;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.badge.won {
  background: #dcfce7;
  color: var(--good);
}

.badge.lost {
  background: #fee2e2;
  color: var(--bad);
}

.badge.new {
  background: #dbeafe;
  color: #1d4ed8;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--brand);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.button.secondary {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.button.danger {
  background: #dc2626;
  color: #ffffff;
}

.button.secondary-danger {
  background: #ffffff;
  border-color: #fecaca;
  color: #b91c1c;
}

.table-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.table-actions form {
  margin: 0;
}

.table-actions .button {
  min-height: 34px;
  padding: 0 11px;
}

.form {
  display: grid;
  gap: 16px;
  max-width: 820px;
}

.form.wide {
  max-width: 1180px;
}

.field {
  display: grid;
  gap: 7px;
}

label {
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  font: inherit;
  background: #ffffff;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
}

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

.alert {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.alert.error {
  background: #fee2e2;
  color: #991b1b;
}

.alert.success {
  background: #dcfce7;
  color: #166534;
}

.login-page,
.public-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card,
.public-card {
  width: min(100%, 520px);
}

.split {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
}

.kanban {
  display: grid;
  grid-auto-columns: minmax(280px, 1fr);
  grid-auto-flow: column;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.kanban-column {
  min-width: 280px;
  background: #eef2f7;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.kanban-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 4px solid var(--brand);
  border-bottom: 1px solid var(--line);
  padding: 13px;
  background: #ffffff;
  border-radius: 8px 8px 0 0;
}

.kanban-list {
  display: grid;
  gap: 12px;
  min-height: 320px;
  padding: 12px;
}

.kanban-empty {
  display: grid;
  place-items: center;
  min-height: 96px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--muted);
}

.lead-card {
  display: grid;
  gap: 10px;
  align-content: start;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
}

.lead-card-title {
  font-weight: 700;
}

.lead-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.compact {
  gap: 4px;
}

.compact select,
.compact input {
  min-height: 34px;
  padding: 7px 9px;
}

.full {
  width: 100%;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

.builder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.builder-head h2 {
  margin: 0 0 4px;
}

.fields-builder {
  display: grid;
  gap: 12px;
  overflow-x: auto;
}

.field-row {
  display: grid;
  grid-template-columns: 1.1fr 140px 150px 0.9fr 0.9fr 0.8fr 80px 118px 118px 86px;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 1120px;
  padding: 12px;
  background: #f8fafc;
}

.choice-list {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.editor-shell {
  display: grid;
  gap: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.editor-header h2 {
  margin: 0 0 4px;
}

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

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  overflow-x: auto;
}

.tab {
  appearance: none;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #475569;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 52px;
  padding: 0 16px;
  white-space: nowrap;
}

.tab.active {
  border-bottom-color: var(--brand);
  color: var(--brand-dark);
}

.editor-form {
  max-width: none;
  gap: 0;
}

.tab-panel {
  display: none;
  padding: 22px 20px;
}

.tab-panel.active {
  display: grid;
  gap: 18px;
}

.section-title h3,
.builder-head h3 {
  margin: 0 0 4px;
  font-size: 20px;
}

.builder-head.clean {
  border-top: 0;
  padding-top: 0;
}

.publish-toggle {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #f8fafc;
}

.publish-toggle small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 400;
}

.embed-panel {
  display: grid;
  gap: 14px;
  max-width: 980px;
}

.embed-panel textarea {
  min-height: 92px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.empty-state {
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--muted);
  padding: 22px;
  background: #f8fafc;
}

.form-preview {
  width: 100%;
  min-height: 680px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.preview-box {
  display: grid;
  gap: 14px;
  max-width: 620px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #f8fafc;
}

.form-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.96);
}

.submitted-data {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 16px;
}

.submitted-data h3 {
  margin: 0;
}

.submitted-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

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

  .sidebar {
    position: static;
  }

  .stats,
  .split {
    grid-template-columns: 1fr;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .submitted-row {
    grid-template-columns: 1fr;
  }

  .editor-header,
  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }
}
