/*────────────────────────────────────────────────────
  THEME VARIABLES
────────────────────────────────────────────────────*/
:root.theme-light,
html.theme-light,
body.theme-light {
  --bg-main: #f0f2f5;
  --text-main: #000000;
  --accent-1: #0c65da;
  /* top bar */
  --accent-2: #0c65da;
  /* row divider */
  --row-divider: var(--accent-1);
    /* use the same blue as the top bar */
  /* sidebar */
  --btn-main: #4A90E2;
  --heading-color: #333333;
  --card-bg: #ffffff;
  /* panels/forms */
  /*--heading-bg: #f2f3f5;    Commented out to see if it removes the heading background colors*/  
  /* table/section headers */
  --subheading-color: #555555;
  --title-color: #ffffff;
  /* top bar title */
  --topbar-title-color: #ffffff;
  /* side bar */
  --sidebar-bg: var(--accent-2);
  --sidebar-text: #ffffff;          /* sidebar base text */
  --sidebar-link: #ffffff;          /* link text in sidebar */
  --sidebar-link-hover-bg: rgba(255,255,255,0.12);
}

:root.theme-dark,
html.theme-dark,
body.theme-dark {
  --bg-main: #2C2C2C;
  --text-main: #f0f2f5;
  --accent-1: #1e1d1d;
  /* top bar */
  --accent-2: #1e1d1d;
  /* row divider */
  --row-divider: rgba(255, 255, 255, .35);
    /* soft light line in dark mode */
  /* sidebar */
  --btn-main: #4A90E2;
  --heading-color: #faf8f8;
  --card-bg: #3a3a3a;
  /*--heading-bg: #2f2f2f;Commented out to see if it removes the heading background colors*/
  --subheading-color: #CCCCCC;
  --title-color: #E4E4E4;
  --topbar-title-color: #E4E4E4;
  /* side bar */
  --sidebar-bg: var(--accent-2);
  --sidebar-text: #ffffff;
  --sidebar-link: #E4E4E4;
  --sidebar-link-hover-bg: rgba(255,255,255,0.12);
}

/*────────────────────────────────────────────────────
  GLOBAL RESET / BASE
────────────────────────────────────────────────────*/
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: var(--text-main);
  background: var(--bg-main);
}

a,
.btn {
  color: var(--text-main) !important;
}

/*────────────────────────────────────────────────────
  TOP BAR
────────────────────────────────────────────────────*/
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: var(--accent-1);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
  /* always above */
}

.logo {
  height: 40px;
}

.dev-banner {
    background-color: #b30000;
    color: #ffffff;
    text-align: center;
    padding: 4px 8px;
    margin-bottom: 10px;
    font-weight: bold;
    border-radius: 4px;
}

.app-title {
  color: var(--title-color) !important;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* optional absolute centering for title if you add .topbar-title class */
.topbar-title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--topbar-title-color);
  pointer-events: none;
  white-space: nowrap;
  font-size: 1.25rem;
}

.topbar-right {
  display: flex;
  align-items: center;
}

.topbar-right .avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  margin-left: 8px;
  margin-right: 16px;
  cursor: pointer;
}

/* Icon in the theme toggle button */
.theme-icon {
  font-size: 2.2rem;
  line-height: 1;
}

/*────────────────────────────────────────────────────
  LAYOUT (SIDEBAR + CONTENT)
────────────────────────────────────────────────────*/
.layout {
  display: flex;
  gap: 24px;
  /* space between sidebar and content */
  margin-top: 120px;
  /* height of the fixed topbar */
  min-height: calc(100vh - 120px);
}

.content {
  flex: 1 1 auto;
  min-width: 0;
  /* prevents overflow from wide tables */
  padding: 32px;
  overflow-y: auto;
  background: transparent;
}

/* SIDEBAR — fixed column, independently scrollable on desktop */
.sidebar {
  flex: 0 0 220px;
  /* fixed width column */
  width: 220px;
  background: var(--accent-2);
  color: var(--text-main);
  padding: 16px 0;
  position: sticky;
  /* stick under the topbar */
  top: 120px;
  /* same height as topbar */
  height: calc(100vh - 120px);
  /* fill remaining viewport height */
  overflow-y: auto;
  /* independent scroll */
  overscroll-behavior: contain;
  /* don't bounce parent */
  z-index: 0;
}

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0 0 16px;
  display: block;
}

.sidebar li+li {
  margin-top: 10px;
}

.sidebar a {
  color: var(--heading-color);
  text-decoration: none;
  display: block;
  padding: 10px 20px;
  border-radius: 8px;
  line-height: 1.2;
}

.sidebar a:hover {
  background: rgba(255, 255, 255, 0.10);
}

.sidebar a.active {
  font-weight: bold;
  text-decoration: underline;
}

/*────────────────────────────────────────────────────
  RESPONSIVE: convert sidebar to wrapping nav bar on small widths
────────────────────────────────────────────────────*/
@media (max-width: 992px) {
  .layout {
    flex-direction: column;
    gap: 12px;
    min-height: auto;
  }

  .sidebar {
    position: static;
    /* no sticky on narrow */
    top: auto;
    width: 100%;
    height: auto;
    overflow: visible;
    padding: 8px 8px 12px;
    border-radius: 0;
  }

  .sidebar ul {
    display: flex;
    flex-wrap: wrap;
    /* wrap items when zoomed/heavy text size */
    gap: 10px 18px;
    padding: 0 12px 8px;
  }

  .sidebar li {
    margin-top: 0;
  }

  .sidebar a {
    padding: 8px 10px;
    background: transparent;
    border-radius: 6px;
  }

  .topbar {
    height: 100px;
  }

  .layout {
    margin-top: 100px;
  }

  /* keep content flush under shorter topbar */
}

@media (max-width: 576px) {
  .sidebar ul {
    gap: 8px 12px;
  }

  .sidebar a {
    padding: 6px 8px;
    font-size: 0.95rem;
  }
}

/*────────────────────────────────────────────────────
  CARDS / TABLES / PANELS
────────────────────────────────────────────────────*/
.bg-white,
.login-container,
.card,
.card-body,
fieldset {
  background-color: var(--card-bg) !important;
  color: var(--text-main) !important;
}

body.theme-dark .table,
body.theme-dark .table th,
body.theme-dark .table td,
body.theme-dark .card,
body.theme-dark .card-body,
body.theme-dark fieldset {
  background-color: var(--card-bg) !important;
  color: var(--text-main) !important;
  border-color: #555 !important;
}

body.theme-dark .table th,
body.theme-dark .table td {
  border-color: #555 !important;
}

.container {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 20px;
}

.content h2,
.content h4 {
  color: var(--heading-color) !important;
  background-color: var(--heading-bg) !important;
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  margin-bottom: 1rem;
}

/* Dashboard cards */
.card-container {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
}

.card {
  flex: 1;
  padding: 24px;
  border-radius: 8px;
  text-align: center;
  background-color: var(--card-bg);
  color: var(--text-main);
}

.card h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
}

.card p {
  margin: 0;
  font-size: 28px;
  font-weight: bold;
}

.card-red {
  background: #FDEDEC;
  color: #A94442;
}

.card-amber {
  background: #FEF5E7;
  color: #8A6D3B;
}

.card-green {
  background: #E9F7EF;
  color: #3C763D;
}

/* Tables */
.ticket-table-wrapper {
  overflow-x: auto;
  margin-top: 16px;
}

.ticket-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 600px;
  table-layout: fixed;
}

.ticket-table th,
.ticket-table td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--row-divider);
  text-align: left;
  vertical-align: middle;
}

.ticket-table th {
  background: var(--heading-bg);
  font-weight: bold;
}

.ticket-table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.04);
}

.ticket-table tr:hover {
  background: rgba(255, 255, 255, 0.1);
}

.ticket-table a {
  color: var(--btn-main);
  text-decoration: none;
}

.ticket-table a:hover {
  text-decoration: underline;
}

.ticket-table th:last-child,
.ticket-table td:last-child {
  width: 120px;
  text-align: center;
}

/*────────────────────────────────────────────────────
  FORMS
────────────────────────────────────────────────────*/
form label {
  display: block;
  margin-bottom: 6px;
  font-weight: bold;
  font-size: 14px;
}

.form-control,
.form-select,
textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
select {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 16px;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 14px;
  background: var(--card-bg);
  color: var(--text-main);
}

body.theme-dark .form-control,
body.theme-dark .form-select,
body.theme-dark textarea,
body.theme-dark input[type="text"],
body.theme-dark input[type="email"],
body.theme-dark input[type="password"],
body.theme-dark input[type="tel"],
body.theme-dark select {
  background-color: #464646 !important;
  color: var(--text-main) !important;
  border-color: #666 !important;
}

.form-control::placeholder,
textarea::placeholder {
  color: #6c757d;
}

body.theme-dark .form-control::placeholder,
body.theme-dark textarea::placeholder {
  color: #cfd3d9 !important;
}

.form-control:focus,
.form-select:focus,
textarea:focus {
  outline: none;
  box-shadow: 0 0 0 .2rem rgba(74, 144, 226, .25) !important;
  border-color: var(--btn-main) !important;
}

.form-check-input {
  accent-color: var(--btn-main);
}

form button {
  padding: 10px 16px;
  background: var(--btn-main);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
}

form button:hover {
  background: #357ABD;
}

form button:active,
.login-container button:active,
.btn:active {
  filter: brightness(0.9);
  transform: translateY(1px);
}

/* tighter spacing (as you had) */
.login-container label,
form label {
  margin: 2px 0 !important;
}

/* Password-eye button must not look like a primary form button */
form .pw-toggle .pw-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent !important;
  color: inherit !important;
  border: 0 !important;
  padding: 4px !important;
  width: auto !important;
  height: auto !important;
  line-height: 1 !important;
  box-shadow: none !important;
  outline: none !important;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

form .pw-toggle .pw-eye:hover,
form .pw-toggle .pw-eye:focus,
form .pw-toggle .pw-eye:active {
  background: transparent !important;
  box-shadow: none !important;
  outline: none !important;
}

/* Make space for the icon so it doesn't overlap the text */
.pw-toggle { position: relative; }
.pw-toggle input { padding-right: 2.25rem; }
.pw-eye i { font-size: 1.1rem; } /* optional: icon size */



.login-container input,
.login-container textarea,
.login-container select,
.login-container .pw-toggle,
form input,
form textarea,
form select {
  margin: 2px 0 6px !important;
  padding: 6px 8px !important;
  font-size: 14px !important;
  line-height: 1.2 !important;
}

/* Password show/hide control */
.pw-toggle { position: relative; }
.pw-toggle input[type="password"],
.pw-toggle input[type="text"] { padding-right: 2.25rem; }

.pw-eye {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  padding: 0;
  line-height: 1;
  cursor: pointer;
  font-size: 1.25rem;      /* eye size */
  color: var(--subheading-color);
}
.pw-eye:hover { color: var(--text-main); }
.pw-eye:focus { outline: none; }

/*────────────────────────────────────────────────────
  LOGIN / REGISTER
────────────────────────────────────────────────────*/
body.login-body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  background: var(--bg-main);
}

.login-container {
  background: var(--card-bg);
  padding: 20px;
  width: 100%;
  max-width: 360px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  text-align: center;
  color: var(--text-main);
}

.login-logo {
  display: block;
  margin: 0 auto 16px;
  max-width: 80%;
  height: auto;
}

.login-container h2 {
  margin-bottom: 16px;
  font-size: 22px;
  color: var(--heading-color);
}

.login-container .alert {
  background: #e0f4ff;
  color: #0077cc;
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 16px;
  text-align: left;
}

.login-container button {
  width: 100%;
  padding: 10px;
  margin: 4px 0 12px;
  background: var(--btn-main);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.login-container button:hover {
  background: #357ABD;
}

/* always Pinnacom blue on login submit */
body.login-body .login-container button.btn-primary {
  background-color: #4A90E2 !important;
  border-color: #4A90E2 !important;
  color: #fff !important;
}

/* Avatar preview */
.avatar-large {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 16px;
}

/* Theme toggle animation (optional) */
#theme-toggle {
  transition: transform 0.2s;
}

#theme-toggle.rotate {
  transform: rotate(180deg);
}

/* Muted text */
.text-muted {
  color: var(--subheading-color) !important;
}

/* Login form: left-align labels and inputs inside the card */
.login-container form {
  text-align: left !important;
}

.login-container form label {
  text-align: left !important;
}

/* ── Date/Time inputs: match other fields (light + dark) ─────────────── */
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"] {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 16px;
  border-radius: 6px;
  border: 1px solid #ccc;
  font-size: 14px;
  background: var(--card-bg);
  color: var(--text-main);
}

/* Dark theme overrides (same palette as other inputs) */
body.theme-dark input[type="date"],
body.theme-dark input[type="time"],
body.theme-dark input[type="datetime-local"],
body.theme-dark input[type="month"] {
  background-color: #464646 !important;
  color: var(--text-main) !important;
  border-color: #666 !important;
  color-scheme: dark; /* render native widget in dark */
}

/* Make calendar/clock glyph visible in dark on Chromium/WebKit */
body.theme-dark input[type="date"]::-webkit-calendar-picker-indicator,
body.theme-dark input[type="time"]::-webkit-calendar-picker-indicator,
body.theme-dark input[type="datetime-local"]::-webkit-calendar-picker-indicator,
body.theme-dark input[type="month"]::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(.85);
}

/* Placeholder tone parity (for browsers that show it) */
input[type="date"]::placeholder,
input[type="time"]::placeholder,
input[type="datetime-local"]::placeholder,
input[type="month"]::placeholder {
  color: #6c757d;
}
body.theme-dark input[type="date"]::placeholder,
body.theme-dark input[type="time"]::placeholder,
body.theme-dark input[type="datetime-local"]::placeholder,
body.theme-dark input[type="month"]::placeholder {
  color: #cfd3d9 !important;
}

/* ────────────────────────────────────────────────────
   Confirm modal (moved from base.html)
   ─────────────────────────────────────────────────── */
.confirm-modal-backdrop{
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.6);
  display: none; align-items: center; justify-content: center;
}
.confirm-modal-backdrop.show{ display:flex; }
.confirm-modal{
  width: min(560px, 96vw);
  background: var(--card-bg);
  color: var(--text-main);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 14px 40px rgba(0,0,0,.45);
  font-size: 1.05rem;
}
/* Smaller “Please Confirm” */
.confirm-modal h3{
  margin: 0 0 4px 0;
  font-size: 1rem;
  font-weight: 600;
  opacity: .9;
}
/* Larger question text (“Take ticket #15?” etc.) */
.confirm-modal p{
  margin: 0 0 18px 0;
  font-size: 1.4rem;
  font-weight: 700;
}

/* -- Force modal typography override (wins over Bootstrap) -- */
.confirm-modal h3{
  font-size: 1rem !important;      /* smaller "Please Confirm" */
  line-height: 1.2 !important;
  font-weight: 600 !important;
  margin: 0 0 4px 0 !important;
  opacity: .9 !important;
}
.confirm-modal p{
  font-size: 1.4rem !important;    /* larger question text */
  line-height: 1.25 !important;
  font-weight: 700 !important;
  margin: 0 0 18px 0 !important;
}

/* === Sidebar colour overrides (independent from main text) === */
.sidebar {
  background: var(--sidebar-bg) !important;
  color: var(--sidebar-text) !important;
}

/* Make sidebar links use sidebar colours, overriding the global link colour */
.sidebar a,
.sidebar .btn {
  color: var(--sidebar-link) !important;
}

/* Hover state: a touch of contrast while keeping text readable */
.sidebar a:hover {
  background: var(--sidebar-link-hover-bg) !important;
  color: var(--sidebar-text) !important;
}

/* Optional: section headings inside the sidebar */
.sidebar h1, .sidebar h2, .sidebar h3,
.sidebar .heading, .sidebar .title {
  color: var(--sidebar-text) !important;
}

/* Ensure password container is aligned properly */
.password-container {
  position: relative;
  display: flex;
  align-items: center; /* vertically center the icon */
  width: 100%;
}

/* Adjust the input padding to make room for the eye */
.password-container input[type="password"],
.password-container input[type="text"] {
  width: 100%;
  padding-right: 40px; /* space for the icon */
  box-sizing: border-box;
}

/* Style and center the eye icon */
.password-container .toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%); /* perfectly center vertically */
  background: none;
  border: none;
  cursor: pointer;
  color: #777; /* medium grey */
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

/* Eye icon color for SVGs or font icons */
.password-container .toggle-password svg,
.password-container .toggle-password i {
  color: #777; /* medium grey */
  font-size: 1.1em;
}

/* Optional hover effect */
.password-container .toggle-password:hover svg,
.password-container .toggle-password:hover i {
  color: #555; /* slightly darker grey on hover */
}



/* ===== Password eye: final version (locked color + correct centering) ===== */
.pw-toggle { 
  position: relative !important; 
}

.pw-toggle input[type="password"],
.pw-toggle input[type="text"] {
  padding-right: 2.25rem !important;   /* space for the icon */
  box-sizing: border-box;
}

.pw-toggle .pw-eye {
  position: absolute !important;
  right: 10px !important;
  top: 50% !important;
  transform: translateY(-65%) !important; /* your visually perfect offset */
  padding: 0 !important;
  width: 1.6rem !important;
  height: 1.6rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  cursor: pointer !important;

  /* locked medium grey, never changes */
  color: #777 !important;
}

.pw-toggle .pw-eye i,
.pw-toggle .pw-eye svg {
  font-size: 1.05rem !important;
  line-height: 1 !important;
  color: #777 !important; /* permanent medium grey */
}

/* Remove any hover color shift */
.pw-toggle .pw-eye:hover,
.pw-toggle .pw-eye:hover i,
.pw-toggle .pw-eye:hover svg {
  color: #777 !important;
}

/* Profile page password fields are slightly shorter */
.profile-page .pw-toggle .pw-eye {
  transform: translateY(-50%) !important;
}


/* Make helper/muted text readable in dark mode across the app */
.theme-dark .form-text,
.theme-dark .text-muted,
.theme-dark .help-text,
.theme-dark .help-block,
.theme-dark small,
.theme-dark .muted,
.theme-dark .attachment-help {
  color: #e8e8e8 !important; /* light grey/near white for dark bg */
  opacity: 1 !important;     /* defeat Bootstrap's lowered opacity on .text-muted */
}

/* If those lines include links, ensure links are readable too */
.theme-dark .form-text a,
.theme-dark .text-muted a,
.theme-dark .help-text a,
.theme-dark .help-block a,
.theme-dark small a,
.theme-dark .muted a,
.theme-dark .attachment-help a {
  color: #f0f0f0 !important;
  text-decoration: underline;
}

/* 1) Prevent header nudge from scrollbar width changes */
:root { scrollbar-gutter: stable both-edges; }  /* modern browsers */
html { overflow-y: scroll; }                    /* fallback for others */

/* 2) Lock header layout + icon sizes so they never jump */
.header-bar { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
}

.header-bar .brand img {
  height: 36px;           /* fix logo size */
  width: auto;
  display: block;
}

.header-bar .right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Theme toggle (sun/moon) — freeze size + line height */
.header-bar .theme-toggle,
.header-bar .theme-toggle:focus,
.header-bar .theme-toggle:active {
  border: none;
  outline: none;
  padding: 0;
  background: transparent;
}

.header-bar .theme-toggle i,
.header-bar .theme-toggle svg {
  font-size: 20px !important;  /* fixed size, not em-based */
  line-height: 1 !important;
  display: inline-block;
  transform: none !important;
}

/* Avoid 'transition: all' inflating icons/borders during re-render */
.header-bar * {
  transition: color .15s ease, background-color .15s ease !important; /* not 'all' */
}

/* Avatar size fixed */
.header-bar .avatar,
.header-bar img.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

/* If your Open/Closed filter buttons increase font-size for children, cancel it */
.header-bar .theme-toggle i.bi { font-size: 20px !important; }



/* THE BELOW HAVE BEEN ADDED TO MAKE THE APP LOOK BETTER ON SMALLER DEVICES */
/* ====== Mobile / small screens polish ====== */
@media (max-width: 576px) {
  /* Top bar: allow items to wrap instead of overlapping */
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;              /* <-- key */
    padding: .5rem .75rem;
    gap: .5rem;
  }

  .topbar-left,
  .topbar-right {
    display: flex;
    align-items: center;
    gap: .5rem;
  }

  /* Keep logo & avatar within sensible bounds */
  .topbar .logo {
    height: auto;
    max-height: 36px;             /* was too tall on phones */
    width: auto;
  }
  .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
  }

  /* Title: move below the row, center it, prevent overflow */
  .topbar-title {
    order: 3;                     /* push after left/right blocks */
    width: 100%;
    text-align: center;
    margin: .25rem 0 0 0;
    font-size: clamp(1rem, 4vw, 1.25rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Layout: one column on phones */
  .layout {
    display: grid;
    grid-template-columns: 1fr !important;
  }

  /* Sidebar: show as a compact, wrapping nav bar */
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: .5rem .75rem;
  }
  .sidebar ul {
    display: flex;
    flex-wrap: wrap;              /* allow multiple rows */
    gap: .5rem .75rem;
    justify-content: center;      /* center on phones */
    padding: 0;
    margin: 0;
    list-style: none;
  }
  .sidebar ul li a {
    display: inline-block;
    padding: .45rem .75rem;
    border: 1px solid var(--border-color, rgba(0,0,0,.1));
    border-radius: .5rem;
    text-decoration: none;
  }
}

/* Tablets: slightly larger header elements */
@media (min-width: 577px) and (max-width: 992px) {
  .topbar .logo { max-height: 42px; }
  .avatar { width: 42px; height: 42px; }
  .topbar-title { font-size: clamp(1.1rem, 2.5vw, 1.5rem); }
}

/* ── Responsive top bar layout fixes ───────────────────────────── */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;                 /* allow the line to wrap on small screens */
  padding:.5rem 1rem;
}

/* logo + avatar sizing that can shrink on phones */
.topbar-left img.logo{
  display:block;
  height:auto;
  max-height:44px;
  max-width:220px;                /* keep from overflowing */
}

.avatar{
  width:44px;
  height:44px;
  border-radius:50%;
  object-fit:cover;
}

/* title can wrap and scale down */
.topbar-title{
  margin:0;
  font-weight:700;
  letter-spacing:.4px;
  white-space:nowrap;             /* desktop: single line */
  font-size:clamp(1rem, 2.5vw, 1.5rem);
}

/* ---------- phones (≤576px) ---------- */
@media (max-width:576px){
  .topbar{
    padding:.5rem .75rem;
  }
  /* put the title on its own line, centered, and let it wrap */
  .topbar-title{
    order:3;                      /* move below logo + avatar */
    width:100%;
    text-align:center;
    white-space:normal;           /* allow wrapping */
    line-height:1.2;
    font-size:1.1rem;             /* smaller title */
  }
  /* logo and avatar stay left/right */
  .topbar-left,
  .topbar-right{
    flex:1 1 auto;
    display:flex;
    align-items:center;
  }
  .topbar-left{ justify-content:flex-start; }
  .topbar-right{ justify-content:flex-end; }

  .topbar-left img.logo{
    max-height:36px;
    max-width:48vw;               /* never wider than half the screen */
  }
  .avatar{
    width:36px;
    height:36px;
  }
}

/* ── Button rows (tabs) stay tidy across sizes ─────────────────── */
.btn-row{
  display:flex;
  flex-wrap:wrap;
  gap:.75rem;
}

.btn-row .btn{
  white-space:nowrap;
}

/* Action cell buttons always side-by-side */
.table-actions{
  display:flex;
  justify-content:flex-end;
  gap:.5rem;
  flex-wrap:nowrap;
}

/* ===== Responsive header bits ===== */
.topbar {
  background-color: var(--accent-1) !important;
}

.topbar .container-fluid { max-width: 1200px; }

.brand-logo {
  height: auto;
  max-height: 40px;      /* phone */
  width: auto;
  max-width: 45vw;       /* never let logo eat the row */
}

@media (min-width: 576px) {
  .brand-logo {
    max-height: 48px;    /* sm+ */
    max-width: 180px;
  }
}

.brand-title {
  font-weight: 700;
  letter-spacing: .4px;
  white-space: nowrap;              /* keep on one line */
  font-size: clamp(14px, 4vw, 24px);
  color: var(--text-main);
}

.avatar    { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.avatar-xs { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }

/* Space below the topbar so content never tucks under it on iOS bounce */
/* Desktop & tablet: no extra gap */
.layout {
  padding-top: 0;
}

/* If you still want a tiny cushion on very small phones only, keep it here */
@media (max-width: 575.98px) {
  .layout {
    padding-top: .25rem;
  }
}

/* Make the “section buttons” stack nicely on phones */
.section-tabs .btn {
  margin: .25rem .4rem .25rem 0;
}

/* When the sidebar is hidden (<lg), let content span full width */
@media (max-width: 991.98px) {
  .layout { display: grid; grid-template-columns: 1fr; }
  .content { padding-left: 1rem; padding-right: 1rem; }
}

/* Offcanvas buttons left-aligned and large enough for thumbs */
.offcanvas .btn { text-align: left; padding: .75rem 1rem; }
.offcanvas .btn + .btn { margin-top: .5rem; }

/* ——— Header sizing & alignment ——— */
.brand-logo { height: 34px; width: auto; }
@media (max-width: 575.98px) { /* phones */
  .brand-logo { height: 26px; }
}

/* Center title area keeps true center even with right tools present */
.brand-title-wrap { min-width: 0; }
.brand-title { font-weight: 700; letter-spacing: .3px; white-space: nowrap; }

/* Avatar that scales on small screens */
.avatar-responsive {
  width: 34px; height: 34px; border-radius: 50%;
  object-fit: cover;
}
@media (max-width: 575.98px) {
  .avatar-responsive { width: 28px; height: 28px; }
}

/* Make the theme icon clearly visible */
.theme-toggle .theme-icon { font-size: 1.3rem; color: #fff; }

/* ——— Offcanvas uses theme colors (works in light & dark) ——— */
.app-offcanvas {
  background-color: var(--bg-main);
  color: var(--text-main);
  border-right: 1px solid rgba(0,0,0,.1);
}
.app-offcanvas .offcanvas-header { border-bottom: 1px solid rgba(255,255,255,.12); }
.app-offcanvas .btn-close { filter: invert(1) grayscale(100%); } /* remains visible in dark */
.app-offcanvas .btn-outline-primary,
.app-offcanvas .btn-outline-danger {
  color: var(--text-main);
  border-color: currentColor;
}
.app-offcanvas .btn-outline-primary:hover,
.app-offcanvas .btn-outline-danger:hover {
  background-color: rgba(255,255,255,.08);
  color: var(--text-main);
}

/* Keep desktop sidebar hidden on phones; visible >= md via base.html classes */
@media (max-width: 767.98px) {
  .layout { display: block; }
}

/* Logo sizes */
.brand-logo { height: 34px; width: auto; }
@media (max-width: 575.98px) { .brand-logo { height: 26px; } }

/* Avatar: larger on desktop, smaller on tablet/phone */
.avatar-responsive {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
}
@media (max-width: 991.98px) { /* md and below */
  .avatar-responsive { width: 36px; height: 36px; }
}
@media (max-width: 575.98px) { /* phones */
  .avatar-responsive { width: 30px; height: 30px; }
}

/* Title styling */
.brand-title-wrap { min-width: 0; }
.brand-title { font-weight: 700; letter-spacing: .3px; white-space: nowrap; }

/* Offcanvas respects theme (so dark mode text is readable) */
.app-offcanvas {
  background-color: var(--bg-main);
  color: var(--text-main);
}
.app-offcanvas .offcanvas-header { border-bottom: 1px solid rgba(255,255,255,.12); }
.app-offcanvas .btn-close { filter: invert(1) grayscale(100%); }
.app-offcanvas .btn-outline-primary,
.app-offcanvas .btn-outline-danger {
  color: var(--text-main); border-color: currentColor;
}
.app-offcanvas .btn-outline-primary:hover,
.app-offcanvas .btn-outline-danger:hover {
  background-color: rgba(255,255,255,.08); color: var(--text-main);
}

/* --- Keep outline buttons outlined unless they are .active --- */
.section-tabs .btn-outline-primary:not(.active):focus,
.section-tabs .btn-outline-primary:not(.active):active,
.section-tabs .btn-outline-primary:not(.active):focus-visible {
  background-color: transparent !important;
  color: var(--bs-primary) !important;
  border-color: var(--bs-primary) !important;
  box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .25); /* optional glow */
}

/* Compact stat cards on small screens */
@media (max-width: 576px) {
  .stat-card { padding: .75rem !important; }
  .stat-card h5 { font-size: .9rem !important; margin-bottom: .25rem !important; }
  .stat-card h2 { font-size: 1.35rem !important; margin: 0 !important; }
}

/* Keep outline buttons outlined on hover/focus unless they're actually .active */
.btn-outline-primary:not(.active):hover,
.btn-outline-primary:not(.active):focus,
.btn-outline-primary:not(.active):active,
.btn-outline-primary:not(.active):focus-visible {
  background-color: transparent !important;
  color: var(--bs-primary) !important;
  border-color: var(--bs-primary) !important;
  box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb,13,110,253), .25); /* optional focus ring */
}

/* --- Tabs: show filled color ONLY on the real active tab --- */
.section-tabs .btn-outline-primary {
  background: transparent;
  color: var(--bs-primary);
  border-width: 2px;
}
.section-tabs .btn-outline-primary.active {
  background: var(--bs-primary);
  color: #fff;
}
/* When not active, keep outline on hover/focus, do not fill */
.section-tabs .btn-outline-primary:not(.active):hover,
.section-tabs .btn-outline-primary:not(.active):focus,
.section-tabs .btn-outline-primary:not(.active):active {
  background: transparent;
  color: var(--bs-primary);
  box-shadow: none;
}

/* --- Explicit subtle backgrounds for KPI cards (can't be overridden) --- */
.bg-danger.bg-opacity-10 { background-color: rgba(220, 53, 69, 0.10) !important; }
.bg-warning.bg-opacity-10 { background-color: rgba(255, 193, 7, 0.10) !important; }
.bg-success.bg-opacity-10 { background-color: rgba(25, 135, 84, 0.10) !important; }

/* If you changed to new Bootstrap 5.3 “-subtle” classes anywhere, keep them crisp too */
.bg-danger-subtle  { background-color: var(--bs-danger-bg-subtle)  !important; }
.bg-warning-subtle { background-color: var(--bs-warning-bg-subtle) !important; }
.bg-success-subtle { background-color: var(--bs-success-bg-subtle) !important; }

/* --- KPI cards: tighter & true 3-up grid on phones --- */
@media (max-width: 575.98px) {
  .row.g-4.mb-5 { 
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
  }
  .row.g-4.mb-5 > [class^="col-"] {
    grid-column: span 1;
  }
  .row.g-4.mb-5 .p-4 { padding: .75rem !important; }
  .row.g-4.mb-5 h5    { font-size: .95rem; margin-bottom: .25rem; }
  .row.g-4.mb-5 h2    { font-size: 1.25rem; margin: 0; }
  .row.g-4.mb-5 small { font-size: .75rem; }
}

/* --- Fix filter buttons (section tabs) --- */
.section-tabs .btn {
  /* start all tabs as outline buttons */
  background: transparent;
}

.section-tabs .btn.active {
  /* only the active tab gets the solid primary style */
  color: #fff !important;
  background-color: var(--bs-primary) !important;
  border-color: var(--bs-primary) !important;
}

.section-tabs .btn:not(.active) {
  color: var(--bs-primary) !important;
  border-color: var(--bs-primary) !important;
}

/* --- Fix stat card backgrounds so Bootstrap's contexts show correctly --- */
.stat-card { background: none !important; } /* don’t force a single colour */

.bg-danger.bg-opacity-10    { background-color: rgba(var(--bs-danger-rgb),   .10) !important; }
.bg-warning.bg-opacity-10   { background-color: rgba(var(--bs-warning-rgb),  .10) !important; }
.bg-success.bg-opacity-10   { background-color: rgba(var(--bs-success-rgb),  .10) !important; }

/* Bulletproof KPI backgrounds used by dashboards */
.kpi-danger  { background-color: rgba(220, 53, 69, 0.10) !important; }   /* red 10% */
.kpi-warning { background-color: rgba(255, 193, 7,  0.10) !important; }   /* amber 10% */
.kpi-success { background-color: rgba(25,  135, 84, 0.10) !important; }   /* green 10% */

/* Mobile: put the logo on its own centered row */
@media (max-width: 575.98px) {
  .topbar { flex-wrap: wrap; }                 /* allow wrapping */
  .topbar .brand {
    order: 1;                                  /* first row */
    flex: 0 0 100%;                            /* full width line */
    display: flex;
    justify-content: center;                   /* centered logo */
    align-items: center;
    padding-top: .25rem;
  }
  /* keep the logo tidy on phones */
  .topbar .brand .brand-logo { max-height: 34px; width: auto; }
}

/* ===== Mobile header layout (≤575.98px) ===== */
@media (max-width: 575.98px) {
  .topbar { 
    display: flex; 
    flex-wrap: wrap; 
    align-items: center; 
    justify-content: flex-start; 
    gap: .5rem;
  }

  /* Row 1: logo centered, full width */
  .topbar .brand {
    order: 1;
    flex: 0 0 100%;
    justify-content: center;
  }
  .topbar .brand .brand-logo { max-height: 34px; width: auto; }

  /* Row 2: title centered, full width */
  .brand-title-xs {
    display: block !important;
    width: 100%;
    text-align: center;
    font-weight: 700;
    letter-spacing: .3px;
    margin-top: .15rem;
  }

  /* Row 3: hamburger (left) + right tools (avatar + sun/moon) on same line */
  #mobileMenuBtn { 
    order: 3; 
    width: 36px; 
    height: 36px; 
    padding: 0; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border-radius: 10px;
  }
  .topbar-right { 
    order: 3; 
    margin-left: auto;        /* push to far right */
  }
  /* make profile image and hamburger same size */
  .topbar-right .avatar,
  .topbar-right img.avatar,
  .avatar-xs { width: 36px; height: 36px; }

  /* optional: tighten the header vertical space */
  .topbar { padding: .5rem .75rem; }
}

/* Lock order/align for the mobile controls row */
@media (max-width: 575.98px){
  .mobile-controls{ display:flex !important; flex-direction:row !important; }
  .mobile-controls .mobile-left{ order:1; }
  .mobile-controls .mobile-right{ order:2; }
  .avatar-mobile{ width:36px; height:36px; border-radius:50%; object-fit:cover; }
}

/* Make sure the theme icon is clearly visible on the topbar */
.theme-toggle .theme-icon { font-size: 1.35rem; color: #fff; line-height: 1; }

/* ---------- Mobile header polish (xs–sm) ---------- */
@media (max-width: 575.98px) {
  .topbar {
    padding: .5rem .75rem 1rem !important;   /* extra bottom padding so controls sit inside the blue bar */
  }
  .mobile-controls-row {
    margin-top: .25rem;
  }
  .btn-menu { width: 42px; height: 42px; border-radius: 12px; }
  .avatar-responsive { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
  .theme-toggle .theme-icon { font-size: 1.35rem; }
}

/* ---------- Compact welcome card on phones ---------- */
@media (max-width: 575.98px) {
  /* target the top welcome card that uses Bootstrap .bg-white/.rounded etc. */
  .content > .bg-white:first-of-type,
  .content > .card:first-of-type {
    text-align: center;
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }
  /* Hide the descriptive subtext on mobile to save vertical space */
  .content > .bg-white:first-of-type small.text-muted,
  .content > .card:first-of-type small.text-muted {
    display: none !important;
  }
  /* Center the date in the right column (your templates place it in a small element) */
  .content > .bg-white:first-of-type .text-muted,
  .content > .card:first-of-type .text-muted {
    display: block;
    text-align: center !important;
    margin-top: .25rem;
  }
}

/* --- Mobile header polish (phones only) --- */
@media (max-width: 575.98px) {
  /* Give the top bar enough vertical room for all three rows:
     logo, title, and the actions row (hamburger + avatar + theme). */
  .topbar {
    padding: .6rem 1rem 1rem !important;   /* extra bottom padding */
    min-height: 152px;                      /* guarantees space; adjust if needed */
  }

  /* Center the logo and title as a stacked block */
  .mobile-brand {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100%;
    margin: .15rem 0 .4rem 0;
  }
  .mobile-brand .brand-logo { max-height: 44px; }
  .mobile-title { margin-top: .25rem; }

  /* Actions row always sits on a new line, inside the bar */
  .mobile-actions {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important; /* hamburger left, avatar/theme right */
    width: 100%;
    margin-top: .25rem;
  }

  /* Make hamburger the same visual size as the avatar */
  .mobile-actions .btn.hamburger {
    width: 44px; height: 44px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 12px;
  }
  .mobile-actions .btn.hamburger i { font-size: 1.6rem; line-height: 1; }

  /* Avatar size harmony on phones */
  .avatar-responsive { width: 44px; height: 44px; }

  /* Keep the theme icon clearly tappable */
  .theme-toggle .theme-icon { font-size: 1.35rem; }
}

/* --- Mobile welcome block: short & centered --- */
@media (max-width: 575.98px) {
  /* The row inside your .p-4 card is the flex container (d-flex) */
  .content .p-4.bg-white.rounded.shadow-sm.mb-4 > .d-flex {
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    gap: .35rem;
  }
  /* Tighten the card padding to save vertical space */
  .content .p-4.bg-white.rounded.shadow-sm.mb-4 {
    padding: .85rem !important;
  }
  /* Make the date appear as the second centered line */
  .content .p-4.bg-white.rounded.shadow-sm.mb-4 small.text-muted {
    display: block !important;
    text-align: center !important;
    margin-top: .15rem;
  }
}

/* --- KPI cards: consistent 3-up grid on phones --- */
@media (max-width: 575.98px) {
  /* Target the first “stats row” used on your dashboards */
  .row.g-4.mb-5, .row.g-4.mb-4 {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: .75rem !important;
  }
  .row.g-4.mb-5 > [class^="col-"],
  .row.g-4.mb-4 > [class^="col-"] {
    grid-column: span 1 !important;
  }

  /* Equal heights & readable content inside */
  .row.g-4.mb-5 .stat-card,
  .row.g-4.mb-4 .stat-card {
    min-height: 110px;          /* adjust if you want tighter/looser */
    padding: .9rem !important;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    border-radius: .75rem;
  }
  .row.g-4.mb-5 h5, .row.g-4.mb-4 h5   { font-size: .95rem; margin-bottom: .25rem; }
  .row.g-4.mb-5 h2, .row.g-4.mb-4 h2   { font-size: 1.25rem; margin: 0; }
  .row.g-4.mb-5 small, .row.g-4.mb-4 small { font-size: .75rem; }
}

/* Keep your context backgrounds crisp (already pink/amber/green) */
.bg-danger.bg-opacity-10  { background-color: rgba(220, 53, 69,  0.10) !important; }
.bg-warning.bg-opacity-10 { background-color: rgba(255, 193, 7,  0.10) !important; }
.bg-success.bg-opacity-10 { background-color: rgba(25, 135, 84, 0.10) !important; }

/* --- KPI cards: make the contextual background fill the whole tile --- */
.stat-card.bg-danger.bg-opacity-10  { background-image:none !important; background-color: rgba(var(--bs-danger-rgb), .10) !important; }
.stat-card.bg-warning.bg-opacity-10 { background-image:none !important; background-color: rgba(var(--bs-warning-rgb), .10) !important; }
.stat-card.bg-success.bg-opacity-10 { background-image:none !important; background-color: rgba(var(--bs-success-rgb), .10) !important; }

/* If any earlier rule zeroed the background, undo it specifically here */
.stat-card { background-color: transparent !important; }            /* neutral */
.stat-card.bg-danger.bg-opacity-10,
.stat-card.bg-warning.bg-opacity-10,
.stat-card.bg-success.bg-opacity-10 { background-color: inherit !important; }

/* Layout: keep all three tiles equal width & tall enough to cover text */
.kpi-row { display:flex; gap:1rem; }
.kpi-row > [class*="col-"] { display:flex; }
.kpi-row .stat-card {
  flex: 1 1 auto;
  width: 100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  min-height: 92px;           /* ensures the color block always covers the title */
  text-align:center;
}

/* Mobile: still 3-up, but slightly tighter spacing and readable titles */
@media (max-width: 575.98px) {
  .kpi-row { gap:.75rem; }
  .kpi-row .stat-card { padding:.75rem !important; min-height: 88px; }
  .kpi-row .stat-card h5 { font-size: .95rem; line-height:1.2; margin-bottom:.25rem; }
  .kpi-row .stat-card h2 { font-size: 1.25rem; margin:0; }
}

/* === KPI COLORS — support both Bootstrap bg-* and your kpi-* classes === */
.stat-card.kpi-danger,
.stat-card.bg-danger.bg-opacity-10 {
  background-image: none !important;
  background-color: rgba(220, 53, 69, 0.10) !important;      /* red */
}

.stat-card.kpi-warning,
.stat-card.bg-warning.bg-opacity-10 {
  background-image: none !important;
  background-color: rgba(255, 193, 7, 0.10) !important;       /* amber */
}

.stat-card.kpi-success,
.stat-card.bg-success.bg-opacity-10 {
  background-image: none !important;
  background-color: rgba(25, 135, 84, 0.10) !important;       /* green */
}

/* If an earlier rule set .stat-card background to transparent, this wins */
.stat-card.kpi-danger,
.stat-card.kpi-warning,
.stat-card.kpi-success,
.stat-card.bg-danger.bg-opacity-10,
.stat-card.bg-warning.bg-opacity-10,
.stat-card.bg-success.bg-opacity-10 { background-clip: padding-box !important; }

/* === KPI LAYOUT — force 3-up and equal heights, even on phones === */
.kpi-row {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 1rem !important;
}
.kpi-row > [class*="col-"] { display: flex !important; }   /* make each cell a flexbox */
.kpi-row .stat-card {
  flex: 1 1 auto;
  width: 100%;
  min-height: 96px;                /* enough to cover long headings */
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: .9rem !important;
}

/* Slightly tighter on very small phones but still 3-up */
@media (max-width: 375px) {
  .kpi-row { gap: .6rem !important; }
  .kpi-row .stat-card { min-height: 90px; padding: .75rem !important; }
  .kpi-row .stat-card h5 { font-size: .95rem; margin-bottom: .15rem; }
  .kpi-row .stat-card h2 { font-size: 1.15rem; margin: 0; }
}

/* === KPI cards: equal width, equal height, tighter spacing === */

/* make the KPI row a real 3-column grid on all viewports */
.kpi-row {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  column-gap: 1rem !important;
  row-gap: 1rem !important;
}

/* remove Bootstrap column padding inside the grid cells and allow full stretch */
.kpi-row > [class^="col-"],
.kpi-row > [class*=" col-"] {
  padding: 0 !important;
  min-width: 0 !important;
  display: block !important;
}

/* make each card fill its grid cell and share the same height */
.kpi-row .stat-card {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100% !important;
  height: 160px !important;              /* unified height */
  border-radius: 12px;
  padding: 0 1rem !important;
  text-align: center;
}

/* tidy the typography so long labels never force wrap artifacts */
.kpi-row .stat-card h5 { 
  margin: 0 0 .35rem 0 !important;
  line-height: 1.2;
}
.kpi-row .stat-card h2 { 
  margin: 0 !important; 
}

/* slightly shorter cards on very small phones while keeping 3-up */
@media (max-width: 375px) {
  .kpi-row { column-gap: .6rem !important; row-gap: .6rem !important; }
  .kpi-row .stat-card { height: 140px !important; padding: 0 .75rem !important; }
}

/* === KPI cards: force 3 equal columns + equal heights (desktop & mobile) === */
.kpi-row{
  display:grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 1.25rem;                  /* spacing between cards */
  align-items: stretch;
}

/* neutralize Bootstrap column sizing so the grid can control widths */
.kpi-row > [class^="col"]{
  grid-column: span 1 !important;
  width: 100% !important;
  padding: 0 !important;
}

/* card block itself */
.kpi-row .stat-card{
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  height: 180px;                 /* equal height */
  border-radius: 12px;
  text-align:center;
}

/* headings inside the card */
.kpi-row .stat-card h5{
  margin: 0 0 .35rem 0;
  font-weight: 600;
}
.kpi-row .stat-card h2{
  margin: 0;
  font-weight: 700;
}

/* background tints (keep if you already have them; harmless to repeat) */
.kpi-danger  { background-color: rgba(220,53,69,  .15) !important; }
.kpi-warning { background-color: rgba(255,193,7,  .18) !important; }
.kpi-success { background-color: rgba(25,135,84,  .15) !important; }

/* Phones: slightly tighter + shorter cards but still 3 across */
@media (max-width: 575.98px){
  .kpi-row{ gap: .75rem; }
  .kpi-row .stat-card{ height: 140px; padding: .5rem; }
  .kpi-row .stat-card h5{ font-size: .95rem; }
  .kpi-row .stat-card h2{ font-size: 1.25rem; }
}

/* === Reduce vertical spacing in ticket tables on mobile === */
@media (max-width: 768px) {
  table {
    border-collapse: collapse !important;
  }

  table th,
  table td {
    padding-top: 0.0rem !important; /*changed to 0.0rem from 0.25rem to get rid of white space at top*/
    padding-bottom: 0.25rem !important;
    line-height: 1.2 !important;
  }

  /* tighten up row spacing */
  table tr {
    margin: 0 !important;
    height: auto !important;
  }

  /* optional: make buttons slightly smaller */
  table .btn {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.85rem !important;
  }
}

.badge.ping-flash {
  animation: pingFlash 1s linear infinite;
}

@keyframes pingFlash {
  0%   { background-color: #dc3545; }  /* red */
  50%  { background-color: #28a745; }  /* green */
  100% { background-color: #dc3545; }  /* red */
}

/* --- Admin Users: Monitor Alerts column alignment --- */
.ticket-table th.col-monitor-alerts,
.ticket-table td.col-monitor-alerts {
  text-align: center !important;
}

.ticket-table td.col-monitor-alerts .form-check.form-switch {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ticket-table td.col-monitor-alerts .form-check-input {
  margin: 0 !important;        /* overrides bootstrap's margin */
  float: none !important;
}
