:root {
  color-scheme: light;
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  color: var(--text-primary);
  background: var(--frame);
  font-weight: 400;
  --surface: #fff;
  --surface-muted: #f8f8f7;
  --surface-hover: #f3f4f4;
  --frame: #f2f2f0;
  --text-primary: #242424;
  --text-secondary: #666663;
  --text-tertiary: #969692;
  --text-light: #b4b4af;
  --border-light: #ececea;
  --border-medium: #e2e2df;
  --border-strong: #d3d3cf;
  --accent: #2868d7;
  --accent-hover: #1f5dc8;
  --accent-subtle: #edf3ff;
  --success-subtle: #edf6ef;
  --success-text: #487754;
  --warning-subtle: #f8f3e8;
  --warning-text: #927339;
  --radius-sm: 5px;
  --radius-md: 7px;
  --radius-lg: 10px;
  --radius-pill: 999px;
  --surface-raised: #fff;
  --surface-sidebar: #fafaf9;
  --surface-subtle: #fafaf9;
  --surface-active: #ebebea;
  --surface-well: #f8f8f7;
  --surface-card: #fff;
  --segment-selected: #fff;
  --brand-bg: #252525;
  --icon: #73736e;
  --icon-strong: #4a4a46;
  --icon-faint: #aaa9a4;
  --icon-dim: #858580;
  --disabled: #c6c6c1;
  --focus-ring: #6d9ce9;
  --focus-border: #8aabe5;
  --focus-glow: #e8effb;
  --accent-border: #dce7fa;
  --accent-text: #315b9f;
  --view-dot: #6487cf;
  --note-ring: #b9cdf2;
  --warning-border: #eadfc5;
  --notice-text: #6f5726;
  --muted-dot: #b7a56f;
  --event-dot: #d9b86a;
  --success-border: #dce9de;
  --danger-text: #a45b4b;
  --danger-border: #f0dfda;
  --danger-bg: #fbefec;
  --danger-bg-soft: #fff8f6;
  --danger-hover: #a93a31;
  --avatar-blue-bg: #e5ecf7;
  --avatar-blue-fg: #4d6588;
  --avatar-peach-bg: #f4e8df;
  --avatar-peach-fg: #916750;
  --avatar-lilac-bg: #eee8f5;
  --avatar-lilac-fg: #755e8b;
  --avatar-green-bg: #e5efe5;
  --avatar-green-fg: #537653;
  --avatar-yellow-bg: #f3edda;
  --avatar-yellow-fg: #89773c;
  --avatar-rose-bg: #f4e5e7;
  --avatar-rose-fg: #8d5d65;
  --avatar-gray-bg: #e9e9e7;
  --avatar-gray-fg: #656560;
  --avatar-user-bg: #e7e4dc;
  --avatar-user-fg: #635b4d;
  --shadow-rgb: 30 30 30;
  --ring-raised: 0 0 0 0 transparent;
  --backdrop: rgb(25 25 25 / 28%);
  --bar-bg: rgb(255 255 255 / 92%);
  --code-bg: rgb(30 30 30 / 6%);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 760px;
  min-height: 100vh;
  margin: 0;
  background: var(--frame);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

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

button:disabled {
  cursor: default;
}

svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  padding: 8px;
  gap: 8px;
}

.sidebar {
  display: flex;
  width: 236px;
  min-width: 236px;
  flex-direction: column;
  padding: 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--surface-sidebar);
}

.workspace-switcher {
  display: flex;
  height: 40px;
  align-items: center;
  padding: 0 6px;
  gap: 9px;
}

.brand-mark {
  display: grid;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  place-items: center;
  border-radius: 7px;
  background: var(--brand-bg);
  color: white;
}

.brand-mark svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.5;
}

.workspace-name {
  overflow: hidden;
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.icon-button:hover,
.toolbar-button:hover,
.shortcut-button:hover,
.pagination-button:not(:disabled):hover {
  background: var(--surface-hover);
}

.icon-button svg {
  width: 16px;
  height: 16px;
}

.workspace-menu {
  width: 24px;
  height: 24px;
}

.workspace-menu svg {
  width: 14px;
  height: 14px;
}

.sidebar-navigation {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding-top: 21px;
  gap: 24px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-heading-row {
  display: flex;
  height: 24px;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
}

.nav-heading {
  margin: 0;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.small-icon-button {
  width: 22px;
  height: 22px;
  color: var(--text-tertiary);
}

.small-icon-button svg {
  width: 14px;
  height: 14px;
}

.nav-group > .nav-heading {
  padding: 0 6px;
  line-height: 24px;
}

.nav-item {
  display: flex;
  width: 100%;
  min-height: 32px;
  align-items: center;
  padding: 0 8px;
  gap: 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.nav-item.is-active {
  background: var(--surface-active);
  color: var(--text-primary);
  font-weight: 600;
}

.nav-item > svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  color: var(--icon);
}

.nav-item.is-active > svg {
  color: var(--icon-strong);
}

.nav-count {
  margin-left: auto;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 400;
}

.saved-view {
  min-height: 30px;
  padding-left: 10px;
  font-size: 12px;
}

.view-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border: 1.5px solid var(--view-dot);
  border-radius: var(--radius-pill);
}

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

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  gap: 6px;
}

.profile-button {
  display: flex;
  min-height: 48px;
  align-items: center;
  padding: 4px 5px;
  gap: 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.profile-button:hover {
  background: var(--surface-hover);
}

.avatar {
  display: inline-grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 600;
}

.avatar-user {
  background: var(--avatar-user-bg);
  color: var(--avatar-user-fg);
}

.profile-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 3px;
}

.profile-copy strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-copy > span {
  overflow: hidden;
  color: var(--text-tertiary);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-more {
  width: 15px;
  height: 15px;
  color: var(--text-tertiary);
}

.main-pane {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.page-bar {
  display: flex;
  height: 48px;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-light);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  color: var(--text-tertiary);
  gap: 7px;
  font-size: 12px;
}

.breadcrumbs svg {
  width: 12px;
  height: 12px;
  color: var(--icon-faint);
}

.breadcrumbs strong {
  color: var(--text-secondary);
  font-weight: 500;
}

.shortcut-button {
  display: flex;
  height: 30px;
  align-items: center;
  padding: 0 5px;
  gap: 7px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 12px;
}

kbd {
  padding: 2px 5px;
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--text-tertiary);
  font-family: inherit;
  font-size: 10px;
  line-height: 1.2;
}

.page-content {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 27px 28px 20px;
}

.page-heading {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.title-line {
  display: flex;
  align-items: center;
  gap: 9px;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.035em;
}

.record-count {
  display: inline-grid;
  min-width: 22px;
  height: 20px;
  place-items: center;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--text-tertiary);
  font-size: 11px;
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button {
  display: inline-flex;
  height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.button svg {
  width: 15px;
  height: 15px;
}

.button-outline {
  border-color: var(--border-medium);
  background: var(--surface);
  color: var(--text-secondary);
}

.button-outline:hover {
  background: var(--surface-muted);
}

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

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

.button-small {
  height: 28px;
  padding: 0 9px;
}

.records-surface {
  min-width: 0;
}

.view-tabs {
  display: flex;
  height: 40px;
  align-items: stretch;
  border-bottom: 1px solid var(--border-light);
  gap: 18px;
}

.view-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 12px;
}

.view-tab:hover {
  color: var(--text-primary);
}

.view-tab.is-selected {
  color: var(--text-primary);
  font-weight: 600;
}

.view-tab.is-selected::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--text-primary);
  content: "";
}

.add-view-button {
  display: inline-grid;
  width: 24px;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}

.add-view-button:hover {
  color: var(--text-primary);
}

.add-view-button svg {
  width: 14px;
  height: 14px;
}

.view-tabs-spacer {
  flex: 1;
}

.view-options {
  align-self: center;
  width: 26px;
  height: 26px;
}

.table-toolbar {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toolbar-actions,
.toolbar-end {
  display: flex;
  align-items: center;
  gap: 5px;
}

.toolbar-button {
  display: inline-flex;
  height: 30px;
  align-items: center;
  padding: 0 8px;
  gap: 7px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  list-style: none;
  white-space: nowrap;
}

.toolbar-button::-webkit-details-marker {
  display: none;
}

.toolbar-button svg {
  width: 15px;
  height: 15px;
  color: var(--text-tertiary);
}

.filter-control {
  position: relative;
}

.filter-control[open] .toolbar-button {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.filter-popover {
  position: absolute;
  z-index: 3;
  top: calc(100% + 5px);
  left: 0;
  width: 220px;
  padding: 6px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--ring-raised), 0 8px 24px rgb(var(--shadow-rgb) / 10%);
}

.popover-heading {
  margin: 3px 7px 5px;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
}

.filter-option {
  display: flex;
  width: 100%;
  min-height: 31px;
  align-items: center;
  padding: 0 7px;
  gap: 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
}

.filter-option:hover,
.filter-option.is-current {
  background: var(--surface-muted);
  color: var(--text-primary);
}

.filter-check {
  width: 14px;
  color: var(--accent);
  font-size: 12px;
}

.search-field {
  display: flex;
  width: 210px;
  height: 30px;
  align-items: center;
  padding: 0 7px;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
}

.search-field:focus-within {
  border-color: var(--focus-border);
  box-shadow: 0 0 0 2px var(--focus-glow);
}

.search-field svg {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
}

.search-field input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
}

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

.search-field input::-webkit-search-cancel-button {
  cursor: pointer;
}

.search-field kbd {
  padding: 1px 5px;
}

.columns-button {
  width: 28px;
  height: 28px;
  margin-left: 1px;
}

.selection-bar {
  display: flex;
  min-height: 38px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--accent-border);
  border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--accent-subtle);
  color: var(--accent-text);
  gap: 12px;
}

.selection-bar[hidden] {
  display: none;
}

.selection-bar span {
  font-size: 12px;
  font-weight: 500;
}

.text-button {
  padding: 3px 2px;
  border: 0;
  background: transparent;
  color: var(--accent-text);
  cursor: pointer;
  font-size: 11px;
}

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

.table-scroll {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}

.selection-bar:not([hidden]) + .table-scroll {
  border-color: var(--accent-border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.people-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
  text-align: left;
}

.people-table th {
  height: 34px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface-subtle);
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.people-table td {
  height: 48px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

.people-table tbody tr:last-child td {
  border-bottom: 0;
}

.people-table tbody tr:hover td {
  background: var(--surface-subtle);
}

.people-table tbody tr.is-checked td {
  background: var(--accent-subtle);
}

.checkbox-column {
  width: 36px;
  padding: 0 9px !important;
}

.checkbox-column input,
.row-checkbox {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.name-column {
  min-width: 185px;
}

.date-column {
  min-width: 106px;
}

.row-menu-column {
  width: 35px;
}

.person-cell {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 9px;
}

.person-cell .avatar {
  width: 28px;
  height: 28px;
  flex-basis: 28px;
}

.person-name {
  color: var(--text-primary);
  font-weight: 500;
}

.person-email {
  color: var(--text-secondary);
}

.person-company {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
}

.company-mark {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  background: var(--surface-raised);
  color: var(--icon);
  font-size: 9px;
  font-weight: 600;
}

.company-empty {
  color: var(--text-light);
}

.owner-cell {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.owner-cell .avatar {
  width: 22px;
  height: 22px;
  flex-basis: 22px;
  font-size: 9px;
}

.avatar-blue {
  background: var(--avatar-blue-bg);
  color: var(--avatar-blue-fg);
}

.avatar-peach {
  background: var(--avatar-peach-bg);
  color: var(--avatar-peach-fg);
}

.avatar-lilac {
  background: var(--avatar-lilac-bg);
  color: var(--avatar-lilac-fg);
}

.avatar-green {
  background: var(--avatar-green-bg);
  color: var(--avatar-green-fg);
}

.avatar-yellow {
  background: var(--avatar-yellow-bg);
  color: var(--avatar-yellow-fg);
}

.avatar-rose {
  background: var(--avatar-rose-bg);
  color: var(--avatar-rose-fg);
}

.avatar-gray {
  background: var(--avatar-gray-bg);
  color: var(--avatar-gray-fg);
}

.row-menu {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  opacity: 0;
}

tr:hover .row-menu,
.row-menu:focus-visible {
  opacity: 1;
}

.row-menu:hover {
  background: var(--surface-hover);
}

.row-menu svg {
  width: 15px;
  height: 15px;
}

.empty-state {
  display: flex;
  min-height: 248px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 7px;
  color: var(--text-tertiary);
}

.empty-state[hidden] {
  display: none;
}

.empty-state-icon {
  display: grid;
  width: 36px;
  height: 36px;
  margin-bottom: 3px;
  place-items: center;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--icon-dim);
}

.empty-state-icon svg {
  width: 18px;
  height: 18px;
}

.empty-state strong {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
}

.empty-state > span {
  font-size: 11px;
}

.empty-state .button {
  margin-top: 5px;
}

.table-footer {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
  color: var(--text-tertiary);
  font-size: 11px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 9px;
}

.pagination-button {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text-tertiary);
}

.pagination-button:disabled {
  color: var(--disabled);
}

.pagination-button svg {
  width: 14px;
  height: 14px;
}

.person-dialog {
  width: min(440px, calc(100vw - 32px));
  max-width: none;
  padding: 0;
  overflow: visible;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--ring-raised), 0 18px 55px rgb(var(--shadow-rgb) / 16%);
}

.person-dialog::backdrop {
  background: var(--backdrop);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 22px 16px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.dialog-header p {
  margin: 6px 0 0;
  color: var(--text-tertiary);
  font-size: 12px;
}

.dialog-close {
  margin: -5px -5px 0 0;
}

.dialog-fields {
  display: grid;
  padding: 0 22px 20px;
  gap: 13px;
}

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

.form-field > span {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
}

.form-field input {
  width: 100%;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 12px;
}

.form-field input::placeholder {
  color: var(--text-light);
}

.form-field input:focus {
  border-color: var(--focus-border);
  outline: 0;
  box-shadow: 0 0 0 2px var(--focus-glow);
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  padding: 12px 22px;
  border-top: 1px solid var(--border-light);
  gap: 8px;
}

.toast {
  position: fixed;
  z-index: 10;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 11px 14px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--ring-raised), 0 6px 20px rgb(var(--shadow-rgb) / 10%);
  color: var(--text-primary);
  opacity: 0;
  pointer-events: none;
  transform: translateY(5px);
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

.status-tag {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1;
}

.stage-proposal,
.task-in-progress {
  border-color: var(--accent-border);
  background: var(--accent-subtle);
  color: var(--accent-text);
}

.stage-negotiation {
  border-color: var(--warning-border);
  background: var(--warning-subtle);
  color: var(--warning-text);
}

.stage-closed,
.task-completed-status {
  border-color: var(--success-border);
  background: var(--success-subtle);
  color: var(--success-text);
}

.task-overdue {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
}

.task-completed {
  color: var(--text-tertiary);
  text-decoration: line-through;
}

.task-action-cell {
  width: 90px;
  text-align: right;
}

.task-action-cell form {
  margin: 0;
}

.task-toggle {
  white-space: nowrap;
}

.form-field select {
  width: 100%;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 12px;
}

.form-field select:focus {
  border-color: var(--focus-border);
  outline: 0;
  box-shadow: 0 0 0 2px var(--focus-glow);
}

@media (max-width: 1050px) {
  .sidebar {
    width: 205px;
    min-width: 205px;
  }

  .page-content {
    padding-right: 20px;
    padding-left: 20px;
  }

  .group-button {
    display: none;
  }

  .search-field {
    width: 180px;
  }
}

@media (max-width: 820px) {
  body {
    min-width: 360px;
  }

  .app-shell {
    padding: 0;
    gap: 0;
  }

  .sidebar {
    display: none;
  }

  .main-pane {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .page-bar {
    padding: 0 16px;
  }

  .page-content {
    padding: 20px 16px;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 16px;
    gap: 14px;
  }

  .heading-actions {
    width: 100%;
  }

  .heading-actions .button-primary {
    margin-left: auto;
  }

  .table-toolbar {
    align-items: flex-start;
    flex-direction: column-reverse;
    padding: 10px 0;
  }

  .toolbar-end {
    width: 100%;
  }

  .search-field {
    width: 100%;
    border-color: var(--border-light);
  }

  .table-footer {
    align-items: flex-start;
    flex-direction: column;
    padding-top: 9px;
    gap: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Дополнения для серверной версии ===== */

a.view-tab,
a.toolbar-button,
a.filter-option,
a.pagination-button,
a.button {
  text-decoration: none;
}

a.filter-option {
  color: inherit;
}

a.pagination-button[aria-disabled="true"] {
  color: var(--disabled);
  pointer-events: none;
}

.stage-lost {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
}

.toast.is-error {
  border-color: var(--danger-border);
  background: var(--danger-bg-soft);
  color: var(--danger-text);
}

.toast.is-success {
  border-color: var(--success-border);
}

.search-form {
  display: contents;
}

.logout-form {
  margin: 0;
}

.profile-menu-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.profile-menu-row .profile-button {
  flex: 1;
  min-width: 0;
}

.nav-item.is-soon {
  opacity: 0.55;
}

/* Страница входа */
.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px 16px;
  background: var(--frame);
}

.auth-card {
  width: min(380px, 100%);
  padding: 26px 24px 22px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 8px 30px rgb(var(--shadow-rgb) / 6%);
}

.auth-brand {
  display: flex;
  align-items: center;
  margin-bottom: 18px;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}

.auth-card h1 {
  margin: 0 0 4px;
  font-size: 18px;
}

.auth-card > p {
  margin: 0 0 18px;
  color: var(--text-tertiary);
}

.auth-card form {
  display: grid;
  gap: 13px;
}

.auth-card .form-field input[type="email"],
.auth-card .form-field input[type="password"] {
  width: 100%;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 12px;
}

.auth-card .form-field input:focus {
  border-color: var(--focus-border);
  outline: 0;
  box-shadow: 0 0 0 2px var(--focus-glow);
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 12px;
}

.auth-error {
  padding: 8px 10px;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-md);
  background: var(--danger-bg-soft);
  color: var(--danger-text);
  font-size: 12px;
}

.auth-card .button {
  width: 100%;
  justify-content: center;
}

/* ===== Канбан сделок ===== */

.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  gap: 2px;
}

.segmented-item {
  display: inline-flex;
  height: 24px;
  align-items: center;
  padding: 0 9px;
  gap: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  text-decoration: none;
}

.segmented-item svg {
  width: 14px;
  height: 14px;
}

.segmented-item:hover {
  color: var(--text-primary);
}

.segmented-item.is-selected {
  background: var(--segment-selected);
  box-shadow: 0 1px 2px rgb(var(--shadow-rgb) / 8%);
  color: var(--text-primary);
  font-weight: 600;
}

.kanban-board {
  display: flex;
  align-items: flex-start;
  padding: 14px 0 6px;
  gap: 12px;
  overflow-x: auto;
}

.kanban-column {
  display: flex;
  max-height: calc(100vh - 290px);
  min-height: 160px;
  flex: 0 0 280px;
  flex-direction: column;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--surface-well);
  transition:
    border-color 120ms ease,
    background 120ms ease;
}

.kanban-column.is-over {
  border-color: var(--focus-border);
  background: var(--accent-subtle);
}

.kanban-column-header {
  display: flex;
  align-items: center;
  padding: 10px 12px 8px;
  gap: 8px;
}

.kanban-column-count {
  color: var(--text-tertiary);
  font-size: 11px;
}

.kanban-column-sum {
  margin-left: auto;
  color: var(--text-secondary);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.kanban-cards {
  display: flex;
  min-height: 70px;
  flex: 1;
  flex-direction: column;
  padding: 2px 8px 8px;
  gap: 8px;
  overflow-y: auto;
}

.kanban-card {
  padding: 10px 11px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  cursor: grab;
  transition:
    box-shadow 120ms ease,
    opacity 120ms ease;
}

.kanban-card:hover {
  box-shadow: 0 2px 8px rgb(var(--shadow-rgb) / 8%);
}

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

.kanban-card.is-dragging {
  opacity: 0.4;
}

.kanban-card.is-saving {
  opacity: 0.65;
}

.kanban-card p {
  margin: 0;
}

.kanban-card-title {
  font-weight: 600;
  line-height: 1.35;
}

.kanban-card-company {
  display: flex;
  align-items: center;
  margin-top: 6px !important;
  gap: 6px;
  color: var(--text-secondary);
}

.kanban-card-meta {
  margin-top: 3px !important;
  color: var(--text-tertiary);
  font-size: 11px;
}

.kanban-card-footer {
  display: flex;
  align-items: center;
  margin-top: 10px;
  gap: 8px;
}

.kanban-card-amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.kanban-card-date {
  margin-left: auto;
  color: var(--text-tertiary);
  font-size: 11px;
}

.kanban-card-date.is-overdue {
  color: var(--danger-text);
}

.kanban-card-footer .avatar {
  flex: 0 0 auto;
}

.kanban-card-date + .avatar {
  margin-left: 0;
}

.kanban-card-amount + .avatar {
  margin-left: auto;
}

.kanban-empty {
  margin: 0;
  padding: 18px 8px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-light);
  font-size: 11px;
  text-align: center;
}

.kanban-empty[hidden] {
  display: none;
}

/* ===== Боковая карточка сделки (1/3 окна) ===== */

:root {
  --drawer-width: clamp(380px, 33.333vw, 560px);
}

.drawer {
  position: fixed;
  z-index: 6;
  top: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  width: var(--drawer-width);
  flex-direction: column;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--ring-raised), 0 10px 40px rgb(var(--shadow-rgb) / 12%);
  transform: translateX(calc(100% + 24px));
  transition: transform 180ms ease;
  visibility: hidden;
}

.drawer.is-open {
  transform: translateX(0);
  visibility: visible;
}

/* Пока панель открыта, основная область уступает ей место. */
body.has-drawer .main-pane {
  margin-right: calc(var(--drawer-width) + 8px);
}

.drawer-body,
.drawer-content {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 16px 12px 20px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}

.drawer-eyebrow {
  margin: 0 0 3px;
  color: var(--text-tertiary);
  font-size: 11px;
}

.drawer-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.drawer-scroll {
  min-height: 0;
  flex: 1;
  padding: 6px 20px 24px;
  overflow-y: auto;
}

.detail-list {
  margin: 0;
}

.detail-row {
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: start;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}

.detail-row dt {
  padding-top: 3px;
  color: var(--text-tertiary);
}

.detail-row dd {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  margin: 0;
  gap: 2px;
  overflow-wrap: anywhere;
}

.detail-strong {
  font-weight: 600;
}

.detail-sub {
  color: var(--text-tertiary);
  font-size: 11px;
}

.stage-select {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 12px;
}

.stage-select:disabled {
  opacity: 0.6;
}

.drawer-section {
  margin-top: 22px;
}

.drawer-section h3 {
  margin: 0 0 10px;
  font-size: 12px;
}

.note-form textarea {
  display: block;
  width: 100%;
  min-height: 70px;
  padding: 8px 10px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font: inherit;
  resize: vertical;
}

.note-form textarea:focus {
  border-color: var(--focus-border);
  outline: 0;
  box-shadow: 0 0 0 2px var(--focus-glow);
}

.note-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.timeline {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline::before {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 4px;
  width: 1px;
  background: var(--border-medium);
  content: "";
}

.timeline-item {
  position: relative;
  display: flex;
  padding: 0 0 14px 20px;
}

.timeline-dot {
  position: absolute;
  top: 5px;
  left: 0;
  width: 9px;
  height: 9px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--border-strong);
  box-shadow: 0 0 0 1px var(--border-medium);
}

.timeline-note .timeline-dot {
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--note-ring);
}

.timeline-event .timeline-dot {
  background: var(--event-dot);
  box-shadow: 0 0 0 1px var(--warning-border);
}

.timeline-text {
  margin: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.timeline-text.is-note {
  padding: 7px 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  white-space: pre-wrap;
}

.timeline-meta {
  margin: 3px 0 0;
  color: var(--text-tertiary);
  font-size: 11px;
}

.kanban-card.is-selected {
  border-color: var(--focus-border);
  box-shadow: 0 0 0 2px var(--focus-glow);
}

tr.is-clickable {
  cursor: pointer;
}

tr.is-clickable.is-selected td {
  background: var(--accent-subtle);
}

@media (max-width: 820px) {
  :root {
    --drawer-width: calc(100vw - 16px);
  }

  body.has-drawer .main-pane {
    margin-right: 0;
  }
}

/* Уведомление не должно перекрывать открытую боковую панель. */
body.has-drawer .toast {
  right: calc(var(--drawer-width) + 24px);
}

@media (max-width: 820px) {
  body.has-drawer .toast {
    right: 24px;
    bottom: auto;
    top: 16px;
  }
}

/* Карточка контакта: шапка, списки сделок/задач/заметок внутри drawer. */
.person-header-row {
  display: flex;
  align-items: center;
  padding: 4px 0 14px;
  gap: 12px;
}

.avatar-lg {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  font-size: 14px;
}

.person-header-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.detail-link {
  color: var(--accent);
  text-decoration: none;
}

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

.section-count {
  margin-left: 2px;
  color: var(--text-tertiary);
  font-weight: 400;
}

.drawer-record-list,
.drawer-notes-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.drawer-record-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.drawer-record-title {
  overflow-wrap: anywhere;
}

.drawer-record-title.is-done {
  color: var(--text-tertiary);
  text-decoration: line-through;
}

.drawer-record-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  color: var(--text-tertiary);
  font-size: 11px;
  gap: 8px;
}

.drawer-record-meta .status-tag {
  line-height: 1.4;
}

.note-form input[type="text"],
.note-form input[type="date"] {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font: inherit;
}

.note-form input[type="date"] {
  margin-top: 8px;
}

.note-form input:focus {
  border-color: var(--focus-border);
  outline: 0;
  box-shadow: 0 0 0 2px var(--focus-glow);
}

/* Карточка задачи: статус + кнопка переключения, описание. */
.detail-row-spaced {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}

.task-description {
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.drawer-notes-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.drawer-note-text {
  margin: 0 0 4px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ==========================================================================
   Мобильная версия (≤ 820px): нижняя навигация, шторка «Ещё», крупные
   зоны нажатия. Правила дизайна для новых экранов описаны в DESIGN.md.
   ========================================================================== */
:root {
  --tabbar-h: 58px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

.tabbar,
.crumb-brand {
  display: none;
}

.sheet {
  width: 100%;
  max-width: none;
  max-height: 85vh;
  margin: auto 0 0;
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 16px 16px 0 0;
  background: var(--surface-raised);
  box-shadow: var(--ring-raised), 0 -10px 40px rgb(var(--shadow-rgb) / 14%);
  color: var(--text-primary);
}

.sheet::backdrop {
  background: var(--backdrop);
}

.sheet[open] {
  animation: sheet-in 200ms ease-out;
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
}

.sheet-grip {
  width: 36px;
  height: 4px;
  margin: 8px auto 2px;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
}

.sheet-profile {
  display: flex;
  align-items: center;
  padding: 12px 20px 8px;
  gap: 12px;
}

.sheet-profile .avatar {
  width: 40px;
  height: 40px;
  flex-basis: 40px;
  font-size: 13px;
}

.sheet-profile-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.sheet-profile-copy strong {
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-profile-copy span {
  overflow: hidden;
  color: var(--text-tertiary);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-list {
  display: flex;
  flex-direction: column;
  padding: 4px 8px calc(12px + var(--safe-bottom));
}

.sheet-item {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  padding: 0 12px;
  gap: 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 15px;
  text-align: left;
}

.sheet-item:active {
  background: var(--surface-hover);
}

.sheet-item svg {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  color: var(--text-secondary);
}

.sheet-item.is-soon {
  color: var(--text-tertiary);
}

.sheet-badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-hover);
  color: var(--text-tertiary);
  font-size: 11px;
}

.sheet-divider {
  height: 1px;
  margin: 6px 12px;
  background: var(--border-light);
}

@media (min-width: 821px) {
  .sheet,
  .sheet::backdrop {
    display: none;
  }
}

@media (max-width: 820px) {
  body {
    min-width: 320px;
  }

  /* clip, а не hidden: иначе липкая шапка не прилипает к верху экрана. */
  .main-pane {
    overflow: clip;
  }

  .page-bar {
    position: sticky;
    z-index: 4;
    top: 0;
    height: calc(52px + var(--safe-top));
    min-height: calc(52px + var(--safe-top));
    padding-top: var(--safe-top);
    background: var(--bar-bg);
    backdrop-filter: blur(10px);
  }

  .crumb-brand {
    display: grid;
  }

  .crumb-root,
  .breadcrumbs > svg {
    display: none;
  }

  .breadcrumbs {
    gap: 10px;
  }

  .breadcrumbs strong {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
  }

  .shortcut-button {
    width: 40px;
    height: 40px;
    justify-content: center;
    margin-right: -8px;
    padding: 0;
  }

  .shortcut-button span,
  .shortcut-button kbd {
    display: none;
  }

  .shortcut-button svg {
    width: 20px;
    height: 20px;
  }

  .page-content {
    padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
  }

  .tabbar {
    position: fixed;
    z-index: 5;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    height: calc(var(--tabbar-h) + var(--safe-bottom));
    grid-template-columns: repeat(4, 1fr);
    padding: 0 4px var(--safe-bottom);
    border-top: 1px solid var(--border-light);
    background: var(--bar-bg);
    backdrop-filter: blur(12px);
  }

  .tab-item {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    gap: 3px;
    border: 0;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }

  .tab-item svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.5;
  }

  .tab-item.is-active {
    color: var(--accent);
    font-weight: 600;
  }

  .tab-item.is-active svg {
    stroke-width: 1.8;
  }

  .tab-item:active {
    color: var(--text-primary);
  }

  /* Уведомление поднимаем над нижней панелью. */
  .toast {
    right: 16px;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
    left: 16px;
    max-width: none;
  }

  /* Зоны нажатия не меньше 40px, поля не меньше 16px (иначе iOS приближает страницу). */
  .button {
    height: 40px;
    padding: 0 14px;
    font-size: 13px;
  }

  .button-small {
    height: 36px;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .search-field {
    height: 40px;
  }

  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select,
  textarea {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sheet[open] {
    animation: none;
  }
}

/* ==========================================================================
   Настройки и пользовательские поля. Базовые стили работают везде,
   правила для телефона в блоке @media (max-width: 820px) в конце.
   ========================================================================== */
:root {
  --danger: #c2453b;
  --danger-subtle: #fbecea;
}

.form-field[hidden] {
  display: none;
}

.form-field select,
.form-field textarea {
  width: 100%;
  padding: 0 9px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 12px;
}

.form-field select {
  height: 34px;
}

.form-field textarea {
  min-height: 96px;
  padding: 8px 9px;
  font-family: inherit;
  line-height: 1.45;
  resize: vertical;
}

.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--focus-border);
  outline: 0;
  box-shadow: 0 0 0 2px var(--focus-glow);
}

.form-hint {
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 1.4;
}

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

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

.icon-button.is-danger:hover {
  background: var(--danger-subtle);
  color: var(--danger);
}

.icon-button:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* Страница настроек */
.settings-tabs {
  display: inline-flex;
  margin-bottom: 20px;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius-md);
  background: var(--surface-hover);
}

.settings-tab {
  display: inline-flex;
  height: 30px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  text-decoration: none;
}

.settings-tab.is-active {
  background: var(--segment-selected);
  box-shadow: 0 1px 2px rgb(var(--shadow-rgb) / 8%);
  color: var(--text-primary);
  font-weight: 600;
}

.settings-section {
  max-width: 760px;
}

.settings-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 16px;
}

.settings-section-head h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.settings-section-head p {
  max-width: 460px;
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.5;
}

.field-list {
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  list-style: none;
}

.field-row {
  display: flex;
  align-items: center;
  padding: 12px 8px 12px 16px;
  gap: 12px;
}

.field-row + .field-row {
  border-top: 1px solid var(--border-light);
}

.field-row-main {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 4px;
}

.field-row-name {
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 600;
}

.field-row-meta {
  color: var(--text-tertiary);
  font-size: 12px;
}

.field-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.field-chip {
  max-width: 100%;
  padding: 2px 8px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--surface-hover);
  color: var(--text-secondary);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-row-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 2px;
}

.field-empty {
  padding: 28px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  text-align: center;
}

.field-empty p {
  margin: 0 0 6px;
  line-height: 1.5;
}

.field-empty strong {
  color: var(--text-primary);
}

/* Поля в карточке контакта и сделки */
.field-form {
  display: grid;
  gap: 12px;
}

.field-hint {
  margin: 14px 0 0;
  color: var(--text-tertiary);
  line-height: 1.5;
}

/* Список с множественным выбором раскрывается прямо в карточке:
   так его не обрезает прокрутка панели и удобно нажимать на телефоне. */
.multiselect > summary {
  display: flex;
  height: 34px;
  align-items: center;
  justify-content: space-between;
  padding: 0 9px;
  gap: 8px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  list-style: none;
}

.multiselect > summary::-webkit-details-marker {
  display: none;
}

.multiselect > summary svg {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  color: var(--text-tertiary);
  transition: transform 140ms ease;
}

.multiselect[open] > summary {
  border-color: var(--focus-border);
  box-shadow: 0 0 0 2px var(--focus-glow);
}

.multiselect[open] > summary svg {
  transform: rotate(180deg);
}

.multiselect-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multiselect-menu {
  max-height: 220px;
  margin-top: 6px;
  padding: 4px;
  overflow-y: auto;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.multiselect-option {
  display: flex;
  min-height: 34px;
  align-items: center;
  padding: 0 8px;
  gap: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
}

.multiselect-option:hover {
  background: var(--surface-hover);
}

.multiselect-option input {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin: 0;
  accent-color: var(--accent);
}

@media (max-width: 820px) {
  .settings-tabs {
    display: flex;
    width: 100%;
  }

  .settings-tab {
    height: 40px;
    flex: 1;
  }

  .settings-section-head {
    flex-direction: column;
  }

  .settings-section-head .button {
    width: 100%;
  }

  .field-row {
    flex-wrap: wrap;
    padding: 14px 8px 8px 16px;
  }

  .field-row-main {
    flex-basis: 100%;
  }

  .field-row-actions {
    width: 100%;
    justify-content: flex-end;
  }

  /* Окна настроек выезжают снизу, как шторка «Ещё». */
  .settings-dialog {
    width: 100%;
    max-width: none;
    max-height: 92vh;
    margin: auto 0 0;
    overflow: auto;
    border-radius: 16px 16px 0 0;
  }

  .settings-dialog[open] {
    animation: sheet-in 200ms ease-out;
  }

  .settings-dialog .dialog-footer {
    padding-bottom: calc(12px + var(--safe-bottom));
  }

  .settings-dialog .dialog-footer .button {
    flex: 1;
  }

  .form-field select,
  .form-field input:not([type="checkbox"]):not([type="radio"]) {
    height: 44px;
  }

  .form-field textarea {
    font-size: 16px;
  }

  .multiselect > summary {
    height: 44px;
  }

  .multiselect-option {
    min-height: 44px;
  }

  .multiselect-option input {
    width: 20px;
    height: 20px;
    flex-basis: 20px;
  }
}

/* Настройки → Tilda */
.notice {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  line-height: 1.55;
}

.notice-warning {
  border: 1px solid var(--warning-border);
  background: var(--warning-subtle);
  color: var(--notice-text);
}

.notice code,
.integration-steps code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--code-bg);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.copy-row {
  display: flex;
  align-items: flex-end;
  margin-bottom: 8px;
  gap: 8px;
}

.copy-row .form-field {
  min-width: 0;
  flex: 1;
}

.copy-row input {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  text-overflow: ellipsis;
}

.settings-subtitle {
  margin: 28px 0 12px;
  font-size: 13px;
  font-weight: 600;
}

.integration-steps {
  margin: 0;
  padding-left: 20px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.integration-steps li + li {
  margin-top: 6px;
}

.integration-steps strong {
  color: var(--text-primary);
  font-weight: 600;
}

.status-pill {
  flex: 0 0 auto;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-hover);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
}

.status-pill-processed {
  background: var(--success-subtle);
  color: var(--success-text);
}

.status-pill-failed {
  background: var(--danger-subtle);
  color: var(--danger);
}

.event-error {
  color: var(--danger);
  font-size: 12px;
  overflow-wrap: anywhere;
}

@media (max-width: 820px) {
  .copy-row {
    flex-direction: column;
    align-items: stretch;
  }

  .copy-row .button {
    width: 100%;
  }

  .field-list .status-pill {
    align-self: flex-start;
  }
}

/* ==========================================================================
   Тёмная тема в стиле Apple. Все различия только в переменных: правила
   компонентов одинаковы в обеих темах. Новые цвета добавляйте парой
   (светлый в :root, тёмный здесь, в обоих блоках одинаково).
   data-theme: light | dark | auto (auto следует настройкам устройства).
   ========================================================================== */
:root[data-theme="dark"] {
  color-scheme: dark;
  --frame: #000;
  --surface: #1c1c1e;
  --surface-muted: #262628;
  --surface-hover: #2a2a2c;
  --surface-raised: #2c2c2e;
  --surface-sidebar: #131315;
  --surface-subtle: #212123;
  --surface-active: #323234;
  --surface-well: #121214;
  --surface-card: #2c2c2e;
  --segment-selected: #48484a;
  --brand-bg: #3a3a3c;
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #8e8e93;
  --text-light: #636366;
  --border-light: #2c2c2e;
  --border-medium: #3a3a3c;
  --border-strong: #48484a;
  --accent: #0a84ff;
  --accent-hover: #409cff;
  --accent-subtle: rgb(10 132 255 / 16%);
  --success-subtle: rgb(48 209 88 / 15%);
  --success-text: #32d74b;
  --warning-subtle: rgb(255 159 10 / 15%);
  --warning-text: #ffb340;
  --icon: #98989d;
  --icon-strong: #d1d1d6;
  --icon-faint: #636366;
  --icon-dim: #8e8e93;
  --disabled: #48484a;
  --focus-ring: #409cff;
  --focus-border: #0a84ff;
  --focus-glow: rgb(10 132 255 / 30%);
  --accent-border: rgb(10 132 255 / 32%);
  --accent-text: #64b0ff;
  --view-dot: #409cff;
  --note-ring: rgb(10 132 255 / 50%);
  --warning-border: rgb(255 159 10 / 34%);
  --notice-text: #ffcf6b;
  --muted-dot: #b08d3a;
  --event-dot: #ffb340;
  --success-border: rgb(48 209 88 / 32%);
  --danger: #ff453a;
  --danger-subtle: rgb(255 69 58 / 16%);
  --danger-text: #ff6961;
  --danger-border: rgb(255 69 58 / 34%);
  --danger-bg: rgb(255 69 58 / 15%);
  --danger-bg-soft: rgb(255 69 58 / 11%);
  --danger-hover: #ff6961;
  --avatar-blue-bg: rgb(10 132 255 / 22%);
  --avatar-blue-fg: #7dbcff;
  --avatar-peach-bg: rgb(255 159 10 / 20%);
  --avatar-peach-fg: #ffb27a;
  --avatar-lilac-bg: rgb(191 90 242 / 22%);
  --avatar-lilac-fg: #dba8f7;
  --avatar-green-bg: rgb(48 209 88 / 20%);
  --avatar-green-fg: #6ee08b;
  --avatar-yellow-bg: rgb(255 214 10 / 18%);
  --avatar-yellow-fg: #ffe066;
  --avatar-rose-bg: rgb(255 55 95 / 20%);
  --avatar-rose-fg: #ff8fa8;
  --avatar-gray-bg: rgb(142 142 147 / 24%);
  --avatar-gray-fg: #c7c7cc;
  --avatar-user-bg: rgb(235 235 245 / 14%);
  --avatar-user-fg: #d1d1d6;
  --shadow-rgb: 0 0 0;
  --ring-raised: 0 0 0 1px rgb(255 255 255 / 8%);
  --backdrop: rgb(0 0 0 / 58%);
  --bar-bg: rgb(28 28 30 / 78%);
  --code-bg: rgb(255 255 255 / 10%);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --frame: #000;
    --surface: #1c1c1e;
    --surface-muted: #262628;
    --surface-hover: #2a2a2c;
    --surface-raised: #2c2c2e;
    --surface-sidebar: #131315;
    --surface-subtle: #212123;
    --surface-active: #323234;
    --surface-well: #121214;
    --surface-card: #2c2c2e;
    --segment-selected: #48484a;
    --brand-bg: #3a3a3c;
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #8e8e93;
    --text-light: #636366;
    --border-light: #2c2c2e;
    --border-medium: #3a3a3c;
    --border-strong: #48484a;
    --accent: #0a84ff;
    --accent-hover: #409cff;
    --accent-subtle: rgb(10 132 255 / 16%);
    --success-subtle: rgb(48 209 88 / 15%);
    --success-text: #32d74b;
    --warning-subtle: rgb(255 159 10 / 15%);
    --warning-text: #ffb340;
    --icon: #98989d;
    --icon-strong: #d1d1d6;
    --icon-faint: #636366;
    --icon-dim: #8e8e93;
    --disabled: #48484a;
    --focus-ring: #409cff;
    --focus-border: #0a84ff;
    --focus-glow: rgb(10 132 255 / 30%);
    --accent-border: rgb(10 132 255 / 32%);
    --accent-text: #64b0ff;
    --view-dot: #409cff;
    --note-ring: rgb(10 132 255 / 50%);
    --warning-border: rgb(255 159 10 / 34%);
    --notice-text: #ffcf6b;
    --muted-dot: #b08d3a;
    --event-dot: #ffb340;
    --success-border: rgb(48 209 88 / 32%);
    --danger: #ff453a;
    --danger-subtle: rgb(255 69 58 / 16%);
    --danger-text: #ff6961;
    --danger-border: rgb(255 69 58 / 34%);
    --danger-bg: rgb(255 69 58 / 15%);
    --danger-bg-soft: rgb(255 69 58 / 11%);
    --danger-hover: #ff6961;
    --avatar-blue-bg: rgb(10 132 255 / 22%);
    --avatar-blue-fg: #7dbcff;
    --avatar-peach-bg: rgb(255 159 10 / 20%);
    --avatar-peach-fg: #ffb27a;
    --avatar-lilac-bg: rgb(191 90 242 / 22%);
    --avatar-lilac-fg: #dba8f7;
    --avatar-green-bg: rgb(48 209 88 / 20%);
    --avatar-green-fg: #6ee08b;
    --avatar-yellow-bg: rgb(255 214 10 / 18%);
    --avatar-yellow-fg: #ffe066;
    --avatar-rose-bg: rgb(255 55 95 / 20%);
    --avatar-rose-fg: #ff8fa8;
    --avatar-gray-bg: rgb(142 142 147 / 24%);
    --avatar-gray-fg: #c7c7cc;
    --avatar-user-bg: rgb(235 235 245 / 14%);
    --avatar-user-fg: #d1d1d6;
    --shadow-rgb: 0 0 0;
    --ring-raised: 0 0 0 1px rgb(255 255 255 / 8%);
    --backdrop: rgb(0 0 0 / 58%);
    --bar-bg: rgb(28 28 30 / 78%);
    --code-bg: rgb(255 255 255 / 10%);
  }
}

/* Плавная смена темы: класс на несколько сотен миллисекунд ставит theme.js. */
.theme-switching,
.theme-switching *,
.theme-switching *::before,
.theme-switching *::after {
  transition:
    background-color 280ms ease,
    border-color 280ms ease,
    color 280ms ease,
    box-shadow 280ms ease,
    fill 280ms ease,
    stroke 280ms ease !important;
}

@media (prefers-reduced-motion: reduce) {
  .theme-switching,
  .theme-switching *,
  .theme-switching *::before,
  .theme-switching *::after {
    transition: none !important;
  }
}

/* Настройки → Оформление: карточки выбора темы */
.theme-options {
  display: grid;
  max-width: 760px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.theme-option {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
}

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

.theme-preview {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 2px solid var(--border-medium);
  border-radius: var(--radius-lg);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.theme-option:hover .theme-preview {
  border-color: var(--border-strong);
}

.theme-option input:checked + .theme-preview {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-glow);
}

.theme-option input:focus-visible + .theme-preview {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

.theme-option-label {
  font-size: 13px;
  font-weight: 600;
}

.theme-option input:checked ~ .theme-option-label {
  color: var(--accent);
}

.theme-option-hint {
  margin-top: -4px;
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.4;
}

/* Мини-макет интерфейса внутри карточки: цвета фиксированы для каждого варианта. */
.tp {
  --tp-frame: #f2f2f0;
  --tp-side: #fafaf9;
  --tp-main: #fff;
  --tp-line: #e2e2df;
  --tp-accent: #2868d7;
  position: absolute;
  display: grid;
  inset: 0;
  grid-template-columns: 30% 1fr;
  padding: 7px;
  gap: 5px;
  background: var(--tp-frame);
}

.tp-dark {
  --tp-frame: #000;
  --tp-side: #131315;
  --tp-main: #1c1c1e;
  --tp-line: #3a3a3c;
  --tp-accent: #0a84ff;
}

.tp-half {
  clip-path: polygon(52% 0, 100% 0, 100% 100%, 48% 100%);
}

.tp-side,
.tp-main {
  display: block;
  border-radius: 6px;
}

.tp-side {
  background: var(--tp-side);
}

.tp-main {
  display: grid;
  align-content: start;
  padding: 8px 7px;
  gap: 5px;
  background: var(--tp-main);
}

.tp-main b {
  display: block;
  height: 5px;
  border-radius: 3px;
  background: var(--tp-line);
}

.tp-main b:first-child {
  width: 38%;
  background: var(--tp-accent);
}

.tp-main b:nth-child(3) {
  width: 72%;
}

@media (max-width: 820px) {
  .theme-options {
    gap: 8px;
  }

  .theme-option-hint {
    display: none;
  }

  .theme-option-label {
    font-size: 12px;
  }
}

/* ==========================================================================
   Звонки, плеер записи и настройки МегаФон ВАТС. Цвета только через переменные.
   ========================================================================== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.settings-form {
  max-width: 560px;
}

.user-login-field {
  width: min(220px, 100%);
  flex: 0 0 auto;
}

/* Список звонков: строки, а не таблица, поэтому одинаково удобно на телефоне */
.call-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.call-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
}

.call-row:hover {
  background: var(--surface-subtle);
}

.call-row.is-selected {
  background: var(--accent-subtle);
}

.call-row:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}

.call-icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--success-subtle);
  color: var(--success-text);
}

.call-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.call-icon-missed {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.call-icon-muted {
  background: var(--surface-muted);
  color: var(--text-tertiary);
}

.call-main {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 3px;
}

.call-title {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  color: var(--text-tertiary);
  font-size: 12px;
}

.call-kind-missed {
  color: var(--danger-text);
}

.call-side {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: right;
}

.call-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-tertiary);
}

.call-rec {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

/* Звонки внутри карточек контакта, сделки и звонка */
.call-mini-list {
  display: grid;
  margin: 0;
  padding: 0;
  gap: 14px;
  list-style: none;
}

.call-mini-head,
.call-summary {
  display: flex;
  align-items: center;
  gap: 10px;
}

.call-summary {
  margin-bottom: 12px;
}

.call-mini-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

.call-mini-copy strong {
  font-size: 13px;
  font-weight: 600;
}

.call-mini-copy span {
  color: var(--text-tertiary);
  font-size: 12px;
}

.call-mini .audio-player {
  margin-top: 8px;
}

.call-note {
  margin: 6px 0 0;
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.5;
}

.call-note.is-error {
  color: var(--danger-text);
}

.call-link-row {
  margin: 0 0 10px;
  color: var(--text-secondary);
}

/* Плеер записи */
.audio-player {
  display: grid;
  align-items: center;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  padding: 8px 10px;
  gap: 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--surface-subtle);
}

.audio-play {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.audio-play:hover:not(:disabled) {
  background: var(--accent-hover);
}

.audio-play:disabled {
  cursor: default;
  opacity: 0.45;
}

.audio-play svg {
  width: 16px;
  height: 16px;
}

.audio-play .icon-play {
  fill: currentColor;
}

.audio-play .icon-pause {
  display: none;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2.4;
}

.audio-player.is-playing .icon-play {
  display: none;
}

.audio-player.is-playing .icon-pause {
  display: block;
}

.audio-wave {
  position: relative;
  height: 40px;
  min-width: 0;
  cursor: pointer;
  touch-action: none;
}

.audio-wave:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.audio-wave canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.audio-player.is-loading .audio-wave {
  opacity: 0.55;
}

.audio-player.is-error .audio-wave {
  opacity: 0.35;
}

.audio-player.is-error .audio-time::after {
  content: " · не загрузилась";
  color: var(--danger-text);
}

.audio-time {
  color: var(--text-secondary);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.audio-speed {
  min-width: 44px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.audio-speed:hover {
  background: var(--surface-hover);
}

@media (max-width: 820px) {
  .call-row {
    padding: 14px 16px;
  }

  .audio-player {
    grid-template-columns: auto minmax(0, 1fr);
    row-gap: 6px;
  }

  .audio-time {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
  }

  .audio-speed {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    height: 32px;
    min-width: 52px;
  }

  .user-login-field {
    width: 100%;
  }
}
