/* CertiSender — sistema de diseño */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --surface-3: #e7eaf2;
  --border: #e3e6ee;
  --border-strong: #cfd4e0;
  --text: #141828;
  --text-2: #3d4459;
  --muted: #6b7286;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0ff;
  --primary-text: #3b33c4;
  --success: #0e8a55;
  --success-soft: #e8f7ef;
  --danger: #d0342c;
  --danger-soft: #fdeeed;
  --warning: #b45309;
  --warning-soft: #fff6e5;
  --info: #0b78b8;
  --info-soft: #e9f5fc;
  --neutral-soft: #eef0f4;
  --sidebar-bg: #11142a;
  --sidebar-text: #aeb4cc;
  --sidebar-active: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(17, 20, 42, .05);
  --shadow: 0 1px 3px rgba(17, 20, 42, .06), 0 6px 20px -8px rgba(17, 20, 42, .10);
  --shadow-lg: 0 24px 60px -12px rgba(17, 20, 42, .28);
  --ring: 0 0 0 3px rgba(79, 70, 229, .22);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e1a; --surface: #151829; --surface-2: #1b1f33; --surface-3: #242942;
    --border: #262b45; --border-strong: #353b5c; --text: #eceef7; --text-2: #c3c7d9; --muted: #8b91ab;
    --primary: #7c74ff; --primary-hover: #918aff; --primary-soft: #23244a; --primary-text: #b3aeff;
    --success: #3ccf8e; --success-soft: #12291f; --danger: #ff6b62; --danger-soft: #2f1717;
    --warning: #f5b544; --warning-soft: #2c2312; --info: #4fb8f0; --info-soft: #11263a; --neutral-soft: #222740;
    --sidebar-bg: #090b16;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 6px 20px -8px rgba(0, 0, 0, .5);
    --ring: 0 0 0 3px rgba(124, 116, 255, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0e1a; --surface: #151829; --surface-2: #1b1f33; --surface-3: #242942;
  --border: #262b45; --border-strong: #353b5c; --text: #eceef7; --text-2: #c3c7d9; --muted: #8b91ab;
  --primary: #7c74ff; --primary-hover: #918aff; --primary-soft: #23244a; --primary-text: #b3aeff;
  --success: #3ccf8e; --success-soft: #12291f; --danger: #ff6b62; --danger-soft: #2f1717;
  --warning: #f5b544; --warning-soft: #2c2312; --info: #4fb8f0; --info-soft: #11263a; --neutral-soft: #222740;
  --sidebar-bg: #090b16;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 6px 20px -8px rgba(0, 0, 0, .5);
  --ring: 0 0 0 3px rgba(124, 116, 255, .3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
code, .mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12.5px; }
[data-lucide] { width: 18px; height: 18px; stroke-width: 2; flex-shrink: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* Layout ------------------------------------------------------------------ */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px; padding: 4px 8px 22px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6d64ff, #4338ca); color: #fff; box-shadow: 0 6px 16px -6px #4f46e5;
}
.brand-logo [data-lucide] { width: 18px; height: 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6b7190; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; color: var(--sidebar-text);
  font-weight: 500; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(124, 116, 255, .16); color: var(--sidebar-active); }
.nav a.active [data-lucide] { color: #a7a1ff; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .07); padding-top: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: #fff; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: #2a2f55; color: #c9c6ff; text-transform: uppercase;
}
.sidebar-footer form button {
  all: unset; cursor: pointer; display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px;
  width: 100%; box-sizing: border-box; color: var(--sidebar-text); font-weight: 500;
}
.sidebar-footer form button:hover { background: var(--sidebar-hover); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 14px 32px; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.menu-toggle { display: none; }
.content { padding: 8px 32px 48px; width: 100%; max-width: 1240px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 6px 0 22px; }
.page-head p { color: var(--muted); margin-top: 4px; }
.breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb [data-lucide] { width: 14px; height: 14px; }

/* Cards ------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; flex-wrap: wrap; }
.card-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-body { padding: 18px 20px 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.sticky { position: sticky; top: 76px; }

.stat { padding: 18px 20px; display: flex; gap: 14px; align-items: flex-start; }
.stat-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 13px; }
.tone-primary { background: var(--primary-soft); color: var(--primary-text); }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-neutral { background: var(--neutral-soft); color: var(--text-2); }

/* Buttons ----------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 15px;
  border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  text-decoration: none !important; user-select: none;
}
.btn [data-lucide] { width: 16px; height: 16px; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn.is-loading { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.95); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-success { background: var(--success); color: #fff; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14.5px; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Forms ------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-weight: 600; font-size: 13px; color: var(--text-2); }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.optional { color: var(--muted); font-weight: 400; font-size: 12px; }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 120px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; min-height: 340px; }
.select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7286' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .8; }
.input.is-invalid, .select.is-invalid { border-color: var(--danger); }
.input-color { padding: 4px; width: 52px; cursor: pointer; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; height: 40px; margin-left: -1px; }
.hint { color: var(--muted); font-size: 12.5px; }
.error-text { color: var(--danger); font-size: 12.5px; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { display: grid; grid-template-columns: 2fr 1fr 1.2fr; gap: 16px; }
.fieldset-title { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 14px; margin-bottom: 4px; }
.fieldset-title .num {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px;
  background: var(--primary-soft); color: var(--primary-text);
}

.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin: 3px 0 0; width: 16px; height: 16px; accent-color: var(--primary); flex-shrink: 0; }
.check strong { display: block; font-weight: 600; font-size: 13.5px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3); position: relative; transition: background .15s; flex-shrink: 0; }
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 10px; gap: 2px; flex-wrap: wrap; }
.segmented button, .segmented label {
  all: unset; cursor: pointer; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.segmented .active, .segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented input { display: none; }
.segmented label span { padding: 6px 12px; border-radius: 8px; margin: -6px -12px; }

/* Dropzone ---------------------------------------------------------------- */
.dropzone {
  position: relative; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
  padding: 28px 20px; text-align: center; transition: border-color .15s, background .15s; cursor: pointer;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone .dz-icon {
  width: 46px; height: 46px; border-radius: 12px; margin: 0 auto 10px; display: grid; place-items: center;
  background: var(--surface); color: var(--primary-text); box-shadow: var(--shadow-sm);
}
.dropzone .dz-title { font-weight: 600; }
.dropzone .dz-file { margin-top: 10px; font-weight: 600; color: var(--primary-text); display: none; }
.dropzone.has-file .dz-file { display: block; }

/* Badges & chips ---------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.no-dot::before { display: none; }
.badge-primary { background: var(--primary-soft); color: var(--primary-text); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: var(--neutral-soft); color: var(--text-2); }
.badge-primary.live::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; font-weight: 500; color: var(--text-2);
  font-family: ui-monospace, Consolas, monospace;
}
button.chip { cursor: pointer; }
button.chip:hover { border-color: var(--primary); color: var(--primary-text); background: var(--primary-soft); }
.chip.on { border-color: var(--primary); color: var(--primary-text); background: var(--primary-soft); }
button.chip:not(.on)[data-vf] { opacity: .65; text-decoration: line-through; }
.color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.company-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 700;
  font-size: 14px; flex-shrink: 0; text-transform: uppercase;
}

/* Alerts ------------------------------------------------------------------ */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; border: 1px solid transparent; }
.alert [data-lucide] { margin-top: 1px; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert .alert-body { color: var(--text-2); }
.alert strong { color: inherit; }
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flash-stack .alert { color: var(--text); }
.flash-stack .alert [data-lucide] { color: inherit; }
.flash-stack .alert-success [data-lucide] { color: var(--success); }
.flash-stack .alert-danger [data-lucide] { color: var(--danger); }
.flash-stack .alert-warning [data-lucide] { color: var(--warning); }
.flash-stack .alert-info [data-lucide] { color: var(--info); }
.alert-close { all: unset; cursor: pointer; margin-left: auto; opacity: .6; display: flex; }
.alert-close:hover { opacity: 1; }

/* Tables ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table .actions { text-align: right; white-space: nowrap; }
.table-compact td, .table-compact th { padding: 8px 12px; }
.cell-title { font-weight: 600; color: var(--text); }
.cell-sub { color: var(--muted); font-size: 12.5px; }

/* Progress ---------------------------------------------------------------- */
.progress { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; display: flex; }
.progress > span { display: block; height: 100%; transition: width .5s ease; }
.progress .p-sent { background: var(--success); }
.progress .p-failed { background: var(--danger); }
.progress-sm { height: 6px; }

/* Stepper ----------------------------------------------------------------- */
.stepper { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: 13px; color: var(--muted); }
.step .dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 12px; }
.step.done { color: var(--text-2); }
.step.done .dot { background: var(--success-soft); color: var(--success); }
.step.current { color: var(--text); border-color: var(--primary); }
.step.current .dot { background: var(--primary); color: #fff; }
.step .dot [data-lucide] { width: 14px; height: 14px; }

/* Empty state ------------------------------------------------------------- */
.empty { text-align: center; padding: 48px 24px; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto 14px; background: var(--primary-soft); color: var(--primary-text); }
.empty-icon [data-lucide] { width: 26px; height: 26px; }
.empty h3 { font-size: 16px; margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 440px; margin: 0 auto 18px; }

/* Onboarding checklist ---------------------------------------------------- */
.checklist { display: flex; flex-direction: column; }
.checklist a { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); color: var(--text); }
.checklist a:hover { background: var(--surface-2); text-decoration: none; }
.checklist .tick { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: grid; place-items: center; flex-shrink: 0; }
.checklist .done .tick { background: var(--success); border-color: var(--success); color: #fff; }
.checklist .done .tick [data-lucide] { width: 14px; height: 14px; }
.checklist .done .grow { color: var(--muted); text-decoration: line-through; }

/* Template cards ---------------------------------------------------------- */
.tpl-card { display: flex; flex-direction: column; overflow: hidden; }
.tpl-thumb {
  aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--primary-soft), var(--surface-2)); display: grid; place-items: center;
  border-bottom: 1px solid var(--border); color: var(--primary-text); position: relative;
}
.tpl-thumb [data-lucide] { width: 36px; height: 36px; opacity: .8; }
.tpl-thumb .badge { position: absolute; top: 10px; right: 10px; }
.tpl-card .card-body { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.tpl-card .card-foot { justify-content: space-between; }

/* Preview ----------------------------------------------------------------- */
.pdf-frame { width: 100%; aspect-ratio: 1.414 / 1; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); display: block; }
.preview-box { position: relative; }
.preview-loading { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 80%, transparent); border-radius: var(--radius-sm); gap: 8px; font-weight: 600; color: var(--muted); }
.mail-preview { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.mail-meta { padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.mail-meta dt { color: var(--muted); }
.mail-meta dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.mail-body { width: 100%; height: 320px; border: 0; background: #fff; display: block; }
.attachment-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; font-weight: 500; font-size: 12.5px; background: var(--surface); }
.attachment-pill [data-lucide] { color: var(--danger); width: 16px; height: 16px; }

/* Mapping ----------------------------------------------------------------- */
.map-row { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1.2fr); align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.map-row:first-child { border-top: 0; }
.map-row .arrow { color: var(--muted); display: grid; place-items: center; }
.map-sources { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.src-tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: var(--surface-2); color: var(--muted); }
.map-row.unmapped .select { border-color: var(--warning); }

/* Choice cards (selección de empresa) -------------------------------------- */
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-body {
  display: flex; align-items: center; gap: 11px; padding: 12px; border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--surface); transition: border-color .15s, box-shadow .15s, background .15s; min-width: 0;
}
.choice:hover .choice-body { border-color: var(--border-strong); }
.choice input:checked + .choice-body { border-color: var(--primary); box-shadow: var(--ring); background: var(--primary-soft); }
.choice input:focus-visible + .choice-body { box-shadow: var(--ring); }
.choice .check-mark { margin-left: auto; color: var(--primary); opacity: 0; }
.choice input:checked + .choice-body .check-mark { opacity: 1; }
.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.save-state [data-lucide] { width: 14px; height: 14px; }
.row-nav { display: inline-flex; align-items: center; gap: 4px; }
.row-nav input { width: 64px; text-align: center; height: 32px; }

/* Toast ------------------------------------------------------------------- */
.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: toast-in .25s ease; font-size: 13.5px;
}
.toast.success [data-lucide] { color: var(--success); }
.toast.danger [data-lucide] { color: var(--danger); }
.toast.info [data-lucide] { color: var(--info); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* Modal ------------------------------------------------------------------- */
dialog.modal { border: 0; padding: 0; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(460px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(10, 12, 25, .55); backdrop-filter: blur(2px); }
.modal-body { padding: 22px 22px 8px; display: flex; gap: 14px; }
.modal-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.modal-foot { padding: 16px 22px 20px; display: flex; justify-content: flex-end; gap: 10px; }

/* Tabs -------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 20px; overflow-x: auto; }
.tab { all: unset; cursor: pointer; padding: 12px 10px; font-weight: 600; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-text); border-bottom-color: var(--primary); }
.tab .count { background: var(--surface-2); color: var(--text-2); font-size: 11px; padding: 1px 7px; border-radius: 999px; }

/* Quill ------------------------------------------------------------------- */
.editor-wrap .ql-toolbar.ql-snow { border: 1px solid var(--border-strong); border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: var(--surface-2); font-family: var(--font); }
.editor-wrap .ql-container.ql-snow { border: 1px solid var(--border-strong); border-top: 0; border-radius: 0 0 var(--radius-sm) var(--radius-sm); background: #fff; color: #1f2937; font-family: Arial, Helvetica, sans-serif; font-size: 14px; }
.editor-wrap .ql-editor { min-height: 320px; line-height: 1.55; }
.ql-snow .ql-stroke { stroke: var(--text-2); }
.ql-snow .ql-fill { fill: var(--text-2); }
.ql-snow .ql-picker { color: var(--text-2); }

/* Login ------------------------------------------------------------------- */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  background: radial-gradient(1200px 600px at 10% 10%, #3b34b8 0%, transparent 60%), radial-gradient(800px 500px at 90% 90%, #1d6fa3 0%, transparent 60%), #0f1226;
  color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-hero h2 { font-size: 34px; line-height: 1.15; font-weight: 700; max-width: 460px; letter-spacing: -.02em; }
.auth-hero p { color: #b9bfdc; max-width: 420px; margin-top: 14px; font-size: 15px; }
.auth-features { display: flex; flex-direction: column; gap: 14px; margin-top: 32px; }
.auth-features div { display: flex; gap: 12px; align-items: center; color: #d9dcf0; }
.auth-features [data-lucide] { color: #a7a1ff; }
.auth-panel { display: grid; place-items: center; padding: 32px 16px; background: var(--bg); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }

/* Responsive -------------------------------------------------------------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
@media (max-width: 960px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 25, .5); z-index: 40; display: none; }
  .sidebar.open + .sidebar-backdrop { display: block; }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 4px 16px 40px; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4, .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; }
  .map-row { grid-template-columns: 1fr; gap: 6px; }
  .map-row .arrow { display: none; }
  .card-head, .card-body { padding-left: 16px; padding-right: 16px; }
  .table td, .table th { padding: 10px 12px; }
  .hide-sm { display: none; }
}
