@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;600;700&display=swap");

:root {
  --bg: #f7f5f1;
  --text: #1f1f1f;
  --muted: #6b6b6b;
  --card: #ffffff;
  --accent: #355c7d;
  --border: #e1ddd6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  background: #fefbf6;
  gap: 16px;
  flex-wrap: wrap;
}

header h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.5px;
}

nav a {
  margin-right: 16px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
}

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

.user-email {
  font-weight: 600;
  color: var(--muted);
}

.lang-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lang-form label {
  font-size: 13px;
  color: var(--muted);
}

.lang-form select {
  min-width: 120px;
}

main {
  padding: 24px 32px 48px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.card .label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.card .value {
  font-size: 28px;
  font-weight: 700;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-top: 24px;
}

.panel h2 {
  margin-top: 0;
}

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.form-row input,
.settings-form input,
textarea,
select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 200px;
}

textarea {
  resize: vertical;
  font-family: inherit;
}

button, .button {
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button.danger {
  background: #b43c3c;
}

.success {
  background: #2f8f5b;
}

.secondary {
  background: #5c6b7a;
}

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

.bulk-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.bulk-status {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 160px;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.tab {
  background: #e9e3da;
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.tab.active {
  background: var(--accent);
  color: white;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #b43c3c;
  color: #fff;
  padding: 14px 18px;
  border-radius: 12px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
  pointer-events: none;
  font-size: 15px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.toast.show {
  opacity: 0.95;
  transform: translateY(0);
}

.note-box {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.note-box textarea {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

button:hover, .button:hover {
  filter: brightness(0.95);
}

table {
  width: 100%;
  border-collapse: collapse;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.leads-table {
  min-width: 1320px;
}

table th,
table td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

.message {
  min-width: 240px;
  max-width: 320px;
  white-space: pre-wrap;
}

.lead-actions-cell {
  min-width: 280px;
  width: 280px;
}

.leads-table td:nth-child(3),
.leads-table td:nth-child(6),
.leads-table td:nth-child(7),
.leads-table td:nth-child(8),
.leads-table td:nth-child(9),
.leads-table td:nth-child(10) {
  white-space: nowrap;
}

.lead-actions-layout {
  display: grid;
  gap: 6px;
}

.lead-actions-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  align-items: start;
}

.lead-actions-row form,
.lead-note-actions form {
  margin: 0;
}

.lead-actions-row-delete {
  grid-template-columns: minmax(0, 1fr);
}

.lead-actions-row > *,
.lead-note-actions > * {
  align-self: start;
}

.lead-action-control,
.lead-actions-row .button,
.lead-actions-row button,
.lead-actions-row select,
.lead-note-actions button {
  width: 100%;
}

.lead-action-control,
.lead-actions-row .button,
.lead-actions-row button,
.lead-note-actions button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
}

.lead-actions-row select {
  min-width: 0;
  appearance: auto;
  justify-content: flex-start;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
}

.lead-inline-form,
.lead-actions-row .status-form {
  display: block;
}

.lead-note-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.lead-note-box {
  margin-top: 0;
}

.lead-note-box textarea {
  min-height: 84px;
}

.message-text {
  white-space: pre-wrap;
}

.message-text.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 10;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.settings-form {
  display: grid;
  gap: 12px;
}

.settings-form label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.help-video {
  margin: 16px 0;
  aspect-ratio: 16 / 9;
  width: min(100%, 720px);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}

.help-video iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.help-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.help-links a {
  font-weight: 600;
}

.panel-soft {
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fcfaf6;
}

.panel-soft h3 {
  margin: 0 0 8px;
}

.auth-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 18px;
}

.auth-tab {
  background: #ece6dc;
  color: var(--text);
  border: 1px solid var(--border);
}

.auth-tab.active {
  background: var(--accent);
  color: #fff;
}

.auth-pane {
  display: none;
}

.auth-pane.active {
  display: block;
}

.status-banner {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-weight: 600;
}

.status-banner.success {
  background: #e6f5ec;
  color: #216741;
  border: 1px solid #b7dfc6;
}

.status-banner.error {
  background: #fae8e8;
  color: #9d2f2f;
  border: 1px solid #edc1c1;
}

.status-banner.info {
  background: #eaf1f8;
  color: #274d6d;
  border: 1px solid #c7d8ea;
}

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

.inline-form {
  margin-top: 10px;
}

.verify-form {
  margin-top: 14px;
  max-width: 420px;
}

.qr-login-box {
  display: none;
  margin-top: 16px;
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #fff;
  max-width: 320px;
}

.qr-login-box.active {
  display: grid;
  gap: 12px;
}

.qr-canvas {
  width: 220px;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  background: #fff;
}

.qr-canvas img,
.qr-canvas canvas {
  max-width: 100%;
  height: auto;
}

.qr-open-link.hidden {
  display: none;
}

.settings-form label.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.help {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.settings-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.settings-col {
  display: grid;
  gap: 12px;
  align-content: start;
}

.top-right {
  margin-top: 2px;
}

.info {
  margin-top: 24px;
  color: var(--muted);
}

.hint {
  color: var(--muted);
  margin-top: 8px;
  font-size: 13px;
}

.error {
  color: #b43c3c;
  font-weight: 600;
}

.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.auth-panel {
  max-width: 420px;
  width: 100%;
}

@media (max-width: 640px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  nav a {
    display: inline-block;
    margin-bottom: 6px;
  }
}
