:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --panel: #ffffff;
  --line: #d9ded7;
  --line-strong: #b7c0b4;
  --text: #1f261f;
  --muted: #667064;
  --accent: #1f7a5b;
  --accent-dark: #15583f;
  --amber: #b66a14;
  --danger: #b33a32;
  --focus: #2563eb;
  --shadow: 0 10px 30px rgba(35, 43, 35, 0.08);
}

/* Modern CRM shell */
:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --line: #dfe5ec;
  --line-strong: #b9c5d1;
  --text: #17201b;
  --muted: #687481;
  --accent: #0f8a6a;
  --accent-dark: #0a624d;
  --accent-soft: #e7f6f1;
  --amber: #b7791f;
  --danger: #c24135;
  --focus: #2563eb;
  --sidebar: #16231d;
  --sidebar-soft: #20332a;
  --sidebar-text: #eef7f2;
  --surface: #f9fbfd;
  --shadow: 0 18px 45px rgba(23, 32, 27, 0.09);
  --shadow-soft: 0 8px 22px rgba(23, 32, 27, 0.07);
}

body {
  background:
    linear-gradient(180deg, #f7fafc 0%, #eef4f7 100%);
  color: var(--text);
}

button,
input,
select,
textarea {
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

button {
  min-height: 40px;
  border-color: #cbd5df;
  border-radius: 8px;
  background: #ffffff;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(23, 32, 27, 0.03);
}

button:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(15, 138, 106, 0.12);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button.primary,
#shabButton {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 24px rgba(15, 138, 106, 0.2);
}

button.primary:hover,
#shabButton:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

button.danger {
  border-color: #f0c5bf;
  background: #fff7f5;
  color: var(--danger);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "sidebar toolbar"
    "sidebar workspace";
}

.topbar {
  grid-area: sidebar;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 22px;
  padding: 24px 18px;
  overflow: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0)),
    var(--sidebar);
  color: var(--sidebar-text);
  box-shadow: 18px 0 40px rgba(22, 35, 29, 0.16);
}

.brand-block {
  gap: 20px;
}

.topbar h1 {
  font-size: 22px;
  color: #ffffff;
}

.topbar p {
  color: #a9bcb3;
  font-size: 13px;
  line-height: 1.45;
}

.main-tabs {
  display: grid;
  width: 100%;
  gap: 8px;
  border: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
}

.main-tabs button {
  position: relative;
  justify-content: flex-start;
  width: 100%;
  min-height: 44px;
  padding: 0 14px 0 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #c7d6cf;
  text-align: left;
  box-shadow: none;
}

.main-tabs button::before {
  position: absolute;
  left: 14px;
  width: 18px;
  color: #89a39a;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.main-tabs button[data-page="akquise"]::before {
  content: "NG";
}

.main-tabs button[data-page="crm"]::before {
  content: "CRM";
  font-size: 10px;
}

.main-tabs button[data-page="websites"]::before {
  content: "SU";
  font-size: 10px;
}

.main-tabs button:last-child {
  border-right: 1px solid transparent;
}

.main-tabs button:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: var(--sidebar-soft);
  box-shadow: none;
}

.main-tabs button.active {
  border-color: rgba(255, 255, 255, 0.13);
  background: #edf8f3;
  color: #0f3228;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}

.main-tabs button.active::before {
  color: var(--accent-dark);
}

.metrics {
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.metric {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: #f5fbf8;
  box-shadow: none;
}

.metric span {
  color: #ffffff;
  font-size: 24px;
}

.metric small {
  color: #a9bcb3;
  font-size: 12px;
}

.toolbar {
  grid-area: toolbar;
  position: sticky;
  top: 0;
  z-index: 5;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(249, 251, 253, 0.92);
  backdrop-filter: blur(16px);
}

.workspace {
  grid-area: workspace;
  min-height: 0;
  grid-template-columns: minmax(360px, 1fr) minmax(620px, 720px);
  gap: 20px;
  padding: 22px 26px 30px;
}

.crm-workspace {
  grid-template-columns: minmax(480px, 1fr) minmax(620px, 720px);
}

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

.page-mode-websites .workspace {
  padding-top: 26px;
}

.page-mode-crm .toolbar {
  grid-template-columns: minmax(0, 1fr) max-content;
}

.page-mode-websites .toolbar {
  display: none;
}

.import-group,
.filter-group,
.action-group {
  gap: 10px;
}

.date-field,
.form-grid label,
.website-search-grid label {
  color: #596776;
  letter-spacing: 0;
}

input[type="search"],
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="number"],
select,
textarea {
  min-height: 42px;
  border-color: #cbd5df;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 0 rgba(23, 32, 27, 0.03);
}

input:hover,
select:hover,
textarea:hover {
  border-color: #9fb0bf;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 138, 106, 0.12);
}

input[type="search"] {
  max-width: 320px;
  min-width: 240px;
}

#cantonFilter,
#legalFormFilter {
  flex-basis: 150px;
}

.segmented {
  border-color: #cbd5df;
  border-radius: 8px;
  background: #eef3f6;
  padding: 3px;
}

.segmented button {
  min-height: 34px;
  border-right: 0;
  border-radius: 6px;
  background: transparent;
  color: #50606f;
  box-shadow: none;
}

.segmented button:hover {
  background: #ffffff;
  box-shadow: none;
  transform: none;
}

.segmented button.active {
  background: #ffffff;
  color: var(--accent-dark);
  box-shadow: 0 2px 10px rgba(23, 32, 27, 0.08);
}

.list-panel,
.map-panel,
.crm-panel,
.website-panel,
.detail-panel {
  border-color: #e1e7ee;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.list-header {
  min-height: 62px;
  padding: 16px 18px;
  border-bottom-color: #e8edf2;
  background: #ffffff;
  border-radius: 8px 8px 0 0;
}

.list-header strong {
  font-size: 16px;
}

.list-header span {
  color: #708090;
}

.table-wrap {
  background: #fff;
  border-radius: 0 0 8px 8px;
}

table {
  font-size: 14px;
}

th,
td {
  padding: 13px 14px;
  border-bottom-color: #edf1f5;
}

th {
  background: #f8fafc;
  color: #667486;
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

tbody tr {
  transition: background-color 0.14s ease;
}

tbody tr:hover,
tbody tr.selected {
  background: #f1faf7;
}

.company-cell strong {
  color: #17201b;
  font-weight: 800;
}

.company-cell small,
.company-cell em,
.crm-table td small,
.website-table td small {
  color: #6f7e8d;
}

.mark-button {
  border-radius: 8px;
}

.status-pill,
.badge,
.score-pill {
  border-radius: 999px;
  font-size: 12px;
}

.status-pill.worked,
.badge.worked {
  background: #e8f2ff;
  color: #1e4f82;
}

.status-pill.marked,
.badge.marked,
.score-pill.medium {
  background: #fff4dc;
  color: #9a5d11;
}

.status-pill.done,
.score-pill.low {
  background: #e8f7ee;
  color: #17613c;
}

.status-pill.open,
.score-pill.bad {
  background: #fff0ec;
  color: #a63d28;
}

.detail-panel {
  background: #fbfdff;
}

.detail-form {
  padding: 22px;
}

.detail-heading {
  align-items: flex-start;
  padding-bottom: 20px;
  border-bottom-color: #e4eaf0;
}

.detail-heading h2,
.empty-detail h2 {
  color: #17201b;
  font-size: 21px;
}

.company-details div {
  border-color: #e1e7ee;
  border-radius: 8px;
  background: #ffffff;
}

.form-section {
  border-top-color: #e4eaf0;
}

.form-section h3 {
  color: #22302a;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.check-card {
  border-color: #cbd5df;
  border-radius: 8px;
  background: #ffffff;
}

.crm-summary {
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  padding: 16px 18px;
  border-bottom-color: #e8edf2;
  background: #f8fbfd;
}

.crm-summary div {
  border-color: #e2e8ef;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.crm-summary span {
  color: var(--accent-dark);
  font-size: 26px;
}

.crm-create-panel,
.website-search-form {
  border-bottom-color: #e8edf2;
  background: #f8fbfd;
}

.website-search-grid {
  grid-template-columns: minmax(180px, 1fr) 120px minmax(320px, 2fr) 120px minmax(240px, auto);
}

.website-table a {
  color: var(--accent-dark);
}

.company-map {
  min-height: 680px;
  background: #dde8e4;
}

.empty {
  color: #7a8795;
}

@media (max-width: 1240px) {
  .app-shell {
    grid-template-columns: 248px minmax(0, 1fr);
  }

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

  .detail-panel {
    min-height: 420px;
  }

  .toolbar,
  .page-mode-crm .toolbar {
    grid-template-columns: 1fr;
  }

  .filter-group,
  .action-group {
    justify-content: flex-start;
  }

  .website-search-grid {
    grid-template-columns: 1fr 1fr;
  }

  .website-search-grid .wide,
  .website-search-grid .check-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .topbar {
    position: static;
    height: auto;
    padding: 18px 16px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .brand-block {
    width: 100%;
  }

  .main-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .main-tabs button {
    min-width: 0;
    justify-content: center;
    padding: 0 8px;
    text-align: center;
  }

  .main-tabs button::before {
    display: none;
  }

  .metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .toolbar,
  .workspace {
    padding-left: 14px;
    padding-right: 14px;
  }

  .toolbar {
    position: static;
  }

  .import-group,
  .filter-group,
  .action-group {
    flex-wrap: wrap;
  }

  .date-field,
  .date-field input,
  input[type="search"],
  #cantonFilter,
  #legalFormFilter {
    max-width: none;
    width: 100%;
    flex-basis: 100%;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
    padding: 0 8px;
  }

  .crm-summary {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid,
  .website-search-grid,
  .entry-info-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .wide,
  .website-search-grid .wide,
  .website-search-grid .check-card {
    grid-column: 1 / -1;
  }

  .company-details,
  .entry-info-grid {
    grid-template-columns: 1fr;
  }
}

.detail-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.detail-actions .danger {
  min-height: 36px;
  padding: 0 12px;
}

@media (max-width: 820px) {
  .detail-heading,
  .detail-actions {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: stretch;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

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

button {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

button:hover {
  border-color: var(--accent);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button.primary,
#shabButton {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover,
#shabButton:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

button.danger {
  color: var(--danger);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.brand-block {
  display: grid;
  gap: 14px;
}

.main-tabs {
  display: inline-flex;
  width: max-content;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  overflow: hidden;
  background: #fbfcfa;
}

.main-tabs button {
  min-width: 104px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-weight: 700;
}

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

.main-tabs button.active {
  background: var(--accent);
  color: #fff;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(86px, 1fr));
  gap: 10px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  min-width: 92px;
  background: #fbfcfa;
}

.metric span {
  display: block;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.metric small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.toolbar {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  gap: 16px;
  align-items: center;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: #eef2ed;
}

.import-group,
.filter-group,
.action-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.filter-group {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.action-group {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.date-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.date-field input {
  width: 148px;
}

.check-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  color: var(--text);
}

input[type="search"],
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="date"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  min-height: 38px;
  padding: 8px 10px;
}

input[type="search"] {
  max-width: 220px;
  min-width: 190px;
  flex: 1 1 190px;
}

#cantonFilter {
  flex: 0 0 118px;
}

#legalFormFilter {
  flex: 0 0 132px;
}

.filter-group .segmented button {
  padding: 0 10px;
}

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

.segmented {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  overflow: hidden;
  background: var(--panel);
  flex: 0 0 auto;
}

.segmented button {
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  min-height: 36px;
  background: transparent;
}

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

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

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 730px;
  gap: 18px;
  padding: 18px 28px 28px;
}

.crm-workspace {
  grid-template-columns: minmax(480px, 1fr) 730px;
}

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

.page-mode-crm .lead-filter-tabs,
.page-mode-crm .import-group,
.page-mode-crm .view-switch {
  display: none;
}

.page-mode-websites .toolbar {
  display: none;
}

.page-mode-crm .toolbar {
  grid-template-columns: minmax(0, 1fr) max-content;
}

.list-panel,
.map-panel,
.crm-panel,
.website-panel,
.detail-panel {
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.list-panel {
  display: grid;
  grid-template-rows: auto 1fr;
}

.map-panel {
  display: grid;
  grid-template-rows: auto 1fr;
}

.crm-panel {
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
}

.website-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.company-map {
  min-height: 640px;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  background: #e7ece5;
}

.leaflet-popup-content {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.35;
}

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

.list-header span {
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.crm-header > div {
  display: grid;
  gap: 4px;
}

.crm-header span,
.website-header span {
  text-align: left;
}

.website-header > div {
  display: grid;
  gap: 4px;
}

.table-wrap {
  min-height: 0;
  overflow: auto;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8faf7;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #eef7f2;
}

.mark-col {
  width: 78px;
  text-align: center;
}

.mark-button {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 7px;
  line-height: 1;
}

.mark-button.active {
  background: #fff2d7;
  border-color: #c88320;
  color: var(--amber);
}

.company-cell strong {
  display: block;
  margin-bottom: 3px;
}

.company-cell small {
  color: var(--muted);
}

.company-cell em {
  display: block;
  max-width: 680px;
  margin-top: 4px;
  color: #52645a;
  font-size: 13px;
  font-style: normal;
  line-height: 1.35;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #edf1ea;
  color: #435040;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.worked,
.badge.worked {
  background: #e8f2ff;
  color: #24517d;
}

.status-pill.marked,
.badge.marked {
  background: #fff2d7;
  color: var(--amber);
}

.status-pill.done {
  background: #e6f4eb;
  color: #1f6b42;
}

.status-pill.open {
  background: #f7ebe7;
  color: #9a3b25;
}

.empty {
  padding: 36px 12px;
  text-align: center;
  color: var(--muted);
}

.detail-panel {
  min-width: 0;
  overflow: auto;
}

.empty-detail {
  padding: 28px;
}

.empty-detail h2,
.detail-heading h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

.empty-detail p,
.detail-heading p {
  margin: 7px 0 0;
  color: var(--muted);
}

.detail-form {
  padding: 20px;
}

.detail-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-heading h2 {
  margin-top: 9px;
}

.company-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px 0 0;
}

.company-details div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf7;
}

.company-details .wide {
  grid-column: 1 / -1;
}

.company-details span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.company-details strong,
.company-details p {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
}

.entry-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-top: 18px;
}

.entry-info-grid div {
  min-width: 0;
  padding: 14px;
  border: 1px solid #e1e7ee;
  border-radius: 8px;
  background: #fff;
}

.entry-info-grid .wide {
  grid-column: 1 / -1;
}

.entry-info-grid span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.entry-info-grid strong,
.entry-info-grid p {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
  white-space: pre-wrap;
}

.form-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.form-section h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
  padding-top: 18px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.check-card {
  align-content: center;
  grid-template-columns: auto 1fr;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text) !important;
}

.check-card input {
  width: auto;
}

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

.epost-actions button {
  flex: 1 1 180px;
}

.epost-status {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid #cfe6dd;
  border-radius: 8px;
  background: #f3fbf8;
  color: var(--text);
}

.epost-status strong {
  font-size: 13px;
}

.epost-status span,
.epost-status small {
  color: var(--muted);
}

.epost-status.has-error {
  border-color: #f0c5bf;
  background: #fff7f5;
}

.epost-status.has-error strong,
.epost-status.has-error span {
  color: var(--danger);
}

.crm-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.crm-summary div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.crm-summary span {
  display: block;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.crm-summary small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.crm-create-panel {
  padding: 0 16px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.crm-create-panel .form-grid {
  padding-top: 16px;
}

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

.website-search-form {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.website-search-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 120px minmax(260px, 2fr) 120px minmax(220px, auto);
  gap: 12px;
  align-items: end;
}

.website-search-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.website-search-grid .wide {
  min-width: 0;
}

.website-table a {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.website-table a:hover {
  text-decoration: underline;
}

.score-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.score-pill.bad {
  background: #f7ebe7;
  color: #9a3b25;
}

.score-pill.medium {
  background: #fff2d7;
  color: var(--amber);
}

.score-pill.low {
  background: #e6f4eb;
  color: #1f6b42;
}

.website-table td small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.crm-filter-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.crm-table td small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.35;
}

.source-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

#sourceData {
  margin: 12px 0 0;
  padding: 12px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf7;
  color: #2f382d;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

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

  .page-mode-crm .toolbar {
    grid-template-columns: 1fr;
  }

  .website-search-grid {
    grid-template-columns: 1fr 1fr;
  }

  .website-search-grid .wide,
  .website-search-grid .check-card {
    grid-column: 1 / -1;
  }

  .filter-group,
  .action-group {
    justify-content: flex-start;
  }

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

  .detail-panel {
    min-height: 420px;
  }
}

@media (max-width: 720px) {
  .topbar {
    display: grid;
    padding: 18px;
  }

  .brand-block,
  .main-tabs {
    width: 100%;
  }

  .main-tabs button {
    flex: 1;
  }

  .metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .toolbar,
  .workspace {
    padding-left: 14px;
    padding-right: 14px;
  }

  .import-group,
  .filter-group,
  .action-group {
    flex-wrap: wrap;
  }

  .date-field,
  .date-field input {
    width: 100%;
  }

  input[type="search"] {
    max-width: none;
    flex-basis: 100%;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
    padding: 0 8px;
  }

  .crm-filter-row .segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .crm-filter-row .segmented button {
    min-width: 0;
    min-height: 42px;
    white-space: normal;
    line-height: 1.2;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .crm-filter-row .segmented button:nth-child(2n) {
    border-right: 0;
  }

  .crm-filter-row .segmented button:last-child {
    grid-column: 1 / -1;
    border-bottom: 0;
  }

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

  .list-panel,
  .map-panel,
  .crm-panel,
  .website-panel,
  .detail-panel {
    border-radius: 7px;
  }

  th:nth-child(4),
  td:nth-child(4),
  th:nth-child(5),
  td:nth-child(5) {
    display: none;
  }

  .crm-table thead {
    display: none;
  }

  .website-table thead {
    display: none;
  }

  .crm-table,
  .crm-table tbody,
  .crm-table tr,
  .crm-table td,
  .website-table,
  .website-table tbody,
  .website-table tr,
  .website-table td,
  .crm-table th:nth-child(4),
  .crm-table td:nth-child(4),
  .crm-table th:nth-child(5),
  .crm-table td:nth-child(5) {
    display: block;
    width: 100%;
  }

  .crm-table tr,
  .website-table tr {
    border-bottom: 1px solid var(--line);
  }

  .crm-table td,
  .website-table td {
    border-bottom: 0;
    padding: 9px 12px;
  }

  .crm-table td::before,
  .website-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  .crm-table td.empty::before,
  .website-table td.empty::before {
    content: "";
    display: none;
  }

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

  .company-details {
    grid-template-columns: 1fr;
  }

  .crm-summary {
    grid-template-columns: 1fr 1fr;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* Final modern CRM layout overrides */
body {
  background: linear-gradient(180deg, #f7fafc 0%, #eef4f7 100%);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "sidebar toolbar"
    "sidebar workspace";
}

.topbar {
  grid-area: sidebar;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 22px;
  padding: 24px 18px;
  overflow: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 0;
  background: var(--sidebar);
  color: var(--sidebar-text);
  box-shadow: 18px 0 40px rgba(22, 35, 29, 0.16);
}

.topbar h1 {
  color: #fff;
  font-size: 22px;
}

.topbar p {
  color: #a9bcb3;
  font-size: 13px;
  line-height: 1.45;
}

.main-tabs {
  display: grid;
  width: 100%;
  gap: 8px;
  border: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
}

.main-tabs button {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px 0 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #c7d6cf;
  text-align: left;
  box-shadow: none;
}

.main-tabs button::before {
  position: absolute;
  left: 14px;
  width: 18px;
  color: #89a39a;
  text-align: center;
  font-size: 10px;
  font-weight: 800;
}

.main-tabs button[data-page="akquise"]::before {
  content: "NG";
}

.main-tabs button[data-page="crm"]::before {
  content: "CRM";
}

.main-tabs button[data-page="websites"]::before {
  content: "SU";
}

.main-tabs button:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: var(--sidebar-soft);
  box-shadow: none;
  transform: none;
}

.main-tabs button.active {
  border-color: rgba(255, 255, 255, 0.13);
  background: #edf8f3;
  color: #0f3228;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}

.metrics {
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.metric {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: #f5fbf8;
  box-shadow: none;
}

.metric span {
  color: #fff;
  font-size: 24px;
}

.metric small {
  color: #a9bcb3;
}

.toolbar {
  grid-area: toolbar;
  position: sticky;
  top: 0;
  z-index: 5;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(249, 251, 253, 0.92);
  backdrop-filter: blur(16px);
}

.workspace {
  grid-area: workspace;
  grid-template-columns: minmax(360px, 1fr) minmax(620px, 720px);
  gap: 20px;
  padding: 22px 26px 30px;
}

.crm-workspace {
  grid-template-columns: minmax(480px, 1fr) minmax(620px, 720px);
}

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

.page-mode-websites .toolbar {
  display: none;
}

.page-mode-crm .toolbar {
  grid-template-columns: minmax(0, 1fr) max-content;
}

button,
input[type="search"],
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="number"],
select,
textarea,
.segmented,
.list-panel,
.map-panel,
.crm-panel,
.website-panel,
.detail-panel,
.company-details div,
.crm-summary div,
.check-card {
  border-radius: 8px;
}

button {
  min-height: 40px;
  border-color: #cbd5df;
  background: #fff;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(23, 32, 27, 0.03);
}

button:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 18px rgba(15, 138, 106, 0.12);
  transform: translateY(-1px);
}

button.primary,
#shabButton {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 24px rgba(15, 138, 106, 0.2);
}

button.danger {
  border-color: #f0c5bf;
  background: #fff7f5;
  color: var(--danger);
}

input[type="search"],
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="number"],
select,
textarea {
  min-height: 42px;
  border-color: #cbd5df;
  background: #fff;
  box-shadow: 0 1px 0 rgba(23, 32, 27, 0.03);
}

input[type="search"] {
  max-width: 320px;
  min-width: 240px;
}

#cantonFilter,
#legalFormFilter {
  flex-basis: 150px;
}

.segmented {
  padding: 3px;
  border-color: #cbd5df;
  background: #eef3f6;
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #50606f;
  box-shadow: none;
}

.segmented button.active {
  background: #fff;
  color: var(--accent-dark);
  box-shadow: 0 2px 10px rgba(23, 32, 27, 0.08);
}

.list-panel,
.map-panel,
.crm-panel,
.website-panel,
.detail-panel {
  border-color: #e1e7ee;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.list-header {
  min-height: 62px;
  padding: 16px 18px;
  border-bottom-color: #e8edf2;
  background: #fff;
}

th,
td {
  padding: 13px 14px;
  border-bottom-color: #edf1f5;
}

th {
  background: #f8fafc;
  color: #667486;
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

tbody tr:hover,
tbody tr.selected {
  background: #f1faf7;
}

.crm-summary,
.crm-create-panel,
.website-search-form {
  border-bottom-color: #e8edf2;
  background: #f8fbfd;
}

.crm-summary {
  gap: 12px;
  padding: 16px 18px;
}

.crm-summary div {
  border-color: #e2e8ef;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.crm-summary span {
  color: var(--accent-dark);
  font-size: 26px;
}

.website-search-grid {
  grid-template-columns: minmax(180px, 1fr) 120px minmax(320px, 2fr) 120px minmax(240px, auto);
}

.detail-panel {
  background: #fbfdff;
}

.detail-form {
  padding: 22px;
}

.detail-heading,
.form-section {
  border-color: #e4eaf0;
}

.company-details div {
  border-color: #e1e7ee;
  background: #fff;
}

.company-map {
  min-height: 680px;
  background: #dde8e4;
}

@media (max-width: 1240px) {
  .app-shell {
    grid-template-columns: 248px minmax(0, 1fr);
  }

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

  .toolbar,
  .page-mode-crm .toolbar {
    grid-template-columns: 1fr;
  }

  .website-search-grid {
    grid-template-columns: 1fr 1fr;
  }

  .website-search-grid .wide,
  .website-search-grid .check-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .topbar {
    position: static;
    height: auto;
    padding: 18px 16px;
    border-right: 0;
  }

  .main-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .main-tabs button {
    justify-content: center;
    padding: 0 8px;
    text-align: center;
  }

  .main-tabs button::before {
    display: none;
  }

  .metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .toolbar {
    position: static;
  }

  .toolbar,
  .workspace {
    padding-left: 14px;
    padding-right: 14px;
  }

  .date-field,
  .date-field input,
  input[type="search"],
  #cantonFilter,
  #legalFormFilter {
    max-width: none;
    width: 100%;
    flex-basis: 100%;
  }

  .website-search-grid,
  .form-grid,
  .company-details,
  .entry-info-grid {
    grid-template-columns: 1fr;
  }
}

/* Detail sidebar behavior */
@media (min-width: 1241px) {
  .workspace:not(.website-workspace) {
    align-items: start;
  }

  .workspace:not(.website-workspace) .detail-panel {
    position: sticky;
    top: 92px;
    max-height: calc(100vh - 116px);
    overflow: auto;
  }
}

.customer-data-section {
  margin-top: 18px;
}

.metric.metric-action {
  display: block;
  width: 100%;
  height: auto;
  min-height: 0;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.metric.metric-action:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.09);
  box-shadow: none;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.internet-button {
  border-color: #cfe0ee;
  background: #f3f8fc;
  color: #166074;
}

.internet-button:hover {
  border-color: #a9cbdd;
  background: #e9f4f9;
  box-shadow: var(--shadow-soft);
}

.crm-save-button {
  border-color: #cce5db;
  background: #eef8f3;
  color: #11734f;
}

.crm-save-button:hover,
.crm-save-button.is-saved {
  border-color: #9ed1bc;
  background: #e1f3eb;
  box-shadow: var(--shadow-soft);
}

/* Compact toolbar */
.toolbar {
  grid-template-columns: minmax(420px, auto) minmax(360px, 1fr) max-content;
  gap: 12px;
  align-items: start;
  padding: 14px 26px;
}

.import-group,
.filter-group,
.action-group {
  gap: 8px;
}

.import-group,
.filter-group {
  padding: 4px;
  border: 1px solid #e2e8ef;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.date-field {
  gap: 6px;
  font-size: 12px;
}

#shabRangeMode {
  width: 74px;
}

.date-field input[type="date"] {
  width: 142px;
}

.week-field {
  gap: 8px;
}

.week-picker {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.week-picker input {
  min-height: 42px;
  padding: 8px 9px;
  text-align: center;
  font-weight: 800;
}

#shabWeekNumber {
  width: 58px;
}

#shabWeekYear {
  width: 76px;
}

#shabButton {
  min-width: 82px;
  padding: 0 14px;
}

.filter-group {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 132px 138px;
  align-items: center;
}

.filter-group input[type="search"],
.filter-group select {
  min-width: 0;
  max-width: none;
}

.filter-group .segmented {
  grid-column: 1 / -1;
  justify-self: start;
}

.filter-group .segmented button,
.view-switch button {
  min-height: 34px;
  padding: 0 11px;
}

.action-group {
  align-items: start;
}

.action-group > button {
  min-height: 42px;
}

@media (max-width: 1420px) {
  .toolbar {
    grid-template-columns: 1fr max-content;
  }

  .filter-group {
    grid-column: 1 / -1;
    order: 3;
  }
}

@media (max-width: 820px) {
  .toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .import-group,
  .filter-group,
  .action-group {
    width: 100%;
  }

  .filter-group {
    grid-template-columns: 1fr;
  }

  #shabRangeMode,
  .date-field input[type="date"],
  #shabWeekNumber,
  #shabWeekYear {
    width: 100%;
  }

  .week-picker {
    width: 100%;
  }
}
