/* v2 additions: settings, stages, leads, documents (Belege), RC4. Uses the look of _general.css. */

.crm-section {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  /* padding: 1.5rem; */
}

.crm-section .daten-section {
  padding: 1.5rem;
}

.crm-hint {
  font-family: 'Martian Mono', monospace;
  font-size: .75rem;
  font-weight: 100;
  max-width: 60rem;
  opacity: .8;
  padding: 1rem 0;
}

.crm-error {
  color: #a90000;
  font-family: 'Martian Mono', monospace;
  font-size: .8rem;
  min-height: 1rem;
  padding: 0 1.5rem;
}

.crm-inactive td {
  opacity: .45;
}

.crm-mono-small {
  font-family: 'Martian Mono', monospace;
  font-size: .7rem !important;
}

.crm-table {
  width: 100%;
}

.crm-table thead tr {
  border-bottom: 1px solid black;
}

.crm-table tbody tr.crm-row-link {
  cursor: pointer;
}

.crm-table tbody tr.crm-row-link:hover {
  background: rgba(0, 0, 0, .05);
}

.crm-check {
  font-family: 'Martian Mono', monospace;
  font-size: .85rem;
  font-weight: 100;
  display: inline-flex;
  gap: .4rem;
  align-items: center;
  cursor: pointer;
  accent-color: #000;
}

.crm-toggle,
.crm-compact {
  /* crm-compact: small action button (looks like a button, not like a toggle) */
  min-width: 0;
}

/* small labels: roles, lead status, document status … */
.crm-badge {
  display: inline-block;
  font-family: 'Martian Mono', monospace;
  font-size: .65rem;
  font-weight: 400;
  border: 1px solid black;
  border-radius: 3px;
  padding: 1px 4px;
  margin: 1px 2px 1px 0;
  white-space: nowrap;
  vertical-align: middle;
}

.crm-badge-dark,
.crm-role-gf {
  background: black;
  color: white;
}

.crm-badge-test {
  background: #ffcf10;
}

.crm-badge-live {
  background: #4a7c59;
  color: white;
  border-color: #4a7c59;
}

.crm-badge-warn {
  background: #c0392b;
  color: white;
  border-color: #c0392b;
}

.crm-badge-muted {
  opacity: .55;
}

/* stage bar in the project header */
.stage-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  margin: .6rem 0;
}

.stage-step {
  font-family: 'Martian Mono', monospace;
  font-size: .7rem;
  font-weight: 100;
  padding: .25rem .7rem .25rem .9rem;
  border: 1px solid black;
  background: transparent;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%, 8px 50%);
  cursor: pointer;
  color: black;
}

.stage-step:first-child {
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%);
}

.stage-step.done {
  background: rgba(0, 0, 0, .15);
}

.stage-step.current {
  background: black;
  color: var(--main-green);
}

body.role-monteur .stage-step {
  cursor: default;
}

/* key/value list used in detail panels */
.crm-kv {
  display: grid;
  grid-template-columns: minmax(8rem, max-content) 1fr;
  gap: .3rem 1rem;
  font-family: 'Martian Mono', monospace;
  font-size: .85rem;
  font-weight: 100;
}

/* the universal `* { font-family }` reset would otherwise win over inheritance */
.crm-kv * {
  font-family: 'Martian Mono', monospace;
}


.crm-kv > div:nth-child(odd) {
  opacity: .7;
}

.crm-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 1rem;
}

.crm-card {
  border: 1px solid black;
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.crm-card h4 {
  font-family: 'Martian Mono', monospace;
  font-size: .9rem;
  font-weight: 400;
}

.crm-counter-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: 1rem 0;
}

.crm-counter {
  border: 1px solid black;
  border-radius: 10px;
  padding: .6rem 1rem;
  min-width: 9rem;
  font-family: 'Martian Mono', monospace;
  font-weight: 100;
  font-size: .75rem;
  cursor: default;
  background: transparent;
  text-align: left;
}

/* only counters that link somewhere look clickable */
a.crm-counter,
button.crm-counter {
  cursor: pointer;
}

.crm-counter strong {
  display: block;
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  font-size: 1.6rem;
}

.crm-counter.active {
  background: black;
  color: var(--main-green);
}

.crm-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.crm-list li {
  border-bottom: 1px solid black;
  padding: .45rem 0;
  font-family: 'Martian Mono', monospace;
  font-size: .8rem;
  font-weight: 100;
  display: flex;
  gap: .6rem;
  align-items: baseline;
}

.crm-list li a {
  color: inherit;
}

.crm-list li strong {
  font-family: inherit;
}

.crm-list li .crm-list-meta {
  margin-left: auto;
  opacity: .7;
  white-space: nowrap;
    font-family: inherit;
}

.crm-list-meta a {
  font-family: inherit;
}

.crm-tree {
  font-family: 'Martian Mono', monospace;
  font-size: .8rem;
  font-weight: 100;
}

.crm-tree ul {
  list-style: none;
  margin: 0 0 0 1.2rem;
  padding: 0;
  border-left: 1px solid black;
}

.crm-tree li {
  padding: .25rem 0 .25rem .8rem;
}

.crm-money {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.crm-totals {
  margin-left: auto;
  min-width: 18rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .2rem 1.5rem;
  font-family: 'Martian Mono', monospace;
  font-size: .85rem;
  font-weight: 100;
}

.crm-totals .crm-total-final {
  font-weight: 400;
  border-top: 1px solid black;
  padding-top: .2rem;
}

.crm-inline-input {
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, .35);
  background: transparent;
  font-family: 'Martian Mono', monospace;
  font-size: .8rem;
  font-weight: 100;
  width: 100%;
  padding: .15rem .1rem;
}

/* document action bar: equal, roomy buttons that wrap as a whole, never inside the label */
.b-actions {
  gap: .5rem;
}

.crm-actions.b-actions .pill-btn,
.crm-actions.b-actions .save-button {
  width: auto;
  min-width: 14rem;
  white-space: nowrap;
  flex-wrap: nowrap;
}

/* invoice type + "→ Rechnung" stay together */
.b-follow-re {
  display: inline-flex;
  gap: .3rem;
  align-items: center;
}

.b-follow-re select.input-rounded {
  width: 14rem;
}

@media (max-width: 500px) {
  .crm-actions.b-actions .pill-btn,
  .crm-actions.b-actions .save-button,
  .b-follow-re,
  .b-follow-re select.input-rounded {
    width: 100%;
    min-width: 0;
  }
}

/* sections one below the other (document head: Empfänger, then Belegdaten) */
.crm-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* payment plan: number input and its unit (%, Tage) on one line */
#plan-table .pl-unit {
  white-space: nowrap;
}

#plan-table .pl-unit .crm-inline-input {
  width: calc(100% - 3.5rem);
}

.crm-inline-input:focus {
  outline: none;
  border-bottom-color: black;
}

textarea.crm-inline-input {
  resize: vertical;
  min-height: 2.2rem;
}

@media (max-width: 800px) {
  .crm-kv {
    grid-template-columns: 1fr;
  }

  .crm-totals {
    min-width: 0;
    width: 100%;
  }
}

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

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

body.role-monteur .btn-billing,
body.role-monteur #btn-change-object {
  display: none !important;
}

.crm-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
  margin: 1rem 0 .5rem;
  padding: 0 1.5rem;
}

.crm-actions .pill-btn {
  min-width: 0;
  flex: 0 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

.crm-actions select.input-rounded {
  width: auto;
}

.dokument-card {
  position: relative;
}

/* Einstellungen → Protokoll: user filter chips (profile pictures) */
.audit-user-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
}

.audit-user-chip {
  position: relative;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 999px;
  border: 1px solid black;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Martian Mono', monospace;
  font-size: .7rem;
  color: inherit;
  text-decoration: none;
  opacity: .55;
}

.audit-user-chip img {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  object-fit: cover;
}

.audit-user-chip small {
  position: absolute;
  right: -.45rem;
  bottom: -.3rem;
  min-width: 1.1rem;
  padding: 0 .2rem;
  border-radius: 999px;
  background: black;
  color: white;
  font-size: .55rem;
  line-height: 1.1rem;
  text-align: center;
}

.audit-user-chip:hover,
.audit-user-chip.active {
  opacity: 1;
}

.audit-user-chip.active {
  outline: 2px solid black;
  outline-offset: 2px;
}

.user-avatar {
  display: block;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  border: 1px solid black;
  object-fit: cover;
  position: relative;
  transition: transform .15s ease;
}

.user-avatar:hover {
  transform: scale(2);
  z-index: 10;
}

/* Cowork proposals (Einstellungen → Cowork-Vorschläge) */
.cowork-card {
    border: 1px solid #000;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #fff;
}
.cowork-card-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.cowork-why { margin: 0 0 0.5rem; }
.cowork-links { display: flex; gap: 1rem; flex-wrap: wrap; margin: 0 0 0.5rem; }
.cowork-fields input.cowork-input,
.cowork-fields textarea.cowork-input { width: 100%; box-sizing: border-box; }
.cowork-fields tr.cowork-changed td { background: #fff7d6; }
.cowork-dups {
    margin-top: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    background: #fff1e6;
}
.cowork-dup {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.35rem 0;
}
.cowork-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}
.cowork-actions .cowork-error { margin-right: auto; }

/* button under a form (e.g. lead → "Als Kunde anlegen"): spacing to the fields, right-aligned */
.crm-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.25rem;
}
