/* ============================================================
   MARKETING CONTROL CENTER — Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f6f7f9;
  --bg-elevated: #ffffff;
  --bg-subtle: #eef0f3;
  --border: #e5e7eb;
  --text: #14161a;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;

  --accent: #4f46e5;
  --accent-soft: #eef0fe;
  --accent-text: #4338ca;

  --green: #16a34a;
  --green-soft: #eafaf0;
  --amber: #d97706;
  --amber-soft: #fef6e7;
  --red: #dc2626;
  --red-soft: #fdecec;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.10);

  --sidebar-w: 240px;
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #0b0c0f;
  --bg-elevated: #16181d;
  --bg-subtle: #1d2026;
  --border: #262a32;
  --text: #f3f4f6;
  --text-muted: #9aa1ac;
  --text-faint: #6b7280;

  --accent: #818cf8;
  --accent-soft: #1e2040;
  --accent-text: #a5b4fc;

  --green: #34d399;
  --green-soft: #0f2a1e;
  --amber: #fbbf24;
  --amber-soft: #2c2410;
  --red: #f87171;
  --red-soft: #2c1414;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

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

a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* ---------- Layout ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 26px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.sidebar-brand .dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.nav-item:hover { background: var(--bg-subtle); color: var(--text); }

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 100px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
}

.topbar h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}

.topbar .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 2px;
}

/* ---------- Components ---------- */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.card-hover { transition: transform var(--transition), box-shadow var(--transition); }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.grid-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-sm);
}

.metric-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.metric-delta {
  margin-top: 6px;
  font-size: 12.5px;
  font-weight: 600;
}

.metric-delta.up { color: var(--green); }
.metric-delta.down { color: var(--red); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-demo { background: var(--amber-soft); color: var(--amber); }
.badge-live { background: var(--green-soft); color: var(--green); }
.badge-active { background: var(--green-soft); color: var(--green); }
.badge-paused { background: var(--bg-subtle); color: var(--text-muted); }
.badge-completed { background: var(--accent-soft); color: var(--accent-text); }

.badge-status-nuevo { background: var(--accent-soft); color: var(--accent-text); }
.badge-status-contactado { background: var(--bg-subtle); color: var(--text-muted); }
.badge-status-cotizado { background: var(--amber-soft); color: var(--amber); }
.badge-status-negociacion { background: var(--amber-soft); color: var(--amber); }
.badge-status-ganado { background: var(--green-soft); color: var(--green); }
.badge-status-perdido { background: var(--red-soft); color: var(--red); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn:hover { background: var(--bg-subtle); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-block { width: 100%; }

.segmented {
  display: inline-flex;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.segmented button {
  border: none;
  background: transparent;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.segmented button.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}

.section-block { margin-bottom: 28px; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  font-weight: 700;
  padding: 0 14px 10px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.data-table td {
  padding: 13px 14px;
  border-top: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tr.row-link { cursor: pointer; transition: background var(--transition); }
.data-table tr.row-link:hover { background: var(--bg-subtle); }

.table-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.alert-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 8px;
}

.alert-success { background: var(--green-soft); color: var(--green); }
.alert-warning { background: var(--amber-soft); color: var(--amber); }
.alert-danger { background: var(--red-soft); color: var(--red); }

.chart-wrap { position: relative; height: 260px; }

/* ---------- Login ---------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(79,70,229,0.10), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(167,139,250,0.10), transparent 40%),
    var(--bg);
}

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

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 6px;
}

.login-card h2 { margin: 18px 0 4px; font-size: 20px; }
.login-card p.hint { color: var(--text-muted); font-size: 13.5px; margin: 0 0 22px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.field input {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}

.field input:focus { border-color: var(--accent); }

.form-error {
  color: var(--red);
  font-size: 13px;
  margin: -4px 0 12px;
  display: none;
}

.login-demo-link {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.login-demo-link a { color: var(--accent-text); font-weight: 600; cursor: pointer; }

/* ---------- Mobile bottom nav ---------- */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  justify-content: space-around;
  z-index: 50;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-faint);
  padding: 4px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item svg { width: 20px; height: 20px; }

.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

/* ---------- Utility ---------- */

.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mb-0 { margin-bottom: 0; }

.icon-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
}

.icon-btn:hover { background: var(--bg-subtle); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.fade-in { animation: fadeIn 220ms ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- Responsive ---------- */

@media (max-width: 880px) {
  .sidebar { display: none; }
  .mobile-topbar { display: flex; }
  .bottom-nav { display: flex; }
  .main { padding: 18px 16px 90px; }
  .app-shell { flex-direction: column; }
}
