:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-soft: rgba(10, 18, 32, 0.72);
  --panel: rgba(13, 22, 41, 0.82);
  --panel-border: rgba(255, 255, 255, 0.09);
  --text: #eef2ff;
  --muted: #9aa7bd;
  --accent: #ff8a3d;
  --accent-2: #33d6a6;
  --danger: #ff5f7a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(255, 138, 61, 0.15), transparent 28%),
    radial-gradient(circle at 80% 20%, rgba(51, 214, 166, 0.12), transparent 30%),
    linear-gradient(180deg, #050b15 0%, #07111f 100%);
  color: var(--text);
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

body.dialog-open { overflow: hidden; }

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(40px);
  opacity: 0.7;
  pointer-events: none;
}

.bg-orb-a {
  width: 320px;
  height: 320px;
  background: rgba(255, 138, 61, 0.18);
  top: -120px;
  right: -100px;
}

.bg-orb-b {
  width: 260px;
  height: 260px;
  background: rgba(51, 214, 166, 0.12);
  left: -80px;
  bottom: 4%;
}

.shell {
  width: min(1400px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 20px;
  align-items: start;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
}

h1 {
  margin: 0;
  font-size: clamp(2.3rem, 4vw, 4.7rem);
  line-height: 0.95;
}

#currentDateHeading {
  font-size: clamp(1.9rem, 3.1vw, 3.7rem);
}

.subcopy {
  max-width: 60ch;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.hero-actions .ghost-button { margin-top: 0; }

@media (min-width: 1081px) {
  .hero { position: relative; }

  .hero-actions {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 1;
    margin-top: 0;
  }

  /* Leave a clear top row for account controls above the dashboard counters. */
  .stats { margin-top: 46px; }
}

.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(51, 214, 166, 0.3);
  border-radius: 999px;
  background: rgba(51, 214, 166, 0.1);
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 600;
}

.users-panel {
  margin: 18px 0;
  padding: 20px;
}

.users-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.users-panel-head h2 {
  margin: 4px 0 0;
}

.user-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.user-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.user-form input,
.user-form select,
.user-row select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  padding: 0 11px;
  background: #0a1423;
  color: #b3bdce;
  font: inherit;
}

.user-form select,
.user-row select {
  color-scheme: dark;
}

.user-form select option,
.user-row select option {
  background: #0a1423;
  color: #aeb9ca;
}

.user-form select option:checked,
.user-row select option:checked {
  background: #17263a;
  color: #c7d0df;
}

.user-form button {
  min-height: 42px;
}

.user-form-state {
  min-height: 20px;
  margin: 10px 0 0;
}

.users-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
}

.user-row > div:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.user-row span {
  color: var(--muted);
  font-size: 12px;
}

.user-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.user-row-actions select {
  min-width: 150px;
  min-height: 42px;
}

.user-row-actions .ghost-button {
  margin-top: 0;
  min-height: 42px;
}

.user-row.is-disabled {
  opacity: .55;
}

@media (max-width: 760px) {
  .users-panel-head,
  .user-row {
    align-items: stretch;
    flex-direction: column;
  }

  .user-form {
    grid-template-columns: 1fr;
  }

  .user-row-actions,
  .user-row-actions select,
  .user-row-actions button {
    width: 100%;
  }
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.stats .stat-card,
.panel,
.column {
  background: var(--bg-soft);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.stats .stat-card {
  border-radius: var(--radius);
  padding: 18px 20px;
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.stats .stat-card:hover,
.stats .stat-card:focus-visible {
  border-color: rgba(255, 138, 61, 0.7);
  background: rgba(20, 32, 56, 0.9);
  outline: none;
  transform: translateY(-2px);
}

.stats span {
  display: block;
  font-size: 2rem;
  font-weight: 700;
}

.stats small {
  color: var(--muted);
}

.panel {
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 18px;
}

.lead-create-action {
  display: flex;
  justify-content: flex-end;
  margin: -4px 0 18px;
}

.create-lead-button,
.lead-form button {
  min-height: 52px;
  border-radius: 14px;
  border: 0;
  padding: 0 20px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #ffb56b);
  color: #180f07;
}

.create-lead-button { min-width: 190px; }

.lead-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.lead-form-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.lead-form-field-wide,
.lead-create-error,
.lead-form-actions { grid-column: 1 / -1; }

.lead-form input,
.lead-form select {
  width: 100%;
  min-width: 0;
  min-height: 50px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
}

.lead-form select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 44px;
  background-image: linear-gradient(45deg, transparent 50%, #eef2ff 50%),
    linear-gradient(135deg, #eef2ff 50%, transparent 50%);
  background-position: calc(100% - 20px) 22px, calc(100% - 14px) 22px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.lead-form select option {
  background: #0d1626;
  color: #eef2ff;
}

.lead-form select option[value=""] {
  color: var(--muted);
}

.lead-form select:focus {
  outline: none;
  border-color: rgba(255, 138, 61, 0.65);
  box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.16);
}

.lead-form input:focus { outline: none; border-color: rgba(255, 138, 61, 0.65); box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.16); }
.lead-form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.lead-form .secondary-button { border: 1px solid var(--panel-border); background: transparent; color: var(--text); }
.lead-form button:disabled { opacity: .6; cursor: wait; }

.client-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.client-filter {
  min-height: 54px;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: rgba(13, 22, 41, 0.82);
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.client-filter span {
  display: inline-flex;
  min-width: 24px;
  min-height: 24px;
  margin-left: 6px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.client-filter:hover,
.client-filter.active {
  border-color: rgba(255, 138, 61, 0.7);
  background: linear-gradient(135deg, rgba(255, 138, 61, 0.2), rgba(255, 181, 107, 0.08));
  color: var(--text);
}

.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.column {
  border-radius: 24px;
  padding: 16px;
  min-height: 68vh;
}

.column-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.column h2 {
  margin: 0;
  font-size: 1rem;
}

.pill,
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 12px;
}

.pill {
  min-width: 34px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.dropzone {
  display: grid;
  gap: 12px;
  min-height: 50vh;
}

.column.dragover {
  outline: 2px dashed rgba(255, 138, 61, 0.72);
  outline-offset: -6px;
  box-shadow: inset 0 0 0 999px rgba(255, 138, 61, 0.06), var(--shadow);
}

.card {
  border-radius: 18px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: grab;
  min-width: 0;
  overflow: hidden;
}

.card:active {
  cursor: grabbing;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.tag {
  padding: 5px 10px;
  background: rgba(255, 138, 61, 0.14);
  color: #ffbd87;
}

.dialog-status-button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(255, 138, 61, 0.3);
  font: inherit;
  line-height: 1;
  white-space: nowrap;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.dialog-status-button::after {
  content: '';
  width: 5px;
  height: 5px;
  margin: -3px 0 0 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
}

.dialog-status-button:hover,
.dialog-status-button:focus-visible {
  border-color: rgba(255, 138, 61, 0.72);
  background: rgba(255, 138, 61, 0.23);
  outline: none;
}

.channel-badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 4px 8px;
  border: 1px solid rgba(126, 190, 255, .24);
  border-radius: 999px;
  background: rgba(67, 148, 224, .12);
  color: #a9d8ff;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

.card-top .channel-badge { margin-left: auto; }

.card-top time {
  min-width: 0;
  max-width: 100%;
  flex: 1 1 170px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-align: right;
}

.card h3 {
  margin: 10px 0 8px;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.meta,
.contact {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* Desktop keeps customer data on one line, with a clear gap before VIN. */
.dialog-meta-customer { margin-right: .55em; }

.secondary {
  color: #b8c2d4;
}

.contact {
  color: #d9e4f5;
}

.ghost-button {
  margin-top: 18px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 9px 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.calendar-panel { padding: 0; overflow: hidden; }
.calendar-summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px; cursor: pointer; list-style: none; }
.calendar-summary::-webkit-details-marker { display: none; }
.calendar-summary::after { content: '＋'; color: var(--accent); font-size: 20px; line-height: 1; }
.calendar-panel[open] .calendar-summary { border-bottom: 1px solid var(--panel-border); }
.calendar-panel[open] .calendar-summary::after { content: '−'; }
.calendar-summary h2 { margin: 0; font-size: 1.35rem; }
.calendar-toggle { margin-left: auto; color: var(--muted); font-size: 12px; }
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; }
.calendar-toolbar .ghost-button { margin: 12px 0 0; }
.calendar-week-navigation { display: flex; align-items: center; gap: 8px; min-width: 0; margin-top: 12px; }
.calendar-week-navigation strong { overflow: hidden; color: var(--text); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.calendar-week-arrow { display: inline-grid; width: 32px; height: 32px; flex: 0 0 auto; place-items: center; border: 1px solid var(--panel-border); border-radius: 10px; background: rgba(255,255,255,.04); color: var(--text); font-size: 22px; line-height: 1; cursor: pointer; }
.calendar-week-arrow:hover, .calendar-week-arrow:focus-visible { border-color: var(--accent); outline: none; }
.calendar-week { display: flex; gap: 8px; margin: 16px 16px 0; overflow-x: auto; scrollbar-width: none; cursor: grab; touch-action: pan-y; user-select: none; }
.calendar-week::-webkit-scrollbar { display: none; }
.calendar-week.dragging { cursor: grabbing; }
.calendar-day { display: grid; flex: 0 0 88px; min-width: 0; gap: 4px; padding: 10px 6px; border: 1px solid rgba(255,255,255,.08); border-radius: 12px; background: rgba(255,255,255,.035); color: var(--muted); text-align: center; cursor: pointer; }
.calendar-day:hover, .calendar-day:focus-visible { border-color: rgba(255,138,61,.65); outline: none; }
.calendar-day.has-events { border-color: rgba(51,214,166,.55); background: rgba(51,214,166,.1); }
.calendar-day.has-events small { color: var(--accent-2); font-weight: 700; }
.calendar-day.active { border-color: var(--accent); background: rgba(255,138,61,.12); color: var(--text); }
.calendar-day.active.has-events { border-color: var(--accent); background: linear-gradient(180deg, rgba(255,138,61,.2), rgba(51,214,166,.1)); }
.calendar-day-name { overflow: hidden; font-size: 11px; text-overflow: ellipsis; text-transform: capitalize; }
.calendar-day strong { color: var(--text); font-size: 18px; }
.calendar-day strong em { color: var(--muted); font-size: 11px; font-style: normal; font-weight: 500; text-transform: lowercase; }
.calendar-day small { min-height: 15px; color: var(--accent); font-size: 10px; white-space: nowrap; }
.calendar-day-label { margin: 14px 16px 0; color: var(--muted); font-size: 13px; text-transform: capitalize; }
.calendar-list { display: grid; gap: 10px; margin-top: 14px; padding: 0 16px 16px; }
.calendar-event { display: grid; grid-template-columns: minmax(120px, .7fr) minmax(150px, .7fr) 1fr; gap: 14px; align-items: center; padding: 13px 15px; border: 1px solid rgba(255,255,255,.08); border-radius: 14px; background: rgba(255,255,255,.04); cursor: pointer; }
.calendar-event time { color: var(--accent); }
.calendar-event span { color: var(--muted); }

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 7, 16, 0.74);
  overflow: hidden;
  overscroll-behavior: none;
}

.dialog-backdrop[hidden] { display: none; }

.mobile-move-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 20px 14px max(20px, env(safe-area-inset-bottom));
  background: rgba(2, 7, 16, 0.7);
}

.mobile-move-backdrop[hidden] { display: none; }

.mobile-move-sheet {
  position: relative;
  width: min(100%, 460px);
  padding: 20px;
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  background: #0b1525;
  box-shadow: var(--shadow);
}

.mobile-move-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-right: 28px;
}

.mobile-move-heading h2 { margin: 0 0 5px; font-size: 1.35rem; }
.mobile-move-heading .meta { margin-bottom: 0; }
.mobile-move-close { top: 16px; right: 16px; }
.mobile-move-actions { display: grid; gap: 10px; margin-top: 18px; }
.mobile-move-actions button,
.mobile-move-cancel {
  min-height: 48px;
  border: 1px solid rgba(51,214,166,.32);
  border-radius: 13px;
  background: rgba(51,214,166,.1);
  color: #baf8e6;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.mobile-move-actions button.current { border-color: rgba(255,138,61,.34); background: rgba(255,138,61,.1); color: #ffbd87; }
.mobile-move-actions button:disabled { cursor: default; opacity: .68; }
.mobile-move-cancel { width: 100%; margin-top: 10px; border-color: var(--panel-border); background: transparent; color: var(--text); }

.create-lead-backdrop { z-index: 20; }

.lead-list-backdrop { z-index: 15; }

.create-lead-dialog {
  position: relative;
  width: min(640px, calc(100vw - 40px));
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 28px;
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  background: #0b1525;
  box-shadow: var(--shadow);
}

.create-lead-heading { padding-right: 34px; margin-bottom: 24px; }
.create-lead-heading h2 { margin: 0; font-size: clamp(1.5rem, 4vw, 2rem); }
.create-lead-heading p:last-child { margin: 8px 0 0; color: var(--muted); line-height: 1.45; }
.lead-create-error { margin: -4px 0 0; }

.lead-list-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(820px, calc(100vw - 40px));
  max-height: min(760px, calc(100dvh - 40px));
  min-height: 0;
  padding: 28px;
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  background: #0b1525;
  box-shadow: var(--shadow);
}

.lead-list-heading { padding-right: 34px; margin-bottom: 18px; }
.lead-list-heading h2 { margin: 0; font-size: clamp(1.5rem, 4vw, 2rem); }
.lead-list { display: grid; gap: 10px; min-height: 0; overflow-y: auto; padding-right: 4px; }
.lead-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 15px 16px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}
.lead-list-item:hover,
.lead-list-item:focus-visible { border-color: rgba(255, 138, 61, .65); background: rgba(255, 138, 61, .08); outline: none; }
.lead-list-item h3 { margin: 0 0 4px; font-size: 1rem; }
.lead-list-item p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.lead-list-item time { color: var(--muted); font-size: 12px; white-space: nowrap; }

.lead-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1080px, calc(100vw - 48px));
  height: min(800px, calc(100dvh - 40px));
  max-height: calc(100dvh - 40px);
  min-height: 0;
  gap: 12px;
  overflow: hidden;
  padding: 20px;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  background: #0b1525;
  box-shadow: var(--shadow);
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 28px;
  cursor: pointer;
}

.dialog-heading { display: flex; justify-content: space-between; gap: 16px; padding-right: 28px; }
.dialog-heading h2 { margin: 0 0 5px; font-size: clamp(1.2rem, 2vw, 1.55rem); line-height: 1.15; }
.dialog-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.delete-button { border: 1px solid rgba(255, 125, 125, .36); border-radius: 9px; padding: 6px 9px; background: rgba(255, 85, 85, .1); color: #ffb1b1; font: inherit; font-size: 11px; cursor: pointer; }
.delete-button:hover { background: rgba(255, 85, 85, .18); }
.delete-button:disabled { opacity: .55; cursor: wait; }
.dialog-workspace { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(290px, .8fr); grid-template-rows: minmax(0, 1fr) auto; gap: 14px 18px; min-height: 0; flex: 1; overscroll-behavior: contain; }
.message-list { grid-column: 1; grid-row: 1; display: grid; align-content: start; gap: 7px; min-height: 0; overflow-y: auto; padding: 3px 5px 3px 3px; overscroll-behavior: contain; }
.dialog-sidebar { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; overflow-y: auto; padding-right: 3px; }
.dialog-composer { grid-column: 1; grid-row: 2; min-width: 0; }
.message { max-width: 90%; padding: 8px 10px; border: 1px solid rgba(255,255,255,.08); border-radius: 12px; background: rgba(255,255,255,.045); }
.message-manager { justify-self: end; background: rgba(255,138,61,.12); }
.message-client { justify-self: start; background: rgba(51,214,166,.09); }
.message-top { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.message p { margin: 5px 0 2px; white-space: pre-wrap; line-height: 1.35; font-size: 13px; }
.message-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.message-form textarea { width: 100%; min-width: 0; resize: vertical; min-height: 58px; border: 1px solid rgba(255,255,255,.1); border-radius: 12px; padding: 10px 12px; background: rgba(255,255,255,.04); color: var(--text); font: inherit; font-size: 13px; }
.message-form button, .login-form button { border: 0; border-radius: 14px; padding: 0 18px; background: linear-gradient(135deg, var(--accent), #ffb56b); color: #180f07; font: inherit; font-weight: 700; cursor: pointer; }
.form-error { min-height: 1.2em; margin: 0; color: #ff9c9c; }
.form-success { min-height: 1.2em; margin: 0; color: #7de0bf; }
.ai-analysis-box { display: grid; gap: 7px; padding: 10px 12px; border: 1px solid rgba(51,214,166,.16); border-radius: 12px; background: rgba(51,214,166,.05); font-size: 12px; }
.ai-analysis-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ai-analysis-head .ghost-button { margin-top: 0; padding: 6px 8px; font-size: 11px; }
.schedule-form { display: grid; gap: 8px; align-items: end; padding-top: 0; }
.schedule-form label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.schedule-form input { width: 100%; min-width: 0; min-height: 40px; border: 1px solid rgba(255,255,255,.1); border-radius: 10px; padding: 0 10px; background: rgba(255,255,255,.04); color: var(--text); font: inherit; font-size: 13px; }
.schedule-form button { min-height: 40px; border: 0; border-radius: 10px; padding: 0 14px; background: rgba(51,214,166,.18); color: #baf8e6; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.login-shell { display: grid; min-height: 100vh; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); padding: 30px; border: 1px solid var(--panel-border); border-radius: 24px; background: var(--bg-soft); box-shadow: var(--shadow); }
.login-card h1 { font-size: clamp(2rem, 6vw, 3.4rem); }
.login-form { display: grid; gap: 14px; margin-top: 24px; }
.login-form label { display: grid; gap: 8px; color: var(--muted); }
.login-form input { width: 100%; min-width: 0; min-height: 50px; border: 1px solid rgba(255,255,255,.1); border-radius: 14px; padding: 0 14px; background: rgba(255,255,255,.04); color: var(--text); font: inherit; }
.login-form button { min-height: 50px; }

.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  min-height: 140px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 18px;
}

@media (max-width: 1080px) {
  .hero,
  .kanban {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 20px, 1400px);
    padding-top: 16px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stats .stat-card {
    min-height: 64px;
    padding: 10px 13px;
    border-radius: 18px;
  }
  .stats span { font-size: 1.65rem; line-height: 1; }
  .stats small { display: block; margin-top: 3px; font-size: 12px; line-height: 1.15; }

  .client-filters {
    grid-template-columns: 1fr;
  }

  .column {
    min-height: auto;
  }

  .card {
    cursor: pointer;
    touch-action: pan-y;
    -webkit-touch-callout: none;
    padding: 11px;
    border-radius: 16px;
  }

  .dropzone { gap: 9px; }
  .card-top { gap: 6px; }
  .card .tag { padding: 4px 8px; }
  .card .channel-badge { padding: 3px 7px; }
  .card-top time { line-height: 1.25; }
  .card h3 { margin: 7px 0 5px; line-height: 1.22; }
  .card .meta,
  .card .contact { margin-top: 3px; line-height: 1.32; }

  .lead-create-action { justify-content: stretch; }
  .create-lead-button { width: 100%; }
  .create-lead-dialog { width: min(100vw - 20px, 640px); max-height: calc(100dvh - 20px); padding: 22px 18px; }
  .lead-list-dialog { width: min(100vw - 20px, 820px); max-height: calc(100dvh - 20px); padding: 22px 18px; }
  .lead-form { grid-template-columns: 1fr; }
  .lead-form-actions { flex-direction: column-reverse; }
  .lead-form-actions button { width: 100%; }
  .lead-list-item { grid-template-columns: 1fr; gap: 5px; }
  .lead-list-item time { font-size: 11px; }
  .card-top { align-items: flex-start; }
  .card-top .channel-badge { margin-left: 0; }
  .card-top time { flex-basis: 100%; text-align: left; }

  .lead-dialog {
    height: calc(100dvh - 20px);
    max-height: calc(100dvh - 20px);
    padding: 14px;
    gap: 8px;
    border-radius: 18px;
  }

  /* Controls, heading and details take separate rows and never overlap. */
  .dialog-heading {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
      "actions"
      "eyebrow"
      "title"
      "meta";
    row-gap: 3px;
    padding-right: 30px;
  }

  .dialog-heading > :first-child { display: contents; }
  .dialog-heading .eyebrow { grid-area: eyebrow; margin: 0; font-size: 11px; line-height: 1.2; }
  .dialog-heading h2 { grid-area: title; margin: 0; line-height: 1.08; }
  .dialog-heading #dialogMeta { grid-area: meta; margin: 0; }
  .dialog-meta-customer { display: block; margin-right: 0; }
  .dialog-meta-vin { display: block; margin-top: 2px; }
  .dialog-actions {
    grid-area: actions;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 5px;
  }
  .dialog-actions .delete-button { flex-basis: auto; padding: 5px 8px; }
  .dialog-status-button { min-height: 26px; padding: 0 8px; }

  .dialog-workspace { display: flex; flex-direction: column; gap: 7px; overflow-y: auto; overscroll-behavior-y: contain; }
  /* Let a long chat grow naturally; the dialog workspace itself scrolls. */
  .message-list { flex: 0 0 auto; min-height: 0; gap: 5px; overflow: visible; }
  .message { padding: 7px 9px; }
  .message p { margin: 4px 0 0; line-height: 1.3; }
  .dialog-composer { order: 2; flex: 0 0 auto; }
  .dialog-sidebar { order: 3; flex: 0 0 auto; overflow: visible; padding-right: 0; }
  .message-form { grid-template-columns: 1fr; }
  .message-form textarea { min-height: 64px; height: 68px; padding: 9px 10px; }
  .message-form button { min-height: 50px; }
  .calendar-event, .schedule-form { grid-template-columns: 1fr; }
  .calendar-summary { align-items: flex-start; }
  .calendar-toggle { text-align: right; }
  .ai-analysis-head { align-items: start; flex-direction: column; }
}
