:root {
  --text: #202a24;
  --text-secondary: #5c6b60;
  --text-tertiary: #8b968e;

  --border: #e3f0e6;
  --border-hover: #cbe6d1;

  --surface: #ffffff;
  --surface-secondary: #f4faf5;
  --surface-hover: #eaf6ec;

  --primary: #4ab861;
  --primary-2: #2f8f49;
  --primary-hover: #3fa355;
  --primary-light: #e6f7ea;
  --primary-light-hover: #d8f2df;

  --gradient-primary: linear-gradient(135deg, #6ecf82 0%, #4ab861 55%, #2f8f49 100%);
  --gradient-soft: linear-gradient(135deg, #eaf8ee 0%, #e2f4fd 100%);

  --success-bg: #e2f2fb;
  --success-text: #0f6aa8;

  --error-bg: #fdeceb;
  --error-text: #c53a4d;

  --radius: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;

  --shadow-sm: 0 1px 2px rgba(32, 42, 36, 0.05), 0 1px 1px rgba(32, 42, 36, 0.04);
  --shadow-md: 0 6px 20px rgba(74, 184, 97, 0.16), 0 2px 6px rgba(32, 42, 36, 0.06);
  --shadow-lg: 0 14px 36px rgba(74, 184, 97, 0.22);

  --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================================================================ /
/ Base /
/ ================================================================ */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family:
    "Segoe UI Variable",
    "Segoe UI",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;

  font-size: 14px;
  line-height: 1.45;

  color: var(--text);
  background: linear-gradient(180deg, #fafcfa 0%, #f4faf5 60%, #eff8f1 100%);

  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

/* ================================================================ /
/ Task pane /
/ ================================================================ */

.taskpane {
  width: 100%;
  max-width: 640px;

  margin: 0 auto;

  padding: 16px 14px 24px;

  display: flex;
  flex-direction: column;

  gap: 14px;
}

/* ================================================================ /
/ Mail preview /
/ ================================================================ */

.mail-preview {
  position: relative;

  padding: 12px 14px 12px 16px;

  border: none;
  border-radius: var(--radius-lg);

  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.mail-preview::before {
  content: "";

  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;

  width: 3px;
  border-radius: var(--radius-pill);

  background: var(--gradient-primary);
}

.mail-preview__eyebrow {
  margin-bottom: 3px;

  font-size: 10px;
  font-weight: 700;

  color: var(--primary);

  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.mail-preview__subject {
  font-size: 14px;
  font-weight: 600;

  line-height: 1.35;

  word-break: break-word;
}

.mail-preview__from {
  margin-top: 2px;

  font-size: 12px;

  color: var(--text-secondary);

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================================================================ /
/ Tabs /
/ ================================================================ */

.tabs {
  display: flex;

  gap: 2px;

  padding: 4px;

  border: none;
  border-radius: var(--radius-pill);

  background: var(--surface-secondary);
}

.tab {
  position: relative;

  flex: 1;

  min-width: 0;

  padding: 8px 8px;

  border: none;
  border-radius: var(--radius-pill);

  background: transparent;
  color: var(--text-secondary);

  font-size: 12px;
  font-weight: 600;

  cursor: pointer;

  transition:
    color var(--transition),
    background var(--transition),
    box-shadow var(--transition);
}

.tab:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.tab--active {
  color: #fff;
  background: var(--gradient-primary);
  box-shadow: var(--shadow-md);
}

.tab--active:hover {
  color: #fff;
  background: var(--gradient-primary);
}

.tab:focus-visible {
  outline: none;

  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 4px var(--primary);
}

/* ================================================================ /
/ Tab panels /
/ ================================================================ */

.tab-panel {
  min-height: 180px;

  display: flex;
  flex-direction: column;

  gap: 12px;
}

[hidden] {
  display: none !important;
}

/* ================================================================ /
/ Generic states /
/ ================================================================ */

.state {
  display: flex;
  align-items: center;

  gap: 12px;

  padding: 14px;

  border: none;
  border-radius: var(--radius-lg);

  font-size: 13px;

  box-shadow: var(--shadow-sm);
}

.state > div:last-child {
  display: flex;
  flex-direction: column;

  min-width: 0;
}

.state strong {
  font-weight: 600;
  color: var(--text);
}

.state span {
  margin-top: 1px;
  color: var(--text-secondary);
}

.state--loading {
  background: var(--surface);
  color: var(--text-secondary);
}

.state--empty {
  background: var(--gradient-soft);
}

.state--error {
  background: var(--error-bg);
  color: var(--error-text);

  box-shadow: none;
}

.state--error strong,
.state--error span {
  color: var(--error-text);
}

.state__icon {
  width: 32px;
  height: 32px;

  display: flex;
  align-items: center;
  justify-content: center;

  flex-shrink: 0;

  border-radius: 50%;

  background: var(--surface);
  color: var(--primary);

  font-size: 16px;

  box-shadow: var(--shadow-sm);
}

/* ================================================================ /
/ Spinner /
/ ================================================================ */

.spinner {
  width: 16px;
  height: 16px;

  flex: 0 0 16px;

  border: 2.5px solid var(--primary-light);
  border-top-color: var(--primary);

  border-radius: 50%;

  animation: spin 0.65s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ================================================================ /
/ Company header /
/ ================================================================ */

.company-header {
  display: flex;
  align-items: center;

  gap: 12px;

  padding: 12px 14px;

  border: none;
  border-radius: var(--radius-lg);

  background: var(--surface);
  box-shadow: var(--shadow-sm);

  cursor: pointer;

  transition:
    transform var(--transition),
    box-shadow var(--transition);
}

.company-header:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.company-header:focus-visible {
  outline: none;

  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 4px var(--primary);
}

.company-header__icon {
  width: 34px;
  height: 34px;

  display: flex;
  align-items: center;
  justify-content: center;

  flex-shrink: 0;

  border-radius: 10px;

  background: var(--gradient-primary);
  color: #fff;

  font-size: 13px;
  font-weight: 700;

  box-shadow: var(--shadow-sm);
}

.company-header__content {
  min-width: 0;

  display: flex;
  flex-direction: column;
}

.company-header__label {
  font-size: 10px;
  font-weight: 700;

  color: var(--text-tertiary);

  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.company-header__name {
  margin-top: 1px;

  font-size: 14px;
  font-weight: 600;

  color: var(--text);

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================================================================ /
/ Tree sections /
/ ================================================================ */

.tree-section {
  display: flex;
  flex-direction: column;

  gap: 8px;
}

.tree-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 10px;

  padding: 8px 10px;

  border-radius: var(--radius);

  cursor: pointer;
  user-select: none;

  transition: background var(--transition);
}

.tree-section__header:hover {
  background: var(--surface-hover);
}

.tree-section__header:focus-visible {
  outline: none;

  box-shadow: 0 0 0 2px var(--primary);
}

.tree-section__header > div {
  min-width: 0;
}

.tree-section h2,
.section-heading h2 {
  margin: 0;

  font-size: 12px;
  font-weight: 700;
  margin-top: 2px;

  color: var(--text);

  text-transform: uppercase;
  letter-spacing: 0.035em;
}

.tree-section__header span:not(.tree-section__count):not(.tree-section__chevron),
.section-heading span {
  display: block;

  margin-top: 1px;

  font-size: 11px;

  color: var(--text-tertiary);
}

.tree-section__count {
  display: flex;
  align-items: center;
  justify-content: center;

  min-width: 22px;
  height: 20px;
   margin-top: 0 !important;

  /* padding: 0 7px; */

  border-radius: var(--radius-pill);

  background: var(--primary-light);
  color: var(--primary-2);

  font-size: 11px;
  font-weight: 700;
}

.tree-section__chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  flex-shrink: 0;

  width: 18px;
  height: 18px;

  color: var(--text-tertiary);
  font-size: 12px;

  transition: transform 180ms ease;
}

/* ================================================================ /
/ Cards /
/ ================================================================ */

.card-list {
  display: flex;
  flex-direction: column;

  gap: 7px;
}

.card-item {
  position: relative;

  width: 100%;

  display: flex;
  flex-direction: column;

  padding: 11px 13px 11px 15px;

  border: none;
  border-radius: var(--radius);

  background: var(--surface);

  color: var(--text);

  text-align: left;

  cursor: pointer;

  box-shadow: var(--shadow-sm);

  transition:
    transform var(--transition),
    box-shadow var(--transition),
    background var(--transition);
}

.card-item::before {
  content: "";

  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;

  width: 3px;
  border-radius: var(--radius-pill);

  background: transparent;

  transition: background var(--transition);
}

.card-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.card-item:focus-visible {
  outline: none;

  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 4px var(--primary);
}

.card-item--selected {
  background: var(--primary-light);
  box-shadow: var(--shadow-md);
}

.card-item--selected::before {
  background: var(--gradient-primary);
}

.card-item__title {
  display: block;

  font-size: 13px;
  font-weight: 600;

  line-height: 1.35;

  word-break: break-word;
}

.card-item__meta {
  display: block;

  margin-top: 4px;

  font-size: 11px;
  line-height: 1.35;

  color: var(--text-secondary);

  word-break: break-word;
}

/* ================================================================ /
/ Search /
/ ================================================================ */

.section-heading {
  padding: 2px;
}

.section-heading h2 {
  font-size: 14px;

  text-transform: none;
  letter-spacing: normal;
}

.search-field {
  position: relative;

  display: flex;
  align-items: center;
}

.search-field__icon {
  position: absolute;
  left: 13px;

  color: var(--text-tertiary);

  font-size: 16px;

  pointer-events: none;
}

.search-field input {
  width: 100%;

  height: 40px;

  padding: 0 36px 0 34px;

  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);

  background: var(--surface);

  color: var(--text);

  outline: none;

  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.search-field input::placeholder {
  color: var(--text-tertiary);
}

.search-field input:focus {
  border-color: var(--primary);

  box-shadow: 0 0 0 4px var(--primary-light);
}

.search-field__spinner {
  position: absolute;
  right: 13px;
}

/* ================================================================ /
/ Search results /
/ ================================================================ */

.company-results {
  max-height: 220px;

  margin: 0;
  padding: 4px;

  overflow-y: auto;

  list-style: none;

  border-radius: var(--radius-lg);
}

.company-results__item {
  padding: 11px 12px;

  border-radius: var(--radius);

  cursor: pointer;

  font-size: 13px;
  font-weight: 500;

  transition:
    background var(--transition),
    padding-left var(--transition);
}

.company-results__item:hover {
  background: var(--primary-light-hover);
  padding-left: 15px;
}

.company-results__empty {
  padding: 10px 11px;

  color: var(--text-tertiary);

  font-size: 12px;
}

/* ================================================================ /
/ Manual fields /
/ ================================================================ */

.manual-fields {
  display: flex;
  flex-direction: column;

  gap: 12px;

  padding-top: 4px;
}

.field {
  display: flex;
  flex-direction: column;

  gap: 5px;
}

.field label {
  font-size: 11px;
  font-weight: 700;

  color: var(--text-secondary);
}

.field input,
.field select {
  width: 100%;

  height: 40px;

  padding: 0 11px;

  border: 1.5px solid var(--border);
  border-radius: var(--radius);

  background: var(--surface);

  color: var(--text);

  outline: none;

  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.field input:focus,
.field select:focus {
  border-color: var(--primary);

  box-shadow: 0 0 0 4px var(--primary-light);
}

/* ================================================================ /
/ Action area /
/ ================================================================ */

.action-area {
  display: flex;
  flex-direction: column;

  gap: 10px;

  padding: 14px 0 0;

  border-top: 1px solid var(--border);
}

.selected-target {
  display: flex;
  align-items: center;

  gap: 8px;

  min-width: 0;

  padding: 9px 8px 9px 12px;

  border-radius: var(--radius);

  background: var(--gradient-soft);
}

.selected-target__label {
  flex-shrink: 0;

  font-size: 10px;
  font-weight: 700;

  color: var(--primary-2);

  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.selected-target__value {
  flex: 1;
  min-width: 0;

  color: var(--text);

  font-size: 12px;
  font-weight: 500;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-target__clear {
  flex-shrink: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 22px;
  height: 22px;

  border: none;
  border-radius: 50%;

  background: rgba(255, 255, 255, 0.7);
  color: var(--text-secondary);

  font-size: 12px;
  line-height: 1;

  cursor: pointer;

  transition:
    background var(--transition),
    color var(--transition);
}

.selected-target__clear:hover {
  background: #fff;
  color: var(--error-text);
}

/* ================================================================ /
/ Confirm button /
/ ================================================================ */

.confirm-btn {
  width: 100%;

  height: 42px;

  padding: 0 14px;

  border: none;
  border-radius: var(--radius-pill);

  background: var(--gradient-primary);
  color: #fff;

  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;

  cursor: pointer;

  box-shadow: var(--shadow-md);

  transition:
    box-shadow var(--transition),
    transform var(--transition),
    opacity var(--transition);
}

.confirm-btn:hover:not(:disabled) {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.confirm-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.confirm-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* ================================================================ /
/ Status /
/ ================================================================ */

.status {
  min-height: 0;

  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

.status.success,
.status.error {
  padding: 9px 12px;

  border-radius: var(--radius);
}

.status.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.status.error {
  background: var(--error-bg);
  color: var(--error-text);
}

/* ================================================================ /
/ Responsive /
/ ================================================================ */

@media (min-width: 560px) {
  .taskpane {
    padding: 20px 22px 28px;
  }

  .card-list {
    display: grid;

    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
}

@media (max-width: 300px) {
  .taskpane {
    padding: 12px 10px 20px;
  }

  .tab {
    padding-left: 4px;
    padding-right: 4px;

    font-size: 11px;
  }

  .company-header {
    padding: 10px;
  }

  .card-item {
    padding: 10px;
  }
}

/* ================================================================ /
/ Status badges /
/ ================================================================ */

.badge {
  display: inline-flex;
  align-items: center;

  max-width: 200px;

  padding: 0.35em 0.9em;

  border-radius: var(--radius-pill);

  font-size: 0.72em;
  font-weight: 600;
  line-height: 1.3;

  text-align: center;
  white-space: nowrap;

  box-sizing: border-box;

  margin-top: 5px;
}

.bg-label-primary {
  background-color: #4438c1 !important;
  color: #eae8fd !important;
}

.bg-label-warning {
  background-color: #ff9f43 !important;
  color: #fff1e3 !important;
}

.bg-label-success {
  background-color: #28c76f !important;
  color: #dff7e9 !important;
}

.bg-label-danger {
  background-color: #ea5455 !important;
  color: #ffe6e6 !important;
}

.section-arrow {
  display: flex;
}


/* ================================================================ /
/ People tree /
/ ================================================================ */

.people-tree {
  display: flex;
  flex-direction: column;

  gap: 18px;

  margin: 0;
  padding: 0;
}


/* ---------------------------------------------------------------- /
/ Person node /
/ ---------------------------------------------------------------- */

.person-tree-node {
  display: block;

  margin: 0;
  padding: 0;

  border: none;
  border-radius: 0;

  background: transparent;
  box-shadow: none;
}

.person-tree-node__header {
  display: flex;
  align-items: center;

  gap: 8px;

  padding: 6px 6px 10px 2px;

  border-bottom: 1px solid var(--border);

  cursor: pointer;
  user-select: none;

  border-radius: var(--radius);

  transition: background var(--transition);
}

.person-tree-node__header:hover {
  background: var(--surface-hover);
}

.person-tree-node__header:focus-visible {
  outline: none;

  box-shadow: 0 0 0 2px var(--primary);
}

.person-tree-node__chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  flex-shrink: 0;

  width: 16px;
  height: 16px;

  color: var(--text-tertiary);
  font-size: 11px;

  transition: transform 180ms ease;
}

.person-tree-node__icon {
  flex-shrink: 0;

  width: 28px;
  height: 28px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 9px;

  background: var(--gradient-primary);

  font-size: 13px;

  box-shadow: var(--shadow-sm);
}

.person-tree-node__info {
  min-width: 0;

  display: flex;
  flex-direction: column;
}

.person-tree-node__name {
  font-size: 13px;
  font-weight: 700;

  color: var(--text);

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-tree-node__id {
  margin-top: 1px;

  font-size: 9px;

  color: var(--text-tertiary);
}

.person-tree-node__empty {
  padding: 8px 2px;

  font-size: 11px;

  color: var(--text-tertiary);
}


/* ---------------------------------------------------------------- /
/ Person -> companies /
/ ---------------------------------------------------------------- */

.person-tree-node__companies {
  display: flex;
  flex-direction: column;

  gap: 9px;

  margin: 10px 0 0 13px;
  padding: 2px 0 2px 15px;

  border-left: 2px solid var(--primary-light);

  background: transparent;
  border-radius: 0;
  box-shadow: none;
}


/* ---------------------------------------------------------------- /
/ Company node /
/ ---------------------------------------------------------------- */

.company-tree-node {
  display: flex;
  flex-direction: column;

  gap: 6px;

  padding: 8px;

  border: none;
  border-radius: var(--radius-lg);

  background: var(--surface);

  box-shadow: var(--shadow-sm);

  transition: box-shadow var(--transition);
}

.company-tree-node:hover {
  box-shadow: var(--shadow-md);
}


/* Company header (compact, inside a company node) */

.company-tree-node .company-header {
  display: flex;
  align-items: center;

  gap: 9px;

  width: 100%;
  min-width: 0;

  padding: 7px 9px;

  border: none;
  border-radius: 10px;

  background: var(--gradient-soft);

  box-shadow: none;

  text-decoration: none;
  cursor: pointer;

  transition:
    background var(--transition),
    transform var(--transition);
}

.company-tree-node .company-header:hover {
  background: var(--primary-light-hover);
  transform: translateY(-1px);
}

.company-tree-node .company-header:focus-visible {
  outline: none;

  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 4px var(--primary);
}

.company-tree-node .company-header__icon {
  width: 26px;
  height: 26px;

  flex-shrink: 0;

  border-radius: 8px;

  font-size: 11px;

  box-shadow: none;
}

.company-tree-node .company-header__content {
  min-width: 0;
  flex: 1;

  display: flex;
  flex-direction: column;
}

.company-tree-node .company-header__label {
  font-size: 8px;
  font-weight: 700;

  color: var(--primary-2);

  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.company-tree-node .company-header__name {
  display: block;

  margin-top: 0;

  font-size: 12px;
  font-weight: 700;

  line-height: 1.25;

  color: var(--text);

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-tree-node .company-header__id {
  display: block;

  margin-top: 1px;

  font-size: 9px;

  color: var(--text-tertiary);
}


/*
 * "Standalone" company-search result: not nested under a
 * person, so it's the sole focus of the view — give it the
 * same prominence as the rest of the app's cards instead of
 * the compact sizing used when nested three levels deep under
 * a person.
 */

.company-tree-node--standalone {
  padding: 12px;
}

.company-tree-node--standalone .company-header {
  padding: 10px 12px;
}

.company-tree-node--standalone .company-header__icon {
  width: 34px;
  height: 34px;

  border-radius: 10px;

  font-size: 15px;
}

.company-tree-node--standalone .company-header__label {
  font-size: 10px;
}

.company-tree-node--standalone .company-header__name {
  font-size: 14px;
}

.company-tree-node--standalone .company-header__id {
  font-size: 10px;
}

.company-tree-node--standalone > .tree-section {
  margin-left: 6px;
  padding-left: 12px;
}

.company-tree-node--standalone > .tree-section h2 {
  font-size: 12px;
}

.company-tree-node--standalone > .tree-section .card-item__title {
  font-size: 13px;
}


/* Company -> offers / commercial proposals */

.company-tree-node > .tree-section {
  margin-left: 4px;
  padding-left: 10px;

  border-left: 1px dashed var(--border);
}

.company-tree-node > .tree-section .tree-section__header {
  min-height: 30px;

  padding: 4px 6px;

  gap: 6px;

  border-radius: 7px;
}

.company-tree-node > .tree-section .tree-section__header:hover {
  background: var(--surface-hover);
}

.company-tree-node > .tree-section h2 {
  font-size: 10px;
  line-height: 1.2;
}

.company-tree-node > .tree-section .tree-section__header span:not(.tree-section__count):not(.tree-section__chevron) {
  margin-top: 0;

  font-size: 9px;
  line-height: 1.15;
}

.company-tree-node > .tree-section .tree-section__count {
  min-width: 19px;
  height: 17px;

  padding: 0 5px;

  font-size: 9px;
}

.company-tree-node > .tree-section .tree-section__chevron {
  width: 15px;
  height: 15px;

  font-size: 10px;
}

.company-tree-node > .tree-section .card-list {
  display: flex;
  flex-direction: column;

  gap: 5px;

  padding-left: 3px;
}

.company-tree-node > .tree-section .card-item {
  position: relative;

  width: 100%;

  display: flex;
  flex-direction: column;

  gap: 4px;

  padding: 8px 10px 8px 12px;

  border: none;
  border-radius: 9px;

  background: var(--surface-secondary);

  box-shadow: none;

  transition:
    background var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
}

.company-tree-node > .tree-section .card-item::before {
  border-radius: var(--radius-pill);
}

.company-tree-node > .tree-section .card-item:hover {
  background: var(--surface-hover);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.company-tree-node > .tree-section .card-item--selected {
  background: var(--primary-light);
  box-shadow: var(--shadow-sm);
}

.company-tree-node > .tree-section .card-item--selected::before {
  background: var(--gradient-primary);
}

.company-tree-node > .tree-section .card-item__title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  word-break: break-word;
}

.company-tree-node > .tree-section .card-item__meta {
  margin-top: 1px;

  font-size: 10px;
  line-height: 1.2;

  color: var(--text-secondary);

  word-break: break-word;
}

.company-tree-node > .tree-section .badge {
  align-self: flex-start;

  min-height: 19px;
  width: fit-content;
  max-width: 100%;

  padding: 3px 9px;

  font-size: 10px;

  white-space: normal;
  overflow-wrap: anywhere;
}


/* ---------------------------------------------------------------- /
/ Mobile /
/ ---------------------------------------------------------------- */

@media (max-width: 420px) {
  .person-tree-node__companies {
    margin-left: 8px;
    padding-left: 11px;

    gap: 7px;
  }

  .company-tree-node {
    padding: 6px;
    gap: 5px;
  }

  .company-tree-node > .tree-section {
    padding-left: 8px;
  }

  .company-tree-node .company-header {
    padding: 6px 7px;
  }

  .company-tree-node > .tree-section .card-item {
    padding: 7px 8px 7px 10px;
  }
}


/* ================================================================ /
/ Create contact /
/ ================================================================ */

.create-person {
  display: flex;
  flex-direction: column;

  gap: 12px;

  padding: 14px;

  border: 1px dashed var(--border-hover);
  border-radius: var(--radius-lg);

  background: var(--surface);
}

.create-person__heading {
  padding: 0 2px;
}

.create-person__heading h2 {
  margin: 0;

  font-size: 13px;
  font-weight: 700;

  color: var(--text);
}

.create-person__heading span {
  display: block;

  margin-top: 2px;

  font-size: 11px;

  color: var(--text-tertiary);
}

.create-person .manual-fields {
  padding-top: 0;
}

.create-person__submit {
  height: 38px;

  font-size: 12px;
}


/* ================================================================
   CRM PEOPLE / COMPANY TREE
   Clean enterprise CRM hierarchy
   ================================================================ */

.people-tree {
  display: flex;
  flex-direction: column;
  gap: 24px;

  margin: 0;
  padding: 0;
}


/* ----------------------------------------------------------------
   PERSON
   ---------------------------------------------------------------- */

.person-tree-node {
  display: block;

  margin: 0;
  padding: 0;

  border: none;
  background: transparent;
  box-shadow: none;
}


/* Person header = subtle section anchor */

.person-tree-node__header {
  display: flex;
  align-items: center;

  gap: 9px;

  min-height: 36px;
  padding: 4px 2px 9px;

  border-bottom: 1px solid var(--border);

  cursor: pointer;
  user-select: none;

  transition:
    color var(--transition),
    border-color var(--transition);
}

.person-tree-node__header:hover {
  background: transparent;
}

.person-tree-node__header:focus-visible {
  outline: none;

  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 4px var(--primary);
}


/* Person chevron */

.person-tree-node__chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  flex: 0 0 18px;

  width: 18px;
  height: 18px;

  color: var(--text-tertiary);

  font-size: 13px;

  transition: transform 180ms ease;
}


/* Person icon */

.person-tree-node__icon {
  display: flex;
  align-items: center;
  justify-content: center;

  flex: 0 0 26px;

  width: 26px;
  height: 26px;

  border-radius: 7px;

  background: var(--primary-light);
  color: var(--primary-2);

  font-size: 12px;
  font-weight: 700;

  box-shadow: none;
}


/* Person information */

.person-tree-node__info {
  min-width: 0;

  display: flex;
  flex-direction: column;
  justify-content: center;
}

.person-tree-node__name {
  font-size: 13px;
  font-weight: 650;

  line-height: 1.25;

  color: var(--text);

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-tree-node__id {
  margin-top: 2px;

  font-size: 10px;
  line-height: 1.2;

  color: var(--text-tertiary);
}

.person-tree-node__empty {
  padding: 10px 0;

  font-size: 11px;

  color: var(--text-tertiary);
}


/* ----------------------------------------------------------------
   PERSON → COMPANIES
   ---------------------------------------------------------------- */

.person-tree-node__companies {
  display: flex;
  flex-direction: column;

  gap: 18px;

  margin: 0;
  padding: 14px 0 0 27px;

  border: none;

  background: transparent;
}


/* ----------------------------------------------------------------
   COMPANY
   ---------------------------------------------------------------- */

.company-tree-node {
  display: flex;
  flex-direction: column;

  gap: 0;

  padding: 0;

  border: 1px solid var(--border);
  border-radius: 9px;

  background: var(--surface);

  box-shadow: none;

  overflow: hidden;

  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.company-tree-node:hover {
  border-color: var(--border-hover);

  box-shadow: var(--shadow-sm);
}


/* ----------------------------------------------------------------
   COMPANY HEADER
   ---------------------------------------------------------------- */

.company-tree-node .company-header {
  display: flex;
  align-items: center;

  gap: 10px;

  width: 100%;
  min-width: 0;

  padding: 11px 13px;

  border: none;
  border-radius: 0;

  background: var(--surface);

  box-shadow: none;

  text-decoration: none;
  cursor: pointer;

  transition:
    background var(--transition);
}

.company-tree-node .company-header:hover {
  background: var(--surface-secondary);

  transform: none;
}

.company-tree-node .company-header:focus-visible {
  outline: none;

  box-shadow:
    inset 0 0 0 2px var(--primary);
}


/* Company icon */

.company-tree-node .company-header__icon {
  display: flex;
  align-items: center;
  justify-content: center;

  flex: 0 0 30px;

  width: 30px;
  height: 30px;

  border-radius: 7px;

  background: var(--primary-light);
  color: var(--primary-2);

  font-size: 12px;
  font-weight: 700;

  box-shadow: none;
}


/* Company content */

.company-tree-node .company-header__content {
  min-width: 0;
  flex: 1;

  display: flex;
  flex-direction: column;
}

.company-tree-node .company-header__label {
  margin-bottom: 1px;

  font-size: 9px;
  font-weight: 700;

  color: var(--text-tertiary);

  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.company-tree-node .company-header__name {
  display: block;

  margin: 0;

  font-size: 13px;
  font-weight: 650;

  line-height: 1.3;

  color: var(--text);

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-tree-node .company-header__id {
  display: block;

  margin-top: 2px;

  font-size: 9px;

  color: var(--text-tertiary);
}


/* ----------------------------------------------------------------
   COMPANY → SECTIONS
   ---------------------------------------------------------------- */

.company-tree-node > .tree-section {
  margin: 0;
  padding: 0;

  border: none;

  border-top: 1px solid var(--border);
}


/* ----------------------------------------------------------------
   SECTION HEADER
   ---------------------------------------------------------------- */

.company-tree-node > .tree-section .tree-section__header {
  display: flex;
  align-items: center;

  min-height: 34px;

  padding: 7px 12px;

  gap: 8px;

  border-radius: 0;

  background: #fafcfa;

  cursor: pointer;

  transition:
    background var(--transition);
}

.company-tree-node > .tree-section .tree-section__header:hover {
  background: var(--surface-secondary);
}

.company-tree-node > .tree-section .tree-section__header:focus-visible {
  outline: none;

  box-shadow: inset 0 0 0 2px var(--primary);
}


/* Section title */

.company-tree-node > .tree-section h2 {
  margin: 0;

  font-size: 10px;
  font-weight: 700;

  line-height: 1.25;

  color: var(--text-secondary);

  text-transform: uppercase;
  letter-spacing: 0.055em;
}


/* Section subtitle */

.company-tree-node > .tree-section
.tree-section__header span:not(.tree-section__count):not(.tree-section__chevron) {
  margin: 0;

  font-size: 10px;
  line-height: 1.2;

  color: var(--text-tertiary);
}


/* Count */

.company-tree-node > .tree-section .tree-section__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 18px;
  height: 18px;

  padding: 0 5px;

  border: 1px solid var(--border);

  border-radius: 5px;

  background: var(--surface);
  color: var(--text-secondary);

  font-size: 9px;
  font-weight: 700;
}


/* Chevron */

.company-tree-node > .tree-section .tree-section__chevron {
  width: 16px;
  height: 16px;

  margin-left: auto;

  color: var(--text-tertiary);

  font-size: 11px;
}


/* ----------------------------------------------------------------
   OFFER / PROPOSAL LIST
   ---------------------------------------------------------------- */

.company-tree-node > .tree-section .card-list {
  display: flex;
  flex-direction: column;

  gap: 0;

  padding: 0;
}


/* Individual record */

.company-tree-node > .tree-section .card-item {
  position: relative;

  width: 100%;

  display: flex;
  flex-direction: column;

  gap: 3px;

  min-height: 46px;

  padding: 9px 12px 9px 17px;

  border: none;
  border-top: 1px solid var(--border);

  border-radius: 0;

  background: var(--surface);

  box-shadow: none;

  color: var(--text);

  cursor: pointer;

  transition:
    background var(--transition),
    padding-left var(--transition);
}


/* Remove card-like hover movement */

.company-tree-node > .tree-section .card-item:hover {
  background: var(--surface-secondary);

  box-shadow: none;

  transform: none;

  padding-left: 20px;
}


/* Small status/accent indicator */

.company-tree-node > .tree-section .card-item::before {
  content: "";

  position: absolute;

  left: 8px;
  top: 13px;
  bottom: 13px;

  width: 2px;

  border-radius: 2px;

  background: transparent;

  transition: background var(--transition);
}

.company-tree-node > .tree-section .card-item:hover::before {
  background: var(--border-hover);
}


/* Selected record */

.company-tree-node > .tree-section .card-item--selected {
  background: var(--primary-light);

  box-shadow: none;
}

.company-tree-node > .tree-section .card-item--selected::before {
  background: var(--primary);
}


/* Record title */

.company-tree-node > .tree-section .card-item__title {
  display: block;

  font-size: 12px;
  font-weight: 600;

  line-height: 1.3;

  color: var(--text);

  word-break: break-word;
}


/* Record metadata */

.company-tree-node > .tree-section .card-item__meta {
  display: block;

  margin: 0;

  font-size: 10px;
  line-height: 1.25;

  color: var(--text-secondary);

  word-break: break-word;
}


/* ----------------------------------------------------------------
   STATUS BADGES
   ---------------------------------------------------------------- */

.company-tree-node > .tree-section .badge {
  align-self: flex-start;

  min-height: 18px;
  width: fit-content;
  max-width: 100%;

  margin-top: 4px;

  padding: 2px 7px;

  border: 1px solid transparent;
  border-radius: 4px;

  font-size: 9px;
  font-weight: 600;
  line-height: 1.3;

  white-space: normal;
  overflow-wrap: anywhere;
}


/* ----------------------------------------------------------------
   STANDALONE COMPANY
   ---------------------------------------------------------------- */

.company-tree-node--standalone {
  padding: 0;
}

.company-tree-node--standalone .company-header {
  padding: 13px 14px;
}

.company-tree-node--standalone .company-header__icon {
  width: 32px;
  height: 32px;

  border-radius: 7px;

  font-size: 13px;
}

.company-tree-node--standalone .company-header__label {
  font-size: 9px;
}

.company-tree-node--standalone .company-header__name {
  font-size: 14px;
}

.company-tree-node--standalone .company-header__id {
  font-size: 10px;
}

.company-tree-node--standalone > .tree-section {
  margin: 0;
  padding: 0;
}


/* ----------------------------------------------------------------
   EMPTY COMPANY
   ---------------------------------------------------------------- */

.company-tree-node .tree-section:has(.card-list:empty) {
  display: none;
}


/* ----------------------------------------------------------------
   MOBILE
   ---------------------------------------------------------------- */

@media (max-width: 420px) {

  .people-tree {
    gap: 20px;
  }

  .person-tree-node__companies {
    padding-left: 12px;
    padding-top: 12px;

    gap: 14px;
  }

  .company-tree-node .company-header {
    padding: 10px 11px;
  }

  .company-tree-node > .tree-section .tree-section__header {
    padding-left: 10px;
    padding-right: 10px;
  }

  .company-tree-node > .tree-section .card-item {
    padding-left: 15px;
  }

  .company-tree-node > .tree-section .card-item:hover {
    padding-left: 18px;
  }
}