html {
  font-size: 13px;
}

@media (min-width: 768px) {
  html {
    font-size: 14px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--brand-primary);
}

html, body {
  margin: 0;
  padding: 0;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
}

.main-content {
  min-width: 0;   /* lets flex children (wide tables) shrink instead of forcing overflow */
}

/* ============================================================
   Mobile first: the page scrolls normally, and the sidebar is a drawer.

   The desktop shell (a fixed 100vh frame with its own inner scroll region) is applied only
   from lg up. On a phone, 100vh + overflow:hidden would trap the content — the viewport unit
   doesn't account for the browser's own chrome, so the bottom of every page would be cut off
   with no way to scroll to it.
   ============================================================ */

/* Below lg the sidebar is a slide-in drawer. Hand-rolled: this project ships Bootstrap 5.1, and
   responsive offcanvas (.offcanvas-lg) only exists from 5.2 — using it here silently applied
   .offcanvas-start, which slid the sidebar off-screen permanently. */
@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1045;
    width: 266px;
    height: 100%;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 0 0 32px rgba(20, 17, 20, .3);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(20, 17, 20, .5);
  }
}

/* The drawer and its backdrop are desktop-irrelevant: the sidebar is just a column again. */
@media (min-width: 992px) {
  .sidebar-backdrop { display: none !important; }
}

.mobile-bar {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .85rem;
  background: var(--brand-sidebar);
  box-shadow: 0 2px 8px rgba(20, 17, 20, .14);
}
.mobile-bar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: .45rem;
  background: transparent;
  color: #fff;
}
.mobile-bar-toggle:active { background: rgba(255, 255, 255, .12); }
.mobile-bar-title {
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: #fff;
}
.mobile-bar-title .dot { color: var(--brand-accent); }

@media (min-width: 992px) {
  /* Desktop: a fixed frame — the sidebar and the content column each scroll independently. */
  html, body {
    height: 100vh;
    overflow: hidden;
  }

  .sidebar {
    height: 100vh;
    overflow-y: auto;
  }

  .main-content {
    height: 100vh;
    overflow: hidden;   /* the inner .content-scroll scrolls, not the whole column */
  }
}

/* Manage-account pill nav → brand indigo (scoped to main content, not the sidebar) */
.main-content .nav-pills .nav-link { color: var(--brand-primary); }
.main-content .nav-pills .nav-link:hover { background-color: var(--brand-primary-tint); }
.main-content .nav-pills .nav-link.active {
  background-color: var(--brand-primary) !important;
  color: #fff !important;
}

/* Centered auth screens (login / register) — no sidebar/top bar */
.auth-body {
  min-height: 100vh;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Bottom padding lifts the centred card off dead-centre so it doesn't feel sunken.
     Keeps the top breathing room, and short viewports still scroll. */
  padding: 1.5rem 0 7rem;
  background: #f4f5fa;
}
.auth-wrap { width: 100%; max-width: 400px; padding: 1.5rem; }

/* App title on the auth screens — a masthead, not just text on the page.
   Larger with a lighter weight than the top bar, tightened tracking, and a short
   accent rule that anchors it above the logo. */
.auth-title {
  font-weight: 600;
  font-size: 1.9rem;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--brand-primary);
}
.auth-title .dot { color: var(--brand-accent); }
.auth-title::after {
  content: "";
  display: block;
  width: 44px;
  height: 3px;
  margin: 0.8rem auto 0;
  border-radius: 2px;
  background: var(--brand-accent);
}

/* Wordmark at the head of the sidebar, above the client logo.
   Two weights in one word ("Doc" light, "Approval" bold) is what makes it read as a designed
   mark rather than a heading — the contrast does the work, so no extra ornament is needed.
   White on the dark indigo (the brand indigo would vanish here); the dot carries the accent. */
.sidebar-title {
  font-size: 1.5rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: #fff;
}
.sidebar-title .w-thin {
  font-weight: 300;
  color: rgba(255, 255, 255, 0.72);
}
.sidebar-title .w-bold { font-weight: 700; }
.sidebar-title .dot { color: var(--brand-accent); }

/* Small letterspaced descender — anchors the wordmark and says what the app is. */
.sidebar-tagline {
  margin-top: 0.4rem;
  margin-bottom: 1rem;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  text-indent: 0.24em;          /* offset the trailing letter-space so it stays optically centred */
  color: rgba(255, 255, 255, 0.42);
}

/* The logo is a dark-on-light mark, so it needs a white chip to sit on. */
.sidebar-logo-chip {
  display: inline-block;
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
}
.sidebar-logo-chip img {
  max-width: 130px;
  height: auto;
  display: block;
}

/* Scrollable content region — keeps the footer out of the scroll so it never overlaps */
.content-scroll {
  flex: 1 1 auto;
  min-height: 0;
}

/* Only the desktop frame has an inner scroll region. On mobile the page itself scrolls — a
   nested scroller inside a normally-scrolling page is what produces the "stuck" feeling. */
@media (min-width: 992px) {
  .content-scroll {
    overflow-y: auto;
  }
}

.sidebar-copyright {
  font-size: .72rem;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: .02em;
  text-align: center;
}

/* Build identifier — lets QA confirm which build is deployed */
.sidebar-version {
  display: block;
  color: rgba(255, 255, 255, 0.3);
  font-size: .68rem;
}

/* Space the pills apart — flush against each other their rounded corners don't read,
   and the active item's highlight has no edge to define it. (.nav is flex, so gap works.) */
.sidebar .nav-pills {
  gap: 0.3rem;
}

.sidebar .nav-link {
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  color: rgba(255, 255, 255, 0.82) !important;   /* beats Bootstrap .text-dark */
  border-left: 3px solid transparent;
}

.sidebar .nav-link:hover {
  background-color: var(--brand-sidebar-hover);
  color: #fff !important;
}

.sidebar .nav-link.active {
  background-color: var(--brand-sidebar-active);
  color: #fff !important;
  font-weight: 600;
  border-left-color: var(--brand-accent);
}

.sidebar-brand { font-size: 1.1rem; }

/* Sidebar account area — embedded in the sidebar, not a floating card: full-bleed,
   no surface or radius, just a hairline rule separating it from the nav. Its presence
   comes from the accent avatar and the weight/colour of the text, not a container. */
.sidebar-account {
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.sidebar-account-email {
  display: block;               /* block so the ellipsis has a width to truncate against */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  color: #fff;
  font-weight: 600;
  font-size: .82rem;
}

.sidebar-account-user:hover .sidebar-account-email { color: var(--brand-accent); }

.sidebar-logout {
  background: transparent;
  border: 1px solid rgba(133, 199, 221, 0.55);
  color: var(--brand-accent);
  font-weight: 600;
  letter-spacing: .02em;
}
.sidebar-logout:hover,
.sidebar-logout:focus {
  background: var(--brand-accent);
  border-color: var(--brand-accent);
  color: #10323d;
}

/* Dark indigo sidebar — brand presence */
.sidebar,
.sidebar.bg-white {
  background-color: var(--brand-sidebar) !important;
  border-right: 0 !important;
}
.sidebar .sidebar-brand .fw-bold,
.sidebar .sidebar-brand { color: #fff !important; }
.sidebar .text-dark { color: rgba(255, 255, 255, 0.82) !important; }  /* login partial links */
.sidebar .border-bottom,
.sidebar .border-top { border-color: rgba(255, 255, 255, 0.15) !important; }

/* ============================================================
   Brand theme — palette matched to upap.co.za (Elementor globals)
   ============================================================ */
:root {
  --brand-primary: #65699A;        /* deep indigo — primary actions, active nav */
  --brand-primary-dark: #53567f;   /* hover/active */
  --brand-primary-light: #93A4D3;  /* light periwinkle */
  --brand-primary-tint: #eef0f7;   /* very light indigo wash */
  --brand-secondary: #8283A2;
  --brand-accent: #85C7DD;         /* sky blue — info */
  --brand-success: #09A328;        /* green */
  --brand-danger: #C00000;         /* red */
  --brand-text: #686868;
  --brand-heading: #141114;
  --brand-bg: #FCFCFC;
  --brand-border: #DDDDDD;
  --brand-sidebar: #3b3e66;        /* deep indigo — sidebar */
  --brand-sidebar-hover: rgba(255, 255, 255, 0.08);
  --brand-sidebar-active: rgba(255, 255, 255, 0.14);

  /* Feed Bootstrap 5.3's CSS-variable theming where supported */
  --bs-primary: #65699A;
  --bs-primary-rgb: 101, 105, 154;
  --bs-link-color: #65699A;
  --bs-link-color-rgb: 101, 105, 154;
  --bs-link-hover-color: #53567f;
}

body {
  background-color: var(--brand-bg);
  color: var(--brand-text);
}

h1, h2, h3, h4, h5, h6, .navbar-brand, .sidebar-brand .fw-bold {
  color: var(--brand-heading);
}

a { color: var(--brand-primary); }
a:hover { color: var(--brand-primary-dark); }

/* Primary buttons */
.btn-primary {
  --bs-btn-bg: var(--brand-primary);
  --bs-btn-border-color: var(--brand-primary);
  --bs-btn-hover-bg: var(--brand-primary-dark);
  --bs-btn-hover-border-color: var(--brand-primary-dark);
  --bs-btn-active-bg: var(--brand-primary-dark);
  --bs-btn-active-border-color: var(--brand-primary-dark);
  --bs-btn-disabled-bg: var(--brand-primary);
  --bs-btn-disabled-border-color: var(--brand-primary);
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.btn-primary:hover, .btn-primary:active, .btn-primary:focus {
  background-color: var(--brand-primary-dark);
  border-color: var(--brand-primary-dark);
}

.btn-outline-primary {
  --bs-btn-color: var(--brand-primary);
  --bs-btn-border-color: var(--brand-primary);
  --bs-btn-hover-bg: var(--brand-primary);
  --bs-btn-hover-border-color: var(--brand-primary);
  --bs-btn-active-bg: var(--brand-primary);
  --bs-btn-active-border-color: var(--brand-primary);
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.btn-outline-primary:hover { background-color: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }

.btn-outline-secondary {
  --bs-btn-color: var(--brand-secondary);
  --bs-btn-border-color: var(--brand-secondary);
  --bs-btn-hover-bg: var(--brand-secondary);
  --bs-btn-hover-border-color: var(--brand-secondary);
  color: var(--brand-secondary);
  border-color: var(--brand-secondary);
}

/* Status badges mapped to brand palette */
.badge.bg-primary { background-color: var(--brand-primary) !important; }
.badge.bg-success { background-color: var(--brand-success) !important; }
.badge.bg-danger  { background-color: var(--brand-danger) !important; }
.badge.bg-info    { background-color: var(--brand-accent) !important; color: #05323f !important; }
.badge.bg-secondary { background-color: var(--brand-secondary) !important; }

/* Dashboard stat tiles: brand-tinted top accents */
.card.border-secondary { border-color: var(--brand-secondary) !important; }
.card.border-info { border-color: var(--brand-accent) !important; }
.card.border-success { border-color: var(--brand-success) !important; }
.card.border-danger { border-color: var(--brand-danger) !important; }
.card .display-6 { color: var(--brand-primary); }

/* Success/danger buttons to brand */
.btn-success { --bs-btn-bg: var(--brand-success); --bs-btn-border-color: var(--brand-success); background-color: var(--brand-success); border-color: var(--brand-success); }
.btn-danger  { --bs-btn-bg: var(--brand-danger);  --bs-btn-border-color: var(--brand-danger);  background-color: var(--brand-danger);  border-color: var(--brand-danger); }
.btn-outline-danger { --bs-btn-color: var(--brand-danger); --bs-btn-border-color: var(--brand-danger); --bs-btn-hover-bg: var(--brand-danger); --bs-btn-hover-border-color: var(--brand-danger); color: var(--brand-danger); border-color: var(--brand-danger); }

/* ===== Auto-dismissing toast (no manual close) ===== */
.app-toast-wrap { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 1090; max-width: 28rem; }
.app-toast {
  display: flex; align-items: center; gap: .8rem;
  background: #fff; color: var(--brand-heading);
  border: 1px solid var(--brand-border);
  border-left: 5px solid var(--brand-success);
  border-radius: .65rem; padding: 1rem 1.25rem;
  box-shadow: 0 10px 34px rgba(20, 17, 20, 0.18);
  animation: app-toast-in .35s cubic-bezier(.22, 1, .36, 1) both,
             app-toast-out .45s ease 6s forwards;
}
.app-toast-icon {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: rgba(9, 163, 40, 0.12); color: var(--brand-success);
}
.app-toast-msg { font-size: 1rem; line-height: 1.3; }
@keyframes app-toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes app-toast-out { to { opacity: 0; transform: translateX(24px); visibility: hidden; } }

/* Toast tint by message type */
.app-toast.is-success { border-left-color: var(--brand-success); }
.app-toast.is-success .app-toast-icon { background: rgba(9, 163, 40, 0.12); color: var(--brand-success); }
.app-toast.is-warning { border-left-color: #d99400; }
.app-toast.is-warning .app-toast-icon { background: rgba(217, 148, 0, 0.15); color: #b27900; }
.app-toast.is-info { border-left-color: var(--brand-accent); }
.app-toast.is-info .app-toast-icon { background: rgba(133, 199, 221, 0.22); color: #2b7f97; }
.app-toast.is-danger { border-left-color: var(--brand-danger); }
.app-toast.is-danger .app-toast-icon { background: rgba(192, 0, 0, 0.12); color: var(--brand-danger); }

/* ===== Typography — Lato, matched to upap.co.za ===== */
:root {
  --brand-font: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
  font-family: var(--brand-font);
  font-weight: 400;
}

/* Light, airy headings (their hero style) */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--brand-font);
  font-weight: 300;
  letter-spacing: .2px;
  line-height: 1.25;
  color: var(--brand-heading);
}

/* Clean, sentence-case buttons (Lato regular) */
.btn {
  font-family: var(--brand-font);
  font-weight: 400;
  letter-spacing: .01em;
}

/* Light uppercase small-caps labels for section/table headers (subtle accent) */
.card-header {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  font-size: .76rem;
  color: var(--brand-secondary);
}

.table > thead th {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  font-size: .72rem;
  color: var(--brand-secondary);
}

.text-uppercase { letter-spacing: .05em; }

.badge {
  font-family: var(--brand-font);
  font-weight: 700;
  letter-spacing: .02em;
}
/* ============================================================
   Lists — replaces Bootstrap's grey/white zebra striping.
   A single white surface, hairline separators, and a brand-tinted hover.
   Striping fights the eye across a row; separators guide it along one.
   ============================================================ */
.table {
  --bs-table-bg: transparent;
  --bs-table-hover-bg: transparent;   /* we do our own, tinted */
  margin-bottom: 0;
}

/* The surface the rows sit on. Every list is wrapped in .table-responsive, which Bootstrap
   already gives `overflow-x: auto` — that clips to the radius on its own. Don't add
   `overflow: hidden` here, or a wide table can no longer be scrolled sideways on a narrow
   screen. */
.table-responsive {
  background: #fff;
  border: 1px solid var(--brand-border);
  border-radius: .7rem;
  box-shadow: 0 1px 2px rgba(20, 17, 20, .04);
}

.table > thead th {
  background: #fbfbfd;
  border-bottom: 1px solid var(--brand-border);
  padding: .8rem 1rem;
  white-space: nowrap;
}

.table > tbody > tr > td {
  padding: .9rem 1rem;
  border-bottom: 1px solid #eff0f4;   /* hairline, lighter than the outer border */
  vertical-align: middle;
}

/* No trailing rule against the container's own border. */
.table > tbody > tr:last-child > td { border-bottom: 0; }

.table > tbody > tr {
  transition: background-color .12s ease;
}
.table > tbody > tr:hover > td {
  background-color: var(--brand-primary-tint);
}

/* The compact History table sits inside the page, not in a surface — keep it airy but
   don't give it a card of its own. */
.table-sm > tbody > tr > td,
.table-sm > thead th { padding: .55rem .6rem; }
.table-sm > tbody > tr:hover > td { background-color: var(--brand-primary-tint); }
