/* =====================================================================
   J Mitra CRM - design tokens and components
   Built on Bootstrap 5.3; tokens drive both light and dark themes.
   ===================================================================== */

:root,
[data-bs-theme="light"] {
  --jm-bg: #f3f6f7;
  --jm-card: #ffffff;
  --jm-card-2: #f8fafb;
  --jm-ink: #12323b;
  --jm-ink-2: #2b4a53;
  --jm-muted: #5a6f77;
  --jm-line: #d8e2e5;
  --jm-line-soft: #e8eef0;
  --jm-primary: #0a7a8a;
  --jm-primary-strong: #075f6c;
  --jm-primary-soft: #e3f3f5;
  --jm-focus: rgba(10, 122, 138, .28);
  --jm-shadow: 0 1px 2px rgba(18, 50, 59, .06), 0 4px 14px rgba(18, 50, 59, .05);
  --jm-shadow-lg: 0 10px 40px rgba(18, 50, 59, .16);

  /* Account-type colour language (used for dots, rails and monogram tiles) */
  --type-distributor: #4c5fd5;
  --type-laboratory: #0a7a8a;
  --type-hospital: #2563a8;
  --type-blood_bank: #b4233c;
  --type-institution: #6b6a1f;

  --ok: #1f7a3a;    --ok-soft: #e4f4e8;
  --warn: #9a6200;  --warn-soft: #fdf1dc;
  --bad: #b42318;   --bad-soft: #fde8e6;
  --info: #1d5fa8;  --info-soft: #e5effa;
  --neutral: #4d5f66; --neutral-soft: #eceff0;

  --bs-body-bg: var(--jm-bg);
  --bs-body-color: var(--jm-ink);
  --bs-secondary-color: var(--jm-muted);
  --bs-border-color: var(--jm-line);
  --bs-primary: var(--jm-primary);
  --bs-primary-rgb: 10, 122, 138;
  --bs-link-color: var(--jm-primary-strong);
  --bs-link-color-rgb: 7, 95, 108;
  --bs-link-hover-color: var(--jm-primary);
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  --bs-border-radius: 10px;

  --sidebar-w: 248px;
  --topbar-h: 60px;
  --bottomnav-h: 64px;
  color-scheme: light;
}

[data-bs-theme="dark"] {
  --jm-bg: #0e181b;
  --jm-card: #15232a;
  --jm-card-2: #1a2a32;
  --jm-ink: #e2ecee;
  --jm-ink-2: #c3d3d7;
  --jm-muted: #8fa5ac;
  --jm-line: #26383f;
  --jm-line-soft: #1f2f36;
  --jm-primary: #4cc3d1;
  --jm-primary-strong: #7ad6e0;
  --jm-primary-soft: #143a40;
  --jm-focus: rgba(76, 195, 209, .32);
  --jm-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --jm-shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);

  --type-distributor: #8e9cf0;
  --type-laboratory: #4cc3d1;
  --type-hospital: #6ea8e8;
  --type-blood_bank: #f07a8c;
  --type-institution: #c4c25a;

  --ok: #6fd18e;    --ok-soft: #173826;
  --warn: #f2b84b;  --warn-soft: #3a2c10;
  --bad: #ff8a80;   --bad-soft: #3f1a17;
  --info: #8bbcf2;  --info-soft: #162b45;
  --neutral: #a9b8bd; --neutral-soft: #24333a;

  --bs-body-bg: var(--jm-bg);
  --bs-body-color: var(--jm-ink);
  --bs-secondary-color: var(--jm-muted);
  --bs-border-color: var(--jm-line);
  --bs-primary: var(--jm-primary);
  --bs-primary-rgb: 76, 195, 209;
  --bs-link-color: var(--jm-primary-strong);
  --bs-link-color-rgb: 122, 214, 224;
  --bs-link-hover-color: var(--jm-primary);
  --bs-tertiary-bg: var(--jm-card-2);
  color-scheme: dark;
}

/* ---------------------------------------------------------------------
   Base
   --------------------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; } /* utility classes like d-grid must not un-hide elements */
body {
  font-feature-settings: "cv11", "ss01";
  font-size: .9375rem;
  line-height: 1.5;
  background: var(--jm-bg);
  color: var(--jm-ink);
}
h1, h2, h3, h4, h5 { color: var(--jm-ink); letter-spacing: -.01em; }
.page-title { font-size: 1.5rem; font-weight: 650; margin: 0; letter-spacing: -.02em; }
.section-title { font-size: 1rem; font-weight: 620; margin: 0; }
.text-muted, .text-secondary { color: var(--jm-muted) !important; }
.num, .code { font-variant-numeric: tabular-nums; }
.code { color: var(--jm-muted); font-size: .8125rem; white-space: nowrap; }
a { text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--jm-focus); outline-offset: 2px; border-radius: 6px; }
.visually-hidden-focusable:focus { position: fixed; top: .5rem; left: .5rem; z-index: 2000; background: var(--jm-card); padding: .5rem 1rem; border-radius: 8px; box-shadow: var(--jm-shadow-lg); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------------
   Buttons & form controls
   --------------------------------------------------------------------- */
.btn { font-weight: 550; border-radius: 10px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding-inline: 1rem; }
.btn-sm { min-height: 36px; padding-inline: .75rem; border-radius: 8px; }
.btn-primary {
  --bs-btn-bg: var(--jm-primary); --bs-btn-border-color: var(--jm-primary);
  --bs-btn-hover-bg: var(--jm-primary-strong); --bs-btn-hover-border-color: var(--jm-primary-strong);
  --bs-btn-active-bg: var(--jm-primary-strong); --bs-btn-active-border-color: var(--jm-primary-strong);
  --bs-btn-disabled-bg: var(--jm-primary); --bs-btn-disabled-border-color: var(--jm-primary);
  --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff;
}
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #062a2f; --bs-btn-hover-color: #062a2f; --bs-btn-active-color: #062a2f; }
.btn-outline-secondary {
  --bs-btn-color: var(--jm-ink-2); --bs-btn-border-color: var(--jm-line);
  --bs-btn-hover-bg: var(--jm-card-2); --bs-btn-hover-color: var(--jm-ink); --bs-btn-hover-border-color: var(--jm-line);
  --bs-btn-active-bg: var(--jm-line-soft); --bs-btn-active-color: var(--jm-ink); --bs-btn-active-border-color: var(--jm-line);
  background: var(--jm-card);
}
.btn-ghost { background: transparent; border: 0; color: var(--jm-ink-2); }
.btn-ghost:hover { background: var(--jm-line-soft); color: var(--jm-ink); }
.btn-icon { width: 44px; padding: 0; }

.form-label { font-weight: 560; font-size: .875rem; color: var(--jm-ink-2); margin-bottom: .35rem; }
.form-text { color: var(--jm-muted); }
.form-control, .form-select {
  min-height: 46px; border-radius: 10px; border-color: var(--jm-line);
  background-color: var(--jm-card); color: var(--jm-ink); font-size: 1rem; /* 16px avoids iOS zoom */
}
textarea.form-control { min-height: 96px; }
.form-control:focus, .form-select:focus { border-color: var(--jm-primary); box-shadow: 0 0 0 .2rem var(--jm-focus); }
.form-check-input { width: 1.25em; height: 1.25em; margin-top: .15em; }
.form-check-input:checked { background-color: var(--jm-primary); border-color: var(--jm-primary); }
.form-check-label { padding-left: .25rem; }
.required::after { content: " *"; color: var(--bad); }

/* ---------------------------------------------------------------------
   App shell: sidebar, topbar, bottom nav
   --------------------------------------------------------------------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1030;
  background: var(--jm-card); border-right: 1px solid var(--jm-line);
  display: flex; flex-direction: column; padding: 1rem .75rem;
}
.brand { display: flex; align-items: center; gap: .65rem; padding: .25rem .5rem 1.25rem; text-decoration: none; color: var(--jm-ink); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--jm-primary); color: #fff; font-weight: 700; font-size: .95rem; letter-spacing: -.02em;
}
[data-bs-theme="dark"] .brand-mark { color: #062a2f; }
.brand-name { font-weight: 680; font-size: 1rem; line-height: 1.1; }
.brand-name small { display: block; font-weight: 500; font-size: .75rem; color: var(--jm-muted); }

.side-nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.side-nav .group { font-size: .75rem; color: var(--jm-muted); padding: 1rem .75rem .35rem; font-weight: 560; }
.side-nav a {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: 10px;
  color: var(--jm-ink-2); text-decoration: none; font-weight: 520; min-height: 44px;
}
.side-nav a i { font-size: 1.1rem; color: var(--jm-muted); }
.side-nav a:hover { background: var(--jm-line-soft); color: var(--jm-ink); }
.side-nav a.active { background: var(--jm-primary-soft); color: var(--jm-primary-strong); }
.side-nav a.active i { color: var(--jm-primary); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--jm-line); padding-top: .75rem; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1020; height: var(--topbar-h);
  display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem;
  background: color-mix(in srgb, var(--jm-bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--jm-line-soft);
}
.topbar-search { flex: 1; max-width: 520px; position: relative; }
.topbar-search i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--jm-muted); pointer-events: none; }
.topbar-search input { padding-left: 2.4rem; min-height: 42px; background: var(--jm-card); }
.topbar-title { display: none; font-weight: 650; font-size: 1.05rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--jm-primary-soft); color: var(--jm-primary-strong); font-weight: 650; font-size: .8rem;
}
.content { padding: 1.5rem; width: 100%; max-width: 1240px; margin: 0 auto; flex: 1; }

.bottom-nav { display: none; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--jm-shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(8, 20, 24, .45); z-index: 1025; display: none; }
  .sidebar.open + .sidebar-backdrop { display: block; }
  .main { margin-left: 0; }
  .topbar { padding: 0 .75rem; }
  .topbar-search { display: none; }
  .topbar-title { display: block; }
  .content { padding: 1rem .875rem calc(var(--bottomnav-h) + 1.5rem + env(safe-area-inset-bottom)); }

  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--jm-card); border-top: 1px solid var(--jm-line);
  }
  .bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    height: var(--bottomnav-h); color: var(--jm-muted); text-decoration: none; font-size: .7rem; font-weight: 560;
    background: none; border: 0;
  }
  .bottom-nav i { font-size: 1.3rem; }
  .bottom-nav a.active { color: var(--jm-primary-strong); }
  .bottom-nav .fab {
    width: 52px; height: 52px; border-radius: 16px; margin: 0 auto; transform: translateY(-10px);
    background: var(--jm-primary); color: #fff; box-shadow: 0 6px 18px rgba(10, 122, 138, .35);
  }
  [data-bs-theme="dark"] .bottom-nav .fab { color: #062a2f; }
  .bottom-nav .fab i { font-size: 1.6rem; }
}

/* ---------------------------------------------------------------------
   Surfaces
   --------------------------------------------------------------------- */
.card-x {
  background: var(--jm-card); border: 1px solid var(--jm-line-soft); border-radius: 12px;
  box-shadow: var(--jm-shadow);
}
.card-x > .card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--jm-line-soft); }
.card-x > .card-body-x { padding: 1.25rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head .sub { color: var(--jm-muted); margin: .25rem 0 0; }

/* Stat tiles: deliberately plain, number first */
.stat { padding: 1rem 1.25rem; display: block; text-decoration: none; color: inherit; height: 100%; }
.stat:hover { border-color: var(--jm-line); }
.stat .v { font-size: 1.75rem; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .k { color: var(--jm-muted); font-size: .85rem; margin-top: .2rem; }
.stat.attention .v { color: var(--warn); }

/* ---------------------------------------------------------------------
   Chips, type markers, monograms
   --------------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .6rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; white-space: nowrap; line-height: 1.5;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-success { color: var(--ok); background: var(--ok-soft); }
.chip-warning { color: var(--warn); background: var(--warn-soft); }
.chip-danger  { color: var(--bad); background: var(--bad-soft); }
.chip-info    { color: var(--info); background: var(--info-soft); }
.chip-neutral { color: var(--neutral); background: var(--neutral-soft); }

.type-tag { display: inline-flex; align-items: center; gap: .4rem; font-size: .8125rem; color: var(--jm-ink-2); white-space: nowrap; }
.type-tag::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--tc, var(--jm-muted)); }
.t-distributor { --tc: var(--type-distributor); }
.t-laboratory  { --tc: var(--type-laboratory); }
.t-hospital    { --tc: var(--type-hospital); }
.t-blood_bank  { --tc: var(--type-blood_bank); }
.t-institution { --tc: var(--type-institution); }

.mono {
  width: 40px; height: 40px; border-radius: 10px; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; letter-spacing: -.01em;
  color: var(--tc, var(--jm-primary)); background: color-mix(in srgb, var(--tc, var(--jm-primary)) 13%, transparent);
}

/* ---------------------------------------------------------------------
   Account 360 header: the one bold element
   --------------------------------------------------------------------- */
.acct-head {
  position: relative; overflow: hidden; padding: 1.25rem 1.25rem 0;
  background:
    linear-gradient(90deg, var(--tc) 0 5px, transparent 5px),
    var(--jm-card);
}
.acct-head .mono-lg {
  width: 64px; height: 64px; border-radius: 16px; font-size: 1.35rem; font-weight: 720;
  display: grid; place-items: center; flex: none;
  color: #fff; background: var(--tc);
}
[data-bs-theme="dark"] .acct-head .mono-lg { color: #0e181b; }
.acct-head h1 { font-size: 1.5rem; font-weight: 680; letter-spacing: -.02em; margin: 0; line-height: 1.2; }
.acct-meta { display: flex; flex-wrap: wrap; gap: .35rem 1rem; color: var(--jm-muted); font-size: .875rem; margin-top: .4rem; }
.acct-meta span { display: inline-flex; align-items: center; gap: .3rem; }
.acct-tabs { display: flex; flex-wrap: nowrap; gap: .25rem; overflow-x: auto; margin: 1rem -1.25rem 0; padding: 0 1rem; border-top: 1px solid var(--jm-line-soft); scrollbar-width: none; }
.acct-tabs::-webkit-scrollbar { display: none; }
.acct-tabs .nav-link {
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--jm-muted);
  padding: .85rem .75rem; font-weight: 560; white-space: nowrap; min-height: 48px; background: none;
}
.acct-tabs .nav-link.active { color: var(--jm-primary-strong); border-bottom-color: var(--jm-primary); }
.acct-tabs .count { font-size: .75rem; color: var(--jm-muted); margin-left: .25rem; font-variant-numeric: tabular-nums; }

.dl { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: .6rem 1rem; margin: 0; }
.dl dt { color: var(--jm-muted); font-weight: 500; font-size: .875rem; }
.dl dd { margin: 0; word-break: break-word; }

/* ---------------------------------------------------------------------
   Lists & responsive tables (become cards on small screens)
   --------------------------------------------------------------------- */
.table-x { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; }
.table-x th { font-size: .8rem; font-weight: 600; color: var(--jm-muted); padding: .7rem 1rem; border-bottom: 1px solid var(--jm-line); text-align: left; white-space: nowrap; background: var(--jm-card-2); }
.table-x td { padding: .8rem 1rem; border-bottom: 1px solid var(--jm-line-soft); vertical-align: middle; }
.table-x tbody tr:last-child td { border-bottom: 0; }
.table-x tbody tr { transition: background-color .12s; }
.table-x tbody tr:hover { background: var(--jm-card-2); }
.row-link { color: var(--jm-ink); font-weight: 600; text-decoration: none; }
.row-link:hover { color: var(--jm-primary-strong); text-decoration: underline; }
.row-link::after { content: ""; position: absolute; inset: 0; } /* whole row clickable */
.table-x tr { position: relative; }
.table-x .actions { position: relative; z-index: 1; }
.table-wrap { overflow-x: auto; }

@media (max-width: 767.98px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { padding: .9rem 1rem; border-bottom: 1px solid var(--jm-line-soft); }
  .table-cards td { padding: .1rem 0; border: 0; display: flex; gap: .5rem; }
  .table-cards td[data-label]::before { content: attr(data-label); color: var(--jm-muted); min-width: 92px; font-size: .8125rem; }
  .table-cards td.primary-cell { display: block; margin-bottom: .35rem; }
  .table-cards td.hide-sm { display: none; }
}

.list-x { list-style: none; margin: 0; padding: 0; }
.list-x > li { display: flex; align-items: center; gap: .85rem; padding: .8rem 1.25rem; border-bottom: 1px solid var(--jm-line-soft); position: relative; }
.list-x > li:last-child { border-bottom: 0; }
.list-x .grow { flex: 1; min-width: 0; }
.list-x .title { font-weight: 600; color: var(--jm-ink); text-decoration: none; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-x a.title::after { content: ""; position: absolute; inset: 0; }
.list-x .sub { color: var(--jm-muted); font-size: .8125rem; }

/* Filter bar */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filters .form-select, .filters .form-control { min-height: 42px; width: auto; font-size: .9rem; }
.filters .search { flex: 1 1 240px; position: relative; }
.filters .search input { width: 100%; padding-left: 2.3rem; }
.filters .search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--jm-muted); }

/* Empty states */
.empty { text-align: center; padding: 2.5rem 1.25rem; color: var(--jm-muted); }
.empty i { font-size: 2rem; color: var(--jm-line); display: block; margin-bottom: .5rem; }
.empty p { margin-bottom: 1rem; }

/* ---------------------------------------------------------------------
   Forms: sections and sticky mobile action bar
   --------------------------------------------------------------------- */
.form-section { padding: 1.25rem; border-bottom: 1px solid var(--jm-line-soft); }
.form-section:last-of-type { border-bottom: 0; }
.form-section > h2 { font-size: 1rem; font-weight: 620; margin-bottom: .25rem; }
.form-section > p.hint { color: var(--jm-muted); font-size: .875rem; margin-bottom: 1rem; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; padding: 1rem 1.25rem; border-top: 1px solid var(--jm-line-soft); background: var(--jm-card-2); border-radius: 0 0 12px 12px; }

@media (max-width: 991.98px) {
  .form-actions.sticky-mobile {
    position: fixed; left: 0; right: 0; bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); z-index: 1029;
    border-radius: 0; box-shadow: 0 -6px 20px rgba(18, 50, 59, .08); background: var(--jm-card);
  }
  .form-actions.sticky-mobile .btn { flex: 1; }
  .has-sticky-actions { padding-bottom: 76px; }
}

/* Duplicate panel */
.dup-panel { border-radius: 12px; border: 1px solid var(--warn); background: var(--warn-soft); padding: 1rem; }
.dup-panel.blocking { border-color: var(--bad); background: var(--bad-soft); }
.dup-panel h3 { font-size: .95rem; font-weight: 650; margin: 0 0 .5rem; display: flex; align-items: center; gap: .4rem; }
.dup-item { background: var(--jm-card); border-radius: 10px; padding: .7rem .85rem; margin-top: .5rem; display: flex; gap: .75rem; align-items: flex-start; }
.dup-item .reasons { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }

/* Skeleton loader */
.skeleton { position: relative; overflow: hidden; background: var(--jm-line-soft); border-radius: 8px; min-height: 14px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--jm-card) 70%, transparent), transparent);
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* History timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.25rem; position: relative; }
.timeline::before { content: ""; position: absolute; left: .4rem; top: .4rem; bottom: .4rem; width: 2px; background: var(--jm-line-soft); }
.timeline li { position: relative; padding: 0 0 1.1rem .75rem; }
.timeline li::before { content: ""; position: absolute; left: -1.07rem; top: .45rem; width: 10px; height: 10px; border-radius: 50%; background: var(--jm-card); border: 2px solid var(--jm-primary); }
.timeline .when { color: var(--jm-muted); font-size: .8125rem; }
.changes { font-size: .8125rem; margin-top: .35rem; display: grid; gap: .15rem; }
.changes .f { color: var(--jm-muted); }
.changes del { color: var(--bad); text-decoration-thickness: 1px; }
.changes ins { color: var(--ok); text-decoration: none; }

/* Pagination */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1.25rem; border-top: 1px solid var(--jm-line-soft); color: var(--jm-muted); font-size: .875rem; flex-wrap: wrap; }

/* Toasts */
.toast-stack { position: fixed; top: calc(var(--topbar-h) + .5rem); right: 1rem; z-index: 1090; display: grid; gap: .5rem; width: min(380px, calc(100vw - 2rem)); }
.toast-x { display: flex; gap: .65rem; align-items: flex-start; padding: .8rem 1rem; border-radius: 12px; background: var(--jm-card); box-shadow: var(--jm-shadow-lg); border-left: 4px solid var(--jm-primary); animation: toast-in .2s ease-out; }
.toast-x.success { border-left-color: var(--ok); } .toast-x.success i { color: var(--ok); }
.toast-x.danger { border-left-color: var(--bad); } .toast-x.danger i { color: var(--bad); }
.toast-x.warning { border-left-color: var(--warn); } .toast-x.warning i { color: var(--warn); }
.toast-x .msg { flex: 1; }
.toast-x button { background: none; border: 0; color: var(--jm-muted); padding: 0 .25rem; min-height: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }
@media (max-width: 991.98px) { .toast-stack { left: 1rem; right: 1rem; width: auto; top: calc(var(--topbar-h) + .25rem); } }

/* Bottom sheet (quick add) */
.offcanvas-bottom.sheet { height: auto; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); background: var(--jm-card); }
.sheet-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .65rem; }
.sheet-grid a {
  display: flex; align-items: center; gap: .75rem; padding: 1rem; border-radius: 12px; min-height: 64px;
  border: 1px solid var(--jm-line); text-decoration: none; color: var(--jm-ink); font-weight: 580;
}
.sheet-grid a i { font-size: 1.35rem; color: var(--jm-primary); }

/* Modal & dropdown theming */
.modal-content, .dropdown-menu, .offcanvas { background: var(--jm-card); color: var(--jm-ink); border-color: var(--jm-line); }
.modal-content { border-radius: 14px; }
.dropdown-menu { border-radius: 12px; box-shadow: var(--jm-shadow-lg); padding: .4rem; }
.dropdown-item { border-radius: 8px; padding: .55rem .75rem; color: var(--jm-ink); }
.dropdown-item:hover { background: var(--jm-line-soft); }

/* Auth screen */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 992px) { .auth-wrap { grid-template-columns: 1.05fr 1fr; } }
.auth-side {
  display: none; position: relative; overflow: hidden; color: #e6f4f6; padding: 3rem;
  background: #0b3a42;
}
@media (min-width: 992px) { .auth-side { display: flex; flex-direction: column; justify-content: space-between; } }
.auth-side h2 { color: #fff; font-size: 2rem; font-weight: 680; letter-spacing: -.025em; line-height: 1.15; max-width: 22ch; }
.auth-side p { color: #a9d3d9; max-width: 44ch; }
.auth-types { display: grid; gap: .55rem; margin-top: 2rem; }
.auth-types span { display: flex; align-items: center; gap: .6rem; color: #d5ecef; font-size: .95rem; }
.auth-types span::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.auth-form { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth-form .inner { width: 100%; max-width: 400px; }

/* Side column on forms: keep long select options from widening the column */
.side-stack { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 992px) { .side-stack { position: sticky; top: calc(var(--topbar-h) + 1rem); } }
.form-select { max-width: 100%; text-overflow: ellipsis; }
.min-w-0 { min-width: 0; }

/* Filters: collapsible on phones, inline on larger screens */
@media (min-width: 768px) { .filters-more.collapse { display: contents !important; } }
@media (max-width: 767.98px) {
  .filters-more.show, .filters-more.collapsing { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; width: 100%; }
  .filters-more .form-select { width: 100%; }
  .table-cards td.inline-sm { display: inline-flex; width: auto; margin-right: .6rem; vertical-align: middle; }
}

/* Duplicate matches: action drops below the details on phones */
.dup-item .btn { white-space: nowrap; flex: none; }
@media (max-width: 575.98px) { .dup-item { flex-wrap: wrap; } .dup-item .btn { width: 100%; } }
.dup-item .chip { white-space: normal; }

/* KPI tiles: number, meaning, and where it comes from */
.kpi .src { margin-top: .5rem; font-size: .72rem; color: var(--jm-muted); }
.kpi[aria-disabled="true"] { pointer-events: none; }
a.stat:hover .v { color: var(--jm-primary-strong); }

/* Notification count */
.badge-dot { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff; font-size: .65rem; font-weight: 700; display: grid; place-items: center; }

/* Opportunity stage bar */
.stage-bar { list-style: none; display: flex; gap: 4px; padding: 0; overflow-x: auto; scrollbar-width: none; }
.stage-bar::-webkit-scrollbar { display: none; }
.stage-bar li { flex: 1 0 auto; }
.stage-bar li > span, .stage-bar li button {
  display: block; width: 100%; padding: .45rem .75rem; border: 0; border-radius: 8px; font-size: .8rem; font-weight: 600; white-space: nowrap; text-align: center;
  background: var(--jm-line-soft); color: var(--jm-muted); min-height: 36px;
}
.stage-bar li.done > span, .stage-bar li.done button { background: var(--jm-primary-soft); color: var(--jm-primary-strong); }
.stage-bar li.current > span { background: var(--jm-primary); color: #fff; }
[data-bs-theme="dark"] .stage-bar li.current > span { color: #062a2f; }
.stage-bar li button:hover { outline: 2px solid var(--jm-primary); }

/* Pipeline board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: .75rem; overflow-x: auto; padding-bottom: .5rem; }
.board-col { background: var(--jm-card-2); border: 1px solid var(--jm-line-soft); border-radius: 12px; display: flex; flex-direction: column; min-height: 200px; }
.board-col-head { padding: .75rem .9rem .5rem; }
.board-col-head h2 { font-size: .9rem; font-weight: 650; margin: 0; display: flex; justify-content: space-between; }
.board-col-head .count { color: var(--jm-muted); font-weight: 500; }
.board-cards { padding: .25rem .6rem .75rem; display: grid; gap: .5rem; align-content: start; flex: 1; min-height: 80px; }
.board-card { background: var(--jm-card); border: 1px solid var(--jm-line-soft); border-radius: 10px; padding: .7rem .8rem; box-shadow: var(--jm-shadow); cursor: grab; }
.board-card a { color: var(--jm-ink); }
.board-card.sortable-ghost { opacity: .4; }
.board-card.sortable-chosen { box-shadow: var(--jm-shadow-lg); }
.board-empty { color: var(--jm-muted); font-size: .8rem; text-align: center; padding: 1rem 0; }
@media (max-width: 991.98px) { .board { grid-auto-flow: row; grid-auto-columns: auto; } .board-card { cursor: default; } }

/* Offline drafts banner */
#offline-drafts .dup-item { align-items: center; }
.offline-pill { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--topbar-h) + .5rem); z-index: 1095; background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); border-radius: 999px; padding: .3rem .9rem; font-size: .8rem; font-weight: 600; }
.table-x .num, .stat .v, .money { white-space: nowrap; }
