:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #0ea5e9;
  --info-light: #e0f2fe;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --bg: #f5f7fb;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--slate-900);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #111c33 100%);
  color: #cbd5e1;
  padding: 1.25rem 0.85rem;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  border-right: 1px solid #1f2a44;
}
.brand {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.5rem 0.6rem 1.5rem 0.6rem;
  border-bottom: 1px solid #1f2a44;
  margin-bottom: 1rem;
}
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 18px;
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
}
.brand-text strong { color: #fff; font-size: 15px; letter-spacing: -0.01em; }
.brand-text small { color: #94a3b8; font-size: 11px; display: block; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-section { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: 0.08em; padding: 0.85rem 0.6rem 0.35rem; }
.nav a {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0.7rem; border-radius: 8px;
  color: #cbd5e1; text-decoration: none; font-size: 14px; font-weight: 500;
  transition: all 0.15s;
}
.nav a:hover { background: #1e293b; color: #fff; }
.nav a.active { background: rgba(79, 70, 229, 0.18); color: #fff; box-shadow: inset 2px 0 0 #818cf8; }
.nav a svg { width: 18px; height: 18px; opacity: 0.85; }
.nav-footer { padding-top: 1rem; border-top: 1px solid #1f2a44; }
.nav-footer .user-pill {
  display: flex; align-items: center; gap: 0.65rem; padding: 0.5rem 0.6rem;
  border-radius: 8px; color: #cbd5e1; font-size: 13px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--slate-200);
  padding: 0.85rem 1.75rem; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.topbar .crumbs { color: var(--slate-500); font-size: 12px; margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 0.85rem; }
.search-box {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--slate-100); padding: 0.5rem 0.85rem; border-radius: 8px;
  width: 280px;
}
.search-box input { background: transparent; border: 0; outline: none; font-size: 13px; flex: 1; }
.empresa-pill {
  background: var(--primary-light); color: var(--primary);
  padding: 0.4rem 0.75rem; border-radius: 8px; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; gap: 0.4rem;
}

.content { padding: 1.75rem; flex: 1; }

/* KPI cards */
.grid { display: grid; gap: 1rem; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2,1fr); } .grid.cols-3 { grid-template-columns: 1fr; } }

.card {
  background: #fff; border: 1px solid var(--slate-200);
  border-radius: 12px; padding: 1.1rem 1.25rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.card h3 { margin: 0 0 0.85rem; font-size: 14px; font-weight: 600; }
.card .label { font-size: 12px; color: var(--slate-500); font-weight: 500; }
.card .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-top: 0.25rem; }
.card .delta { font-size: 12px; margin-top: 0.5rem; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.delta.up { background: var(--success-light); color: #047857; }
.delta.down { background: var(--danger-light); color: #b91c1c; }

.kpi-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0.75rem;
}
.kpi-icon svg { width: 20px; height: 20px; }
.bg-indigo { background: var(--primary-light); color: var(--primary); }
.bg-green { background: var(--success-light); color: #047857; }
.bg-amber { background: var(--warning-light); color: #b45309; }
.bg-rose  { background: var(--danger-light); color: #b91c1c; }
.bg-sky   { background: var(--info-light); color: #0369a1; }

/* Tables */
.table-wrap { background: #fff; border: 1px solid var(--slate-200); border-radius: 12px; overflow: hidden; }
.table-tools {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--slate-200);
}
.filters { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  background: var(--slate-50); text-align: left; padding: 0.7rem 1.25rem;
  font-size: 12px; color: var(--slate-500); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
tbody td { padding: 0.85rem 1.25rem; border-top: 1px solid var(--slate-100); vertical-align: middle; }
tbody tr:hover { background: var(--slate-50); }
.row-link { cursor: pointer; }

/* Buttons & inputs */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 0.9rem; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: all 0.15s; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--slate-700); border-color: var(--slate-200); }
.btn-ghost:hover { background: var(--slate-50); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-icon { padding: 0.45rem; }
.btn svg { width: 14px; height: 14px; }

.input, select, textarea {
  width: 100%; padding: 0.55rem 0.8rem; border: 1px solid var(--slate-200);
  border-radius: 8px; font-size: 13.5px; outline: none; background: #fff; font-family: inherit;
}
.input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.12); }
label { font-size: 12px; font-weight: 500; color: var(--slate-700); margin-bottom: 4px; display: block; }

/* Badges */
.badge {
  font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
}
.badge.gray   { background: var(--slate-100); color: var(--slate-700); }
.badge.green  { background: var(--success-light); color: #047857; }
.badge.amber  { background: var(--warning-light); color: #b45309; }
.badge.red    { background: var(--danger-light); color: #b91c1c; }
.badge.blue   { background: var(--info-light); color: #0369a1; }
.badge.indigo { background: var(--primary-light); color: var(--primary-dark); }

/* Login */
.login-page {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--slate-50);
}
.login-hero {
  background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 60%, #6d28d9 100%);
  color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
}
.login-hero h2 { font-size: 28px; font-weight: 700; margin: 0 0 0.5rem; letter-spacing: -0.02em; }
.login-hero p { color: #c7d2fe; font-size: 15px; line-height: 1.6; max-width: 420px; }
.login-hero ul { list-style: none; padding: 0; margin: 1.75rem 0; }
.login-hero li { padding: 0.5rem 0; color: #e0e7ff; font-size: 14px; display: flex; align-items: center; gap: 0.55rem; }
.login-hero li::before { content: "✔"; color: #a5f3fc; font-weight: 700; }
.login-form-wrap { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.login-form { width: 100%; max-width: 380px; }
.login-form h1 { font-size: 24px; font-weight: 700; margin: 0 0 0.4rem; letter-spacing: -0.02em; }
.login-form .sub { color: var(--slate-500); font-size: 14px; margin-bottom: 1.75rem; }
.login-form .field { margin-bottom: 1rem; }
@media (max-width: 880px) { .login-page { grid-template-columns: 1fr; } .login-hero { display: none; } }

/* Timeline */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--slate-200); }
.timeline-item { position: relative; padding-bottom: 1.5rem; }
.timeline-item::before {
  content: ''; position: absolute; left: -1.5rem; top: 4px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--primary);
}
.timeline-item.green::before { background: var(--success); box-shadow: 0 0 0 1px var(--success); }
.timeline-item.amber::before { background: var(--warning); box-shadow: 0 0 0 1px var(--warning); }
.timeline-item.red::before   { background: var(--danger);  box-shadow: 0 0 0 1px var(--danger); }
.timeline-meta { font-size: 11px; color: var(--slate-500); }
.timeline-title { font-size: 13.5px; font-weight: 600; margin: 2px 0; }
.timeline-body { font-size: 13px; color: var(--slate-700); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--slate-200); margin-bottom: 1rem; }
.tab { padding: 0.65rem 1rem; font-size: 13.5px; font-weight: 600; color: var(--slate-500); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55);
  display: none; align-items: center; justify-content: center; z-index: 50;
  padding: 1rem;
}
.modal-bg.show { display: flex; }
.modal {
  background: #fff; border-radius: 14px; max-width: 520px; width: 100%;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.25); overflow: hidden;
}
.modal-header { padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--slate-200); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 1.4rem; }
.modal-foot { padding: 0.85rem 1.4rem; background: var(--slate-50); display: flex; justify-content: flex-end; gap: 0.5rem; }
.close-x { background: transparent; border: 0; cursor: pointer; color: var(--slate-500); font-size: 22px; }

/* Misc */
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 1.25rem 0 0.85rem; }
.section-title h2 { margin: 0; font-size: 16px; font-weight: 600; }
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap-1 { gap: 0.5rem; } .gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.muted { color: var(--slate-500); font-size: 13px; }
.right { text-align: right; }
.empty { padding: 2.5rem; text-align: center; color: var(--slate-500); font-size: 14px; }
.toast {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 100;
  background: var(--slate-900); color: #fff; padding: 0.75rem 1rem; border-radius: 10px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25); display: none;
}
.toast.show { display: block; animation: slidein 0.25s ease-out; }
@keyframes slidein { from { transform: translateY(20px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

.progress { background: var(--slate-100); border-radius: 999px; height: 8px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); }

.script-card {
  border: 1px solid var(--slate-200); border-radius: 10px; padding: 1rem;
  background: var(--slate-50); margin-bottom: 0.75rem;
}
.script-card h4 { margin: 0 0 0.4rem; font-size: 13.5px; }
.script-card p { margin: 0; font-size: 13px; color: var(--slate-700); line-height: 1.5; }
