:root {
  color-scheme: dark;
  --bg: #050505;
  --rail: #000000;
  --surface: #111111;
  --surface-strong: #1a1a1a;
  --surface-soft: #0b0b0b;
  --text: #f8fafd;
  --muted: #a6adb7;
  --line: #2b2f36;
  --line-strong: #3b4048;
  --brand: #ffffff;
  --brand-strong: #e8eaed;
  --danger: #ffb4ab;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px 1fr;
  background: var(--bg);
  color: var(--text);
  font-family: "Google Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

body.auth-locked {
  display: block;
}

body.auth-locked .sidebar,
body.auth-locked .app {
  display: none;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(320px, 440px);
  gap: 32px;
  align-items: center;
  padding: 48px;
  background:
    #000;
}

.auth-screen[hidden] {
  display: none !important;
}

.landing-logo {
  width: min(280px, 36vw);
  height: auto;
  display: block;
  margin-bottom: 28px;
}

.landing h1 {
  max-width: 760px;
  font-size: clamp(42px, 6vw, 78px);
  line-height: 0.96;
  margin-bottom: 18px;
}

.landing-copy {
  max-width: 640px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.auth-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.auth-tabs button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.auth-tabs button.active {
  background: #fff;
  color: #000;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: grid;
}

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

.sidebar {
  min-height: 100vh;
  width: 236px;
  padding: 18px 12px;
  background: var(--rail);
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  border-right: 1px solid var(--line);
  transition: width 0.2s ease;
}

.burger {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.burger span {
  width: 17px;
  height: 2px;
  background: var(--text);
  display: block;
  border-radius: 999px;
}

.burger:hover {
  background: var(--surface-strong);
  border-color: var(--line-strong);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 66px;
}

.brand-mark {
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 0;
  background: #000;
  color: #fff;
  position: relative;
  overflow: visible;
}

.product-logo {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

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

.brand-copy span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.brand-copy strong {
  font-size: 16px;
  letter-spacing: 0;
}

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

.nav button {
  border: 0;
  color: var(--muted);
  background: transparent;
  text-align: left;
  padding: 12px 13px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav button:hover,
.nav button.active {
  background: #202124;
  color: var(--text);
}

.nav-note {
  margin-top: auto;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  padding: 0 10px 4px;
}

.nav-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: grid;
  place-items: center;
  color: currentColor;
  font-weight: 800;
}

.nav button[data-icon="analytics"] .nav-icon::before {
  content: "";
  width: 16px;
  height: 14px;
  background:
    linear-gradient(currentColor 0 0) 1px 8px / 3px 6px no-repeat,
    linear-gradient(currentColor 0 0) 7px 4px / 3px 10px no-repeat,
    linear-gradient(currentColor 0 0) 13px 1px / 3px 13px no-repeat;
}

.nav button[data-icon="sales"] .nav-icon::before {
  content: "$";
  font-size: 18px;
  line-height: 1;
}

.nav button[data-icon="clients"] .nav-icon::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: -6px 7px 0 currentColor, 6px 7px 0 currentColor;
}

.nav button[data-icon="crm"] .nav-icon::before {
  content: "";
  width: 17px;
  height: 11px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  background: linear-gradient(135deg, transparent 43%, currentColor 44% 55%, transparent 56%);
}

.sidebar.collapsed {
  width: 72px;
  padding-left: 14px;
  padding-right: 14px;
}

body:has(.sidebar.collapsed) {
  grid-template-columns: 72px 1fr;
}

.sidebar.collapsed .brand-copy,
.sidebar.collapsed .nav span,
.sidebar.collapsed .nav-note {
  display: none;
}

.sidebar.collapsed .nav button {
  text-align: center;
  min-height: 42px;
  padding: 0;
  border-radius: 50%;
  justify-content: center;
}

.app {
  min-width: 0;
  padding: 28px;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.07), transparent 34vw),
    var(--bg);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.top-actions {
  margin-left: auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.logout-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 13px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.secondary-button {
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 14px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(24px, 2.2vw, 34px);
  line-height: 1.2;
  letter-spacing: 0;
  color: var(--text);
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  letter-spacing: 0;
  color: var(--text);
}

.section {
  display: none;
}

.section.active {
  display: grid;
  gap: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
  position: relative;
}

.metric span,
.panel-head span,
label,
.sales-table small,
.account-cell small {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 32px;
  line-height: 1;
  color: var(--text);
}

.hold-metric button {
  position: absolute;
  right: 14px;
  bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.panel {
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

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

.settings-stack {
  display: grid;
  gap: 18px;
}

.compact-form {
  gap: 14px;
}

.compact-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.compact-grid.two {
  grid-template-columns: minmax(220px, 0.45fr) 1fr;
}

.wide-field {
  grid-column: 1 / -1;
}

.api-box {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.api-box div {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: var(--surface-soft);
}

.api-box strong,
.api-box span {
  display: block;
}

.api-box span {
  margin-top: 6px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.account-script-table,
.settings-table {
  display: grid;
  gap: 8px;
  overflow-x: auto;
}

.settings-row {
  min-width: 980px;
  display: grid;
  grid-template-columns: 150px 210px 170px 170px minmax(260px, 1fr) 110px;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: var(--surface-soft);
}

.settings-row.header {
  align-items: center;
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 700;
}

.settings-row small,
.file-cell span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.file-cell input[type="file"] {
  padding: 8px;
  font-size: 12px;
}

.settings-row textarea {
  min-height: 92px;
  max-height: 160px;
}

.settings-row button[type="submit"] {
  align-self: center;
  white-space: nowrap;
}

.timer-cell {
  display: grid;
  gap: 8px;
}

.timer-cell label {
  font-size: 12px;
}

.script-row {
  min-width: 1320px;
  display: grid;
  grid-template-columns: 170px 210px 190px 150px minmax(360px, 1fr) 140px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: var(--surface-soft);
}

.script-row.header {
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 700;
}

.script-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.script-row textarea {
  min-height: 72px;
  max-height: 140px;
}

.script-actions {
  display: grid;
  gap: 8px;
}

.cell-stack {
  display: grid;
  gap: 8px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 7px;
}

.checkline input {
  width: auto;
}

form {
  display: grid;
  gap: 13px;
}

label {
  display: grid;
  gap: 7px;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
}

button[type="submit"] {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  background: var(--brand);
  color: #000;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.16s ease;
}

button[type="submit"]:hover {
  background: var(--brand-strong);
  transform: translateY(-1px);
}

.inline-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.form-message {
  min-height: 20px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.form-message.error {
  color: var(--danger);
}

.sales-table {
  display: grid;
  gap: 8px;
  overflow-x: auto;
}

.sales-table .row {
  min-width: 780px;
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 0.8fr 0.8fr;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: var(--surface-soft);
}

.sales-table .analytics-row {
  min-width: 1040px;
  grid-template-columns: 1.2fr 1.1fr 0.8fr 0.7fr 0.7fr 0.7fr 0.8fr 0.8fr;
}

#bindingTable .row {
  grid-template-columns: 1.1fr 1fr 1fr 1fr;
}

.sales-table .row.header {
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 700;
}

.sales-table small {
  display: block;
  margin-top: 4px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 18px;
  color: var(--muted);
}

.ai-line {
  padding: 14px;
}

.ai-line form {
  grid-template-columns: 280px 1fr 180px;
  align-items: end;
}

.compact-select {
  min-width: 240px;
}

.summary-output {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.system-answer {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  line-height: 1.45;
}

.system-label {
  color: var(--text);
  font-weight: 700;
  margin-bottom: 6px;
}

.ai-line p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.crm-panel {
  overflow: hidden;
}

.crm-matrix {
  overflow-x: auto;
  display: grid;
  gap: 8px;
}

.matrix-row {
  min-width: 1040px;
  display: grid;
  grid-template-columns: 180px repeat(var(--stage-count), minmax(150px, 1fr));
  gap: 8px;
}

.matrix-row > div {
  border: 1px solid var(--line);
  border-radius: 16px;
  min-height: 74px;
  padding: 10px;
  background: var(--surface-soft);
}

.matrix-row.header > div {
  min-height: auto;
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 700;
}

.account-cell strong,
.account-cell small {
  display: block;
}

.crm-cell {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 7px;
}

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

.lead-chip {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 10px;
  background: #ffffff;
  color: #000;
  cursor: pointer;
  font-size: 13px;
  max-width: 100%;
  font-weight: 650;
}

.lead-chip small {
  display: block;
  margin-top: 3px;
  color: #3f3f46;
  font-size: 11px;
}

.hold-chip {
  background: #d4d4d8;
}

.lead-chip:hover {
  border-color: #fff;
  background: #e8eaed;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
}

.modal[hidden] {
  display: none !important;
}

.modal-card {
  width: min(920px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.app-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 20px;
  padding: 10px 2px 0;
  color: var(--muted);
  font-size: 11px;
}

.app-footer a {
  color: var(--muted);
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--text);
}

.assistant-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 60;
  width: min(420px, 100vw);
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
  padding: 18px;
  border-left: 1px solid var(--line);
  background: #050505;
  box-shadow: var(--shadow);
}

.assistant-drawer[hidden] {
  display: none !important;
}

.assistant-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

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

.assistant-head span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.assistant-form {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  background: var(--surface);
}

.assistant-messages {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.assistant-message {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 11px 12px;
  background: var(--surface);
  color: var(--muted);
  line-height: 1.45;
}

.assistant-message.user {
  align-self: flex-end;
  max-width: 88%;
  background: #fff;
  color: #000;
}

.assistant-message.error {
  color: var(--danger);
}

@media (max-width: 1100px) {
  .settings-grid,
  .metric-grid,
  .compact-grid,
  .compact-grid.two,
  .api-box,
  .modal-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .auth-screen {
    grid-template-columns: 1fr;
    padding: 24px;
  }

  .landing-logo {
    width: 180px;
  }

  body {
    grid-template-columns: 72px 1fr;
  }

  body:has(.sidebar:not(.collapsed)) {
    grid-template-columns: 196px 1fr;
  }

  .sidebar {
    width: 196px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .sidebar:not(.collapsed) .nav-note {
    display: none;
  }

  .sidebar.collapsed {
    width: 72px;
  }

  .app {
    padding: 16px;
  }

  .topbar,
  .panel-head,
  .ai-line form,
  .settings-grid,
  .metric-grid,
  .inline-fields,
  .compact-grid,
  .compact-grid.two,
  .api-box,
  .modal-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .metric-grid {
    gap: 10px;
  }

  .metric {
    padding: 14px;
  }

  .metric strong {
    font-size: 26px;
  }

  .settings-row {
    min-width: 860px;
    grid-template-columns: 130px 180px 140px 150px minmax(220px, 1fr) 100px;
  }

  .modal {
    padding: 12px;
  }

  .modal-card {
    max-height: calc(100vh - 24px);
  }
}
/* --- Prompt templates (added 2026-05-17) --- */

.modal-card--wide { width: min(1080px, 100%); }

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

.danger-button {
  border: 1px solid rgba(220, 80, 80, 0.45);
  background: rgba(220, 80, 80, 0.08);
  color: #fca5a5;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}
.danger-button:hover { background: rgba(220, 80, 80, 0.18); }

.templates-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.template-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: var(--surface);
  display: grid;
  gap: 10px;
}

.template-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.template-card-head strong { font-size: 14px; }

.template-card-head .template-meta {
  color: var(--muted);
  font-size: 11px;
}

.template-card-desc {
  color: var(--muted);
  font-size: 12px;
}

.template-card-body {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  max-height: 120px;
  overflow: hidden;
  position: relative;
  white-space: pre-wrap;
  color: var(--text);
}

.template-card-body::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 24px;
  background: linear-gradient(to bottom, transparent, var(--surface));
  pointer-events: none;
}

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

.template-card-actions button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
}
.template-card-actions button:hover { background: rgba(255, 255, 255, 0.07); }

.template-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.template-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.template-chip.muted { color: var(--muted); border-style: dashed; }
.template-chip.unbound { border-color: rgba(220, 180, 80, 0.45); color: #fde68a; }

.template-vars-label {
  font-size: 12px;
  color: var(--muted);
}

.template-vars-detected {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.template-vars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.template-vars-grid label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.template-vars-grid input,
.template-vars-grid textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.template-defaults {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.template-defaults label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.groups-bind-list {
  display: grid;
  gap: 10px;
}

.group-bind-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 2fr 2fr auto;
  gap: 12px;
  align-items: center;
}

.group-bind-row .group-bind-template {
  font-size: 12px;
  color: var(--muted);
}

.group-bind-row code {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 6px;
  border-radius: 6px;
}
