:root {
  --brand-yellow: #fbc100;
  --brand-blue: #002473;
  --brand-gray: #464646;
  --brand-orange: #ff8800;
  --sidebar-ink: #142235;
  --sidebar-accent: var(--brand-yellow);
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --surface-3: #edf2f8;
  --ink: #061438;
  --muted: #5f6674;
  --line: #d8deea;
  --line-strong: #bdc6d8;
  --green: var(--brand-blue);
  --green-2: #eef2ff;
  --yellow: var(--brand-yellow);
  --yellow-2: #fff7d7;
  --red: #bd3f35;
  --red-2: #fdebea;
  --blue: var(--brand-blue);
  --blue-2: #eef2ff;
  --active-accent: #7db7ff;
  --shadow: 0 14px 34px rgba(15, 35, 70, 0.06);
  --radius: 8px;
  font-family: "Nirmala UI", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

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

button {
  border: 0;
  cursor: pointer;
}

.svg {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.svg svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px 1fr;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 72px 1fr;
}

.sidebar {
  position: relative;
  background: var(--sidebar-ink);
  color: #f5f7f4;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar-toggle {
  position: absolute;
  top: 12px;
  right: 10px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #dce6f4;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px 12px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #ffffff;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 auto;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 18px rgba(0, 0, 0, 0.12);
}

.brand-mark img {
  display: block;
  width: 88%;
  height: 88%;
  object-fit: contain;
}

.brand strong {
  display: block;
  font-size: 17px;
  white-space: nowrap;
}

.brand span {
  display: block;
  color: #dbe4ff;
  font-size: 12px;
  margin-top: 2px;
}

.app-shell.sidebar-collapsed .sidebar {
  align-items: center;
  padding: 52px 10px 16px;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

.app-shell.sidebar-collapsed .brand {
  padding: 0;
}

.app-shell.sidebar-collapsed .brand-copy,
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .sidebar-section,
.app-shell.sidebar-collapsed .sidebar-footer {
  display: none;
}

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

.nav button,
.colleague-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #dce6f4;
  background: transparent;
  min-height: 40px;
  padding: 9px 10px;
  border-radius: 8px;
  text-align: left;
  border: 1px solid transparent;
}

.app-shell.sidebar-collapsed .nav button {
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
}

.nav button.active,
.colleague-button.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 3px 0 0 var(--active-accent);
  color: #fff;
}

.nav button:hover,
.colleague-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar .tag {
  background: rgba(255, 255, 255, 0.92);
  color: var(--brand-blue);
  border-color: rgba(255, 255, 255, 0.3);
}

.sidebar-section {
  border-top: 1px solid rgba(255, 255, 255, 0.11);
  padding-top: 14px;
}

.sidebar-label {
  color: #95a5b5;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 8px 8px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #dbe2ea;
  line-height: 1.35;
}

.sidebar-footer small {
  display: block;
  color: #aeb9c5;
  margin-top: 5px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 62px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 4;
}

.search {
  flex: 1;
  max-width: 520px;
  position: relative;
}

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

.search input {
  padding-right: 40px;
}

.search-clear {
  position: absolute;
  right: 7px;
  top: 50%;
  width: 28px;
  height: 28px;
  transform: translateY(-50%);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.search-clear:hover,
.search-clear:focus-visible {
  background: var(--green-2);
  color: var(--brand-blue);
}

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

.search input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0, 36, 115, 0.12);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--brand-blue);
  color: #fff;
  font-weight: 800;
}

.btn.secondary {
  background: var(--surface);
  color: var(--brand-blue);
  border: 1px solid var(--line);
}

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

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

.btn.icon {
  width: 38px;
  padding: 0;
}

.btn.action-btn {
  min-height: 34px;
  padding: 7px 9px;
  gap: 6px;
  white-space: nowrap;
}

.btn.action-btn .svg,
.btn.action-btn .svg svg {
  width: 16px;
  height: 16px;
}

.content {
  padding: 28px 26px 34px;
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.page-title h1 {
  font-size: 30px;
  line-height: 1.1;
  margin: 0 0 8px;
  letter-spacing: 0;
}

.page-title p {
  color: var(--muted);
  margin: 0;
}

.page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.segmented button {
  min-height: 38px;
  padding: 8px 11px;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  border-right: 1px solid var(--line);
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--brand-blue);
  color: #fff;
}

.calendar-jump {
  display: inline-flex;
  gap: 6px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.work-pulse {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.pulse-card {
  display: grid;
  align-content: start;
  min-height: 96px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.pulse-card:hover,
.pulse-card:focus-visible {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 1px rgba(0, 36, 115, 0.16);
}

.pulse-card.attention {
  border-color: rgba(189, 63, 53, 0.22);
  background: linear-gradient(135deg, #fff, #fff7f6);
}

.pulse-card span,
.pulse-card small {
  color: var(--muted);
  font-size: 12px;
}

.pulse-card strong {
  margin: 4px 0;
  font-size: 26px;
  line-height: 1;
}

.pulse-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric-button {
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.metric-button.active {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 1px var(--brand-blue);
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 23px;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--brand-blue);
  font: inherit;
  font-weight: 700;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}

.workspace.no-detail-panel {
  grid-template-columns: minmax(0, 1fr);
}

.workspace > .panel,
.workspace > .detail-panel {
  min-width: 0;
}

.geoportal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.geoportal-card {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.geoportal-state {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.geoportal-card h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

.geoportal-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.geoportal-card .btn {
  align-self: flex-start;
}

.settings-layout {
  max-width: 920px;
}

.kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(210px, 1fr);
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 10px;
}

.stage {
  min-height: 510px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.stage.drag-over {
  outline: 2px solid var(--green);
  background: var(--green-2);
}

.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}

.stage-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 13px;
}

.stage-help {
  position: relative;
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #c7d2f0;
  border-radius: 999px;
  background: #fff;
  color: var(--brand-blue);
  font-size: 11px;
  line-height: 1;
  cursor: help;
}

.stage-help::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  z-index: 20;
  width: max-content;
  max-width: 230px;
  transform: translateX(-50%);
  padding: 8px 9px;
  border-radius: 8px;
  background: #102033;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  white-space: normal;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.stage-help::before {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(100% + 3px);
  z-index: 21;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: #102033;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.stage-help:hover::after,
.stage-help:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(2px);
}

.stage-help:hover::before,
.stage-help:focus-visible::before {
  opacity: 1;
}

.count {
  min-width: 24px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 12px;
}

.lead-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 0 rgba(16, 32, 51, 0.03);
}

.lead-card.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0, 36, 115, 0.12);
}

.lead-card:active {
  cursor: grabbing;
}

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

.lead-name {
  font-weight: 800;
  margin-bottom: 3px;
}

.lead-address {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.lead-meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.lead-actions {
  margin-top: 10px;
}

.lead-open {
  width: 100%;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 8px;
  border: 1px solid #c7d2f0;
  background: var(--green-2);
  color: var(--brand-blue);
  font-weight: 800;
  font-size: 12px;
}

.lead-open:hover,
.lead-open:focus-visible {
  border-color: var(--brand-blue);
  background: #fff;
}

.lead-open .svg,
.lead-open .svg svg {
  width: 15px;
  height: 15px;
}

.tag {
  border-radius: 7px;
  padding: 4px 7px;
  font-size: 11px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}

.tag.green {
  background: var(--green-2);
  color: var(--green);
  border-color: #c7d2f0;
}

.tag.yellow {
  background: var(--yellow-2);
  color: var(--brand-gray);
  border-color: #f1d36a;
}

.tag.red {
  background: var(--red-2);
  color: var(--red);
  border-color: #f0c4c1;
}

.tag.blue {
  background: #eaf0ff;
  color: var(--brand-blue);
  border-color: #c7d2f0;
}

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

.detail-panel {
  position: sticky;
  top: 82px;
  overflow: hidden;
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-child {
  border-bottom: 0;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.status-grid div {
  display: grid;
  gap: 4px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-title h2,
.panel-title h3 {
  margin: 0;
  font-size: 15px;
}

.detail-panel > .panel-section:first-child .panel-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.detail-panel > .panel-section:first-child .panel-title h2 {
  overflow-wrap: anywhere;
}

.detail-panel > .panel-section:first-child .row-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px;
  width: 100%;
}

.detail-panel > .panel-section:first-child .row-actions .btn {
  min-width: 0;
}

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

.stage-preferences {
  display: grid;
  gap: 12px;
}

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

.accent-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.accent-option {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-weight: 700;
  cursor: pointer;
}

.accent-option.active {
  border-color: var(--brand-blue);
  background: var(--green-2);
  box-shadow: 0 0 0 1px rgba(0, 36, 115, 0.12);
}

.accent-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.accent-swatch {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line-strong);
  flex: 0 0 auto;
}

.setting-subsection {
  display: grid;
  gap: 8px;
  padding-top: 4px;
}

.setting-subsection h3,
.setting-subsection p {
  margin: 0;
}

.check-option {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-weight: 700;
}

.check-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-blue);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.kv {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 7px 9px;
  font-size: 13px;
}

.kv span:nth-child(odd) {
  color: var(--muted);
}

.call-steps {
  display: grid;
  gap: 7px;
}

.step {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.step strong {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--yellow-2);
  color: var(--brand-blue);
}

.step span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 9px;
  align-items: start;
}

.timeline-marker {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--brand-blue);
  box-shadow: 0 0 0 4px var(--green-2);
}

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

.timeline-item p {
  margin: 5px 0 0;
  color: var(--ink);
}

.customer-page {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(380px, 1.1fr);
  gap: 14px;
  align-items: start;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 10px;
}

.profile-grid div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.profile-grid span {
  color: var(--muted);
  font-size: 12px;
}

.profile-grid strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.call-record {
  display: grid;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.call-record p {
  margin: 0;
  color: var(--ink);
  white-space: pre-wrap;
}

.commission-table td,
.commission-table th {
  text-align: right;
}

.commission-table td:first-child,
.commission-table th:first-child {
  text-align: left;
}

.map-preview {
  height: 176px;
  background:
    linear-gradient(135deg, rgba(0, 36, 115, 0.07), transparent 44%),
    linear-gradient(315deg, rgba(47, 111, 159, 0.08), transparent 42%),
    linear-gradient(90deg, rgba(16, 32, 51, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(16, 32, 51, 0.06) 1px, transparent 1px),
    #e9efe9;
  background-size: 100% 100%, 100% 100%, 34px 34px, 34px 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.map-preview.large {
  height: 520px;
}

.customer-profile .map-preview.large {
  height: 320px;
}

.map-canvas,
.map-fallback {
  position: absolute;
  inset: 0;
}

.map-canvas {
  z-index: 0;
}

.map-fallback {
  z-index: 1;
}

.map-preview.has-real-map {
  background: #dce4df;
}

.map-preview.has-real-map .map-fallback {
  display: none;
}

.map-preview .leaflet-container {
  font: inherit;
}

.map-preview .leaflet-control-layers,
.map-preview .leaflet-control-attribution {
  font-size: 11px;
}

.map-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.map-lines path {
  fill: none;
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 1.2;
  stroke-linecap: round;
  filter: drop-shadow(0 0 1px rgba(16, 32, 51, 0.18));
}

.map-region {
  position: absolute;
  color: rgba(16, 32, 51, 0.32);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}

.map-region.north {
  top: 12px;
  left: 14px;
}

.map-region.south {
  right: 14px;
  bottom: 12px;
}

.pin {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -18px 0 0 -9px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--green);
  box-shadow: 0 0 0 3px #fff, 0 6px 16px rgba(16, 32, 51, 0.18);
  border: 0;
  z-index: 1;
}

.pin:hover,
.pin:focus-visible {
  z-index: 3;
  outline: none;
  box-shadow: 0 0 0 4px #fff, 0 0 0 7px rgba(0, 36, 115, 0.22), 0 8px 18px rgba(16, 32, 51, 0.22);
}

.pin.active {
  background: var(--yellow);
  z-index: 4;
}

.pin::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  left: 5px;
  top: 5px;
}

.pin span {
  position: absolute;
  left: 14px;
  top: -18px;
  transform: rotate(45deg);
  display: none;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(16, 32, 51, 0.1);
}

.map-preview.large .pin.active span,
.map-preview.large .pin:hover span,
.map-preview.large .pin:focus-visible span {
  display: block;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(var(--calendar-columns, 7), minmax(120px, 1fr));
  gap: 8px;
}

.calendar-grid[data-calendar-mode-current="5"] {
  --calendar-columns: 5;
}

.calendar-grid.month {
  --calendar-columns: 7;
}

.day {
  min-height: 150px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.calendar-grid.month .day {
  min-height: 118px;
}

.day.outside-month {
  background: #f8f9fc;
  color: var(--muted);
}

.day.drag-over {
  outline: 2px solid var(--green);
  background: var(--green-2);
}

.day strong {
  display: block;
  margin-bottom: 8px;
}

.event {
  background: var(--green-2);
  border: 1px solid #c7d2f0;
  color: var(--brand-blue);
  border-radius: 8px;
  padding: 7px;
  font-size: 12px;
  margin-bottom: 6px;
  overflow: hidden;
}

.event.lost {
  background: #f1f3f6;
  border-color: #d1d7e0;
  color: #4f5f73;
}

.event[draggable="true"] {
  cursor: grab;
}

.event-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 8px;
}

.event-top > div:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.event-actions {
  display: grid;
  grid-template-columns: repeat(2, 20px);
  gap: 3px;
  justify-content: end;
}

.event-action {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--brand-blue);
  border: 1px solid rgba(0, 36, 115, 0.16);
}

.event.lost .event-action {
  color: #526174;
  border-color: #c8d0da;
}

.event-action.danger {
  color: var(--red);
}

.event-action .svg,
.event-action .svg svg {
  width: 12px;
  height: 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

.table-scroll .table {
  min-width: 720px;
}

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

.table th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table tr.active-row td {
  background: var(--yellow-2);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.workspace .row-actions {
  flex-wrap: nowrap;
}

.workspace .btn.action-btn {
  width: 34px;
  min-width: 34px;
  padding: 0;
}

.workspace .btn.action-btn .action-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

.customer-visual {
  display: grid;
  grid-template-columns: 152px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.customer-image-frame {
  width: 152px;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.customer-image-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.customer-image-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--brand-blue);
  background: var(--green-2);
  font-size: 30px;
  font-weight: 900;
}

.customer-visual p {
  margin: 4px 0 10px;
  color: var(--muted);
  line-height: 1.4;
}

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

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

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

.customer-tools,
.map-tools {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

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

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  padding: 0 14px 14px;
}

.table-wrap .table {
  min-width: 760px;
}

.due-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-bottom: 4px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.due-badge.overdue {
  border-color: rgba(189, 63, 53, 0.28);
  background: var(--red-2);
  color: var(--red);
}

.due-badge.today {
  border-color: rgba(0, 36, 115, 0.22);
  background: var(--green-2);
  color: var(--brand-blue);
}

.due-badge.week {
  border-color: rgba(251, 193, 0, 0.45);
  background: var(--yellow-2);
  color: #765600;
}

.priority-tag {
  text-transform: lowercase;
}

.map-tools {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.customer-tools .field,
.map-tools .field {
  min-width: 0;
}

.customer-export-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--line);
}

.select-cell {
  width: 38px;
  text-align: center;
}

.select-cell input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.source-options {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  display: none;
  max-height: 210px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.source-combo.open .source-options {
  display: grid;
  gap: 3px;
}

.source-options button {
  width: 100%;
  min-height: 32px;
  padding: 7px 9px;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.source-options button:hover,
.source-options button:focus-visible {
  background: var(--green-2);
  color: var(--brand-blue);
}

.customer-tools .btn,
.map-tools .btn {
  white-space: nowrap;
}

.lead-import {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
  padding: 12px;
  display: grid;
  gap: 10px;
}

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

.lead-import-head div {
  display: grid;
  gap: 3px;
}

.lead-import-head span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.lead-import .file-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 11px;
}

.lead-import-status {
  min-height: 18px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

.duplicate-warning {
  border: 1px solid #f0c36a;
  border-radius: 8px;
  background: #fff8e5;
  color: #6f4d00;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.35;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 24, 36, 0.36);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 20;
}

.modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 26px 80px rgba(13, 24, 36, 0.25);
  border: 1px solid var(--line);
}

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

.modal-foot {
  border-bottom: 0;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.modal-body {
  padding: 16px;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
}

.login-art {
  background:
    linear-gradient(135deg, rgba(0, 36, 115, 0.96), rgba(0, 36, 115, 0.82)),
    radial-gradient(circle at 80% 12%, rgba(251, 193, 0, 0.8), transparent 26%),
    var(--brand-blue);
  color: #fff;
  padding: 54px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-art h1 {
  max-width: 560px;
  font-size: 42px;
  line-height: 1.05;
  margin: 18px 0 12px;
  letter-spacing: 0;
}

.login-art p {
  max-width: 540px;
  color: #e7ecff;
  font-size: 16px;
  line-height: 1.55;
}

.login-card {
  display: grid;
  place-items: center;
  padding: 32px;
}

.login-card .panel {
  width: min(430px, 100%);
  padding: 22px;
}

.login-card h2 {
  margin: 0 0 6px;
  font-size: 24px;
}

.login-card p {
  color: var(--muted);
  margin: 0 0 18px;
}

.empty {
  border: 1px dashed var(--line-strong);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--brand-blue);
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 40;
}

.offer-calculator {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
  align-items: start;
  gap: 18px;
}

.offer-inputs {
  display: grid;
  gap: 16px;
  min-width: 0;
  overflow: hidden;
}

.offer-calculator .panel {
  min-width: 0;
  padding: 20px;
}

.internal-note {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #ffd7a3;
  border-radius: 8px;
  background: #fff8ed;
  color: #6d3300;
}

.internal-note a {
  color: var(--brand-blue);
  font-weight: 800;
}

.internal-note span {
  color: var(--muted);
}

.offer-results-panel {
  display: grid;
  gap: 16px;
  min-width: 0;
  position: sticky;
  top: 76px;
}

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

.offer-save-box {
  display: grid;
  gap: 12px;
}

.offer-save-box .field {
  min-width: 0;
}

.lead-search-combo {
  position: relative;
  z-index: 4;
}

.lead-search-options {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  display: none;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  z-index: 50;
}

.lead-search-combo:focus-within .lead-search-options {
  display: grid;
}

.lead-search-options button {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.lead-search-options button:hover {
  background: var(--surface-2);
}

.lead-search-empty {
  padding: 11px;
  color: var(--muted);
}

.offer-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.offer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  column-gap: 18px;
  row-gap: 18px;
}

.offer-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.offer-calculator .panel-title {
  margin-bottom: 18px;
}

.offer-calculator .field {
  gap: 8px;
}

.offer-calculator .table-wrap {
  padding: 0;
}

.offer-mounting-table input,
.offer-mounting-table select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.offer-mounting-table th:first-child,
.offer-mounting-table td:first-child {
  width: 90px;
}

.offer-mounting-table th:nth-child(2),
.offer-mounting-table td:nth-child(2) {
  width: 92px;
  min-width: 92px;
  max-width: 92px;
}

.offer-mounting-table th:nth-child(3),
.offer-mounting-table td:nth-child(3) {
  width: 170px;
  min-width: 170px;
  max-width: 170px;
}

.offer-mounting-table th:nth-child(4),
.offer-mounting-table td:nth-child(4) {
  min-width: 260px;
}

.offer-mounting-table .offer-module-input {
  max-width: 68px;
  text-align: right;
}

.offer-result-list {
  display: grid;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
}

.offer-result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.offer-result-row:last-child {
  border-bottom: 0;
}

.offer-result-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.offer-result-row > strong {
  white-space: nowrap;
  text-align: right;
}

.offer-result-row.total {
  border-top: 1px solid var(--line-strong);
  background: var(--surface-2);
}

.wr-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 13px;
}

.wr-status.ok {
  color: #12683a;
  background: #e8f7ef;
  border: 1px solid #b9e5cc;
}

.wr-status.warn,
.wr-status.missing {
  color: #8a3300;
  background: #fff4e5;
  border: 1px solid #ffd7a3;
}

.offer-wr-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface-2);
}

.offer-wr-card small {
  color: var(--muted);
  line-height: 1.35;
}

.offer-wr-card.ok {
  border-color: #b9e5cc;
  background: #f2fbf6;
}

.offer-wr-card.warn,
.offer-wr-card.missing {
  border-color: #ffd7a3;
  background: #fff8ed;
}

.inverter-catalog .table td {
  vertical-align: top;
}

.inverter-catalog .table td span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.inverter-tools {
  align-items: end;
  margin-bottom: 14px;
}

.inverter-tools .field {
  min-width: min(420px, 100%);
}

.table-sort {
  display: inline-flex;
  align-items: center;
  width: 100%;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
}

.table-sort:hover,
.table-sort:focus-visible {
  color: var(--blue);
  outline: none;
}

.btn.small {
  min-height: 30px;
  padding: 6px 10px;
}

.site-survey-page {
  padding: 10px 12px 0;
}

.site-survey-page .page-head {
  margin-bottom: 22px;
}

.site-survey-tools {
  display: grid;
  grid-template-columns: minmax(260px, 1.2fr) minmax(220px, 0.9fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 18px;
}

.site-survey-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
  padding: 16px;
}

.site-survey-preview > div {
  display: grid;
  gap: 4px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.site-survey-preview strong {
  font-size: 18px;
}

.site-survey-preview span:last-child {
  color: var(--muted);
}

.site-survey-info h2 {
  margin-bottom: 12px;
}

.site-survey-info {
  padding: 18px;
}

.site-survey-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.site-survey-chip-grid span {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-weight: 700;
}

.email-template-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.15fr);
  gap: 16px;
  align-items: start;
}

.email-template-list {
  display: grid;
  gap: 10px;
}

.email-template-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.email-template-card p {
  margin: 6px 0;
  color: var(--muted);
  line-height: 1.45;
  white-space: pre-wrap;
  max-height: 86px;
  overflow: hidden;
}

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

  .customer-tools,
  .map-tools,
  .filters {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .detail-panel {
    position: static;
  }

  .customer-page {
    grid-template-columns: 1fr;
  }

  .table th:last-child,
  .table td:last-child {
    width: 86px;
  }

  .offer-mounting-table th:last-child,
  .offer-mounting-table td:last-child {
    width: auto;
    min-width: 230px;
  }

  .row-actions {
    flex-wrap: nowrap;
  }

  .btn.action-btn {
    width: 34px;
    min-width: 34px;
    padding: 0;
  }

  .btn.action-btn .action-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

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

  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .metrics,
  .work-pulse,
  .offer-calculator,
  .email-template-layout,
  .customer-tools,
  .map-tools,
  .filters,
  .profile-grid,
  .form-grid,
  .offer-grid,
  .offer-summary,
  .login-screen {
    grid-template-columns: 1fr;
  }

  .offer-results-panel {
    position: static;
  }

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

  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 12px;
  }

  .search {
    order: 2;
    max-width: none;
    width: 100%;
  }
}
