:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #697586;
  --line: #d8dee6;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --ok: #0f8a5f;
  --warn: #b45309;
  --danger: #c2410c;
  --soft-blue: #eef4ff;
  --soft-green: #ecfdf5;
  --soft-amber: #fff7ed;
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.mark,
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 8px;
}

.mark {
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.brand-logo {
  display: block;
  object-fit: cover;
  background: #ffd400;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.25;
}

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

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

.field label {
  color: #27364a;
  font-weight: 650;
  font-size: 14px;
}

.required-mark {
  color: #dc2626;
  font-weight: 800;
}

.label-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.status-hint {
  margin: -8px 0 0;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  min-height: 42px;
  outline: none;
}

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

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--muted);
  border-radius: 6px;
  transform: translateY(-50%);
}

.password-toggle:hover {
  color: var(--brand-strong);
  background: #eff6ff;
}

.password-toggle svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.remember-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #27364a;
  font-size: 14px;
  font-weight: 650;
  margin: 4px 0 2px;
}

.remember-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.unit-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}

.unit-input input {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.unit-input:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.unit-input span {
  padding: 0 10px;
  color: var(--muted);
  font-weight: 700;
}

.inline-unit {
  min-height: 30px;
}

.inline-unit .editable-input {
  border: 0;
  box-shadow: none;
}

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

.span-2 {
  grid-column: 1 / -1;
}

.primary-btn,
.ghost-btn,
.chip {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 700;
}

.primary-btn {
  background: var(--brand);
  color: #fff;
}

.primary-btn:hover {
  background: var(--brand-strong);
}

.ghost-btn {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.ghost-btn:hover {
  border-color: #b7c2d1;
  background: #f9fafb;
}

.login-panel .primary-btn {
  width: 100%;
  margin-top: 16px;
}

.error {
  margin-top: 12px;
  color: #b91c1c;
  font-size: 14px;
  min-height: 20px;
}

.form-success {
  margin-bottom: 12px;
  padding: 9px 10px;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  background: #f0fdf4;
  color: #047857;
  font-size: 14px;
  font-weight: 700;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
}

.sidebar {
  background: #111827;
  color: #f9fafb;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar .subtle {
  color: #a7b0c0;
}

.module-tabs {
  display: grid;
  gap: 8px;
}

.module-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 12px;
  color: #dbe4f0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}

.module-tab.active,
.module-tab:hover {
  background: #273449;
  color: #fff;
}

.user-box {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.user-name-line {
  display: grid;
  gap: 4px;
  line-height: 1.25;
}

.tenure-message {
  display: grid;
  gap: 2px;
  color: #dbe4f0;
  font-size: 12px;
  font-weight: 650;
}

.tenure-message strong {
  display: inline-block;
  margin: 0 2px;
  color: #facc15;
  font-size: 16px;
  line-height: 1;
}

.sidebar-info {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.clock-card,
.weather-card {
  display: grid;
  gap: 3px;
  padding: 8px 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
}

.clock-card span,
.weather-card span,
.weather-card em {
  color: #a7b0c0;
  font-size: 12px;
  font-style: normal;
  line-height: 1.35;
}

.clock-card strong {
  color: #f9fafb;
  font-size: 22px;
  letter-spacing: 0;
  line-height: 1.1;
}

.weather-card strong {
  color: #f9fafb;
  font-size: 14px;
  line-height: 1.35;
}

.main {
  min-width: 0;
  padding: 24px;
}

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

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

.welcome-banner {
  margin: -4px 0 14px;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 750;
  line-height: 1.35;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  appearance: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  text-align: left;
  width: 100%;
  font: inherit;
}

.stat.alert {
  border-color: #fb923c;
  background: #fff7ed;
}

.stat.clickable {
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.stat.clickable:hover {
  border-color: #3b82f6;
  box-shadow: 0 10px 22px rgba(59, 130, 246, 0.08);
  transform: translateY(-1px);
}

.stat.clickable:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.stat.active {
  border-color: #3b82f6;
  background: #eff6ff;
}

.stat.active strong,
.stat.active span {
  color: #1d4ed8;
}

.stat.alert strong,
.stat.alert span {
  color: #c2410c;
}

.stat strong {
  display: block;
  font-size: 26px;
  margin-bottom: 4px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
  min-width: 0;
}

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

.panel-head h3 {
  font-size: 17px;
}

.panel-body {
  padding: 18px;
}

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

.chip {
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
}

.chip.active {
  color: var(--brand-strong);
  background: var(--soft-blue);
  border-color: #b9cdfd;
}

.muted-chip {
  color: #596273;
  background: #f8fafc;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-row input {
  min-width: 0;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
}

.date-filter {
  display: grid;
  grid-template-columns: auto 150px;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.date-filter input {
  height: 36px;
  flex: initial;
}

.lead-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(300px, 1fr));
  gap: 12px;
  max-height: 590px;
  overflow: auto;
  padding-right: 2px;
}

.lead-card {
  display: grid;
  gap: 0;
}

.lead-item {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 18px 14px;
  display: grid;
  align-items: start;
  gap: 14px;
  cursor: pointer;
}

.lead-item.danger {
  border-color: #fb923c;
  background: #fff7ed;
}

.lead-item:hover,
.lead-item.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.11);
}

.lead-title {
  display: block;
}

.lead-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
}

.lead-primary {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.lead-primary span {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.lead-source-link,
.lead-primary strong {
  font-size: 20px;
  line-height: 1.25;
}

.lead-source-link {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.lead-title-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 2px;
}

.expand-text {
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
  white-space: nowrap;
}

.delete-lead-btn {
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid #fecaca;
  border-radius: 999px;
  color: #b91c1c;
  background: #fff1f2;
  font-size: 12px;
  font-weight: 800;
}

.delete-lead-btn:hover {
  border-color: #fca5a5;
  background: #fee2e2;
}

.delete-lead-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.lead-summary-grid {
  display: contents;
}

.title-model-field {
  min-height: 0;
  width: 100%;
  min-width: 0;
}

.title-model-field .compact-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  font-size: 19px;
  line-height: 1.25;
  resize: none;
}

.title-model-field .compact-input.editing {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.lead-created-time strong {
  color: #1d4ed8;
}

.compact-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  min-height: 0;
}

.compact-field > span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
}

.compact-field.readonly strong {
  color: #475569;
  font-size: 16px;
  font-weight: 750;
  line-height: 1.3;
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}

.compact-input {
  min-height: 30px;
  width: 100%;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 750;
  line-height: 1.3;
  padding: 0;
}

textarea.compact-input {
  min-height: 56px;
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.lead-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 28px;
}

.lead-card-grid .wide-field {
  grid-column: span 1;
}

.bottom-note-field {
  grid-column: 1 / -1;
}

.full-text-field,
.full-text-field .compact-input {
  cursor: zoom-in;
}

.field-phone {
  min-width: 0;
}

.field-next_follow_at {
  min-width: 0;
}

.field-next_follow_at .compact-input {
  font-size: 15px;
}

.field-distance {
  min-width: 0;
}

.field-vehicle_model {
  min-width: 0;
}

.compact-input:not(.editing) {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.compact-input:not(.editing):hover {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.compact-input.editing {
  min-width: min(420px, 70vw);
  overflow: visible;
}

select.compact-input:not(.editing) {
  appearance: none;
  background-image: none;
}

.compact-unit {
  min-height: 30px;
  border-color: transparent;
  background: transparent;
  display: inline-flex;
  align-items: center;
  grid-template-columns: minmax(0, max-content) max-content;
  gap: 2px;
  width: max-content;
  max-width: 100%;
}

.compact-unit span {
  min-height: 30px;
  padding: 0 1px;
  line-height: 1.35;
}

.price-field {
  justify-content: start;
}

.price-field .compact-unit {
  display: inline-flex;
  align-items: center;
  grid-template-columns: none;
  gap: 0;
  width: max-content;
  min-width: 0;
  max-width: max-content;
  overflow: visible;
}

.price-field .compact-input {
  padding-left: 0;
  padding-right: 0;
  line-height: 1.35;
  width: 5.6ch !important;
  min-width: 5.6ch;
  max-width: 5.6ch;
}

.field-city .compact-input {
  width: 6em;
  min-width: 4em;
  max-width: 6em;
}

.field-phone .compact-input {
  width: 12ch;
  max-width: 12ch;
}

.price-field .compact-unit span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-left: 0;
  padding-left: 0;
  padding-right: 0;
  line-height: 1.35;
}

.compact-unit:not(.editing) span {
  border-color: transparent;
  background: transparent;
}

.compact-unit.editing {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.compact-unit.editing .compact-input {
  border-color: transparent;
  box-shadow: none;
}

.compact-field.wide-field {
  grid-column: auto;
}

.compact-field.danger-text-field .compact-input {
  color: #c2410c;
}

.compact-field.due-text-field .compact-input {
  color: #1d4ed8;
}

.card-save-state {
  grid-column: 1 / -1;
  min-height: 14px;
  margin: -3px 0 0;
}

.lead-note-line {
  color: #475569;
  font-size: 14px;
}

.lead-card.expanded .lead-item {
  border-color: var(--brand);
  border-radius: 8px;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.11);
}

.inline-detail {
  border: 1px solid var(--brand);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: #fff;
  padding: 12px;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.lead-status-badge {
  min-height: 28px;
  padding: 0 12px;
  font-size: 13px;
  line-height: 1;
}

.badge.uncontacted {
  background: var(--soft-blue);
  color: #1d4ed8;
}

.badge.unreachable {
  background: #fff7ed;
  color: var(--warn);
}

.badge.following {
  background: var(--soft-green);
  color: var(--ok);
}

.badge.won {
  background: #e8fff3;
  color: #047857;
}

.badge.invalid,
.badge.defeated {
  background: #f3f4f6;
  color: #4b5563;
}

.badge.overdue {
  background: #fed7aa;
  color: #9a3412;
}

.danger-text {
  color: #c2410c;
  font-weight: 800;
}

.due-text {
  color: #1d4ed8;
  font-weight: 800;
}

.detail-empty,
.empty-state {
  border: 1px dashed #c8d1dc;
  border-radius: 8px;
  color: var(--muted);
  padding: 26px;
  text-align: center;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.kv {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  min-width: 0;
}

.kv span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.kv strong {
  overflow-wrap: anywhere;
}

.source-link {
  color: var(--brand-strong);
  font-weight: 800;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.source-link:hover {
  text-decoration: underline;
}

.editable-kv {
  display: grid;
  gap: 5px;
}

.editable-input {
  width: 100%;
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  font-weight: 750;
  padding: 4px 6px;
  outline: none;
}

.editable-input:hover {
  border-color: #cbd5e1;
  background: #fff;
}

.editable-input:focus,
.editable-input.editing {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

textarea.editable-input {
  min-height: 54px;
  resize: vertical;
  font-weight: 650;
}

.compact-textarea textarea.editable-input {
  height: 58px;
  min-height: 58px;
  max-height: 58px;
  overflow-y: auto;
  resize: none;
}

.save-state {
  min-height: 18px;
  color: var(--ok);
  font-size: 12px;
  margin: 2px 0 8px;
}

.save-state.error-state {
  color: #b91c1c;
}

.section-title {
  font-size: 15px;
  margin: 14px 0 10px;
}

.timeline {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.timeline-item {
  border-left: 3px solid #c7d2fe;
  padding: 4px 0 6px 12px;
}

.follow-time-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 6px 0;
}

.follow-time-row span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
}

.follow-time-row span + span {
  background: #fff7ed;
  color: #c2410c;
}

.timeline-item p {
  margin-top: 6px;
  white-space: pre-wrap;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.48);
}

.modal {
  width: min(920px, 100%);
  max-height: min(92vh, 820px);
  overflow: auto;
}

.follow-modal {
  width: min(760px, 100%);
}

.follow-panel {
  box-shadow: var(--shadow);
}

.follow-panel .panel-head h3 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.text-modal {
  width: min(680px, 100%);
}

.admin-modal {
  width: min(1180px, 100%);
}

.text-panel {
  box-shadow: var(--shadow);
}

.admin-panel {
  box-shadow: var(--shadow);
}

.admin-body {
  display: grid;
  gap: 18px;
}

.admin-section {
  display: grid;
  gap: 10px;
}

.admin-create-user {
  align-items: end;
}

.admin-table-wrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
  background: #fff;
}

.admin-table th,
.admin-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

.admin-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #475569;
  font-weight: 800;
}

.admin-table input,
.admin-table select {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
}

.admin-table .ghost-btn,
.admin-table .delete-lead-btn {
  min-height: 30px;
  margin: 2px 3px 2px 0;
}

.admin-active-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.admin-active-toggle input {
  width: 16px;
  min-height: 16px;
}

.admin-search-row {
  margin-bottom: 0;
}

.full-text-form {
  display: grid;
  gap: 10px;
}

.full-text-content {
  width: 100%;
  min-height: 120px;
  max-height: 62vh;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  line-height: 1.7;
  resize: vertical;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.create-panel {
  box-shadow: var(--shadow);
}

.create-panel .panel-head {
  padding: 12px 14px;
}

.create-panel .panel-body {
  padding: 14px;
}

.create-panel .form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.create-panel .field {
  gap: 4px;
}

.create-panel .field label {
  font-size: 13px;
}

.create-panel .field input,
.create-panel .field select,
.create-panel .field textarea {
  min-height: 34px;
  padding: 7px 9px;
}

.create-panel .field textarea {
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  resize: none;
  overflow-y: auto;
}

.create-panel .unit-input input {
  min-height: 32px;
}

.create-panel .span-2 {
  grid-column: span 2;
}

.create-panel .actions {
  align-items: end;
  justify-content: flex-end;
  margin-top: 0;
}

.create-panel .primary-btn {
  min-width: 128px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.icon-btn:hover {
  color: var(--ink);
  background: #f9fafb;
}

@media (max-width: 1580px) {
  .lead-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  .lead-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    flex-direction: row;
    align-items: center;
  }

  .module-tabs {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    flex: 1;
  }

  .user-box {
    margin-top: 0;
  }

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

@media (max-width: 760px) {
  .main {
    padding: 12px;
  }

  .sidebar,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .sidebar {
    position: static;
    padding: 14px;
    gap: 12px;
  }

  .sidebar .brand-row {
    margin-bottom: 0;
  }

  .user-box {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .topbar {
    margin-bottom: 12px;
  }

  .welcome-banner {
    margin: 0 0 12px;
    font-size: 14px;
  }

  .topbar h2 {
    font-size: 21px;
  }

  .topbar .primary-btn {
    width: 100%;
  }

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

  .stat {
    padding: 12px;
  }

  .stat strong {
    font-size: 22px;
  }

  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .panel-body {
    padding: 14px;
  }

  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .filters::-webkit-scrollbar {
    display: none;
  }

  .chip {
    flex: 0 0 auto;
  }

  .search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .date-filter {
    grid-column: 1 / -1;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .lead-list {
    grid-template-columns: 1fr;
    min-width: 0;
    max-height: none;
    overflow: visible;
  }

  .lead-item {
    padding: 12px;
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "summary"
      "notes";
    min-width: 0;
    align-items: start;
    gap: 7px;
    border-top: 1px solid var(--line);
    border-left-width: 1px;
    border-radius: 8px;
  }

  .lead-summary-grid {
    display: contents;
  }

  .lead-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 18px;
  }

  .compact-field.wide-field {
    grid-column: span 2;
  }

  .compact-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    min-height: 0;
    padding: 0;
    border-right: 0;
  }

  .compact-field > span {
    display: block;
  }

  .compact-input {
    min-height: 24px;
    width: 100% !important;
    padding: 2px 4px;
  }

  .lead-card-head {
    grid-area: title;
  }

  .lead-card-grid {
    grid-area: summary;
  }

  .lead-title-actions {
    grid-area: notes;
  }

  .lead-title {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .lead-primary,
  .lead-title-actions {
    min-height: 0;
    padding: 0;
    border-right: 0;
  }

  .lead-primary {
    display: grid;
  }

  .lead-primary span {
    display: inline;
  }

  .lead-source-link,
  .lead-primary strong {
    font-size: 18px;
    line-height: 1.2;
  }

  .lead-title-actions {
    justify-content: flex-start;
  }

  .inline-detail {
    padding: 10px;
  }

  .modal-backdrop {
    align-items: start;
    padding: 10px;
  }

  .modal {
    max-height: calc(100vh - 20px);
    width: 100%;
  }

  .modal .panel-head {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #fff;
  }

  .create-panel .form-grid {
    grid-template-columns: 1fr;
  }

  .create-panel .span-2 {
    grid-column: auto;
  }

  .actions {
    justify-content: stretch;
  }

  .actions .primary-btn {
    width: 100%;
  }

  .span-2 {
    grid-column: auto;
  }
}

@media (max-width: 420px) {
  .search-row {
    grid-template-columns: 1fr;
  }
}
