/* =====================================================
   DASHBOARD CONTRATACIONES — MundoMÓVIL Network
   Clonado de SeguimientoSIM v2.3 · Studio 9 Inch · MADE Tommy
===================================================== */

@import url("https://fuente-madetommy.netlify.app/madetommy.css");

:root {
  --bg-base: #0f0d1c;
  --bg-elevated: #161427;
  --bg-card: #272340;
  --bg-card-hover: #332d4f;
  --bg-input: #13111f;
  --border: #332e48;
  --border-strong: #544a70;
  --border-active: #9a88de;
  --text: #d8d2ea;
  --text-soft: #a8a0c0;
  --text-muted: #7a7298;
  --text-faint: #524a6e;
  --accent: #9a88de;
  --accent-strong: #b5a5f0;
  --accent-deep: #5c49a8;
  --accent-glow: rgba(154, 136, 222, 0.16);
  --state-noiniciado: #7a7298;
  --state-iniciado: #5fa0dc;
  --state-proceso: #e89a4f;
  --state-terminado: #4fb58a;
  --success: #4fb58a;
  --success-bg: rgba(79, 181, 138, 0.13);
  --warning: #d9a862;
  --warning-bg: rgba(217, 168, 98, 0.13);
  --danger: #d87080;
  --danger-bg: rgba(216, 112, 128, 0.13);
  --info: #5fa0dc;
  --info-bg: rgba(95, 160, 220, 0.13);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --font: "MADE Tommy", "Inter", system-ui, sans-serif;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
}

body.light-mode {
  --bg-base: #f4f0fa;
  --bg-elevated: #ffffff;
  --bg-card: #ede7f7;
  --bg-card-hover: #e0d6f0;
  --bg-input: #f8f5fc;
  --border: #c9bee5;
  --border-strong: #a99ce0;
  --border-active: #5a47b3;
  --text: #2a2440;
  --text-soft: #5a5278;
  --text-muted: #837aa0;
  --text-faint: #b0a6cc;
  --accent: #6a4fb8;
  --accent-strong: #5a47b3;
  --accent-deep: #6a4fb8;
  --accent-glow: rgba(106, 79, 184, 0.1);
  --success: #2a9968;
  --success-bg: rgba(42, 153, 104, 0.1);
  --warning: #c18a38;
  --warning-bg: rgba(193, 138, 56, 0.1);
  --danger: #c04565;
  --danger-bg: rgba(192, 69, 101, 0.1);
  --info: #2e70c0;
  --info-bg: rgba(46, 112, 192, 0.1);
  --shadow: 0 1px 2px rgba(90, 71, 179, 0.06);
  --shadow-md: 0 4px 16px rgba(90, 71, 179, 0.1);
  --shadow-lg: 0 16px 40px rgba(90, 71, 179, 0.18);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 15px;
}

body {
  font-family: var(--font);
  background:
    radial-gradient(
      ellipse 80% 50% at 20% 0%,
      var(--accent-glow),
      transparent 65%
    ),
    radial-gradient(
      ellipse 60% 50% at 100% 100%,
      var(--accent-glow),
      transparent 65%
    ),
    var(--bg-base);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  transition:
    background 0.3s,
    color 0.3s;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.app {
  max-width: 1500px;
  margin: 0 auto;
  padding: 18px;
}

/* ── LOGIN ── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 30px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 22px;
}
.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--accent-deep);
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
  box-shadow: var(--shadow-md);
  object-fit: cover;
}
.logo-mark.sm {
  width: 34px;
  height: 34px;
  font-size: 1rem;
}
.logo-text strong {
  font-size: 1rem;
  font-weight: 700;
  display: block;
  line-height: 1.1;
  color: var(--text);
}
.logo-text small {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.login-card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 5px;
  color: var(--text);
}
.login-sub {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 22px;
}
.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.field input,
.field select {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.92rem;
  transition: var(--transition);
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--border-active);
}
.btn-primary {
  width: 100%;
  padding: 12px 18px;
  margin-top: 6px;
  background: var(--accent-deep);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.login-error {
  margin-top: 13px;
  padding: 10px 12px;
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.82rem;
}

/* ── HEADER ── */
.header {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 22px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-title strong {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  display: block;
  line-height: 1.1;
}
.header-title small {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}
.header-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  background: var(--success-bg);
  border: 1px solid var(--success);
  border-radius: 999px;
  font-size: 0.76rem;
  color: var(--success);
  font-weight: 600;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 1.5s infinite;
}
.live-badge.off {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}
.live-badge.off .live-dot {
  background: var(--danger);
  animation: none;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}
.btn-icon,
.btn-ghost {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 9px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: var(--transition);
  box-shadow: var(--shadow);
}
.btn-icon {
  width: 38px;
  padding: 0;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.btn-ghost:hover,
.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-icon.muted {
  opacity: 0.45;
}

/* ── STATS ── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.stat-card {
  position: relative;
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
}
.stat-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: var(--accent-bar, var(--text-faint));
  transition: width var(--transition);
}
.stat-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-card:hover::before {
  width: 4px;
}
.stat-card.active {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.stat-card.active::before {
  width: 4px;
}
.stat-card .stat-num {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
  color: var(--text);
}
.stat-card .stat-label {
  color: var(--text-muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.stat-card[data-estado=""] {
  --accent-bar: var(--text-faint);
}
.stat-card[data-estado="no_iniciado"] {
  --accent-bar: var(--state-noiniciado);
}
.stat-card[data-estado="iniciado"] {
  --accent-bar: var(--state-iniciado);
}
.stat-card[data-estado="en_proceso"] {
  --accent-bar: var(--state-proceso);
}
.stat-card[data-estado="terminado"] {
  --accent-bar: var(--state-terminado);
}

/* ── TOOLBAR ── */
.toolbar {
  display: flex;
  gap: 9px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: var(--shadow);
}
.toolbar input[type="search"],
.toolbar select {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 13px;
  color: var(--text);
  font-size: 0.88rem;
  transition: var(--transition);
}
.toolbar input[type="search"] {
  flex: 1;
  min-width: 200px;
}
.toolbar input:focus,
.toolbar select:focus {
  outline: none;
  border-color: var(--border-active);
}

/* ── TABLA ── */
.table-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  padding: 13px 16px;
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-input);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 13px 16px;
  font-size: 0.86rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.data-table tbody tr {
  transition: var(--transition);
  cursor: pointer;
}
.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}
.data-table tbody tr.new-row {
  animation: highlight 2.4s ease-out;
}
@keyframes highlight {
  0% {
    background: var(--accent-glow);
  }
  100% {
    background: transparent;
  }
}
.data-table .empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}
.badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border: 1px solid;
}
.badge-no_iniciado {
  background: rgba(122, 114, 152, 0.13);
  color: var(--state-noiniciado);
  border-color: var(--state-noiniciado);
}
.badge-iniciado {
  background: var(--info-bg);
  color: var(--state-iniciado);
  border-color: var(--state-iniciado);
}
.badge-en_proceso {
  background: var(--warning-bg);
  color: var(--state-proceso);
  border-color: var(--state-proceso);
}
.badge-terminado {
  background: var(--success-bg);
  color: var(--state-terminado);
  border-color: var(--state-terminado);
}
.badge-riesgo {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}
.badge-ok {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success);
}
.cell-primary {
  font-weight: 600;
  color: var(--text);
}
.cell-muted {
  color: var(--text-muted);
  font-size: 0.78rem;
}
.cell-date {
  color: var(--text-soft);
  font-size: 0.8rem;
  white-space: nowrap;
}
.cell-agente {
  color: var(--accent-strong);
  font-weight: 600;
}
.cell-agente.none {
  color: var(--text-faint);
  font-weight: 400;
  font-style: italic;
}
.btn-row {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--accent-strong);
  padding: 6px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  transition: var(--transition);
}
.btn-row:hover {
  background: var(--accent-deep);
  color: #fff;
  border-color: var(--accent);
}

/* ── MODAL ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(15, 13, 28, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease-out;
}
body.light-mode .modal {
  background: rgba(106, 79, 184, 0.18);
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.modal-content {
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 30px;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  transition: var(--transition);
}
.modal-close:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}
.modal h2 {
  font-weight: 700;
  margin-bottom: 18px;
  font-size: 1.3rem;
  color: var(--text);
}
.process-box {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}
.process-field {
  display: flex;
  flex-direction: column;
}
.process-field.full {
  grid-column: 1 / -1;
}
.process-field label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  font-weight: 600;
}
.process-field select,
.process-field input,
.process-field textarea {
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.88rem;
  resize: vertical;
  transition: var(--transition);
}
.process-field select:focus,
.process-field input:focus,
.process-field textarea:focus {
  outline: none;
  border-color: var(--border-active);
}
.process-box .btn-primary {
  grid-column: 1 / -1;
  width: auto;
  justify-self: end;
  padding: 10px 26px;
}
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 22px;
  margin-bottom: 22px;
}
.modal-row {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.modal-row label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  font-weight: 600;
}
.modal-row span,
.modal-row a {
  font-size: 0.9rem;
  color: var(--text);
  word-break: break-word;
}
.modal-row a {
  color: var(--accent-strong);
  text-decoration: none;
}
.modal-row a:hover {
  text-decoration: underline;
}
.modal-actions {
  display: flex;
  gap: 10px;
}
.btn-danger {
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 22px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: var(--transition);
  margin-left: 10px;
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}
.process-box .btn-danger {
  grid-column: 1 / -1;
  justify-self: start;
}

/* ── HISTORIAL ── */
.historial-wrap {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 13px;
}
.historial-wrap summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-size: 0.84rem;
  font-weight: 600;
}
.historial-body {
  margin-top: 11px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.hist-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.hist-item:last-child {
  border-bottom: none;
}
.hist-meta {
  color: var(--text-faint);
  font-size: 0.72rem;
}

/* ── TOAST ── */
.toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: var(--accent-deep);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 15px 19px;
  min-width: 310px;
  max-width: 370px;
  box-shadow: var(--shadow-lg);
  color: #fff;
  pointer-events: auto;
  cursor: pointer;
  animation: toastIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.toast.risk {
  background: var(--danger);
  border-color: var(--danger);
}
.toast::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.4);
  animation: toastBar 8s linear forwards;
}
.toast.leaving {
  animation: toastOut 0.3s ease-in forwards;
}
@keyframes toastIn {
  from {
    transform: translateX(120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
@keyframes toastOut {
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}
@keyframes toastBar {
  from {
    width: 100%;
  }
  to {
    width: 0;
  }
}
.toast-title {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 4px;
}
.toast-body {
  font-size: 0.84rem;
  opacity: 0.96;
}
.toast-meta {
  font-size: 0.74rem;
  opacity: 0.82;
  margin-top: 5px;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .app {
    padding: 12px;
  }
  .header {
    padding: 13px 15px;
  }
  .header-title small {
    display: none;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat-card .stat-num {
    font-size: 1.5rem;
  }
  .process-box,
  .modal-grid {
    grid-template-columns: 1fr;
  }
  .data-table th:nth-child(3),
  .data-table td:nth-child(3),
  .data-table th:nth-child(4),
  .data-table td:nth-child(4) {
    display: none;
  }
  .toast {
    min-width: auto;
    max-width: calc(100vw - 36px);
  }
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: var(--bg-input);
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}
