:root {
  --brand: #6366f1;
  --brand-dark: #4f46e5;
  --brand-light: #eef2ff;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --green: #10b981;
  --green-light: #ecfdf5;
  --red: #ef4444;
  --red-light: #fef2f2;
  --amber: #f59e0b;
  --amber-light: #fffbeb;
  --whatsapp: #25d366;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: rgba(99,102,241,0.15);
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.04);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; -webkit-font-smoothing: antialiased; }

a { color: var(--brand); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--brand-dark); }

/* ── App Shell ── */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar { background: var(--sidebar-bg); color: #cbd5e1; padding: 28px 16px 24px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.sidebar h1 { color: white; font-size: 20px; margin: 0 0 2px; font-weight: 700; letter-spacing: -0.02em; padding-left: 12px; }
.sidebar .subtitle { font-size: 11px; color: #475569; margin-bottom: 32px; padding-left: 12px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.sidebar nav { flex: 1; }
.sidebar nav a { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-radius: var(--radius); color: #94a3b8; margin-bottom: 2px; font-size: 14px; font-weight: 500; transition: all var(--transition); }
.sidebar nav a:hover { background: var(--sidebar-hover); color: #e2e8f0; text-decoration: none; }
.sidebar nav a.active { background: var(--sidebar-active); color: #818cf8; font-weight: 600; }
.nav-badge { background: var(--red); color: white; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px; min-width: 18px; text-align: center; display: none; line-height: 1.4; }
.nav-badge.show { display: inline-block; }
.sidebar nav a.active .nav-badge { background: #818cf8; color: white; }
.sidebar .footer { margin-top: auto; font-size: 11px; color: #475569; padding-left: 12px; }

/* ── Main Area ── */
.main { padding: 28px 36px; overflow-x: hidden; max-width: 1400px; }

/* ── Top Bar ── */
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.topbar h2 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.user-chip { display: flex; align-items: center; gap: 12px; }
.user-chip .avatar { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: white; display: grid; place-items: center; font-weight: 700; font-size: 15px; box-shadow: 0 2px 8px rgba(99,102,241,0.3); }

/* ── Cards ── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow-sm); transition: box-shadow var(--transition); }
.card:hover { box-shadow: var(--shadow); }
.card h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.card-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

/* ── KPI Cards ── */
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi .card { padding: 20px 24px; border-left: 4px solid var(--brand); transition: transform var(--transition), box-shadow var(--transition); }
.kpi .card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi .card:nth-child(2) { border-left-color: var(--green); }
.kpi .card:nth-child(3) { border-left-color: var(--amber); }
.kpi .card:nth-child(4) { border-left-color: var(--red); }
.kpi .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.kpi .value { font-size: 32px; font-weight: 800; margin-top: 4px; letter-spacing: -0.03em; color: var(--text); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: white; cursor: pointer; font-size: 13px; font-weight: 500; transition: all var(--transition); font-family: inherit; }
.btn:hover { background: #f1f5f9; border-color: #cbd5e1; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--brand); color: white; border-color: var(--brand); box-shadow: 0 1px 3px rgba(99,102,241,0.3); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); box-shadow: 0 4px 12px rgba(99,102,241,0.35); }
.btn-success { background: var(--green); color: white; border-color: var(--green); }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--red); color: white; border-color: var(--red); }
.btn-danger:hover { background: #dc2626; }
.btn-whatsapp { background: var(--whatsapp); color: white; border-color: var(--whatsapp); }
.btn-whatsapp:hover { background: #1da851; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-link { background: transparent; border: none; color: var(--brand); padding: 4px; cursor: pointer; font-weight: 500; font-family: inherit; }
.btn-link:hover { color: var(--brand-dark); }

/* ── Forms ── */
input, select, textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; font-family: inherit; background: white; color: var(--text); transition: all var(--transition); }
input:hover, select:hover, textarea:hover { border-color: #cbd5e1; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── Tables ── */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: 12px 14px; text-align: left; font-size: 13px; vertical-align: middle; }
th { background: #f8fafc; font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 2px solid var(--border); position: sticky; top: 0; }
td { border-bottom: 1px solid #f1f5f9; }
tr { transition: background var(--transition); }
tr:hover td { background: #f8fafc; }
tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-new { background: #e0e7ff; color: #3730a3; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-long_term { background: #fef3c7; color: #78350f; }
.badge-ready { background: #fce7f3; color: #9d174d; }
.badge-paused { background: #fde68a; color: #78350f; }
.badge-closed { background: #e5e7eb; color: #374151; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-sent { background: #d1fae5; color: #065f46; }
.badge-scheduled { background: #ede9fe; color: #5b21b6; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-done { background: #d1fae5; color: #065f46; }

/* ── Agenda Items ── */
.agenda-item { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid #f1f5f9; align-items: center; transition: background var(--transition); }
.agenda-item:last-child { border-bottom: none; }
.agenda-item:hover { background: #fafbfc; margin: 0 -12px; padding-left: 12px; padding-right: 12px; border-radius: var(--radius); }
.agenda-item .time { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: white; padding: 8px 12px; border-radius: var(--radius); font-weight: 600; font-size: 12px; min-width: 82px; text-align: center; box-shadow: 0 2px 6px rgba(99,102,241,0.2); }
.agenda-item .info { flex: 1; }
.agenda-item .info strong { display: block; font-size: 14px; }
.agenda-item .info .sub { color: var(--muted); font-size: 12px; }

/* ── Template Cards ── */
.template-card { padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; transition: border-color var(--transition), box-shadow var(--transition); }
.template-card:hover { border-color: #cbd5e1; box-shadow: var(--shadow-sm); }
.template-card .header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.template-card .body { background: #f8fafc; padding: 12px 14px; border-radius: 8px; font-size: 13px; white-space: pre-wrap; color: #374151; border: 1px solid #f1f5f9; }

/* ── Document Chips ── */
.doc-chip { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fafbfc; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; transition: all var(--transition); }
.doc-chip:hover { border-color: #cbd5e1; box-shadow: var(--shadow-sm); transform: translateX(2px); }
.doc-chip .icon { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; font-size: 16px; flex-shrink: 0; }
.doc-chip .icon.pdf { background: #fee2e2; color: #b91c1c; }
.doc-chip .icon.image { background: #fef3c7; color: #b45309; }
.doc-chip .icon.doc { background: #dbeafe; color: #1e40af; }
.doc-chip .icon.link { background: #ede9fe; color: #6d28d9; }
.doc-chip .icon.other { background: #e5e7eb; color: #374151; }
.doc-chip .meta { flex: 1; min-width: 0; }
.doc-chip .name { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-chip .sub { color: var(--muted); font-size: 11px; }

/* ── Bulk WhatsApp ── */
.recipient-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 6px; background: white; transition: all var(--transition); }
.recipient-row:hover { border-color: #cbd5e1; }
.recipient-row.sent { background: var(--green-light); border-color: #a7f3d0; }
.recipient-row .name { flex: 1; font-weight: 500; }
.recipient-row .phone { color: var(--muted); font-size: 12px; font-family: 'SF Mono', 'Fira Code', monospace; }

/* ── Search Box ── */
.search-box { display: flex; gap: 10px; margin-bottom: 18px; }
.search-box input { flex: 1; }
.search-box select { width: auto; min-width: 200px; }

.copy-block { background: #f8fafc; border: 1px dashed var(--border); border-radius: var(--radius); padding: 14px; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; white-space: pre-wrap; word-break: break-word; }

/* ── Modals ── */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,0.5); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-bg.show { display: flex; animation: fadeIn 0.2s ease-out; }
.modal { background: white; border-radius: var(--radius-lg); padding: 28px; max-width: 600px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: slideUp 0.25s ease-out; }
.modal h3 { margin: 0 0 18px; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ── Utilities ── */
.empty { text-align: center; padding: 48px; color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); font-size: 13px; }
.flex { display: flex; gap: 8px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

/* ── Toast ── */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--text); color: white; padding: 14px 22px; border-radius: var(--radius); box-shadow: var(--shadow-lg); display: none; z-index: 200; font-size: 14px; font-weight: 500; animation: slideUp 0.25s ease-out; }
.toast.show { display: block; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

/* ── Login Page ── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #4f46e5 0%, #0f172a 100%); padding: 20px; position: relative; overflow: hidden; }
.login-wrap::before { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(circle at 30% 40%, rgba(99,102,241,0.15), transparent 50%), radial-gradient(circle at 70% 80%, rgba(99,102,241,0.1), transparent 50%); animation: float 20s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-2%, -2%); } }
.login-card { background: white; border-radius: 20px; padding: 44px 40px; max-width: 420px; width: 100%; box-shadow: 0 25px 60px rgba(0,0,0,0.25); position: relative; z-index: 1; }
.login-card h1 { margin: 0 0 6px; font-size: 24px; font-weight: 800; letter-spacing: -0.03em; color: var(--text); }
.login-card .subtitle { color: var(--muted); margin-bottom: 28px; font-size: 14px; }
.demo-creds { background: var(--brand-light); border: 1px solid #c7d2fe; border-radius: var(--radius); padding: 14px; margin-top: 20px; font-size: 12px; line-height: 1.8; }
.demo-creds strong { color: var(--text); }
.demo-creds code { background: white; padding: 2px 6px; border-radius: 4px; font-size: 11px; border: 1px solid var(--border); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 16px; }
  .field-row { grid-template-columns: 1fr; }
  .kpi { grid-template-columns: 1fr 1fr; }
  .topbar h2 { font-size: 20px; }
  .card-row { grid-template-columns: 1fr; }
}
