:root {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;

  /* Plata-inspired palette — design.platacard.mx */
  --plata-orange: #ff5000;
  --plata-orange-dark: #ff4000;
  --plata-orange-light: #ff711f;
  --plata-gradient: linear-gradient(135deg, #ff4000 0%, #ff5000 50%, #ff711f 100%);

  --bg-base: #fafaf9;
  --bg-elevated: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-hover: #fff5f0;
  --bg-muted: #f4f4f2;
  --bg-input: #ffffff;

  --border: #e8e8e4;
  --border-subtle: #f0f0ec;

  --text-primary: #0a0a0a;
  --text-secondary: #525252;
  --text-muted: #737373;

  --accent: var(--plata-orange);
  --accent-hover: #e64800;
  --accent-soft: rgba(255, 80, 0, 0.1);
  --accent-ring: rgba(255, 80, 0, 0.22);

  --danger: #e11d48;
  --danger-hover: #be123c;
  --warning: #f59e0b;
  --warning-hover: #d97706;
  --success: #059669;
  --info: #ff5000;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(10, 10, 10, 0.04);
  --shadow-md: 0 4px 24px rgba(10, 10, 10, 0.06);
  --shadow-lg: 0 12px 40px rgba(10, 10, 10, 0.08);

  --font-brand: "Manrope", system-ui, -apple-system, sans-serif;

  color: var(--text-primary);
  background: var(--bg-base);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

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

.header {
  position: relative;
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 0.95rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 3.75rem;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-nav {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 2.25rem;
}

.header nav a {
  color: var(--text-secondary);
  margin-right: 0;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.header nav a:last-child {
  margin-right: 0;
}

.header nav a:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.header nav a.active {
  color: var(--accent);
  font-weight: 600;
}

.header nav a.header-nav-import {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  margin-right: 0;
  text-decoration: none;
  background: var(--plata-gradient);
  color: #fff;
  border: none;
  box-shadow: 0 2px 12px rgba(255, 80, 0, 0.28);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.header nav a.header-nav-import:hover {
  background: linear-gradient(135deg, #e63a00 0%, #e64800 50%, #ff5000 100%);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(255, 80, 0, 0.35);
}

.header nav a.header-nav-import.active {
  color: #fff;
  box-shadow: 0 4px 16px rgba(255, 80, 0, 0.4);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.header-user {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  text-decoration: none;
  color: inherit;
  font-weight: inherit;
  cursor: pointer;
}

a.header-brand:hover,
a.header-brand:focus-visible {
  text-decoration: none;
  color: inherit;
}

.header-brand-text {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  flex-wrap: wrap;
  font-family: var(--font-brand);
  line-height: 1.1;
  border-radius: var(--radius-md);
  padding: 0.35rem 0.5rem;
  transition: background 0.15s ease;
}

a.header-brand:hover .header-brand-text,
a.header-brand:focus-visible .header-brand-text {
  background: var(--bg-surface-hover);
}

a.header-brand:active .header-brand-text {
  background: var(--accent-soft);
}

.header-brand-title {
  font-size: 1.0625rem;
  font-weight: 800;
  letter-spacing: -0.045em;
  color: var(--text-primary);
}

.header-brand-by {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: -0.01em;
}

.header-brand-accent {
  font-weight: 700;
  background: var(--plata-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header-logo {
  height: 30px;
  width: auto;
  display: block;
}

.header .btn {
  background: var(--bg-muted);
  border-color: var(--border);
  color: var(--text-primary);
  border-radius: 999px;
  font-weight: 500;
}

.header .btn:hover {
  background: var(--bg-surface-hover);
  border-color: #d4d4d0;
}

@media (max-width: 960px) {
  .header-brand-by {
    display: none;
  }
}

.main {
  flex: 1;
  padding: 1.75rem 1.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1rem;
}

h1,
h2 {
  color: var(--text-primary);
}

h1 {
  margin: 0 0 1rem;
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

h2 {
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

th {
  background: var(--bg-muted);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

th:first-child {
  border-radius: var(--radius-sm) 0 0 0;
}

th:last-child {
  border-radius: 0 var(--radius-sm) 0 0;
}

tbody tr:hover td {
  background: var(--bg-surface-hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

.btn {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

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

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--plata-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(255, 80, 0, 0.28);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #e63a00 0%, #e64800 50%, #ff5000 100%);
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(255, 80, 0, 0.35);
}

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

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

.btn-warning {
  background: #fff;
  color: var(--text-primary);
  border-color: var(--border);
  font-weight: 500;
}

.btn-warning:hover {
  background: var(--bg-surface-hover);
  border-color: var(--plata-orange-light);
  color: var(--accent);
}

.btn + .btn {
  margin-left: 0.5rem;
}

.form-row {
  margin-bottom: 0.875rem;
}

.form-row label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.form-row input,
.form-row select {
  width: 100%;
  max-width: 400px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-row input:focus,
.form-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}

.form-row select option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.accounts-search-row {
  margin-bottom: 1rem;
}

.accounts-search-input {
  width: 100%;
  max-width: 420px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.accounts-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}

.accounts-search-empty {
  margin-top: 0.75rem;
  color: var(--text-muted);
}

.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9375rem;
}

.alert-error {
  background: #fff1f2;
  color: #9f1239;
  border: 1px solid #fecdd3;
}

.alert-success {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.page-notice {
  margin-bottom: 1rem;
}

.page-notice:empty {
  display: none;
}

.alert-info {
  background: var(--accent-soft);
  color: #c2410c;
  border: 1px solid rgba(255, 80, 0, 0.22);
}

.alert-loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
  padding-bottom: 1.125rem;
}

.alert-loading-text {
  flex: 1;
  font-weight: 500;
}

.alert-spinner {
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid rgba(255, 80, 0, 0.18);
  border-top-color: var(--plata-orange);
  border-right-color: var(--plata-orange-light);
  border-radius: 50%;
  animation: alert-spin 0.7s linear infinite;
  flex-shrink: 0;
}

.alert-progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 80, 0, 0.12);
  overflow: hidden;
}

.alert-progress-bar {
  display: block;
  height: 100%;
  width: 42%;
  background: var(--plata-gradient);
  border-radius: 0 3px 3px 0;
  animation: alert-progress 1.35s ease-in-out infinite;
}

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

@keyframes alert-progress {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(320%);
  }
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 15% 10%, rgba(255, 80, 0, 0.12) 0%, transparent 45%),
    radial-gradient(ellipse at 85% 90%, rgba(255, 113, 31, 0.1) 0%, transparent 45%),
    var(--bg-base);
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  font-size: 1.5rem;
}

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

.grid-2 > .card {
  min-width: 0;
}

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

.sidebar-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-list li {
  margin-bottom: 0.25rem;
}

.sidebar-list button {
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.875rem;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-list button.active,
.sidebar-list button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.mono {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

pre.preview {
  background: #1a1a1a;
  color: #f5f5f5;
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: none;
  overflow: auto;
  max-height: 400px;
  font-size: 0.75rem;
}

.status-active {
  color: var(--success);
  font-weight: 600;
}

.status-archived {
  color: var(--text-muted);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-pending {
  background: #fef3c7;
  color: #b45309;
}

.badge-running {
  background: var(--accent-soft);
  color: #c2410c;
}

.badge-completed {
  background: #d1fae5;
  color: #047857;
}

.badge-failed {
  background: #ffe4e6;
  color: #be123c;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.table-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0;
}

.table-actions .btn {
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 0.8125rem;
  padding: 0.38rem 0.75rem;
}

td .actions {
  margin-bottom: 0;
}

th[colspan] {
  text-align: center;
}

.table-actions-lead-forms {
  justify-content: center;
  gap: 0.75rem;
}

.table-actions-lead-forms .btn {
  font-size: 0.9375rem;
  padding: 0.55rem 1.25rem;
  min-width: 7.5rem;
}

.table-actions-account {
  justify-content: flex-end;
}

td .table-actions-account {
  margin-bottom: 0;
}

.table-actions-account .btn {
  margin: 0;
  white-space: nowrap;
}

.template-row-actions {
  flex-wrap: wrap;
  margin-bottom: 0;
  justify-content: center;
  gap: 0.35rem;
}

.template-row-actions .btn {
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 0.35rem 0.6rem;
}

.template-move-menu {
  position: fixed;
  z-index: 1000;
  width: 260px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
}

.template-move-menu-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.template-move-menu-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
}

.template-move-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.8125rem;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
}

.template-move-menu-item:hover {
  background: var(--bg-surface-hover);
}

.template-move-menu-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.template-move-menu-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.template-move-menu-actions .btn {
  margin: 0;
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
}

.templates-table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

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

.templates-table col.col-file {
  width: 46%;
}

.templates-table col.col-id {
  width: 12%;
}

.templates-table col.col-actions {
  width: 42%;
}

.templates-table th,
.templates-table td {
  overflow: hidden;
}

.templates-table .template-name-cell {
  vertical-align: middle;
  padding-right: 0.75rem;
}

.templates-table .template-name-text {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.templates-table .template-id {
  white-space: nowrap;
  vertical-align: middle;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  padding-left: 0.25rem;
  padding-right: 0.75rem;
}

.templates-table th.template-actions-header {
  text-align: center;
}

.templates-table .template-actions-cell {
  white-space: normal;
  vertical-align: middle;
  text-align: center;
  padding-left: 0.5rem;
  overflow: visible;
}

.import-page h1 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

.import-page .import-card {
  padding: 2.25rem 2.5rem;
  max-width: 720px;
}

.import-page .form-row {
  margin-bottom: 1.75rem;
}

.import-page .form-row label {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.import-page .form-row select {
  max-width: 100%;
  width: 100%;
  font-size: 1.0625rem;
  padding: 0.8rem 1rem;
  min-height: 3rem;
}

.import-page .import-submit {
  font-size: 1.0625rem;
  padding: 0.85rem 2.25rem;
  margin-top: 0.25rem;
}

.import-page .page-notice .alert {
  font-size: 1rem;
  max-width: 720px;
}
