:root {
  --bg: #eaf1fb;
  --panel: #f6f9ff;
  --panel-strong: #e3ecfb;
  --ink: #17253a;
  --muted: #4f6a8b;
  --accent: #1c5fd1;
  --accent-2: #0b8fc3;
  --line: rgba(23, 37, 58, 0.12);
  --shadow: 0 18px 40px rgba(23, 37, 58, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Verdana", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 20%, rgba(214, 232, 255, 0.9), transparent 45%),
    radial-gradient(circle at 90% 10%, rgba(179, 216, 255, 0.7), transparent 45%),
    var(--bg);
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.brand-logo-image {
  width: 78px;
  height: 78px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand-title {
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 24px;
  letter-spacing: 0.5px;
}

.brand-sub {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
}

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

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 0 0 auto;
}

.tab.active {
  background: var(--panel-strong);
  border-color: var(--line);
  color: var(--ink);
}

.top-meta {
  text-align: right;
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.view-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
}

.view-label {
  font-weight: 700;
  color: var(--ink);
}

.user-name {
  font-weight: 700;
  color: var(--ink);
}

.top-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.top-value {
  font-size: 20px;
  font-weight: 700;
}

#contact-count {
  color: var(--accent);
}

.page {
  display: none;
  padding: 24px 28px 40px;
}

.page.active {
  display: block;
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 0.9fr) minmax(380px, 1.12fr);
  gap: 20px;
  align-items: start;
}

.sidebar,
.content,
.timeline {
  background: var(--panel);
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 18px;
}

.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-toggle {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.filter-toggle.active {
  background: rgba(11, 143, 195, 0.16);
  color: var(--accent-2);
  border-color: rgba(11, 143, 195, 0.35);
}

.search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
}

.search-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  gap: 10px;
  flex-wrap: wrap;
}

.search-hint {
  font-size: 12px;
  color: var(--muted);
}

.search-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
}

.search-actions .btn {
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.add-contact-btn {
  font-size: 24px;
  line-height: 1;
  padding-bottom: 2px;
}

.segmented {
  display: flex;
  margin-top: 14px;
  background: var(--panel-strong);
  border-radius: 999px;
  padding: 4px;
}

.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
}

.seg-btn.active {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.list {
  margin-top: 16px;
  max-height: calc(100vh - 280px);
  overflow: auto;
  padding-right: 4px;
}

.list-item {
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.list-item:hover {
  border-color: var(--line);
}

.list-item.active {
  background: var(--panel-strong);
  border-color: var(--line);
}

.list-name {
  font-weight: 700;
}

.list-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.content {
  padding: 18px 20px;
}

.detail-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.glyph {
  font-size: 28px;
  margin-bottom: 10px;
}

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

.detail-name {
  margin: 0;
  font-size: 28px;
  font-family: "Georgia", "Times New Roman", serif;
}

.detail-org {
  margin: 6px 0 0;
  color: var(--muted);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.detail-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
  justify-content: flex-end;
}

.tag {
  background: rgba(11, 143, 195, 0.16);
  color: var(--accent-2);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.tag-warn {
  background: rgba(220, 80, 40, 0.14);
  color: #c0392b;
}

.tag-ok {
  background: rgba(39, 174, 96, 0.14);
  color: #27ae60;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.info-card {
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--line);
}

.info-card-products {
  grid-column: 1 / -1;
}

.info-card-inline {
  display: flex;
  flex-direction: column;
}

.info-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.info-value {
  margin-top: 6px;
  font-weight: 600;
  word-break: break-word;
}

.inline-field-row {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-field-input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  font: inherit;
  color: var(--ink);
}

.inline-field-input[readonly] {
  background: rgba(23, 37, 58, 0.04);
  color: var(--ink);
  cursor: default;
}

.inline-field-toggle {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
}

.classify {
  margin-top: 18px;
  padding: 16px;
  background: var(--panel-strong);
  border-radius: 16px;
}

.classify-grid {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.classify-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 600;
}

.classify-pill.active {
  border-color: var(--accent);
  color: var(--accent);
}

.products-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.product-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 600;
  cursor: pointer;
}

.product-pill input {
  margin: 0;
}

.product-pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(11, 143, 195, 0.08);
}

.settings-product-pill {
  cursor: default;
  color: var(--ink);
}

.product-token-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.product-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  border: none;
  font-weight: 700;
  font-size: 13px;
}

.product-chip-sm {
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  gap: 0;
}

.product-input {
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

.product-remove {
  border: none;
  background: transparent;
  color: #b42318;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.settings-products-grid {
  margin-top: 14px;
}

.classify-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.note-block {
  margin-top: 20px;
  padding: 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
}

.note-title {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 12px;
  color: var(--muted);
}

.dashboard-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.audit-contact {
  font-weight: 700;
}

.audit-contact-id {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.detail-id {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

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

.edit-grid label,
.panel-form label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
  gap: 6px;
}

.switch {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.switch.push-right {
  margin-left: auto;
}

.switch-label {
  font-size: 12px;
}

.switch-knob {
  width: 34px;
  height: 18px;
  border-radius: 999px;
  background: rgba(23, 37, 58, 0.12);
  position: relative;
  transition: all 0.2s ease;
}

.switch-knob::after {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  box-shadow: 0 2px 6px rgba(23, 37, 58, 0.2);
  transition: all 0.2s ease;
}

.switch.on {
  background: rgba(11, 143, 195, 0.16);
  color: var(--accent-2);
  border-color: rgba(11, 143, 195, 0.4);
}

.switch.on .switch-knob {
  background: rgba(11, 143, 195, 0.45);
}

.switch.on .switch-knob::after {
  left: 18px;
}

.edit-grid input,
.panel-form input,
textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  background: #fff;
}

select {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  background: #fff;
}

.edit-notes {
  display: flex;
  flex-direction: column;
  margin-top: 12px;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.edit-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.timeline {
  padding: 16px;
  position: sticky;
  top: 92px;
  height: calc(100vh - 120px);
  overflow: auto;
}

.panel-tabs {
  display: flex;
  gap: 8px;
}

.panel-tab {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 8px 10px;
  background: var(--panel-strong);
  color: var(--muted);
  cursor: pointer;
}

.panel-tab.active {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.panel-body {
  display: none;
  margin-top: 14px;
}

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

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 12px;
}

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

.data-table tr.clickable {
  cursor: pointer;
}

.data-table tr.clickable:hover {
  background: var(--panel-strong);
}

.empty-row {
  color: var(--muted);
  text-align: center;
}

.btn {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn.ghost.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.lead-switch {
  background: #dbeafe;
  border-color: #155eef;
  color: #155eef;
}

.lead-switch .switch-knob {
  background: #155eef;
}

.lead-switch.on {
  background: #fde3e3;
  border-color: #b42318;
  color: #b42318;
}

.lead-switch.on .switch-knob {
  background: #b42318;
}

.lead-badge {
  display: inline-flex;
  align-items: center;
  margin-right: 8px;
  margin-bottom: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}

.lead-badge-hot {
  background: #fde3e3;
  color: #b42318;
}

.lead-badge-cold {
  background: #dbeafe;
  color: #155eef;
}

.btn.mini {
  padding: 6px 10px;
  font-size: 11px;
}

.btn.danger {
  background: #b42318;
  color: #fff;
  border-color: #b42318;
}

.btn.ghost.danger {
  background: #b42318;
  color: #fff;
  border-color: #b42318;
}

.btn.ghost.danger:hover,
.btn.danger:hover {
  background: #911c12;
  border-color: #911c12;
}

.detail-edit-actions {
  align-items: center;
}

.save-status {
  font-size: 12px;
  color: var(--muted);
}

.followup-btn-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  justify-content: center;
}

.followup-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.followup-icon-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 3px 10px rgba(0,0,0,0.18);
}

.followup-icon-btn.draft {
  background: var(--panel-strong, #eee);
  color: var(--ink);
}

.followup-icon-btn.send {
  background: #2563eb;
  color: #fff;
}

.followup-icon-btn.cancel {
  background: #b42318;
  color: #fff;
}

.followup-draft-modal-card {
  width: min(680px, 92vw) !important;
  max-height: 85vh;
  overflow-y: auto;
}

.followup-draft-modal-card textarea {
  min-height: 220px;
  max-height: 50vh;
  resize: vertical;
  field-sizing: content;
}

.followup-actions {
  white-space: nowrap;
}

.track-view-toggle {
  max-width: 260px;
  margin: 12px 0 10px;
}

.exchange-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.exchange-row-text {
  min-width: 0;
  flex: 1;
}

.exchange-delete-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 8px;
}

.exchange-delete-btn:hover {
  color: #c0392b;
  background: rgba(192, 57, 43, 0.08);
}

.followup-error {
  margin-top: 4px;
  color: #b42318;
}

.followup-table {
  table-layout: fixed;
  width: 100%;
}

.followup-table th,
.followup-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 5px 4px;
  font-size: 11px;
}

.followup-table th:nth-child(1) { width: 35%; }
.followup-table th:nth-child(2) { width: 30%; }
.followup-table th:nth-child(3) { width: 15%; }
.followup-table th:nth-child(4) { width: 20%; }

.dashboard {
  background: var(--panel);
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 24px;
  box-shadow: var(--shadow);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.dash-card {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--line);
}

.dash-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.dash-value {
  font-size: 20px;
  font-weight: 700;
  margin-top: 8px;
}

.mail-layout,
.sms-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 20px;
}

.prospection {
  background: var(--panel);
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 24px;
  box-shadow: var(--shadow);
}

.prospect-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(0, 1.6fr) minmax(0, 1.4fr);
  gap: 20px;
}

.table-shell,
.drafts {
  background: var(--panel);
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 20px;
  box-shadow: var(--shadow);
}

.mail-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.settings {
  background: var(--panel);
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 24px;
  box-shadow: var(--shadow);
}

.settings-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  margin-top: 16px;
}

.settings-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-section {
  background: #f8f9fc;
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.settings-meta {
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 8px 10px;
  border-radius: 10px;
}

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

.settings-inline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  align-items: end;
}

.settings-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-card.ghost {
  background: var(--panel);
}

.collab-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.collab-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  background: var(--panel-strong);
  color: var(--muted);
}

.badge.ok {
  background: rgba(11, 143, 195, 0.16);
  color: var(--accent-2);
}

.badge.warn {
  background: rgba(28, 95, 209, 0.16);
  color: var(--accent);
}
.settings-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.settings-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.edit-actions.compact {
  margin: 0;
}

@media (max-width: 1100px) {
  .settings-shell {
    grid-template-columns: 1fr;
  }
  .settings-split {
    grid-template-columns: 1fr;
  }
}

.improve-grid {
  grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr);
  align-items: start;
}

.improve-table th,
.improve-table td {
  vertical-align: top;
}

.admin-only {
  display: none;
}

.admin-only.admin-visible {
  display: revert !important;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  background: var(--panel-strong);
  color: var(--muted);
  white-space: nowrap;
}

.status-proposee {
  background: rgba(28, 95, 209, 0.16);
  color: var(--accent);
}

.status-en-cours {
  background: rgba(11, 143, 195, 0.16);
  color: var(--accent-2);
}

.status-fait {
  background: rgba(31, 143, 95, 0.16);
  color: #1f8f5f;
}

.status-annulee {
  background: rgba(176, 65, 62, 0.16);
  color: #b0413e;
}

.improve-actions {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn.mini {
  padding: 4px 10px;
  font-size: 11px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.signature-preview {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 12px;
  min-height: 160px;
}

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

.draft-subject {
  font-weight: 700;
  margin-bottom: 6px;
}

.draft-body {
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
  margin-bottom: 8px;
}

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

.draft-status {
  font-size: 12px;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(23, 37, 58, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}

.modal.active {
  display: flex;
}

.modal-card {
  background: #fff;
  border-radius: 18px;
  padding: 20px;
  width: min(520px, 92vw);
  box-shadow: var(--shadow);
}

#mail-modal .modal-card {
  width: min(720px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
}

#sms-direct-modal .modal-card {
  width: min(640px, 92vw);
}

#mail-modal #mail-body {
  min-height: 200px;
  max-height: 50vh;
  resize: vertical;
  field-sizing: content;
}

#login-modal .modal-card,
#password-modal .modal-card {
  width: min(420px, 92vw);
}

.auth-card {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 249, 242, 0.95), #fff);
}

.auth-header {
  margin-bottom: 12px;
}

.auth-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.auth-sub {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

.auth-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.auth-input {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px 14px;
  font-family: inherit;
}

.auth-actions {
  align-items: center;
}

.modal-label {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.modal-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.modal-save {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.ia-direct-toolbar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.ia-direct-toolbar .edit-notes {
  flex: 1;
}

.ia-direct-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  border-color: rgba(28, 95, 209, 0.35);
  color: var(--accent);
}

.icon-btn.recording {
  background: rgba(220, 80, 40, 0.12);
  border-color: rgba(220, 80, 40, 0.35);
  color: #c0392b;
}

.modal-body {
  white-space: pre-wrap;
  font-size: 13px;
  color: var(--ink);
  margin-top: 10px;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: none;
}

.toast.active {
  display: block;
}

.improve-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffd55f, #ffb703);
  color: #5b3b00;
  box-shadow: 0 18px 36px rgba(91, 59, 0, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 15;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.improve-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 42px rgba(91, 59, 0, 0.28);
  filter: saturate(1.05);
}

.improve-fab.active {
  background: linear-gradient(135deg, #fff1b8, #ffd55f);
  box-shadow: 0 22px 44px rgba(91, 59, 0, 0.34);
}

.improve-fab-icon {
  font-size: 28px;
  line-height: 1;
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .timeline {
    position: static;
    height: auto;
  }

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

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

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

@media (max-width: 768px) {
  .topbar {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
  }

  .brand,
  .user-meta,
  .view-banner,
  .top-meta {
    width: 100%;
  }

  .tabs {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  .tabs::-webkit-scrollbar {
    height: 6px;
  }

  .page {
    padding: 16px 16px 28px;
  }

  .layout {
    gap: 16px;
  }

  .sidebar,
  .content,
  .timeline,
  .dashboard,
  .prospection,
  .settings,
  .table-shell,
  .drafts {
    padding: 16px;
  }

  .sidebar {
    order: 1;
  }

  .content {
    order: 2;
  }

  .timeline {
    order: 3;
    top: auto;
  }

  .list {
    max-height: none;
  }

  .search-row,
  .detail-header,
  .mail-actions,
  .settings-header,
  .collab-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-actions,
  .detail-actions,
  .detail-tags,
  .panel-actions,
  .edit-actions,
  .draft-actions,
  .modal-actions {
    justify-content: flex-start;
  }

  .info-grid,
  .edit-grid,
  .settings-inline,
  .settings-shell,
  .settings-split,
  .prospect-grid,
  .mail-layout,
  .sms-layout,
  .improve-grid {
    grid-template-columns: 1fr;
  }

  .detail-name {
    font-size: 24px;
  }

  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .data-table thead,
  .data-table tbody,
  .data-table tr {
    width: max-content;
    min-width: 100%;
  }

  .modal {
    padding: 12px;
  }

  .modal-card {
    width: 100%;
    max-height: calc(100vh - 24px);
    overflow: auto;
    padding: 16px;
  }

  .improve-fab {
    right: 16px;
    bottom: 16px;
    width: 58px;
    height: 58px;
  }
}

@media (max-width: 480px) {
  .brand-title {
    font-size: 21px;
  }

  .top-value {
    font-size: 18px;
  }

  .tab,
  .btn,
  .btn.ghost {
    min-height: 42px;
  }

  .search input,
  .edit-grid input,
  .panel-form input,
  textarea,
  select,
  .auth-input {
    font-size: 16px;
  }

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