/* ============================================================
   Najeeb Insurance — admin / agent dashboard styles
   ============================================================ */
:root {
  --brand: #1f6feb;
  --brand-dark: #1a5fd0;
  --ink: #0f1f3d;
  --body: #2b3a55;
  --muted: #6b7a93;
  --line: #e4e9f2;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ok: #138a52;
  --ok-bg: #e7f6ee;
  --warn: #b25e00;
  --warn-bg: #fdf0e1;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 31, 61, .06), 0 1px 3px rgba(16, 31, 61, .08);
  --shadow-md: 0 6px 20px rgba(16, 31, 61, .10);
  --shadow-lg: 0 24px 60px rgba(16, 31, 61, .22);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--body);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--ink); margin: 0; line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; transition: .15s ease; white-space: nowrap; background: #eef1f7; color: var(--ink);
}
.btn:hover { background: #e4e9f2; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: #f0f3f9; }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: #fadbd6; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Auth (login) ---------- */
.auth-body { display: grid; place-items: center; min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, #e8efff 0%, var(--bg) 55%); }
.auth-wrap { width: 100%; max-width: 400px; padding: 24px; }
.auth-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 34px 30px; box-shadow: var(--shadow-md); display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.auth-card h1 { font-size: 22px; }
.auth-card label { text-align: left; display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); }
.auth-card input { font: inherit; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; }
.auth-card input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,111,235,.15); }
.auth-card .btn { margin-top: 6px; }
.brand-badge {
  width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 4px;
  background: linear-gradient(135deg, var(--brand), #5a9bff); color: #fff;
  font-weight: 800; font-size: 26px; display: grid; place-items: center; box-shadow: var(--shadow-sm);
}

/* ---------- Alerts ---------- */
.alert { border-radius: 10px; padding: 10px 13px; font-size: 13.5px; text-align: left; }
.alert.error { background: var(--danger-bg); color: var(--danger); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- Top bar + layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; background: rgba(255,255,255,.9); backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 22px; height: 60px;
}
.topbar .logo { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--ink); font-size: 16px; }
.topbar .logo .mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), #5a9bff);
  color: #fff; display: grid; place-items: center; font-weight: 800; }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .who { text-align: right; line-height: 1.2; }
.user-chip .who b { color: var(--ink); font-size: 14px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #e7eefc; color: var(--brand-dark);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; }

.tabbar { display: flex; gap: 4px; padding: 0 14px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 60px; z-index: 20; overflow-x: auto; }
.tab { padding: 13px 14px; font-weight: 600; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent;
  cursor: pointer; white-space: nowrap; background: none; border-top: none; border-left: none; border-right: none; font-family: inherit; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.container { max-width: 1120px; margin: 0 auto; padding: 26px 22px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 3px; }

/* ---------- Cards & stats ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat-card .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-card .value { font-size: 30px; font-weight: 800; color: var(--ink); margin-top: 4px; }
.stat-card .foot { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th { text-align: left; font-size: 12px; letter-spacing: .03em; text-transform: uppercase; color: var(--muted);
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fbfcfe; position: sticky; top: 0; }
table.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr.clickable { cursor: pointer; }
table.tbl tr.clickable:hover td { background: #f7f9fd; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 38px; margin-bottom: 8px; }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.role-admin { background: #efe7fb; color: #6b2fb3; }
.badge.role-agent { background: #e7eefc; color: var(--brand-dark); }
.badge.on { background: var(--ok-bg); color: var(--ok); }
.badge.off { background: #eef1f5; color: var(--muted); }
.carrier-pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px 4px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; color: #fff; max-width: 210px; vertical-align: middle; }
.carrier-pill .swatch { flex: none; width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.85); }
.carrier-pill .cp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---------- Forms (inputs) ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; width: 100%; color: var(--ink);
}
textarea.input { resize: vertical; min-height: 70px; }
.input:focus, select.input:focus, textarea.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,111,235,.14); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); font-weight: 500; }
.checkline input { width: 16px; height: 16px; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(16,31,61,.45); display: grid; place-items: center;
  padding: 20px; z-index: 60; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-width: 620px;
  max-height: 92vh; display: flex; flex-direction: column; animation: pop .16s ease; }
.modal.wide { max-width: 820px; }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 18px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 15px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.x-btn { border: none; background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.x-btn:hover { background: #f0f3f9; color: var(--ink); }

/* ---------- Form builder ---------- */
.builder-field { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: #fbfcfe; }
.builder-field.locked { background: #f3f1fb; border-color: #ddd5f3; }
.builder-field .bf-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.builder-field .bf-head .grip { color: var(--muted); cursor: default; }
.builder-field .bf-actions { margin-left: auto; display: flex; gap: 6px; }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 30px; height: 30px; cursor: pointer;
  display: grid; place-items: center; color: var(--muted); font-size: 15px; }
.icon-btn:hover { background: #f0f3f9; color: var(--ink); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.lock-tag { font-size: 11.5px; font-weight: 700; color: #6b2fb3; background: #efe7fb; padding: 3px 8px; border-radius: 999px; }

.copybar { display: flex; gap: 8px; align-items: stretch; }
.copybar input { flex: 1; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; font-size: 14px; }
.kv .k { color: var(--muted); font-weight: 600; }
.detail-list { display: flex; flex-direction: column; gap: 0; }
.detail-list .di { display: grid; grid-template-columns: 200px 1fr; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.detail-list .di:last-child { border-bottom: none; }
.detail-list .di .dk { color: var(--muted); font-weight: 600; }
.detail-list .di .dv.empty-val { color: #aab4c5; font-style: italic; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 4px 2px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar select.input, .toolbar input.input { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-md); z-index: 90; animation: pop .16s ease; }

@media (max-width: 640px) {
  .row2 { grid-template-columns: 1fr; }
  .detail-list .di, .kv { grid-template-columns: 1fr; gap: 2px; }
  .user-chip .who { display: none; }
  .container { padding: 18px 14px 70px; }
}

/* ============================================================
   Dark mode — applied to the internal portal (login + dashboard).
   The public carrier-branded form is intentionally not dark.
   ============================================================ */
:root[data-theme="dark"] {
  --brand: #4f8cf7;
  --brand-dark: #3f7ae6;
  --ink: #eaf0fb;
  --body: #c4cdda;
  --muted: #8f9bb0;
  --line: #283447;
  --bg: #0e1622;
  --surface: #161f2e;
  --ok: #3ecf8e; --ok-bg: #11331f;
  --warn: #e0a64a; --warn-bg: #3a2a12;
  --danger: #ff6f63; --danger-bg: #3a1d1a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow-md: 0 6px 22px rgba(0,0,0,.45);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.6);
}
[data-theme="dark"] .topbar { background: rgba(18,26,40,.88); }
[data-theme="dark"] .auth-body { background: radial-gradient(1200px 600px at 50% -10%, #16243a 0%, var(--bg) 55%); }
[data-theme="dark"] .btn { background: #222e42; color: var(--ink); }
[data-theme="dark"] .btn:hover { background: #2b3a52; }
[data-theme="dark"] .btn-ghost { background: transparent; }
[data-theme="dark"] .btn-ghost:hover { background: #1d2a3e; }
[data-theme="dark"] .input,
[data-theme="dark"] select.input,
[data-theme="dark"] textarea.input,
[data-theme="dark"] .auth-card input { background: #0f1b2b; color: var(--ink); border-color: var(--line); }
[data-theme="dark"] table.tbl th { background: #121b29; }
[data-theme="dark"] table.tbl tr.clickable:hover td { background: #1a2740; }
[data-theme="dark"] .builder-field { background: #121b29; }
[data-theme="dark"] .builder-field.locked { background: #1b1733; border-color: #332b53; }
[data-theme="dark"] .icon-btn { background: #16202f; border-color: var(--line); }
[data-theme="dark"] .icon-btn:hover, [data-theme="dark"] .x-btn:hover { background: #22304a; }
[data-theme="dark"] .badge.off { background: #222e42; color: var(--muted); }
[data-theme="dark"] .toast { background: #e8edf6; color: #0f1f3d; }
