:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #697386;
  --border: #e2e8f0;
  --sidebar: #111827;
  --sidebar-soft: #1f2937;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.is-hidden {
  display: none !important;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: #8490a6;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  font-size: 24px;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.28);
}

.brand-mark-small {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 17px;
  box-shadow: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 35%),
    radial-gradient(circle at bottom right, rgba(124, 58, 237, 0.16), transparent 35%),
    #0f172a;
}

.login-card {
  width: min(100%, 460px);
  padding: 38px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
}

.login-card h1 {
  margin: 18px 0 8px;
  font-size: 30px;
}

.login-card label,
.field-grid label,
.drawer-section > label {
  display: grid;
  gap: 7px;
  margin-top: 18px;
  color: #374151;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  transition: transform 0.15s, background 0.15s, opacity 0.15s;
}

.button:hover {
  transform: translateY(-1px);
}

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

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

.button-primary:hover {
  background: var(--primary-dark);
}

.button-ghost {
  color: #334155;
  border: 1px solid var(--border);
  background: #fff;
}

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

.login-card .button {
  width: 100%;
  margin-top: 22px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  color: #e5e7eb;
  background: var(--sidebar);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 24px;
}

.sidebar-brand strong,
.sidebar-brand span,
.sidebar-account strong,
.sidebar-account span {
  display: block;
}

.sidebar-brand strong {
  font-size: 15px;
}

.sidebar-brand span,
.sidebar-account span {
  margin-top: 2px;
  color: #94a3b8;
  font-size: 11px;
}

.main-nav {
  display: grid;
  gap: 5px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: 10px;
  color: #cbd5e1;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.is-active {
  color: #fff;
  background: var(--sidebar-soft);
}

.nav-item.is-active {
  box-shadow: inset 3px 0 0 #60a5fa;
}

.nav-icon {
  width: 22px;
  text-align: center;
  color: #93c5fd;
  font-size: 17px;
}

.sidebar-spacer {
  flex: 1;
}

.secondary-nav {
  margin-bottom: 16px;
}

.sidebar-account {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid #2b3547;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.14);
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  font-size: 23px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-control {
  display: grid;
  justify-items: end;
  gap: 3px;
}

.sync-status {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.auto-refresh-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #475569;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.auto-refresh-toggle input {
  width: 14px;
  min-height: auto;
  height: 14px;
}

.search-box {
  min-width: 330px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
}

.search-box input {
  min-height: 42px;
  padding: 0;
  border: 0;
  box-shadow: none;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 11px;
  color: #334155;
  background: #fff;
  cursor: pointer;
  font-size: 20px;
}

.icon-button.is-spinning {
  animation: spin 0.9s linear infinite;
}

.content {
  padding: 26px 28px 40px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.04);
}

.metric-card .metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-card .metric-value {
  display: block;
  margin-top: 8px;
  font-size: 26px;
  font-weight: 900;
}

.metric-card .metric-help {
  display: block;
  margin-top: 6px;
  color: #94a3b8;
  font-size: 11px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(310px, 0.8fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.04);
}

.panel + .panel {
  margin-top: 18px;
}

.dashboard-grid .panel + .panel,
.settings-grid .panel + .panel {
  margin-top: 0;
}

.panel-header,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-header h2,
.section-heading h3 {
  margin: 0;
  font-size: 17px;
}

.text-button {
  padding: 0;
  color: var(--primary);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.stage-overview {
  display: grid;
  gap: 14px;
}

.stage-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) 70px;
  align-items: center;
  gap: 12px;
}

.stage-row strong,
.stage-row span {
  font-size: 12px;
}

.stage-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f7;
}

.stage-fill {
  height: 100%;
  min-width: 4px;
  border-radius: inherit;
}

.compact-list,
.data-list,
.task-list {
  display: grid;
  gap: 10px;
}

.compact-item,
.data-row,
.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-soft);
}

.compact-item button,
.data-row button,
.task-item button {
  padding: 0;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.compact-item strong,
.data-row strong,
.task-item strong {
  display: block;
  font-size: 13px;
}

.compact-item span,
.data-row span,
.task-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar select {
  width: auto;
  min-width: 160px;
  background: #fff;
}

.pipeline-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -4px 2px 10px;
  color: var(--muted);
  font-size: 11px;
}

.pipeline-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 2px 2px 22px;
  scroll-snap-type: x proximity;
  scrollbar-color: #94a3b8 #e2e8f0;
  scrollbar-width: thin;
}

.pipeline-board::-webkit-scrollbar {
  height: 11px;
}

.pipeline-board::-webkit-scrollbar-track {
  border-radius: 999px;
  background: #e2e8f0;
}

.pipeline-board::-webkit-scrollbar-thumb {
  border: 2px solid #e2e8f0;
  border-radius: 999px;
  background: #94a3b8;
}

.pipeline-column {
  min-width: 330px;
  width: 330px;
  flex: 0 0 330px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #eef2f7;
  scroll-snap-align: start;
}

.pipeline-column.is-drag-over {
  outline: 2px dashed #60a5fa;
  outline-offset: 2px;
}

.pipeline-column-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid #dbe3ed;
  background: rgba(238, 242, 247, 0.96);
  backdrop-filter: blur(8px);
}

.pipeline-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.pipeline-column-header strong {
  font-size: 13px;
}

.pipeline-column-header span {
  color: var(--muted);
  font-size: 11px;
}

.pipeline-list {
  min-height: 220px;
  max-height: calc(100vh - 278px);
  display: grid;
  align-content: start;
  gap: 10px;
  overflow-y: auto;
  padding: 10px;
}

.opportunity-card {
  position: relative;
  padding: 13px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
  cursor: pointer;
  transition: transform 0.16s, box-shadow 0.16s, border-color 0.16s;
}

.opportunity-card::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  border-radius: 12px 0 0 12px;
  content: "";
  background: #cbd5e1;
}

.opportunity-card.idle-ok::before {
  background: #22c55e;
}

.opportunity-card.idle-warning::before {
  background: #f59e0b;
}

.opportunity-card.idle-critical::before {
  background: #ef4444;
}

.opportunity-card:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.1);
}

.opportunity-card[draggable="true"] {
  cursor: grab;
}

.opportunity-card.is-dragging {
  opacity: 0.45;
}

.card-top,
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-top strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.card-phone,
.card-message,
.card-meta {
  color: var(--muted);
  font-size: 11px;
}

.card-phone {
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-message {
  min-height: 34px;
  margin: 9px 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-value {
  color: #0f766e;
  font-size: 12px;
  font-weight: 900;
}

.card-badges,
.label-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.card-context {
  display: grid;
  gap: 3px;
  margin: 10px 0;
  padding: 8px 9px;
  border-radius: 9px;
  color: #475569;
  background: #f8fafc;
  font-size: 10px;
}

.card-context span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-age.idle-warning {
  color: #b45309;
  font-weight: 800;
}

.activity-age.idle-critical {
  color: #b91c1c;
  font-weight: 900;
}

.card-task-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid #e2e8f0;
}

.card-task {
  margin-top: 5px;
  overflow: hidden;
  color: #475569;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge,
.label-chip,
.count-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
}

.badge {
  color: #475569;
  background: #f1f5f9;
}

.badge-more {
  color: #64748b;
  background: #e2e8f0;
}

.badge.urgent,
.badge.high {
  color: #991b1b;
  background: #fee2e2;
}

.badge.medium {
  color: #92400e;
  background: #fef3c7;
}

.badge.unread {
  color: #1e40af;
  background: #dbeafe;
}

.label-chip {
  color: #334155;
  background: #e2e8f0;
}

.count-badge {
  color: #334155;
  background: #f1f5f9;
}

.task-due {
  color: #92400e;
  font-size: 10px;
  font-weight: 800;
}

.task-due.overdue {
  color: #b91c1c;
}

.task-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.task-status-pending {
  color: #1e40af;
  background: #dbeafe;
}

.task-status-overdue {
  color: #991b1b;
  background: #fee2e2;
}

.task-status-done {
  color: #065f46;
  background: #d1fae5;
}

.task-status-none {
  color: #64748b;
  background: #f1f5f9;
}

.table-panel {
  padding-bottom: 8px;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  font-size: 12px;
}

th {
  color: #64748b;
  background: #f8fafc;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #f8fafc;
}

.table-contact strong,
.table-contact span {
  display: block;
}

.table-contact span {
  color: var(--muted);
  font-size: 10px;
}

.row-action {
  color: var(--primary);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.task-item.is-complete {
  opacity: 0.62;
}

.task-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.task-filter {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #475569;
  background: #fff;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.task-filter:hover,
.task-filter.is-active {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
}

.task-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.task-summary-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #f8fafc;
}

.task-summary-card strong {
  font-size: 20px;
}

.task-summary-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.task-summary-card.overdue strong {
  color: #b91c1c;
}

.task-summary-card.pending strong {
  color: #1d4ed8;
}

.task-summary-card.done strong {
  color: #047857;
}

.task-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex-wrap: wrap;
}

.task-toggle {
  padding: 6px 9px !important;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  color: #1d4ed8 !important;
  background: #eff6ff !important;
  font-size: 10px;
  font-weight: 900;
}

.task-toggle.is-done {
  border-color: #d1d5db;
  color: #475569 !important;
  background: #f8fafc !important;
}

.task-state-panel {
  min-height: 74px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.field-caption {
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.task-state-value {
  font-size: 13px;
}

.task-state-overdue {
  color: #b91c1c;
}

.task-state-done {
  color: #047857;
}

.task-state-pending {
  color: #1d4ed8;
}

.task-state-panel small {
  color: var(--muted);
  font-size: 10px;
}

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

.result-box {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  white-space: pre-wrap;
}

.definition-list {
  margin: 0 0 18px;
}

.definition-list div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.definition-list dt {
  color: var(--muted);
}

.definition-list dd {
  margin: 0;
  font-weight: 800;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s;
}

.drawer.is-open {
  pointer-events: auto;
  opacity: 1;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(760px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: -24px 0 60px rgba(15, 23, 42, 0.2);
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

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

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

.drawer-header h2 {
  margin: 0;
  font-size: 22px;
}

.drawer-header p:last-child {
  margin: 5px 0 0;
  font-size: 12px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}

.drawer-section {
  margin: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

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

.field-grid label {
  margin-top: 0;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  min-height: 42px;
  margin-top: 0 !important;
  font-weight: 700;
}

.checkbox-label input {
  width: 16px;
  min-height: auto;
  height: 16px;
}

.drawer-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.conversation-section {
  min-height: 420px;
}

.message-thread {
  max-height: 420px;
  display: grid;
  gap: 9px;
  overflow-y: auto;
  padding: 6px 2px 14px;
}

.message-bubble {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 12px;
  background: #eef2f7;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-bubble.outgoing {
  justify-self: end;
  color: #fff;
  background: #1d4ed8;
}

.message-bubble.private {
  justify-self: center;
  color: #713f12;
  background: #fef3c7;
}

.message-bubble .message-meta {
  display: block;
  margin-top: 5px;
  color: inherit;
  opacity: 0.72;
  font-size: 9px;
  text-align: right;
}

.reply-box {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.reply-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: #fff;
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(3px);
}

.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-overlay p {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
}

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

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: grid;
  gap: 8px;
}

.toast {
  min-width: 260px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 11px;
  color: #fff;
  background: #1e293b;
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 700;
}

.toast.success {
  background: #047857;
}

.toast.error {
  background: #b91c1c;
}

@media (max-width: 1100px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .sync-control {
    display: none;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .sidebar {
    padding: 14px 8px;
  }

  .sidebar-brand > div:last-child,
  .nav-item:not(.is-active) {
    font-size: 0;
  }

  .nav-item {
    justify-content: center;
    padding: 11px 8px;
  }

  .nav-icon {
    font-size: 18px;
  }

  .sidebar-account div,
  .sidebar-account .status-dot {
    display: none;
  }

  .sidebar-account {
    justify-content: center;
    min-height: 42px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .search-box {
    width: 100%;
    min-width: 0;
  }

  .topbar-actions {
    align-items: stretch;
  }

  .pipeline-column {
    min-width: 310px;
    width: 310px;
    flex-basis: 310px;
  }

  .task-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .task-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .content {
    padding: 18px;
  }
}

@media (max-width: 600px) {
  .metrics-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 14px 18px;
  }

  .toolbar select {
    width: 100%;
  }

  .pipeline-hint {
    align-items: flex-start;
    flex-direction: column;
  }

  .pipeline-column {
    min-width: calc(100vw - 112px);
    width: calc(100vw - 112px);
    flex-basis: calc(100vw - 112px);
  }

  .task-summary {
    grid-template-columns: 1fr;
  }

  .drawer-section {
    margin: 8px;
    padding: 14px;
  }
}


/* CRM V1.2 — pipeline configurável e operação rápida */
.toolbar-divider {
  width: 1px;
  align-self: stretch;
  min-height: 38px;
  background: var(--border);
}

.pipeline-board {
  height: calc(100vh - 250px);
  min-height: 480px;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 14px;
}

.pipeline-column {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  max-height: 100%;
}

.pipeline-column-header {
  flex: 0 0 auto;
}

.pipeline-column-meta {
  white-space: nowrap;
}

.pipeline-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.pipeline-empty {
  display: grid;
  place-items: center;
  min-height: 110px;
  padding: 16px;
  border: 1px dashed #cbd5e1;
  border-radius: 11px;
  color: #94a3b8;
  text-align: center;
  font-size: 11px;
}

.card-quick-actions {
  display: flex;
  gap: 5px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid #eef2f7;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity .15s, transform .15s;
}

.opportunity-card:hover .card-quick-actions,
.opportunity-card:focus-within .card-quick-actions {
  opacity: 1;
  transform: translateY(0);
}

.card-quick-action {
  width: 29px;
  height: 27px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid #dbe3ed;
  border-radius: 8px;
  color: #475569;
  background: #f8fafc;
  cursor: pointer;
  font-size: 12px;
}

.card-quick-action:hover { background: #e2e8f0; }
.card-quick-action.action-won:hover { color: #047857; background: #d1fae5; }
.card-quick-action.action-lost:hover { color: #b91c1c; background: #fee2e2; }
.card-quick-action.action-chatwoot { margin-left: auto; }

.stage-manager-list {
  display: grid;
  gap: 9px;
  margin-top: 16px;
}

.stage-manager-row {
  display: grid;
  grid-template-columns: 42px minmax(180px, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #f8fafc;
}

.stage-manager-row.is-archived { opacity: .58; }
.stage-manager-row input[type="color"] { width: 38px; height: 38px; min-height: 38px; padding: 3px; }
.stage-manager-info { display: grid; gap: 4px; }
.stage-manager-info input { min-height: 36px; padding: 8px 10px; }
.stage-manager-info code { color: var(--muted); font-size: 10px; }
.stage-manager-actions { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.icon-button-small { width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; }
.button-small { min-height: 30px; padding: 6px 9px; font-size: 10px; }
.stage-manager-form { display: grid; grid-template-columns: minmax(180px, 1fr) 52px auto; gap: 9px; margin-top: 14px; }
.stage-manager-form input[type="color"] { min-height: 42px; padding: 4px; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 18px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s;
}
.modal.is-open { pointer-events: auto; opacity: 1; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); }
.modal-card {
  position: relative;
  z-index: 1;
  width: min(500px, 100%);
  padding: 20px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.modal-header h2 { margin: 0; font-size: 20px; }
.modal-header p:last-child { margin: 5px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; }

@media (max-width: 820px) {
  .pipeline-board { height: calc(100vh - 285px); }
  .stage-manager-row { grid-template-columns: 38px 1fr; }
  .stage-manager-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 600px) {
  .toolbar-divider { display: none; }
  .card-quick-actions { opacity: 1; transform: none; }
  .stage-manager-form { grid-template-columns: 1fr 52px; }
  .stage-manager-form .button { grid-column: 1 / -1; }
}
