:root {
  color-scheme: light;
  --bg: #f5f4ef;
  --panel: rgba(255, 255, 255, 0.88);
  --line: rgba(35, 128, 195, 0.14);
  --text: #161311;
  --muted: #5b5850;
  --accent: #2580c3;
  --accent-strong: #02753c;
  --sage: #75b743;
  --mint: #2380c3;
  --rose: #e31958;
  --gold: #f4a51c;
  --red: #e11f26;
  --purple: #5a295c;
  --shadow: 0 18px 52px rgba(25, 72, 110, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(244, 165, 28, 0.22), transparent 28%),
    radial-gradient(circle at top right, rgba(37, 128, 195, 0.18), transparent 26%),
    radial-gradient(circle at 20% 80%, rgba(117, 183, 67, 0.14), transparent 24%),
    linear-gradient(180deg, #fffdfa 0%, var(--bg) 56%, #eef4f4 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 22px 28px;
}

.hero,
.spotlight,
.sidebar,
.content,
.table-card {
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 18px;
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(255, 249, 235, 0.96)),
    linear-gradient(115deg, rgba(244, 165, 28, 0.06), rgba(37, 128, 195, 0.04));
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-logo {
  width: clamp(76px, 8vw, 100px);
  height: auto;
  flex: 0 0 auto;
  filter: drop-shadow(0 8px 20px rgba(37, 128, 195, 0.12));
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  color: var(--accent);
}

.hero h1,
.section-heading h2,
.project-header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
}

.hero h1 {
  font-size: clamp(1.45rem, 2.6vw, 2.1rem);
  line-height: 1.05;
  max-width: 14ch;
}

.hero-copy,
.project-subtitle,
.meta-subtle {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.95rem;
}

.hero-actions {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 12px;
  min-width: min(380px, 100%);
}

.mobile-tabs {
  position: sticky;
  top: 10px;
  z-index: 12;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  margin-bottom: 14px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 24px rgba(37, 128, 195, 0.08);
  backdrop-filter: blur(10px);
}

.mobile-panel {
  display: none;
}

.mobile-panel.active {
  display: block;
}

.ghost-button,
.save-button,
.danger-button,
.project-card,
.mobile-tab-button,
.filter-button {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 252, 246, 0.9);
  color: var(--text);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.mobile-tab-button {
  min-height: 42px;
  padding: 10px 14px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}

.mobile-tab-button.active {
  background: linear-gradient(145deg, rgba(244, 165, 28, 0.18), rgba(37, 128, 195, 0.12));
  border-color: rgba(37, 128, 195, 0.34);
  color: var(--accent-strong);
}

.ghost-button:hover,
.save-button:hover,
.danger-button:hover,
.project-card:hover,
.mobile-tab-button:hover,
.filter-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(37, 128, 195, 0.08);
  border-color: rgba(37, 128, 195, 0.35);
}

.ghost-button {
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.meta-card {
  width: 100%;
  padding: 12px 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(240, 247, 255, 0.9));
  border: 1px solid var(--line);
}

.meta-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.meta-value {
  margin-top: 8px;
  font-weight: 600;
  line-height: 1.6;
  word-break: break-word;
}

.overview-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.project-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.metric-card {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  min-width: 0;
}

.metric-card.warm {
  background: linear-gradient(145deg, rgba(255, 245, 224, 0.98), rgba(244, 165, 28, 0.16));
}

.metric-card.sage {
  background: linear-gradient(145deg, rgba(242, 252, 233, 0.98), rgba(117, 183, 67, 0.18));
}

.metric-card.sand {
  background: linear-gradient(145deg, rgba(255, 251, 237, 0.98), rgba(244, 165, 28, 0.12));
}

.metric-card.mint {
  background: linear-gradient(145deg, rgba(237, 248, 255, 0.98), rgba(37, 128, 195, 0.16));
}

.metric-card.rose {
  background: linear-gradient(145deg, rgba(255, 241, 247, 0.98), rgba(227, 25, 88, 0.16));
}

.metric-label {
  color: var(--muted);
  font-size: 0.88rem;
}

.metric-value {
  margin-top: 6px;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}

.project-summary .metric-card {
  padding: 10px 12px;
}

.project-summary .metric-label {
  font-size: 0.8rem;
}

.project-summary .metric-value {
  font-size: clamp(0.92rem, 1.05vw, 1.02rem);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spotlight {
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 22px;
}

.risk-section {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.risk-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(245, 250, 255, 0.86));
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.risk-card-body {
  display: flex;
  gap: 12px;
  align-items: center;
}

.donut-chart {
  --donut-angle: 0deg;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: conic-gradient(var(--rose) 0deg var(--donut-angle), rgba(37, 128, 195, 0.18) var(--donut-angle) 360deg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.donut-hole {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: rgba(255, 251, 244, 0.96);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(82, 60, 44, 0.08);
}

.donut-hole strong {
  font-size: 1.15rem;
  line-height: 1;
}

.donut-hole span,
.risk-window {
  color: var(--muted);
  font-size: 0.82rem;
}

.risk-info {
  display: grid;
  gap: 10px;
}

.risk-stats,
.risk-project-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.risk-project-list {
  display: grid;
  gap: 10px;
}

.risk-project-card {
  padding: 10px 12px;
  border: 1px solid rgba(82, 60, 44, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
}

.risk-project-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.risk-project-title {
  font-weight: 700;
}

.risk-project-days {
  color: var(--rose);
  font-weight: 700;
  white-space: nowrap;
}

.risk-project-date {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.section-heading.compact {
  margin-bottom: 12px;
}

.top-unpaid-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.crm-panel {
  margin-top: 14px;
}

.crm-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.crm-sidebar {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(82, 60, 44, 0.1);
  background: rgba(255, 255, 255, 0.72);
}

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

.crm-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.crm-note {
  padding: 12px 13px;
  border-radius: 16px;
  background: rgba(37, 128, 195, 0.08);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.crm-table-card {
  min-width: 0;
  border-radius: 20px;
  border: 1px solid rgba(82, 60, 44, 0.1);
  background: rgba(255, 255, 255, 0.76);
  overflow: hidden;
}

.crm-table-wrap {
  max-height: 430px;
  overflow: auto;
}

.crm-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  table-layout: fixed;
  background: rgba(255, 255, 255, 0.65);
}

.crm-col-shop { width: 220px; }
.crm-col-phone { width: 150px; }
.crm-col-project { width: 250px; }
.crm-col-date { width: 120px; }
.crm-col-count { width: 96px; }
.crm-col-money { width: 130px; }

.crm-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 11px 10px;
  background: #f4eadc;
  text-align: left;
  font-size: 0.82rem;
  color: var(--muted);
}

.crm-table td {
  padding: 9px 10px;
  border-top: 1px solid rgba(82, 60, 44, 0.08);
  vertical-align: top;
  font-size: 0.9rem;
}

.crm-cell-shop {
  font-weight: 700;
}

.crm-cell-phone {
  white-space: nowrap;
  color: var(--accent-strong);
  font-weight: 600;
}

.crm-cell-project {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.debt-card {
  padding: 16px;
  border-radius: 22px;
  border: 1px solid rgba(227, 25, 88, 0.16);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(255, 240, 247, 0.92));
}

.debt-card-head,
.project-card-top,
.project-card-metrics,
.table-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.debt-shop,
.project-card-name {
  font-weight: 700;
}

.debt-amount {
  color: var(--rose);
  font-weight: 700;
  white-space: nowrap;
}

.debt-project,
.debt-meta,
.project-card-title,
.flash-message,
.table-meta,
.search-box span {
  color: var(--muted);
}

.debt-project,
.debt-meta {
  margin-top: 8px;
  font-size: 0.92rem;
}

.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.sidebar,
.content {
  padding: 16px;
  border-radius: 22px;
}

.project-list {
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 310px);
  overflow: auto;
  padding-right: 4px;
}

.project-card {
  width: 100%;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
}

.project-card.active {
  border-color: rgba(37, 128, 195, 0.42);
  background: linear-gradient(145deg, rgba(240, 248, 255, 0.96), rgba(255, 247, 231, 0.96));
}

.project-card-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(227, 25, 88, 0.1);
  color: var(--rose);
  font-size: 0.82rem;
}

.project-card-title {
  margin-top: 10px;
  line-height: 1.5;
  font-size: 0.94rem;
}

.project-card-metrics {
  margin-top: 12px;
  color: var(--accent-strong);
  font-weight: 600;
}

.project-actions {
  margin-top: 10px;
}

.danger-button {
  padding: 8px 12px;
  cursor: pointer;
  background: linear-gradient(145deg, rgba(255, 242, 243, 0.96), rgba(225, 31, 38, 0.14));
  border-color: rgba(225, 31, 38, 0.26);
  color: var(--red);
}

.danger-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.project-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 58%);
  gap: 16px;
  align-items: flex-start;
  min-width: 0;
}

.project-header > * {
  min-width: 0;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.search-box {
  display: grid;
  gap: 8px;
  flex: 1 1 320px;
}

.search-box input,
.cell-input {
  width: 100%;
  min-width: 0;
  padding: 7px 9px;
  border-radius: 12px;
  border: 1px solid rgba(82, 60, 44, 0.12);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font-size: 0.9rem;
}

.search-box input:focus,
.cell-input:focus {
  outline: 2px solid rgba(37, 128, 195, 0.2);
  border-color: rgba(37, 128, 195, 0.4);
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-button {
  padding: 8px 12px;
  cursor: pointer;
}

.filter-button.active {
  background: linear-gradient(145deg, rgba(244, 165, 28, 0.18), rgba(37, 128, 195, 0.12));
  border-color: rgba(37, 128, 195, 0.34);
}

.table-card {
  margin-top: 14px;
  padding: 12px;
  border-radius: 22px;
}

.table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1120px;
  table-layout: fixed;
  background: rgba(255, 255, 255, 0.78);
}

col.col-booth { width: 64px; }
col.col-shop { width: 210px; }
col.col-phone { width: 140px; }
col.col-price { width: 102px; }
col.col-fee { width: 86px; }
col.col-fee-wide { width: 96px; }
col.col-money { width: 110px; }
col.col-account { width: 98px; }
col.col-customer { width: 170px; }
col.col-status { width: 92px; }
col.col-save { width: 84px; }

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 11px 10px;
  background: #f4eadc;
  text-align: left;
  font-size: 0.82rem;
  color: var(--muted);
}

tbody td {
  padding: 8px 10px;
  border-top: 1px solid rgba(82, 60, 44, 0.08);
  vertical-align: top;
  overflow: hidden;
}

tbody tr.saving {
  opacity: 0.6;
}

.money-cell {
  white-space: nowrap;
  font-weight: 700;
  font-size: 0.88rem;
}

.money-cell.danger {
  color: var(--rose);
}

.money-cell.ok {
  color: var(--mint);
}

.save-button {
  padding: 7px 10px;
  cursor: pointer;
  min-width: 72px;
  font-size: 0.88rem;
}

.visible-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.summary-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(37, 128, 195, 0.08);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
}

.summary-chip.danger {
  background: rgba(227, 25, 88, 0.1);
  color: var(--rose);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.status-badge.paid {
  background: rgba(2, 117, 60, 0.12);
  color: var(--accent-strong);
}

.status-badge.unpaid {
  background: rgba(227, 25, 88, 0.12);
  color: var(--rose);
}

.status-badge.available {
  background: rgba(117, 183, 67, 0.14);
  color: var(--sage);
}

.status-badge.pending {
  background: rgba(244, 165, 28, 0.14);
  color: var(--gold);
}

.flash-message[data-variant="error"] {
  color: var(--rose);
}

.flash-message[data-variant="success"] {
  color: var(--mint);
}

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

.compact-empty {
  padding: 18px 12px;
  font-size: 0.92rem;
}

@media (max-width: 920px) {
  .app-shell {
    padding: 16px 12px 22px;
  }

  .mobile-tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .mobile-tab-button {
    padding: 10px 8px;
  }

  .hero {
    flex-direction: column;
    gap: 14px;
  }

  .hero-actions {
    flex-direction: column;
    min-width: 0;
  }

  .overview-strip,
  .project-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .risk-section,
  .layout,
  .crm-layout,
  .project-header {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .content,
  .spotlight,
  .risk-card {
    padding: 14px;
  }

  .project-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(240px, 82vw);
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
  }

  .project-card {
    scroll-snap-align: start;
  }

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

  .filter-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .filter-button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .table-wrap,
  .crm-table-wrap,
  .project-list,
  .filter-group {
    -webkit-overflow-scrolling: touch;
  }

  .ghost-button,
  .save-button,
  .danger-button,
  .filter-button {
    min-height: 42px;
  }

  .search-box input,
  .cell-input {
    min-height: 42px;
    font-size: 16px;
  }
}

@media (max-width: 1180px) {
  .hero {
    flex-direction: column;
  }

  .project-header {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .risk-section {
    grid-template-columns: 1fr;
  }

  .overview-strip,
  .project-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .project-list {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 18px 14px 24px;
  }

  .hero,
  .spotlight,
  .sidebar,
  .content,
  .risk-card {
    padding: 18px;
    border-radius: 24px;
  }

  .overview-strip,
  .project-summary {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .table-meta,
  .crm-stats {
    flex-direction: column;
    align-items: stretch;
  }

  .project-list {
    grid-auto-columns: minmax(220px, 88vw);
  }

  .risk-card-body {
    flex-direction: column;
    align-items: flex-start;
  }

  .donut-chart {
    width: 144px;
    height: 144px;
  }

  .donut-hole {
    width: 92px;
    height: 92px;
  }

  .filter-group {
    width: 100%;
  }

  .crm-sidebar {
    padding: 12px;
  }

  .crm-table-card {
    border: none;
    background: transparent;
  }

  .crm-table-wrap {
    max-height: none;
    overflow: visible;
  }

  .crm-table {
    min-width: 0;
    display: block;
    background: transparent;
  }

  .crm-table colgroup,
  .crm-table thead {
    display: none;
  }

  .crm-table tbody {
    display: grid;
    gap: 10px;
  }

  .crm-table tr {
    display: grid;
    gap: 8px;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid rgba(82, 60, 44, 0.08);
    background: rgba(255, 255, 255, 0.82);
  }

  .crm-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 0;
    border-top: none;
    font-size: 0.88rem;
  }

  .crm-table td::before {
    content: attr(data-label);
    flex: 0 0 92px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
  }

  .crm-cell-shop,
  .crm-cell-phone,
  .crm-cell-project,
  .crm-table td.money-cell {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    text-align: right;
  }

  .crm-cell-project {
    max-width: 62%;
  }
}

.followup-layout,
.manage-grid {
  display: grid;
  gap: 14px;
}

.followup-layout {
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  align-items: start;
}

.followup-list-card,
.contact-card,
.manage-card {
  border: 1px solid rgba(82, 60, 44, 0.1);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  padding: 14px;
  min-width: 0;
}

.panel-tools,
.stack-form,
.contact-form-grid {
  display: grid;
  gap: 12px;
}

.contact-form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.stack-field {
  display: grid;
  gap: 8px;
}

.stack-field span,
.toggle-field span {
  color: var(--muted);
  font-size: 0.88rem;
}

.stack-field.wide {
  grid-column: 1 / -1;
}

.stack-field input,
.stack-field select,
.stack-field textarea {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(82, 60, 44, 0.12);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font: inherit;
}

.stack-field textarea {
  resize: vertical;
}

.workbook-library {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.workbook-item {
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(35, 128, 195, 0.12);
  background: rgba(255, 255, 255, 0.76);
}

.workbook-item.active {
  border-color: rgba(2, 117, 60, 0.28);
  background: linear-gradient(145deg, rgba(241, 252, 243, 0.96), rgba(237, 248, 255, 0.92));
}

.workbook-item.missing {
  border-color: rgba(225, 31, 38, 0.18);
}

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

.toggle-field {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.toggle-field input {
  margin-top: 2px;
}

.followup-table-wrap {
  margin-top: 12px;
  max-height: 520px;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.followup-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  table-layout: fixed;
  background: rgba(255, 255, 255, 0.72);
}

.followup-col-project { width: 250px; }
.followup-col-shop { width: 190px; }
.followup-col-phone { width: 130px; }
.followup-col-money { width: 120px; }
.followup-col-meta { width: 170px; }
.followup-col-action { width: 140px; }
.crm-col-status { width: 120px; }

.followup-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 11px 10px;
  background: #f4eadc;
  text-align: left;
  font-size: 0.82rem;
  color: var(--muted);
}

.followup-table td {
  padding: 10px;
  border-top: 1px solid rgba(82, 60, 44, 0.08);
  vertical-align: top;
  font-size: 0.9rem;
}

.followup-table tr[data-contact-row] {
  cursor: pointer;
}

.row-stack {
  display: grid;
  gap: 4px;
}

.row-stack span {
  color: var(--muted);
  font-size: 0.84rem;
}

.row-actions,
.contact-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.contact-actions {
  margin-top: 12px;
}

.mini-button,
.export-button {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 252, 246, 0.92);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.mini-button {
  padding: 7px 10px;
  min-height: 36px;
}

.mini-button.ghost {
  background: rgba(175, 93, 56, 0.06);
}

.active-row {
  background: rgba(175, 93, 56, 0.06);
}

.contact-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-heading {
  margin-top: 14px;
}

.history-list,
.anomaly-list {
  display: grid;
  gap: 10px;
}

.history-list {
  margin-top: 12px;
}

.compact-history {
  max-height: 300px;
  overflow: auto;
}

.history-item,
.anomaly-item {
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(82, 60, 44, 0.08);
  background: rgba(255, 255, 255, 0.84);
}

.history-item.highlight {
  border-color: rgba(176, 75, 85, 0.24);
  background: linear-gradient(145deg, rgba(255, 245, 246, 0.96), rgba(255, 255, 255, 0.92));
}

.history-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.history-top span,
.history-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.history-note {
  margin-top: 6px;
  line-height: 1.5;
}

.history-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

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

.manage-card.wide {
  grid-column: span 2;
}

.export-button-grid {
  display: grid;
  gap: 10px;
}

.export-button {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  text-align: left;
}

.export-button span {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.anomaly-item.high {
  border-color: rgba(176, 75, 85, 0.24);
}

.anomaly-item.medium {
  border-color: rgba(175, 93, 56, 0.2);
}

.anomaly-item.low {
  border-color: rgba(95, 126, 104, 0.2);
}

@media (max-width: 1180px) {
  .followup-layout,
  .manage-grid {
    grid-template-columns: 1fr;
  }

  .manage-card.wide {
    grid-column: auto;
  }
}

@media (max-width: 920px) {
  .mobile-tab-button {
    font-size: 0.82rem;
    padding-inline: 6px;
  }

  .followup-layout,
  .contact-form-grid,
  .manage-grid {
    grid-template-columns: 1fr;
  }

  .followup-list-card,
  .contact-card,
  .manage-card {
    padding: 14px;
  }
}

@media (max-width: 720px) {
  .followup-table {
    min-width: 0;
    display: block;
    background: transparent;
  }

  .followup-table colgroup,
  .followup-table thead {
    display: none;
  }

  .followup-table tbody {
    display: grid;
    gap: 10px;
  }

  .followup-table tr {
    display: grid;
    gap: 8px;
    padding: 12px;
    border-radius: 16px;
    border: 1px solid rgba(82, 60, 44, 0.08);
    background: rgba(255, 255, 255, 0.82);
  }

  .followup-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 0;
    border-top: none;
    font-size: 0.88rem;
  }

  .followup-table td::before {
    content: attr(data-label);
    flex: 0 0 82px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
  }

  .history-top,
  .history-meta,
  .contact-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
