:root {
  color-scheme: light;
  --bg: #f7f4f0;
  --panel: #ffffff;
  --text: #1a1018;
  --muted: #6b5e68;
  --line: rgba(106, 30, 55, 0.12);
  --accent: #7a1b3a;
  --accent-dark: #5c1029;
  --accent-light: rgba(122, 27, 58, 0.08);
  --accent-soft: rgba(122, 27, 58, 0.14);
  --accent-glow: rgba(122, 27, 58, 0.06);
  --success: #1b6e3a;
  --success-bg: rgba(27, 110, 58, 0.08);
  --danger: #b43f3f;
  --danger-bg: rgba(180, 63, 63, 0.08);
  --warning: #b87a1b;
  --warning-bg: rgba(184, 122, 27, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 2px 8px rgba(26, 16, 24, 0.06);
  --shadow: 0 8px 30px rgba(26, 16, 24, 0.08);
  --shadow-lg: 0 20px 50px rgba(26, 16, 24, 0.12);
  --transition: 0.2s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  padding: 0;
}

/* ── Logo ── */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-text {
  line-height: 1.15;
}

.logo-text strong {
  display: block;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.12em;
}

.logo-text span {
  display: block;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Layout ── */
.page-shell {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 80px;
}

/* ── Header ── */
.header {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 2px solid var(--accent-soft);
}

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

/* ── Cards ── */
.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.card-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.card-body {
  padding: 16px;
}

.card-accent {
  border-top: 3px solid var(--accent);
}

/* ── Hero (login) ── */
.hero {
  text-align: center;
  padding: 32px 20px;
}

.hero-brand strong {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.12em;
}

.hero-brand span {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero h1 {
  font-size: 1.5rem;
  line-height: 1.2;
  margin: 12px 0 8px;
  color: var(--text);
}

.hero p {
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 32ch;
  margin: 0 auto;
}

.badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 12px;
  border-radius: 999px;
  text-transform: uppercase;
}

/* ── Form elements ── */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-required::after {
  content: " *";
  color: var(--danger);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder,
textarea::placeholder {
  color: #a89da5;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b5e68' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

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

input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  -webkit-appearance: auto;
  appearance: auto;
  border: none;
  background: none;
  box-shadow: none;
}

/* ── Choice groups (checkboxes / radios) ── */
.choice-group {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--accent-light);
}

.choice-group legend {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 4px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.checkbox-grid label,
.radio-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background var(--transition);
}

.checkbox-grid label:active,
.radio-row label:active {
  background: var(--accent-soft);
}

.radio-row {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

/* ── Buttons ── */
button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0;
  transition: all var(--transition);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 4px 14px rgba(122, 27, 58, 0.3);
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(122, 27, 58, 0.2);
}

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.btn-secondary:active {
  background: var(--accent);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--line);
}

.btn-sm {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.82rem;
}

.btn-icon {
  min-height: 40px;
  width: 40px;
  padding: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-block {
  width: 100%;
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.form-actions {
  display: flex;
  gap: 10px;
  padding-top: 4px;
}

.form-actions .btn {
  flex: 1;
}

/* ── Messages ── */
.message {
  min-height: 1rem;
  font-size: 0.88rem;
  font-weight: 500;
}

.message:empty {
  display: none;
}

.message-error {
  color: var(--danger);
  background: var(--danger-bg);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}

.message-success {
  color: var(--success);
  background: var(--success-bg);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}

/* ── Tabs / nav ── */
.tab-bar {
  display: flex;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.tab-bar button {
  flex: 1;
  padding: 10px 8px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  text-align: center;
}

.tab-bar button.active {
  background: var(--panel);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* ── Lead list ── */
.lead-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lead-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: box-shadow var(--transition);
}

.lead-item:active {
  box-shadow: var(--shadow);
}

.lead-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.lead-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.lead-company {
  font-size: 0.85rem;
  color: var(--muted);
}

.lead-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 6px;
}

.lead-desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.4;
}

.lead-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.pill-accent {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.pill-success {
  background: var(--success-bg);
  color: var(--success);
}

.pill-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.pill-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.pill-urgent {
  background: var(--danger);
  color: #fff;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-bar select {
  padding: 8px 32px 8px 12px;
  font-size: 0.85rem;
  min-height: auto;
  flex: 1;
  min-width: 120px;
}

.count-badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 16, 24, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 12px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--panel);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 85dvh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: var(--shadow-lg);
}

.modal-overlay.visible .modal {
  transform: translateY(0);
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: 10px auto 0;
}

.modal-header {
  padding: 16px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-body {
  padding: 16px;
}

.modal-footer {
  padding: 12px 16px 20px;
  display: flex;
  gap: 10px;
}

.modal-footer .btn {
  flex: 1;
}

.summary-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--accent-light);
  font-size: 0.88rem;
}

.summary-label {
  color: var(--muted);
  font-weight: 500;
  flex-shrink: 0;
}

.summary-value {
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ── Utilities ── */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ── Responsive ── */
@media (max-width: 420px) {
  .field-row {
    grid-template-columns: 1fr;
  }

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

  .header {
    padding: 12px;
  }

  .card-body,
  .card-header {
    padding: 14px;
  }
}

@media (min-width: 640px) {
  .page-shell {
    padding: 20px;
  }

  .modal {
    border-radius: var(--radius);
    margin-bottom: 10vh;
  }

  .modal-overlay {
    align-items: center;
  }
}
