.crm-body {
  background: linear-gradient(180deg, #f8f9fb 0%, #ffffff 55%);
  --hp-green: #a2bf1a;
  --hp-red: #d9423d;
  --hd-lime: var(--hp-green);
  --hd-lime-2: var(--hp-green);
}

.crm-topbar {
  position: sticky;
  top: 0;
  z-index: 80;
}

.crm-topbar__inner {
  gap: 18px;
}

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

.crm-nav-toggle {
  display: none;
  margin-left: auto;
}

.crm-nav a {
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 600;
  color: var(--ink-2);
}

.crm-nav a:hover,
.crm-nav a.is-active {
  background: var(--fog);
}

.crm-user-box {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.crm-user-icon {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.crm-user-icon:hover,
.crm-user-icon.is-active {
  background: var(--fog);
}

.crm-user-icon img {
  opacity: 0.85;
}

.crm-global-search input {
  width: 120px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
}

.crm-global-search input:focus {
  width: 180px;
}

.crm-main {
  padding-top: 28px;
  padding-bottom: 56px;
}

.crm-section {
  margin-bottom: 20px;
}

.crm-section-sm {
  margin-bottom: 14px;
}

.crm-hero {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 18px;
}

.crm-hero h1 {
  font-family: var(--font-display);
  margin: 0 0 8px;
  font-size: clamp(26px, 3vw, 34px);
}

.crm-hero--plain {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.crm-greeting {
  margin: 0;
}

.crm-greeting span {
  font-weight: 400;
}

.crm-greeting strong {
  font-weight: 700;
}

.crm-quote-day {
  margin: 8px 0 0;
  color: var(--muted);
  font-style: italic;
}

.crm-body .btn--primary {
  background: var(--hp-green);
  border-color: transparent;
}

.crm-body .btn--primary:hover {
  background: var(--hp-green);
  filter: brightness(0.95);
}

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

.crm-card {
  grid-column: span 12;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 18px;
}

.crm-main > .crm-card + .crm-card {
  margin-top: 20px;
}

.crm-card--kpi {
  grid-column: span 3;
}

.crm-kpi-link {
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.crm-kpi-link:nth-child(1) {
  border-left: 5px solid #3b8a3e;
}

.crm-kpi-link:nth-child(2) {
  border-left: 5px solid #e0b100;
}

.crm-kpi-link:nth-child(3) {
  border-left: 5px solid #e0b100;
}

.crm-kpi-link:nth-child(4) {
  border-left: 5px solid #d9423d;
}

.crm-kpi-link:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.crm-kpi-title {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 5px;
}

.crm-kpi-value {
  margin: 0;
  font: 700 30px/1 var(--font-display);
}

.crm-card h2 {
  margin: 0 0 12px;
  font-size: 22px;
  font-family: var(--font-display);
}

.crm-page-head-card h1 {
  margin: 0 0 8px;
  font-size: clamp(34px, 4vw, 58px);
  line-height: 1.02;
  font-family: var(--font-display);
}

.crm-page-head-card--compact h1 {
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.1;
}

.crm-page-head-card .crm-note {
  margin-bottom: 12px;
}

.crm-plus-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: var(--hp-green);
  color: #fff;
  font: 700 26px/1 var(--font-display);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.crm-plus-btn:hover {
  filter: brightness(0.95);
}

.crm-row {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.crm-filter-actions {
  flex-direction: row;
  align-items: center;
}

.crm-field.crm-filter-actions {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

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

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

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

[hidden] {
  display: none !important;
}

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

.crm-field label {
  font-size: 13px;
  color: var(--muted);
}

.crm-section-subhead {
  color: #9da3af;
  display: flex;
  align-items: center;
  gap: 10px;
  font-style: italic;
  font-size: 13px;
  margin-top: 8px;
  padding-top: 2px;
}

.crm-stammdaten-section + .crm-stammdaten-section {
  margin-top: 24px;
}

.crm-stammdaten-section .crm-form-grid {
  margin-top: 12px;
}

.crm-section-subhead::before {
  content: "";
  width: 58px;
  height: 1px;
  background: #cfd3db;
}

.crm-field-meta {
  font-size: 12px;
  color: #7f8694;
  font-weight: 400;
  margin-left: 6px;
}

.crm-field input,
.crm-field select,
.crm-field textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.crm-field textarea {
  min-height: 112px;
}

.crm-phone-combo {
  display: grid;
  grid-template-columns: 122px 1fr;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.crm-phone-combo > select {
  border: 0 !important;
  border-right: 1px solid var(--line) !important;
  border-radius: 0 !important;
  text-align: center;
  background: #f3f4f7;
  padding: 10px 8px !important;
}

.crm-phone-combo > input {
  border: 0 !important;
  border-radius: 0 !important;
  padding: 10px 12px !important;
}

.crm-phone-combo:focus-within {
  outline: 2px solid rgba(162, 191, 26, 0.35);
  border-color: rgba(162, 191, 26, 0.6);
}

.crm-customer-logo {
  max-height: 64px;
  width: auto;
  object-fit: contain;
}

.crm-format-feedback {
  color: #5b6476;
  font-size: 12px;
  min-height: 16px;
}

.crm-field input:focus,
.crm-field select:focus,
.crm-field textarea:focus {
  outline: 2px solid rgba(162, 191, 26, 0.35);
  border-color: rgba(162, 191, 26, 0.6);
}

.crm-full {
  grid-column: span 2;
}

.crm-table-wrap {
  overflow: auto;
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}

.crm-table th,
.crm-table td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  vertical-align: top;
}

.crm-table th {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.crm-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--fog);
}

.crm-badge--ok {
  background: #e9f8e7;
  color: #156f20;
}

.crm-badge--warn {
  background: #fff7cc;
  color: #8e6a00;
}

.crm-badge--alert {
  background: #ffe4e2;
  color: #a5221d;
}

.crm-kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(230px, 1fr));
  gap: 14px;
  overflow: auto;
}

.crm-column {
  background: var(--fog);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  min-height: 130px;
}

.crm-column h3 {
  margin: 0 0 8px;
  font-size: 14px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.crm-ticket {
  background: #fff;
  border: 1px solid #dde2eb;
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
}

.crm-ticket strong {
  display: block;
  margin-bottom: 5px;
}

.crm-flash {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.crm-flash--success {
  background: #eaf8ef;
  border-color: #b9e8c7;
}

.crm-flash--error {
  background: #fff0f0;
  border-color: #ffcccc;
}

.crm-login {
  max-width: 430px;
  margin: 34px auto;
}

.crm-note {
  color: var(--muted);
  font-size: 14px;
}

.crm-doc-link {
  color: var(--hp-green);
  text-decoration: underline;
}

.crm-link {
  color: inherit;
  text-decoration: none;
}

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

.crm-action-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.crm-action-icon {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 700 15px/1 var(--font-body);
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: none;
  padding: 0;
  appearance: none;
}

.crm-action-icon:hover {
  background: var(--fog);
}

.crm-action-icon--danger {
  color: #8a1b1b;
  border-color: #f0d2d2;
}

.crm-action-icon--mini {
  width: 26px;
  height: 26px;
  font-size: 12px;
  margin-left: 8px;
}

.crm-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.crm-tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font: 600 14px/1.2 var(--font-body);
  cursor: pointer;
}

.crm-tab:hover {
  background: var(--fog);
}

.crm-tab.is-active {
  border-color: var(--hp-green);
  color: var(--hp-green);
  background: rgba(162, 191, 26, 0.15);
}

.crm-tab-panel {
  display: none;
}

.crm-tab-panel.is-active {
  display: block;
}

.crm-modal-open {
  overflow: hidden;
}

.crm-modal {
  position: fixed;
  inset: 0;
  z-index: 420;
  display: grid;
  place-items: center;
  padding: 20px;
}

.crm-modal[hidden] {
  display: none;
}

.crm-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
}

.crm-modal__dialog {
  position: relative;
  width: min(980px, 100%);
  max-height: min(90vh, 920px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-md);
  padding: 16px;
}

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

.crm-modal__head h3 {
  margin: 0;
}

.crm-order-anchor-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.crm-order-anchor-nav a {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
  background: #fff;
}

.crm-order-anchor-nav a:hover {
  background: var(--fog);
}

.crm-customer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.crm-customer-header__actions {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.crm-upcoming-box {
  min-width: 280px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
}

.crm-upcoming-item {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 8px;
  display: grid;
  gap: 3px;
}

.crm-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 220;
}

.crm-fab__toggle {
  width: 52px;
  height: 52px;
  font-size: 30px;
}

.crm-fab__menu {
  position: absolute;
  right: 0;
  bottom: 62px;
  width: max-content;
  max-width: min(90vw, 300px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-md);
  padding: 8px;
  display: grid;
  gap: 6px;
}

.crm-fab__menu a {
  color: var(--ink-2);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  font: 600 13px/1.2 var(--font-body);
}

.crm-fab__menu a:hover {
  background: var(--fog);
}

.crm-order-metrics {
  margin-bottom: 14px;
}

.crm-order-metrics .crm-card {
  margin-top: 0;
}

.crm-edit-row {
  display: none;
  background: #fafbfd;
}

.crm-edit-row.is-open {
  display: table-row;
}

.crm-context-menu {
  position: fixed;
  z-index: 300;
  min-width: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  display: none;
  gap: 6px;
  align-items: center;
}

.crm-context-menu.is-open {
  display: inline-flex;
}

.crm-context-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 700 15px/1 var(--font-body);
  cursor: pointer;
}

.crm-context-btn:hover {
  background: var(--fog);
}

.crm-context-btn--danger {
  color: #8a1b1b;
  border-color: #f0d2d2;
}

.crm-pagination {
  margin-top: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

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

[data-proposal-builder] hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

[data-proposal-builder] h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.proposal-badges {
  gap: 8px;
}

.crm-badge-toggle {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font: 600 13px/1.1 var(--font-body);
  color: var(--ink-2);
  cursor: pointer;
}

.crm-badge-toggle.is-active {
  background: rgba(162, 191, 26, 0.18);
  border-color: var(--hp-green);
  color: #193200;
}

[data-line-items-table] input {
  min-width: 96px;
  width: 100%;
}

[data-line-items-table] td:first-child input {
  min-width: 280px;
}

[data-line-items-table] tfoot th {
  font-weight: 700;
}

.crm-table-add-row td {
  padding: 10px 0 6px;
}

.crm-icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 600 12.5px/1 var(--font-body);
  color: var(--ink-2);
  cursor: pointer;
}

.crm-icon-btn__icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(162, 191, 26, 0.18);
  color: #193200;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

.tom-select,
.ts-control,
.ts-dropdown {
  width: 100%;
}

.ts-control input {
  min-width: 0;
}

@media (max-width: 1100px) {
  .crm-card--kpi {
    grid-column: span 6;
  }

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

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

  .crm-full {
    grid-column: span 1;
  }

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

  .crm-nav-toggle {
    display: inline-flex;
  }

  .crm-nav {
    display: none;
    position: absolute;
    right: 12px;
    top: 64px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 8px;
    flex-direction: column;
    align-items: stretch;
    min-width: 200px;
    margin-left: 0;
    z-index: 160;
  }

  .crm-nav.is-open {
    display: flex;
  }

  .crm-user-box {
    margin-left: auto;
  }
}

@media (max-width: 680px) {
  .crm-card--kpi {
    grid-column: span 12;
  }

  .crm-main {
    padding-top: 18px;
  }
}

@media (max-width: 900px) {
  .crm-topbar__inner {
    flex-wrap: wrap;
  }

  .crm-user-box {
    width: 100%;
    justify-content: space-between;
  }

  .crm-global-search {
    flex: 1 1 auto;
  }

  .crm-global-search input {
    width: 100%;
  }

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

  .crm-grid > * {
    grid-column: span 1 !important;
  }

  .crm-card {
    padding: 16px;
  }

  .crm-row {
    flex-direction: column;
    align-items: stretch;
  }

  .crm-row .crm-field,
  .crm-row .btn,
  .crm-row .crm-nav-toggle {
    width: 100%;
  }

  .crm-page-head-card .crm-row {
    align-items: flex-start;
  }

  .crm-customer-header {
    flex-direction: column;
    align-items: stretch;
  }

  .crm-customer-header__actions {
    flex-direction: column;
  }

  .crm-upcoming-box {
    min-width: 0;
  }

  .crm-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
  }

  .crm-tab {
    white-space: nowrap;
  }

  .crm-modal {
    padding: 10px;
  }

  .crm-modal__dialog {
    max-height: 94vh;
    padding: 12px;
  }

  .crm-table {
    min-width: 0;
  }

  .crm-table thead {
    display: none;
  }

  .crm-table,
  .crm-table tbody,
  .crm-table tr,
  .crm-table td {
    display: block;
    width: 100%;
  }

  .crm-table tr {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px;
    margin-bottom: 12px;
    background: #fff;
  }

  .crm-table td {
    border-bottom: 1px dashed var(--line);
    padding: 8px 0;
    display: grid;
    grid-template-columns: minmax(120px, 40%) 1fr;
    gap: 10px;
    align-items: start;
  }

  .crm-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
  }

  .crm-table td > * {
    justify-self: end;
    text-align: right;
  }

  .crm-table td:last-child {
    border-bottom: 0;
  }
}
