:root {
  --sidebar-bg: #1c1f26;
  --sidebar-text: #e8eaed;
  --sidebar-muted: #9aa0a6;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-soft: #dcfce7;
  --surface: #ffffff;
  --bg: #f4f6f8;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --font: "DM Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* display:flex en componentes no debe anular el atributo hidden */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.view {
  display: none;
  min-height: 100vh;
}

.view--active {
  display: flex;
}

/* Login */
#view-login {
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(145deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 32px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.login-card-top {
  display: flex;
  justify-content: flex-end;
  margin: -8px 0 4px;
}

.locale-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.locale-switch--topbar {
  flex-shrink: 0;
}

.locale-switch__btn {
  min-width: 2.25rem;
  padding: 4px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.2;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}

.locale-switch__btn:hover {
  color: var(--text);
}

.locale-switch__btn--active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.locale-switch__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.login-brand {
  text-align: center;
  margin-bottom: 24px;
}

.login-brand h1 {
  margin: 12px 0 4px;
  font-size: 1.5rem;
}

.login-tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
}

.logo-mark--sm {
  width: 32px;
  height: 32px;
  font-size: 0.75rem;
  border-radius: 8px;
}

.login-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 16px;
  line-height: 1.5;
}

.login-connecting {
  padding: 20px 0 8px;
  text-align: center;
}

.login-connecting-text {
  margin: 0;
  color: var(--accent-hover);
  font-weight: 600;
}

#login-connecting:not([hidden]) ~ #login-form-fields {
  opacity: 0.35;
  pointer-events: none;
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.8rem;
  margin-bottom: 4px;
  margin-top: 12px;
}

input[type="email"],
input[type="password"],
input[type="search"],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}

.api-key-row {
  display: flex;
  gap: 8px;
}

.api-key-row input {
  flex: 1;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
}

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 12px 0 0;
}

.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.login-footer a {
  color: var(--accent-hover);
}

.login-footer--legal {
  margin-top: 8px;
}

.sidebar-legal {
  margin: 8px 0 0;
  font-size: 0.7rem;
}

.sidebar-legal a,
.settings-legal a {
  color: var(--accent-hover);
}

.settings-legal {
  margin-top: 16px;
}

/* App shell */
#view-app {
  display: none;
}

#view-app.view--active {
  display: flex;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-name {
  font-weight: 700;
  font-size: 1.1rem;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
}

.nav-group {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-muted);
  margin: 16px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-item--active {
  background: var(--accent);
  color: #fff;
}

.nav-icon {
  opacity: 0.9;
  width: 1.25rem;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  color: var(--sidebar-muted);
  font-size: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.shell-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-search {
  flex: 1;
  max-width: 420px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  flex: 1;
  padding: 24px 28px 40px;
  overflow: auto;
}

.panel {
  display: none;
}

.panel--active {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.content-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.content-header h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
}

.content-sub {
  margin: 4px 0 0;
  color: var(--text-muted);
}

.content-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.select-wrap select {
  width: auto;
  min-width: 180px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn--primary {
  width: 100%;
  margin-top: 8px;
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--outline {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn--outline:hover {
  background: var(--bg);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn--sm {
  padding: 8px 14px;
  font-size: 0.85rem;
}

.btn-icon {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
}

.state-box {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.state-box--error {
  color: var(--danger);
  border-color: #fecaca;
  background: #fef2f2;
}

.hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.8rem;
  font-weight: 500;
}

.pill--accent {
  background: var(--accent-soft);
  color: #166534;
}

.email-cell-subject {
  font-weight: 600;
  margin: 0 0 4px;
  line-height: 1.35;
}

.email-cell-meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.activity-opens {
  font-weight: 600;
  margin: 0 0 4px;
}

.activity-opens--zero {
  color: var(--text-muted);
  font-weight: 500;
}

.activity-last {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.activity-clicks {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--accent-hover);
}

.row-actions {
  text-align: right;
}

.btn-dots {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--text-muted);
}

.btn-dots:hover {
  background: var(--bg);
}

.settings-card {
  max-width: 520px;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.settings-dl {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px 16px;
  margin: 16px 0;
}

.settings-dl dt {
  font-weight: 600;
  color: var(--text-muted);
}

.settings-dl code {
  font-size: 0.85rem;
  word-break: break-all;
}

/* Detail dialog */
.detail-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 560px;
  width: calc(100% - 32px);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
}

.detail-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.detail-dialog-inner {
  padding: 0;
  margin: 0;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.detail-header h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.4;
}

.detail-meta {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.detail-close {
  font-size: 1.5rem;
  line-height: 1;
}

.detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 20px;
  background: #f8fafc;
}

.stat-chip {
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.stat-chip strong {
  display: block;
  font-size: 1.1rem;
}

.detail-events-title {
  margin: 0;
  padding: 12px 20px 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.detail-events {
  max-height: 280px;
  overflow-y: auto;
  padding: 0 20px 12px;
}

.event-row {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.event-row:last-child {
  border-bottom: none;
}

.event-type {
  flex-shrink: 0;
  width: 72px;
  font-weight: 600;
  text-transform: capitalize;
}

.event-type--open {
  color: #059669;
}

.event-type--click {
  color: #2563eb;
}

.human-prob-bar {
  margin-top: 6px;
  max-width: 220px;
}

.human-prob-bar__track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.human-prob-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, #059669, #34d399);
  border-radius: 3px;
}

.human-prob-bar__label {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.event-body {
  flex: 1;
  min-width: 0;
}

.event-time {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.event-url {
  display: block;
  margin-top: 2px;
  color: #2563eb;
  word-break: break-all;
  font-size: 0.8rem;
}

.detail-footer {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
  text-align: right;
}

@media (max-width: 900px) {
  #view-app.view--active {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    padding: 8px;
  }

  .nav-group {
    display: none;
  }

  .sidebar-footer {
    display: none;
  }
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stat-card-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.stat-card strong {
  font-size: 1.35rem;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  padding: 12px 18px;
  background: #0f172a;
  color: #fff;
  border-radius: var(--radius);
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.toast--error {
  background: #b91c1c;
}

.toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

#refresh.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

.col-star {
  width: 40px;
}

.btn-star {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px;
  color: #cbd5e1;
}

.btn-star--on {
  color: #eab308;
}

.recipient-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 200px;
}

.recipient-pills .pill {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-menu {
  position: fixed;
  z-index: 2000;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.15);
  padding: 6px 0;
}

.row-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.row-menu button:hover {
  background: #f1f5f9;
}

.detail-gmail-link {
  display: inline-block;
  margin-top: 8px;
  font-weight: 600;
  color: var(--accent-hover);
  text-decoration: none;
}

.detail-gmail-link:hover {
  text-decoration: underline;
}

.settings-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 14px 0;
  font-size: 0.9rem;
}

.settings-row select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.settings-row--check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.tr--starred .email-cell-subject {
  font-weight: 700;
}

@media (max-width: 900px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* —— Portal v2: virtual grid + side panel —— */

.content-split {
  display: flex;
  gap: 0;
  min-height: 0;
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.grid-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.grid-root {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 220px);
  min-height: 320px;
}

.grid-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.grid-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.grid-outer {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.grid-scroll-wrap {
  flex: 1;
  overflow: auto;
  position: relative;
  min-height: 0;
}

.grid-header {
  display: flex;
  min-width: min-content;
  position: sticky;
  top: 0;
  z-index: 3;
  height: 40px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.grid-th {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  position: relative;
  padding: 0 8px;
  height: 40px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  cursor: default;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}

.grid-th-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grid-th[data-sort] {
  cursor: pointer;
}

.grid-th[data-sort]:hover {
  color: var(--text);
  background: #f1f5f9;
}

.grid-th[data-col-drag] {
  cursor: grab;
}

.grid-th--drag {
  opacity: 0.55;
}

.grid-th--drop-target {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.grid-th--right .grid-th-label {
  text-align: right;
}

.grid-col-resize {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  z-index: 2;
}

.grid-col-resize::after {
  content: '';
  position: absolute;
  top: 20%;
  bottom: 20%;
  right: 2px;
  width: 1px;
  background: var(--border);
  opacity: 0;
  transition: opacity 0.15s;
}

.grid-th:hover .grid-col-resize::after,
.grid-col-resize:hover::after {
  opacity: 1;
}

body.grid-col-resizing {
  cursor: col-resize !important;
  user-select: none;
}

body.grid-col-resizing * {
  cursor: col-resize !important;
}

.grid-body-spacer {
  position: relative;
  width: 100%;
}

.grid-body {
  position: absolute;
  top: 0;
  left: 0;
}

.grid-row {
  display: flex;
  align-items: center;
  height: 44px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.1s;
}

.grid-row:hover {
  background: #f8fafc;
}

.grid-row--active {
  background: #ecfdf5;
  box-shadow: inset 3px 0 0 var(--accent);
}

.grid-row--starred .grid-cell-subject {
  font-weight: 700;
}

.grid-td {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 8px;
  height: 44px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.grid-td--right {
  justify-content: flex-end;
  text-align: right;
}

.grid-cell-subject {
  font-weight: 500;
}

.grid-cell-muted {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.status-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  max-width: 100%;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.status--human {
  background: var(--accent-soft);
  color: #166534;
}

.status--open {
  background: #e0f2fe;
  color: #0369a1;
}

.status--click {
  background: #fef3c7;
  color: #b45309;
}

.status--none {
  background: #f1f5f9;
  color: var(--text-muted);
}

.human-pct {
  font-size: 0.8rem;
  font-weight: 600;
  color: #166534;
}

.column-picker {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
}

.column-picker-inner {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 320px;
  max-height: 70vh;
  overflow: auto;
}

.column-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.column-picker-list {
  list-style: none;
  margin: 0;
  padding: 8px;
}

.column-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius);
}

.column-picker-item:hover {
  background: var(--bg);
}

.column-picker-item label {
  flex: 1;
  cursor: pointer;
  font-size: 0.9rem;
}

.column-drag {
  color: var(--text-muted);
  cursor: grab;
  font-size: 0.75rem;
}

.column-picker-foot {
  padding: 8px 16px 16px;
  border-top: 1px solid var(--border);
}

.device-pair {
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}

.device-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}

.device-chip {
  display: inline-block;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.detail-section-title {
  margin: 0;
  padding: 8px 16px 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.detail-notice {
  margin: 0 16px 8px;
  padding: 8px 10px;
  background: #fffbeb;
  border-radius: var(--radius);
  border: 1px solid #fde68a;
  font-size: 0.8rem;
  line-height: 1.45;
}

.recipients-table-wrap {
  padding: 0 16px 12px;
  overflow-x: auto;
}

.recipients-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.recipients-table th,
.recipients-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.recipients-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.recipients-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.recipients-table .email-cell {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-panel {
  width: 380px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}

.detail-panel-header {
  display: flex;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.detail-panel-head-text {
  flex: 1;
  min-width: 0;
}

.detail-panel-head-text h2 {
  margin: 0 0 6px;
  font-size: 1rem;
  line-height: 1.35;
  word-break: break-word;
}

.detail-events--panel {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
  max-height: none;
}

#panel-tracking.panel--active {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.link-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent-hover);
  font: inherit;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.link-btn:hover {
  color: var(--accent);
}

/* Help / guía de uso */
.help-panel-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.help-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.help-toc {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.help-toc-link {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1.35;
}

.help-toc-link:hover {
  background: var(--bg);
  color: var(--text);
}

.help-body {
  max-width: 820px;
}

.help-section {
  margin-bottom: 32px;
  padding-bottom: 8px;
  scroll-margin-top: 16px;
}

.help-section--flash {
  animation: help-flash 1.2s ease;
}

@keyframes help-flash {
  0% {
    background: var(--accent-soft);
  }
  100% {
    background: transparent;
  }
}

.help-h2 {
  margin: 0 0 12px;
  font-size: 1.25rem;
  font-weight: 700;
}

.help-h3 {
  margin: 20px 0 8px;
  font-size: 1rem;
  font-weight: 600;
}

.help-p {
  margin: 0 0 12px;
  line-height: 1.55;
  color: var(--text);
}

.help-p a {
  color: var(--accent-hover);
}

.help-list {
  margin: 0 0 12px;
  padding-left: 1.25rem;
  line-height: 1.55;
}

.help-list--ol {
  padding-left: 1.4rem;
}

.help-table-wrap {
  overflow-x: auto;
  margin-bottom: 12px;
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.help-table th,
.help-table td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.help-table th {
  background: var(--bg);
  font-weight: 600;
}

.help-callout {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  line-height: 1.5;
}

.help-callout--info {
  background: #e0f2fe;
  color: #0c4a6e;
  border: 1px solid #bae6fd;
}

.help-callout--warn {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.help-dl {
  margin: 0 0 12px;
}

.help-dl-item {
  margin-bottom: 14px;
}

.help-dl dt {
  font-weight: 600;
  margin-bottom: 4px;
}

.help-dl dd {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.help-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 900px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 32px);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
}

.help-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.help-dialog-inner {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  margin: 0;
}

.help-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.help-dialog-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.help-dialog-body {
  flex: 1;
  overflow: auto;
  padding: 20px;
}

.help-dialog-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  text-align: right;
}

#panel-help.panel--active {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

@media (max-width: 768px) {
  .help-layout {
    grid-template-columns: 1fr;
  }

  .help-toc {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .help-toc-link {
    font-size: 0.8rem;
    padding: 4px 8px;
    background: var(--bg);
  }

  .content-split {
    flex-direction: column;
  }

  .detail-panel {
    position: fixed;
    inset: 0;
    z-index: 150;
    width: 100%;
    border-left: none;
  }

  .grid-root {
    height: calc(100vh - 200px);
  }
}

/* ===================== SMTP Settings ===================== */
.settings-card--smtp {
  margin-top: 20px;
}

.smtp-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.settings-section-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--text);
}

.smtp-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 16px;
}
.smtp-status-badge--none {
  background: #f1f5f9;
  color: var(--text-muted);
}
.smtp-status-badge--ok {
  background: var(--accent-soft);
  color: #15803d;
}
.smtp-status-badge--ok::before { content: "✓ "; }
.smtp-status-badge--fail {
  background: #fee2e2;
  color: var(--danger);
}

/* ─── SMTP account cards ────────────────────────────────── */
.smtp-accounts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.smtp-account-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.smtp-account-card--inactive {
  opacity: 0.6;
}

.smtp-account-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.smtp-account-card__label {
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1;
}
.smtp-account-card__badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.smtp-account-card__badge--ok    { background: var(--accent-soft); color: #15803d; }
.smtp-account-card__badge--warn  { background: #fef9c3; color: #854d0e; }
.smtp-account-card__badge--idle  { background: #f1f5f9; color: var(--text-muted); }
.smtp-account-card__badge--off   { background: #f3f4f6; color: var(--text-muted); }

/* Badges de proveedor SMTP */
.smtp-provider-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 10px;
  font-size: 0.7rem; font-weight: 700; white-space: nowrap;
}
.provider--gmail      { background: #fce8e6; color: #b31412; }
.provider--workspace  { background: #e8f0fe; color: #1a73e8; }
.provider--sendgrid   { background: #e8f5ff; color: #0066b2; }
.provider--ses        { background: #fff3e0; color: #e65100; }
.provider--mailgun    { background: #fce4ec; color: #c2185b; }
.provider--zoho       { background: #e8f5e9; color: #2e7d32; }
.provider--custom     { background: #f3f4f6; color: #4b5563; }

/* Hint de proveedor en el modal */
.smtp-provider-hint {
  margin: 0; padding: 8px 12px;
  background: #f0f9ff; border: 1px solid #bae6fd;
  border-radius: 6px; font-size: 0.8rem; color: #0369a1;
  line-height: 1.5;
}

/* Botón ⓘ de ayuda contextual en labels del formulario SMTP */
.smtp-help-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  border: none; background: none; padding: 0; margin-left: 4px;
  color: var(--accent); font-size: 0.85rem; font-weight: 700;
  cursor: pointer; vertical-align: middle; border-radius: 50%;
  line-height: 1; opacity: 0.8; transition: opacity 0.15s;
}
.smtp-help-btn:hover { opacity: 1; color: var(--accent-dark, #1d4ed8); }
.smtp-help-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Popover flotante de ayuda de campo SMTP */
.smtp-help-popover {
  position: absolute;
  width: 340px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
  z-index: 9999;
  font-size: 0.82rem;
  line-height: 1.55;
  overflow: hidden;
  animation: smtp-pop-in 0.12s ease;
}
@keyframes smtp-pop-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.smtp-help-popover__header {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 12px 8px;
  background: #f8fafc; border-bottom: 1px solid #e2e8f0;
}
.smtp-help-popover__title {
  flex: 1; font-weight: 700; font-size: 0.83rem; color: var(--text);
}
.smtp-help-popover__close {
  border: none; background: none; padding: 0; cursor: pointer;
  color: var(--text-muted); font-size: 0.75rem; line-height: 1;
  flex-shrink: 0; margin-top: 1px;
}
.smtp-help-popover__close:hover { color: var(--text); }
.smtp-help-popover__body {
  padding: 10px 12px;
  color: var(--text);
}
.smtp-help-popover__body ol,
.smtp-help-popover__body ul {
  margin: 6px 0 0 0; padding-left: 18px;
}
.smtp-help-popover__body li { margin-bottom: 3px; }
.smtp-help-popover__body code {
  background: #f1f5f9; padding: 1px 4px; border-radius: 3px;
  font-size: 0.78rem; font-family: monospace;
}
.smtp-help-popover__body a { color: var(--accent); text-decoration: underline; }
.smtp-help-popover__link {
  display: block; padding: 7px 12px;
  border-top: 1px solid #e2e8f0;
  color: var(--accent); font-weight: 600; font-size: 0.8rem;
  text-decoration: none;
}
.smtp-help-popover__link:hover { background: #f0f9ff; }

.smtp-account-card__meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.5;
}

.smtp-quota-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin-bottom: 10px;
}
.smtp-quota-col { display: flex; flex-direction: column; gap: 3px; }

.smtp-quota-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
  margin: 6px 0 4px;
}
.smtp-quota-bar__fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.3s;
}
.smtp-quota-bar__fill--warn { background: #f59e0b; }
.smtp-quota-bar__fill--full { background: var(--danger); }
.smtp-quota-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.smtp-account-card__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.smtp-account-card__actions button {
  font-size: 0.78rem;
  padding: 4px 10px;
}

/* ─── Modal password eye ──────────────────────────────── */
.password-input-wrap {
  position: relative;
  width: 100%;
  max-width: 400px;
}
.password-input-wrap input {
  width: 100%;
  max-width: none;
  padding-right: 38px;
}
.password-eye-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
}
.password-eye-btn:hover { color: var(--text); }

.smtp-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-row--stack {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.settings-row--stack input {
  width: 100%;
  max-width: 400px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
}

.settings-row--stack input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn--danger {
  color: var(--danger);
  border-color: var(--danger);
}
.btn--danger:hover {
  background: #fee2e2;
}

/* ===================== Contacts Panel ===================== */
.contacts-view {
  padding: 0;
}

.contacts-lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 4px 0;
}

.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}
.list-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--accent);
}
.list-card__name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}
.list-card__meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.list-card__actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.list-card__actions button {
  font-size: 0.75rem;
  padding: 3px 8px;
}

.contacts-members-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.contacts-list-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  flex: 1;
}

.contacts-members-actions {
  display: flex;
  gap: 8px;
}

.contacts-search {
  flex: 1;
  min-width: 220px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font);
  background: var(--surface);
}

.contacts-table-wrap {
  overflow-x: auto;
}

.contacts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.contacts-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.contacts-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.contacts-table tr:last-child td {
  border-bottom: none;
}
.contacts-table tr:hover td {
  background: var(--bg);
}

.contact-tag {
  display: inline-block;
  background: var(--accent-soft);
  color: #15803d;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-right: 3px;
}

.contacts-pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ─── Lists toolbar ─────────────────────────────────────────────── */
.contacts-lists-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.contacts-lists-search {
  flex: 1;
  min-width: 160px;
}
.contacts-sort-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.contacts-sort-select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

/* ─── View toggle buttons ───────────────────────────────────────── */
.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.view-toggle__btn {
  background: var(--surface);
  border: none;
  padding: 5px 10px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
  line-height: 1;
}
.view-toggle__btn:hover { background: var(--bg); color: var(--text); }
.view-toggle__btn--active { background: var(--accent); color: #fff; }

/* ─── Lists table view ──────────────────────────────────────────── */
.contacts-lists-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.contacts-lists-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  user-select: none;
}
.contacts-lists-table th[data-sort] { cursor: pointer; }
.contacts-lists-table th[data-sort]:hover { color: var(--accent); }
.contacts-lists-table th .sort-arrow { margin-left: 4px; opacity: 0.4; }
.contacts-lists-table th.sort-active .sort-arrow { opacity: 1; color: var(--accent); }
.contacts-lists-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.contacts-lists-table tr:last-child td { border-bottom: none; }
.contacts-lists-table tr:hover td { background: var(--bg); }
.contacts-lists-table .list-row-actions { display: flex; gap: 6px; }
.contacts-lists-table .list-row-actions button { font-size: 0.75rem; padding: 3px 8px; }

/* ─── List card dates ───────────────────────────────────────────── */
.list-card__date {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Sortable table headers ────────────────────────────────────── */
.contacts-table th[data-sort] {
  cursor: pointer;
  user-select: none;
}
.contacts-table th[data-sort]:hover { color: var(--accent); }
.contacts-table th .sort-arrow { margin-left: 4px; opacity: 0.4; font-size: 0.75rem; }
.contacts-table th.sort-active .sort-arrow { opacity: 1; color: var(--accent); }

/* ─── Status badge ──────────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge--active    { background: #dcfce7; color: #15803d; }
.status-badge--unsubscribed { background: #fef9c3; color: #854d0e; }
.status-badge--bounced   { background: #fee2e2; color: #b91c1c; }
.status-badge--spam      { background: #f3e8ff; color: #7e22ce; }

/* ─── Edit contact modal – two-column grid ──────────────────────── */
.modal-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}
.modal-grid-2 .modal-full { grid-column: 1 / -1; }
@media (max-width: 480px) {
  .modal-grid-2 { grid-template-columns: 1fr; }
}

/* ===================== Send Panel ===================== */
.send-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 780px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.send-form-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.send-form-row--body {
  flex-direction: column;
}

.send-label {
  min-width: 60px;
  font-weight: 600;
  font-size: 0.85rem;
  padding-top: 8px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.send-form-row--body .send-label {
  padding-top: 0;
  margin-bottom: 4px;
}

.send-from-text {
  padding-top: 8px;
  font-size: 0.9rem;
  color: var(--text);
}

.send-input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
}
.send-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.send-textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-family: monospace;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
}
.send-textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.send-recipients-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.send-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
}

.send-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-soft);
  color: #15803d;
  border-radius: 16px;
  padding: 3px 10px 3px 10px;
  font-size: 0.8rem;
  font-weight: 500;
}
.send-chip--list {
  background: #e0f2fe;
  color: #0369a1;
}
.send-chip--raw {
  background: #f0fdf4;
  color: #16a34a;
  font-style: italic;
}
.send-chip__remove {
  cursor: pointer;
  font-size: 0.9rem;
  opacity: 0.7;
  background: none;
  border: none;
  padding: 0 2px;
  line-height: 1;
}

.send-recipients-btns {
  display: flex;
  gap: 8px;
}

.send-variables-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: var(--radius);
}
.send-variables-hint code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.78rem;
}

.send-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.send-actions .hint {
  flex: 1;
}

.send-progress {
  margin-top: 8px;
}
.send-progress-bar {
  height: 6px;
  background: var(--accent-soft);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.send-progress-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: var(--pct, 0%);
  background: var(--accent);
  transition: width 0.3s;
}

.send-result {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.88rem;
}
.send-result__ok { color: #15803d; font-weight: 600; }
.send-result__fail { color: var(--danger); font-weight: 600; }

/* ===================== Modals ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-box h2 {
  margin: 0;
  font-size: 1.05rem;
}
.modal-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font);
}
.modal-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.modal-error {
  color: var(--danger);
  font-size: 0.83rem;
}

.import-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.88rem;
  transition: border-color 0.15s, background 0.15s;
}
.import-drop-zone:hover,
.import-drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.import-drop-zone input[type="file"] {
  display: none;
}

.mapping-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 0.85rem;
}
.mapping-grid label {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.mapping-grid select {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  background: var(--surface);
}

.import-preview-table {
  width: 100%;
  font-size: 0.78rem;
  border-collapse: collapse;
  overflow-x: auto;
  display: block;
}
.import-preview-table th, .import-preview-table td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  text-align: left;
  white-space: nowrap;
}

/* ─── Send panel: From select ───────────────────────────────────────────── */
.send-from-select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  appearance: auto;
}
.send-from-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ─── Send panel: Individual tracking toggle ─────────────────────────────── */
.send-tracking-row {
  margin: 4px 0 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-muted, #f7f8fa);
}
.send-tracking-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}
.send-tracking-label input[type="checkbox"] {
  display: none;
}
/* Toggle knob */
.send-tracking-toggle-knob {
  flex-shrink: 0;
  margin-top: 2px;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--border);
  position: relative;
  transition: background 0.18s;
}
.send-tracking-toggle-knob::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: left 0.18s;
}
.send-tracking-label input[type="checkbox"]:checked ~ .send-tracking-toggle-knob {
  background: var(--accent);
}
.send-tracking-label input[type="checkbox"]:checked ~ .send-tracking-toggle-knob::after {
  left: 19px;
}
.send-tracking-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.875rem;
}
.send-tracking-text strong {
  color: var(--text);
}
.send-tracking-text .hint {
  line-height: 1.4;
  margin: 0;
}
