:root {
  --ink: #16181d;
  --ink-soft: #5b6270;
  --line: #e4e6eb;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --brand: #1e4d8c;
  --brand-dark: #163b6c;
  --brand-soft: #eaf1fb;
  --danger: #c0392b;
  --success: #1d7a4c;
  --radius: 10px;
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

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

/* ---- Shell / Nav ---- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 10px 24px; position: sticky; top: 0; z-index: 10;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--brand);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.brand-name { font-size: 16px; }
.topnav { display: flex; gap: 4px; flex: 1; }
.topnav a { color: var(--ink-soft); padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.topnav a:hover { background: var(--brand-soft); color: var(--brand-dark); text-decoration: none; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.user-chip small { color: var(--ink-soft); }

.app-main { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: 24px; }
.app-footer { text-align: center; color: var(--ink-soft); font-size: 12px; padding: 16px; }

/* ---- Typography ---- */
.page-title { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--ink-soft); }
.text-muted { color: var(--ink-soft); }
.text-right { text-align: right; }
.back-link { display: inline-block; margin-bottom: 8px; font-size: 13px; }

/* ---- Panels / Grid ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---- Stat cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-value { display: block; font-size: 26px; font-weight: 800; color: var(--brand); }
.stat-label { display: block; font-size: 12px; color: var(--ink-soft); margin-top: 4px; text-transform: uppercase; letter-spacing: .03em; }

/* ---- Forms ---- */
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="file"], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.inline-form { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.inline-form label { margin: 0; white-space: nowrap; }
.inline-form select { width: auto; }

/* ---- Buttons ---- */
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: #fdecea; color: var(--danger); border-color: #f5c6c1; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; text-align: center; margin-top: 16px; }
.row-actions { display: flex; gap: 6px; }
.danger-zone { margin-top: 20px; padding-top: 14px; border-top: 1px dashed var(--line); }

/* ---- Tables ---- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { color: var(--ink-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.table-compact td, .table-compact th { padding: 6px 8px; }
.table-scroll { overflow-x: auto; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-new { background: #eef1f5; color: #444; }
.badge-contacted { background: #e6f0fb; color: #1e5fa8; }
.badge-followup { background: #fef3d6; color: #93690a; }
.badge-interested { background: #e3f6e9; color: #1d7a4c; }
.badge-not-interested { background: #fdecea; color: #c0392b; }
.badge-converted { background: #1e4d8c; color: #fff; }
.badge-invalid { background: #f0f0f0; color: #999; }
.badge-role-admin { background: #1e4d8c; color: #fff; }
.badge-role-bde { background: #eef1f5; color: #444; }

/* ---- Alerts ---- */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.alert-success { background: #e3f6e9; color: #1d7a4c; }
.alert-error { background: #fdecea; color: #c0392b; }

/* ---- Filters / bulk bar ---- */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filter-bar input, .filter-bar select { width: auto; min-width: 160px; }
.bulk-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.bulk-bar select { width: auto; }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 6px; margin-top: 16px; }
.pagination a { padding: 6px 11px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; color: var(--ink); }
.pagination a.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---- Activity log ---- */
.activity-list { list-style: none; margin: 12px 0 0; padding: 0; }
.activity-list li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.activity-list li:last-child { border-bottom: none; }
.activity-list p { margin: 4px 0 0; color: var(--ink); }

.hidden { display: none; }

/* ---- Login page ---- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #163b6c, #1e4d8c 60%, #2a6bb8);
}
.login-card {
  background: #fff; border-radius: 14px; padding: 32px 30px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.login-brand h1 { font-size: 18px; margin: 0; }
.login-sub { color: var(--ink-soft); font-size: 13px; margin: 0 0 16px; }
.login-footnote { color: var(--ink-soft); font-size: 12px; text-align: center; margin-top: 18px; }
