:root {
  --primary: #f59e0b;
  --primary-dark: #d97706;
  --secondary: #0f172a;
  --accent: #0f766e;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --danger: #dc2626;
  --success: #059669;
  --sidebar: #0b1220;
  --sidebar-2: #111827;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

.btn {
  display: inline-flex; align-items: center; gap: .5rem; border: 0; border-radius: .75rem;
  padding: .7rem 1.1rem; font-weight: 600; cursor: pointer; transition: .2s ease;
}
.btn-primary { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 25px -8px rgba(245,158,11,.45); }
.btn-dark { background: #0f172a; color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: .45rem .8rem; font-size: .85rem; }
.btn-danger { background: #dc2626; color: #fff; }

.alert {
  padding: .85rem 1rem; border-radius: .75rem; margin-bottom: 1rem; font-size: .92rem;
}
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; color: #334155; }
.form-control, select.form-control, textarea.form-control {
  width: 100%; border: 1px solid var(--border); border-radius: .7rem; padding: .7rem .9rem;
  font: inherit; background: #fff; color: var(--text);
}
.form-control:focus { outline: 2px solid rgba(245,158,11,.35); border-color: #f59e0b; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 768px) { .form-row { grid-template-columns: 1fr; } }

.table-wrap { overflow: auto; background: #fff; border: 1px solid var(--border); border-radius: 1rem; }
table.data { width: 100%; border-collapse: collapse; min-width: 720px; }
table.data th, table.data td { padding: .85rem 1rem; border-bottom: 1px solid #f1f5f9; text-align: left; font-size: .9rem; }
table.data th { background: #f8fafc; color: #475569; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
table.data tr:hover td { background: #fffbeb; }

.badge {
  display: inline-flex; align-items: center; padding: .2rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 700;
}
.badge-new, .badge-pending { background: #fff7ed; color: #c2410c; }
.badge-contacted, .badge-documentation, .badge-under_review { background: #eff6ff; color: #1d4ed8; }
.badge-approved, .badge-disbursed, .badge-active, .badge-eligible, .badge-paid { background: #ecfdf5; color: #047857; }
.badge-rejected, .badge-inactive { background: #fef2f2; color: #b91c1c; }
.badge-direct { background: #f1f5f9; color: #334155; }
.badge-cp { background: #fef3c7; color: #92400e; }

.panel {
  background: #fff; border: 1px solid var(--border); border-radius: 1rem; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.2rem; border-bottom: 1px solid #f1f5f9;
}
.panel-head h3 { margin: 0; font-size: 1rem; }
.panel-body { padding: 1.2rem; }

.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem;
}
@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .stats-grid { grid-template-columns: 1fr; } }
.stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: 1rem; padding: 1.15rem 1.2rem;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}
.stat-card .stat-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.85rem;
}
.stat-icon {
  width: 42px; height: 42px; border-radius: 0.75rem; display: grid; place-items: center;
  color: #fff; font-size: 1rem;
}
.stat-icon.amber { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-icon.blue { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.stat-icon.green { background: linear-gradient(135deg, #34d399, #059669); }
.stat-icon.purple { background: linear-gradient(135deg, #c084fc, #7c3aed); }
.stat-card .delta { font-size: 0.75rem; font-weight: 700; color: #10b981; }
.stat-card .label { color: var(--muted); font-size: .8rem; font-weight: 500; }
.stat-card .value {
  font-size: 1.55rem; font-weight: 800; color: var(--secondary); margin-top: .15rem;
  line-height: 1.2; word-break: break-word;
}

.admin-shell, .cp-shell { display: flex; min-height: 100vh; position: relative; }
.sidebar {
  width: 260px; background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: #e2e8f0; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; z-index: 40;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.2rem; border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-mark {
  width: 40px; height: 40px; border-radius: .8rem; background: linear-gradient(135deg, #f59e0b, #d97706);
  display: grid; place-items: center; font-weight: 800; color: #fff;
}
.brand-text { font-weight: 800; font-size: 1.15rem; color: #fff; }
.brand-text span { color: #f59e0b; }
.brand-sub { font-size: .65rem; letter-spacing: .12em; text-transform: uppercase; color: #94a3b8; margin-top: .1rem; }
.sidebar-nav { padding: 1rem .8rem; display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .7rem; padding: .75rem .9rem; border-radius: .75rem;
  color: #cbd5e1; font-weight: 600; font-size: .92rem;
}
.sidebar-nav a:hover, .sidebar-nav a.active { background: rgba(245,158,11,.12); color: #fbbf24; }
.sidebar-foot { padding: 1rem; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-user { display: flex; align-items: center; gap: .75rem; }
.sidebar-user strong { display: block; font-size: .88rem; color: #fff; }
.sidebar-user span { font-size: .75rem; color: #94a3b8; }
.avatar {
  width: 40px; height: 40px; border-radius: .7rem; background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff; display: grid; place-items: center; font-weight: 800; flex-shrink: 0; font-size: .85rem;
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 35;
}
.sidebar-overlay.show { display: block; }
.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 1.5rem; min-height: 68px; background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: .85rem; }
.topbar-actions, .page-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.topbar-clock {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 2.35rem;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: #f8fafc;
  color: #475569;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.topbar-clock i { color: #d97706; }
.topbar h1 { margin: 0; font-size: 1.15rem; font-weight: 800; }
.menu-toggle {
  display: none; width: 40px; height: 40px; border: none; border-radius: .65rem;
  background: var(--bg); cursor: pointer; color: var(--text);
}
.search-box { position: relative; }
.search-box i {
  position: absolute; left: .85rem; top: 50%; transform: translateY(-50%);
  color: #94a3b8; font-size: .85rem; pointer-events: none;
}
.search-box input {
  width: 220px; height: 2.4rem; border: 1px solid var(--border); border-radius: .65rem;
  padding: 0 .85rem 0 2.2rem; outline: none; background: #fff; font: inherit;
}
.search-box input:focus { border-color: var(--primary); }
.content { padding: 1.5rem; flex: 1; }
.admin-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: auto;
  padding: 0.7rem 1.5rem;
  background: #fff;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
}
.admin-footer-meta { color: #94a3b8; }
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.55rem 0.65rem;
}
.filters .form-control {
  width: auto;
  min-width: 0;
  flex: 0 1 auto;
  height: 2.1rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.8125rem;
  border-radius: 0.5rem;
  line-height: 1.2;
}
.filters input.form-control[type="text"],
.filters input.form-control[type="search"] {
  flex: 1 1 180px;
  min-width: 160px;
  max-width: 280px;
}
.filters select.form-control {
  flex: 0 1 140px;
  min-width: 120px;
  max-width: 180px;
}
.filters .btn {
  height: 2.1rem;
  padding: 0 0.75rem;
  font-size: 0.8125rem;
  border-radius: 0.5rem;
  white-space: nowrap;
}
.filters .btn-sm {
  padding: 0 0.75rem;
}
@media (max-width: 768px) {
  .filters input.form-control[type="text"],
  .filters input.form-control[type="search"],
  .filters select.form-control {
    flex: 1 1 100%;
    max-width: none;
  }
}
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1rem; margin-bottom: 1.25rem; }
@media (max-width: 980px) {
  .grid-2 { grid-template-columns: 1fr; }
  .cp-shell .menu-toggle { display: grid; place-items: center; }
  .cp-shell .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-105%);
    transition: transform .25s ease; height: 100vh;
  }
  .cp-shell .sidebar.open { transform: translateX(0); }
  .admin-shell .sidebar { display: none; }
  .search-box input { width: 160px; }
}
@media (max-width: 640px) {
  .search-box { display: none; }
}

.panel-meta { font-size: .8rem; color: #64748b; }
.panel-link { font-size: .82rem; font-weight: 600; color: #d97706; }
.panel-link:hover { color: #b45309; }

.chart-bars {
  display: flex; align-items: flex-end; gap: .65rem; height: 180px; padding-top: .5rem;
}
.chart-bars .bar-wrap {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  height: 100%; justify-content: flex-end; gap: .45rem;
}
.chart-bars .bar {
  width: 100%; border-radius: .5rem .5rem .25rem .25rem;
  background: linear-gradient(180deg, #fbbf24, #d97706); min-height: 8px;
  transition: height .4s ease;
}
.chart-bars span { font-size: .7rem; color: var(--muted); font-weight: 600; }

.lead-list { display: flex; flex-direction: column; gap: .85rem; }
.lead-item {
  display: flex; align-items: center; gap: .85rem; color: inherit; text-decoration: none;
  padding: .35rem; border-radius: .75rem; transition: background .15s ease;
}
.lead-item:hover { background: #fffbeb; }
.lead-item .avatar { width: 38px; height: 38px; font-size: .8rem; }
.lead-item .meta { flex: 1; min-width: 0; }
.lead-item .meta strong { display: block; font-size: .88rem; color: var(--secondary); }
.lead-item .meta span { font-size: .75rem; color: var(--muted); }
.empty-leads { text-align: center; color: #64748b; padding: 1.25rem .5rem; font-size: .9rem; }
.empty-leads a { color: #d97706; font-weight: 600; }

.tip-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem;
}
.tip-card { padding: 1rem; border-radius: .85rem; }
.tip-card strong { display: block; font-size: .92rem; }
.tip-card p { font-size: .85rem; margin-top: .35rem; color: #64748b; }
.tip-amber { background: #fffbeb; }
.tip-amber strong { color: #b45309; }
.tip-blue { background: #eff6ff; }
.tip-blue strong { color: #1d4ed8; }
.tip-green { background: #ecfdf5; }
.tip-green strong { color: #047857; }

.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; }
.auth-visual {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
  color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-visual h1 { font-size: 2.4rem; line-height: 1.2; }
.auth-visual em { color: #fbbf24; font-style: normal; }
.auth-panel { display: grid; place-items: center; padding: 2rem; background: #f8fafc; }
.auth-card {
  width: min(440px, 100%); background: #fff; border: 1px solid var(--border);
  border-radius: 1.25rem; padding: 2rem; box-shadow: 0 20px 40px -24px rgba(15,23,42,.25);
}
.auth-card h2 { margin: 0 0 .35rem; }
.auth-card .subtitle { color: var(--muted); margin-bottom: 1.25rem; }
.auth-tabs { display: flex; gap: .5rem; margin-bottom: 1.25rem; background: #f1f5f9; padding: .35rem; border-radius: .8rem; }
.auth-tabs a { flex: 1; text-align: center; padding: .55rem; border-radius: .6rem; font-weight: 700; color: #64748b; }
.auth-tabs a.active { background: #fff; color: #0f172a; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
@media (max-width: 900px) { .auth-page { grid-template-columns: 1fr; } .auth-visual { display: none; } }

.timeline { display: flex; flex-direction: column; gap: 1rem; }
.timeline-item { display: grid; grid-template-columns: 16px 1fr; gap: .85rem; }
.timeline-dot { width: 12px; height: 12px; border-radius: 50%; background: #f59e0b; margin-top: .35rem; }
.timeline-body { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: .85rem; padding: .9rem 1rem; }
.timeline-body .meta { color: #64748b; font-size: .8rem; margin-bottom: .35rem; }

.chart-box { height: 260px; }
.empty { text-align: center; color: #64748b; padding: 2rem; }

.cms-content {
  color: #475569;
  line-height: 1.7;
  font-size: 0.98rem;
}
.cms-content > *:first-child { margin-top: 0; }
.cms-content > *:last-child { margin-bottom: 0; }
.cms-content p { margin: 0 0 0.9rem; }
.cms-content h1, .cms-content h2, .cms-content h3, .cms-content h4 {
  color: #0f172a;
  font-weight: 800;
  line-height: 1.3;
  margin: 1.25rem 0 0.65rem;
}
.cms-content h2 { font-size: 1.4rem; }
.cms-content h3 { font-size: 1.15rem; }
.cms-content ul, .cms-content ol {
  margin: 0 0 1rem;
  padding-left: 1.35rem;
}
.cms-content li { margin: 0.35rem 0; }
.cms-content a { color: #d97706; text-decoration: underline; }
.cms-content strong, .cms-content b { color: #0f172a; }
.cms-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}
.cms-content table th,
.cms-content table td {
  border: 1px solid #e2e8f0;
  padding: 0.6rem 0.75rem;
  text-align: left;
}
.cms-content table th { background: #f8fafc; }
.tox-tinymce { border-radius: 0.75rem !important; border-color: #e2e8f0 !important; }
