:root {
  --ink: #141414;
  --coal: #1f2227;
  --soft-coal: #2c3037;
  --orange: #f74e14;
  --orange-dark: #c93d0c;
  --bg: #f4f5f7;
  --paper: #ffffff;
  --line: #e5e7eb;
  --muted: #6b7280;
  --text: #24272c;
  --success: #11845b;
  --warning: #b7791f;
  --danger: #c2410c;
  --radius: 8px;
  --shadow: 0 18px 42px rgba(20, 20, 20, .12);
}

* { box-sizing: border-box; }

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

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

button {
  cursor: pointer;
}

.hidden { display: none !important; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 460px);
  background: var(--ink);
  color: #fff;
}

.auth-brand {
  padding: clamp(32px, 7vw, 88px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    linear-gradient(135deg, rgba(247, 78, 20, .24), transparent 45%),
    linear-gradient(180deg, #141414, #24272c);
}

.brand-mark {
  width: 66px;
  height: 66px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--orange);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 18px 34px rgba(247, 78, 20, .28);
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  font-size: 14px;
}

.auth-brand p,
.auth-brand span,
.topbar p,
.card p,
.dialog-head p {
  margin: 0;
  color: rgba(255,255,255,.72);
}

.auth-brand h1 {
  margin: 30px 0 10px;
  font-size: clamp(42px, 7vw, 72px);
  line-height: .94;
}

.auth-brand span {
  max-width: 580px;
  font-size: 18px;
}

.auth-panel {
  margin: auto;
  width: min(86%, 420px);
  background: #fff;
  color: var(--text);
  padding: 28px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
  background: #f1f3f5;
  padding: 4px;
  border-radius: var(--radius);
}

.auth-tab {
  border: 0;
  border-radius: 6px;
  padding: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.auth-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: #3b3f47;
  font-size: 13px;
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
  outline: 0;
}

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

input:focus, select:focus, textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(247,78,20,.14);
}

.primary, .ghost, .link-button, .icon-button, .chip {
  border-radius: 7px;
  border: 1px solid transparent;
  min-height: 40px;
}

.primary {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
  padding: 0 16px;
  font-weight: 800;
}

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

.full { width: 100%; }

.ghost {
  background: #fff;
  color: var(--coal);
  border-color: var(--line);
  padding: 0 14px;
  font-weight: 700;
}

.link-button {
  margin-top: 10px;
  border: 0;
  background: transparent;
  color: var(--orange);
  font-weight: 800;
}

.auth-hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px;
  background: var(--ink);
  color: #fff;
}

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

.sidebar-head span,
.user-card span {
  display: block;
  margin-top: 2px;
  color: rgba(255,255,255,.62);
  font-size: 12px;
}

#nav {
  display: grid;
  gap: 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: rgba(255,255,255,.78);
  text-align: left;
  font-weight: 700;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(247,78,20,.16);
  color: #fff;
}

.nav-icon {
  width: 24px;
  text-align: center;
  color: var(--orange);
}

.user-card {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius);
  background: rgba(255,255,255,.04);
}

.user-card .ghost {
  margin-top: 12px;
  width: 100%;
  background: rgba(255,255,255,.08);
  color: #fff;
  border-color: rgba(255,255,255,.16);
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 18px;
  justify-content: space-between;
  padding: 18px 26px;
  background: rgba(244,245,247,.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.topbar h2 {
  margin: 2px 0 0;
  font-size: 24px;
}

.topbar p,
.dialog-head p {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 900;
}

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

.top-actions input {
  width: min(28vw, 320px);
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--coal);
  font-weight: 900;
}

#menuToggle { display: none; }

.content {
  padding: 26px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 8px 20px rgba(20,20,20,.04);
}

.metric strong {
  display: block;
  margin-top: 9px;
  font-size: 25px;
  color: var(--ink);
}

.metric small {
  color: var(--success);
  font-weight: 800;
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, .8fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.panel-title h3 {
  margin: 0;
  font-size: 17px;
}

.chart {
  height: 250px;
  display: flex;
  align-items: end;
  gap: 12px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.bar {
  flex: 1;
  min-width: 22px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--orange), #272a30);
  position: relative;
}

.bar span {
  position: absolute;
  left: 50%;
  bottom: -24px;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 12px;
}

.conversion {
  display: grid;
  gap: 10px;
}

.progress-row {
  display: grid;
  grid-template-columns: 118px 1fr 42px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.progress-track {
  height: 10px;
  background: #eceff3;
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--orange);
  border-radius: 99px;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #eef0f4;
  border-radius: var(--radius);
}

.list-item strong { display: block; }
.list-item span, .muted { color: var(--muted); font-size: 13px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

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

.filters input,
.filters select {
  width: auto;
  min-width: 170px;
}

.table-wrap {
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th, td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  color: #434850;
  font-size: 12px;
  text-transform: uppercase;
}

td button {
  margin-right: 6px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--coal);
  font-size: 12px;
  font-weight: 900;
}

.status.good { background: #e7f8ef; color: var(--success); }
.status.warn { background: #fff6dc; color: var(--warning); }
.status.bad { background: #fff1e8; color: var(--danger); }
.status.accent { background: rgba(247,78,20,.12); color: var(--orange-dark); }

.kanban {
  display: grid;
  grid-template-columns: repeat(8, minmax(250px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-col {
  min-height: 580px;
  background: #edf0f4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.kanban-col header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--coal);
  font-weight: 900;
}

.lead-card {
  display: grid;
  gap: 9px;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--orange);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 8px 18px rgba(0,0,0,.04);
}

.lead-card strong { color: var(--ink); }
.lead-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lead-card[draggable="true"] { cursor: grab; }

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-color: var(--line);
  background: #fff;
  color: var(--coal);
  font-size: 12px;
  font-weight: 900;
}

dialog {
  width: min(780px, calc(100vw - 24px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(20,20,20,.58);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 20px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h3 {
  margin: 3px 0 0;
  font-size: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
  padding: 20px;
  max-height: min(68vh, 720px);
  overflow: auto;
}

.form-grid label.wide {
  grid-column: 1 / -1;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
}

.detail-panel {
  background: #fff;
}

#detailBody {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-field {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}

.detail-field b {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.automation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.automation-card {
  display: grid;
  gap: 10px;
}

.tabbar {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #eef0f4;
}

.tab-button {
  min-height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.tab-button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
}

.compact {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.automation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.template-card {
  min-height: 170px;
}

.schema {
  background: #171a1f;
  color: #f4f5f7;
  border-radius: var(--radius);
  padding: 16px;
  overflow: auto;
  font-size: 13px;
}

@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .grid-two { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-brand { min-height: 42vh; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    z-index: 10;
    width: min(84vw, 310px);
    transform: translateX(-110%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  #menuToggle { display: inline-grid; place-items: center; }
  .topbar {
    align-items: stretch;
    flex-wrap: wrap;
    padding: 14px;
  }
  .top-actions {
    width: 100%;
  }
  .top-actions input {
    flex: 1;
    width: auto;
    min-width: 0;
  }
  .content { padding: 14px; }
  .metrics { grid-template-columns: 1fr; }
  .form-grid, #detailBody { grid-template-columns: 1fr; }
  .filters input, .filters select { width: 100%; }
}

.public-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, .9fr) minmax(360px, 1.1fr);
  background: var(--ink);
  color: #fff;
}

.public-hero {
  padding: clamp(28px, 6vw, 72px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  background:
    linear-gradient(135deg, rgba(247, 78, 20, .24), transparent 46%),
    linear-gradient(180deg, #141414, #24272c);
}

.public-hero h1 {
  margin: 12px 0 0;
  font-size: clamp(38px, 6vw, 64px);
  line-height: .98;
}

.public-hero p,
.public-hero span {
  margin: 0;
  color: rgba(255,255,255,.74);
}

.public-hero span {
  max-width: 560px;
  font-size: 18px;
}

.public-proof {
  margin-top: 18px;
  display: grid;
  gap: 7px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  background: rgba(255,255,255,.05);
}

.public-proof small {
  color: rgba(255,255,255,.62);
}

.public-card {
  align-self: center;
  width: min(92%, 760px);
  margin: 28px auto;
  padding: 24px;
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
}

.public-card h2 {
  margin: 4px 0 20px;
  font-size: 25px;
}

.public-kicker {
  margin: 0;
  color: var(--orange);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 900;
}

.public-step {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.public-step:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.public-step span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-weight: 900;
}

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

.public-form-grid .wide {
  grid-column: 1 / -1;
}

.public-success {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}

.public-success h3 {
  margin: 0;
  font-size: 22px;
}

.public-success p {
  margin: 0;
  color: var(--muted);
}

.public-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.public-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  text-decoration: none;
}

.quiz-page {
  grid-template-columns: minmax(320px, .82fr) minmax(380px, 1.18fr);
}

.quiz-card {
  max-width: 820px;
}

.quiz-progress {
  height: 9px;
  margin: 12px 0 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #eef0f4;
}

.quiz-progress span {
  display: block;
  width: 20%;
  height: 100%;
  border-radius: 999px;
  background: var(--orange);
  transition: width .22s ease;
}

.quiz-counter {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.quiz-form {
  display: grid;
  gap: 18px;
}

.quiz-step {
  display: none;
  animation: quizFade .18s ease;
}

.quiz-step.active {
  display: block;
}

@keyframes quizFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.quiz-question {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.quiz-question span {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-weight: 900;
}

.quiz-question h3 {
  margin: 0 0 5px;
  font-size: 22px;
  color: var(--ink);
}

.quiz-question p {
  margin: 0;
  color: var(--muted);
}

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

.quiz-option {
  margin: 0;
  display: block;
  cursor: pointer;
}

.quiz-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.quiz-option span {
  min-height: 76px;
  display: flex;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  color: var(--coal);
  font-weight: 800;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.quiz-option input:checked + span {
  border-color: var(--orange);
  background: rgba(247,78,20,.08);
  box-shadow: 0 0 0 3px rgba(247,78,20,.12);
}

.quiz-inline {
  margin-top: 16px;
}

.quiz-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.quiz-actions .primary,
.quiz-actions .ghost {
  min-width: 132px;
}

.quiz-actions .ghost:disabled {
  opacity: .5;
  cursor: not-allowed;
}

@media (max-width: 900px) {
  .public-page,
  .quiz-page {
    grid-template-columns: 1fr;
  }
  .public-hero {
    min-height: auto;
  }
  .public-card {
    margin: 0 auto 18px;
  }
}

@media (max-width: 620px) {
  .public-form-grid {
    grid-template-columns: 1fr;
  }
  .option-grid {
    grid-template-columns: 1fr;
  }
  .public-card {
    width: calc(100% - 24px);
    padding: 18px;
  }
  .quiz-question h3 {
    font-size: 19px;
  }
  .quiz-actions {
    position: sticky;
    bottom: 0;
    margin: 0 -18px -18px;
    padding: 12px 18px;
    background: #fff;
  }
}
