* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: rgba(37, 99, 235, 0.08);
  --success: #16a34a;
  --success-light: rgba(22, 163, 74, 0.1);
  --warning: #d97706;
  --warning-light: rgba(217, 119, 6, 0.1);
  --danger: #dc2626;
  --danger-light: rgba(220, 38, 38, 0.1);
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-focus: #2563eb;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --header-height: 68px;
  --footer-height: 48px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: var(--header-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

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

.header-titles {
  min-width: 0;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-subtitle {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.status-indicator.saved {
  background: var(--success-light);
  color: var(--success);
}

.status-indicator.saved .status-dot {
  background: var(--success);
}

.status-indicator.modified {
  background: var(--warning-light);
  color: var(--warning);
}

.status-indicator.modified .status-dot {
  background: var(--warning);
}

.status-indicator.loading {
  background: var(--primary-light);
  color: var(--primary);
}

.status-indicator.loading .status-dot {
  background: var(--primary);
  animation: pulse 1.5s infinite;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.status-text {
  font-size: 12px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: var(--font);
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
  color: var(--text);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: 100%;
  color: var(--text-secondary);
  font-size: 14px;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.columns-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.card-help {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.card-help code {
  font-size: 12px;
  padding: 1px 5px;
  background: var(--primary-light);
  border-radius: 4px;
  color: var(--primary);
  font-family: var(--font);
}

/* ── Form Elements ── */
.input-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  background: var(--card-bg);
  resize: vertical;
  transition: border-color 0.15s;
  line-height: 1.5;
}

.input-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-textarea:disabled {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
}

.char-count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.input-text, .input-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  background: var(--card-bg);
  transition: border-color 0.15s;
}

.input-text:focus, .input-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-select {
  cursor: pointer;
  appearance: auto;
}

.field-group {
  margin-bottom: 16px;
}

.field-group:last-child {
  margin-bottom: 0;
}

.field-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-group.half {
  flex: 1;
  min-width: 0;
}

.field-error {
  display: none;
  font-size: 11px;
  color: var(--danger);
  margin-top: 4px;
}

.field-error.visible {
  display: block;
}

/* ── Toggle Switch ── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}

.toggle-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 24px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.toggle-switch input:focus-visible + .toggle-slider {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.settings-divider {
  border-top: 1px solid var(--border);
  margin: 10px 0 6px;
}

.field-group select[disabled],
.field-group select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Days Grid ── */
.days-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.day-btn {
  width: 44px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

.day-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.day-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.day-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Preview Tabs ── */
.preview-tabs {
  display: flex;
  gap: 4px;
}

.preview-tab {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

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

.preview-tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Chat Preview ── */
.chat-preview {
  background: #e8f0fe;
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
  min-height: 120px;
  max-height: 360px;
  overflow-y: auto;
}

.chat-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.chat-message.received {
  background: #fff;
  color: var(--text);
  border-bottom-left-radius: 4px;
  margin-right: auto;
}

.chat-message .msg-sector {
  display: block;
  padding: 6px 0;
}

.chat-message .sector-option {
  display: block;
  padding: 2px 0;
  color: var(--text);
}

.chat-message .sector-instruction {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Footer ── */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: var(--footer-height);
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.footer-items {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
  flex-wrap: wrap;
}

.footer-item {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.footer-status {
  font-weight: 500;
}

.footer-status.ok {
  color: var(--success);
}

.footer-status.err {
  color: var(--danger);
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toastIn 0.25s ease-out;
  max-width: 400px;
}

.toast.toast-success {
  background: var(--success);
}

.toast.toast-error {
  background: var(--danger);
}

.toast.toast-warning {
  background: var(--warning);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── Responsive ── */
@media (max-width: 860px) {
  .columns-layout {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }

  .app-header {
    padding: 0 16px;
    flex-wrap: wrap;
    height: auto;
    min-height: var(--header-height);
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .header-right {
    width: 100%;
    justify-content: flex-end;
  }

  .header-subtitle {
    display: none;
  }

  .app-footer {
    padding: 0 16px;
    flex-wrap: wrap;
    height: auto;
    min-height: var(--footer-height);
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .footer-items {
    gap: 12px;
  }
}

/* ── Header Tabs ── */
.header-nav {
  display: flex;
  gap: 4px;
  margin: 0 16px;
  flex-shrink: 0;
}

.header-tab {
  padding: 6px 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
  white-space: nowrap;
}

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

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

.header-tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Tab Panels ── */
.tab-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
}

/* ── Sectors Page ── */
.sectors-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 0;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.sectors-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.sectors-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  padding: 20px 24px 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

.sectors-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
}

.sectors-preview {
  position: sticky;
  top: 20px;
  align-self: start;
}

.sectors-preview .chat-preview {
  min-height: 200px;
  max-height: 500px;
}

/* ── Sector Card ── */
.sector-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: start;
  transition: border-color 0.15s;
}

.sector-card:hover {
  border-color: var(--primary-light);
}

.sector-card.reorder-mode {
  border-color: var(--warning);
  border-style: dashed;
}

.sector-number-badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.sector-info {
  min-width: 0;
}

.sector-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.sector-description {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  line-height: 1.4;
}

.sector-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.sector-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sector-meta-item svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.sector-meta-item.meta-warning {
  color: var(--warning);
}

.sector-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  align-items: center;
}

.sector-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-size: 14px;
  font-family: var(--font);
}

.sector-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--text-muted);
}

.sector-btn.sector-btn-edit:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.sector-btn.sector-btn-duplicate:hover {
  background: var(--warning-light);
  color: var(--warning);
  border-color: var(--warning);
}

.sector-btn.sector-btn-delete:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger);
}

.sector-btn.sector-btn-move:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
}

.badge-active {
  background: var(--success-light);
  color: var(--success);
}

.badge-inactive {
  background: var(--bg);
  color: var(--text-muted);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  font-family: var(--font);
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-body {
  padding: 20px 24px;
}

.modal-body .field-group {
  margin-bottom: 16px;
}

.modal-body .field-group:last-child {
  margin-bottom: 0;
}

.modal-body .char-count {
  display: block;
  text-align: right;
  margin-top: 2px;
}

.modal-body .field-error {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--danger);
}

.modal-body .field-error.visible {
  display: block;
}

.required {
  color: var(--danger);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 24px 20px;
}

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 8px;
}

.empty-state-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ── Responsive ── */
/* ── Integrations Page ── */
.integrations-page {
  padding: 24px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.integrations-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 8px;
}

.integrations-grid .card {
  padding: 24px;
}

.integration-status {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.integration-status.status-not-configured {
  background: var(--bg);
  color: var(--text-muted);
}

.integration-status.status-connected {
  background: var(--success-light);
  color: var(--success);
}

.integration-status.status-error {
  background: var(--danger-light);
  color: var(--danger);
}

.integration-status.status-testing {
  background: var(--primary-light);
  color: var(--primary);
}

.password-field {
  display: flex;
  gap: 4px;
  align-items: stretch;
}

.password-field .input-text {
  flex: 1;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.password-toggle {
  width: 40px;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--card-bg);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-size: 14px;
  font-family: var(--font);
}

.password-toggle:hover {
  background: var(--bg);
  color: var(--text-secondary);
}

.field-help {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.integration-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.integration-actions .btn {
  font-size: 12px;
  padding: 7px 14px;
}

.integrations-save-row {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.integrations-save-row .btn {
  font-size: 14px;
  padding: 12px 32px;
}

.integration-summary {
  display: flex;
  gap: 20px;
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}

.summary-item {
  font-size: 12px;
  color: var(--text-secondary);
}

.summary-label {
  font-weight: 600;
  color: var(--text);
}

.evolution-instance-wrapper {
  position: relative;
}

/* ── Chatwoot notice in sectors modal ── */
.chatwoot-notice {
  display: block;
  padding: 8px 12px;
  margin-top: 4px;
  background: var(--warning-light);
  color: var(--warning);
  border-radius: var(--radius-sm);
  font-size: 11px;
  line-height: 1.4;
}

@media (max-width: 860px) {
  .app-header {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--header-height);
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .header-nav {
    order: 3;
    width: 100%;
    justify-content: center;
    margin: 8px 0 0;
  }

  .sectors-header {
    flex-direction: column;
    padding: 16px 16px 0;
  }

  .sectors-actions {
    width: 100%;
  }

  .sectors-actions .btn {
    flex: 1;
    justify-content: center;
  }

  .sectors-layout {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }

  .sectors-preview {
    position: static;
  }

  .sector-card {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .sector-actions {
    justify-content: flex-end;
  }

  .header-right {
    width: auto;
  }
}

/* ── Reception Page ── */
.reception-page {
  padding: 24px;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

.reception-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 8px 0 24px;
}

.rcard {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rcard-action {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.rcard-action .btn {
  align-self: stretch;
  justify-content: center;
}

.rcard-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.rcard-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.rcard-value-status {
  font-size: 16px;
}

.rcard-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
}

.rcard-status-on {
  background: var(--success-light);
  color: var(--success);
}

.rcard-status-off {
  background: var(--bg);
  color: var(--text-muted);
}

.reception-list {
  min-height: 100px;
}

.reception-list-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reception-item {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 2fr auto auto;
  gap: 16px;
  align-items: center;
  transition: border-color 0.15s;
}

.reception-item:hover {
  border-color: var(--primary-light);
}

.ri-phone {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.ri-message {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ri-time {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.ri-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

@media (max-width: 860px) {
  .reception-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .reception-item {
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .ri-message {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@media (max-width: 480px) {
  .reception-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .header-right {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .btn {
    padding: 7px 14px;
    font-size: 12px;
  }

  .day-btn {
    width: 38px;
    height: 32px;
    font-size: 11px;
  }
}

/* ── WhatsApp Provider Section ── */
.card-whatsapp {
  border-left: 3px solid var(--primary);
}

.provider-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.provider-option {
  cursor: pointer;
}

.provider-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.provider-option-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  transition: all 0.15s;
}

.provider-option-box strong {
  font-size: 14px;
  color: var(--text);
}

.provider-option-box small {
  font-size: 11px;
  color: var(--text-muted);
}

.provider-option-box code {
  font-size: 11px;
  background: var(--bg);
  padding: 1px 4px;
  border-radius: 4px;
}

.provider-option input[type="radio"]:checked + .provider-option-box {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 1px var(--primary);
}

.provider-option input[type="radio"]:focus-visible + .provider-option-box {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.whatsapp-status-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.whatsapp-status-text {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── QR Code Modal ── */
.whatsapp-qr-status {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-secondary);
}

.whatsapp-qr-status.status-connected {
  background: var(--success-light);
  color: var(--success);
}

.whatsapp-qr-status.status-testing {
  background: var(--primary-light);
  color: var(--primary);
}

.whatsapp-qr-status.status-error {
  background: var(--danger-light);
  color: var(--danger);
}

.whatsapp-qr-status.status-disconnected {
  background: var(--danger-light);
  color: var(--danger);
}

.whatsapp-qr-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}

.whatsapp-qr-box img {
  max-width: 260px;
  max-height: 260px;
  width: 100%;
  height: auto;
}

.whatsapp-qr-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  width: 100%;
  color: var(--text-muted);
  font-size: 13px;
}

.whatsapp-pairing-code {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: var(--text-secondary);
  word-break: break-all;
}

/* ── Auth / Login ── */
#authRoot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-secondary);
  font-size: 14px;
}

.login-screen {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
}

.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 400px;
  padding: 32px;
}

.login-brand {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo {
  font-size: 42px;
  line-height: 1;
}

.login-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin-top: 10px;
  letter-spacing: 0.03em;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.login-error {
  display: none;
  padding: 10px 12px;
  margin-bottom: 16px;
  background: var(--danger-light);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.4;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 14px;
}

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

/* ── Companies (SUPER_ADMIN) ── */
.company-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  white-space: nowrap;
}

.company-chip-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.companies-page {
  padding: 24px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.companies-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
  min-height: 120px;
}

.company-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px;
  align-items: center;
}

.company-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.company-slug {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.company-status {
  display: flex;
  align-items: center;
}

.new-company-card {
  margin-top: 20px;
}

@media (max-width: 720px) {
  .company-card {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .company-actions {
    justify-content: flex-start;
  }
}
