/* ============================================================
   Bootsempire CRM - style.css
   Clean, Minimal, Mobile-Friendly UI
   Palette: Bootsempire Green (#3AA63A), White, Dark Coal Charcoal
   ============================================================ */

/* -- Typography ------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* -- Design Tokens ---------------------------------------- */
:root {
  /* Brand Green */
  --green-main     : #3AA63A;
  --green-hover    : #318f31;
  --green-dark     : #257025;
  --green-subtle   : rgba(58, 166, 58, 0.12);

  /* Status Colors */
  --danger         : #dc2626;
  --danger-subtle  : #fee2e2;

  /* Semantic Variables (Dark Mode Default) */
  --bg             : #0d110e;
  --surface        : #141a15;
  --surface-subtle : #1b231c;
  --border         : #242d25;
  --border-strong  : #313d33;
  --text-main      : #edf2ee;
  --text-muted     : #8b9c8d;
  --text-faint     : #556457;

  --accent         : var(--green-main);
  --accent-hover   : var(--green-hover);
  --accent-text    : #ffffff;

  --header-bg      : #0e120f;
  --header-border  : #202721;
  --header-text    : #edf2ee;

  --sidebar-bg     : #0a0d0b;
  --sidebar-border : #1b221c;
  --sidebar-text   : #8b9c8d;
  --sidebar-hover  : rgba(255, 255, 255, 0.05);
  --sidebar-active : var(--green-subtle);
  --sidebar-active-text: var(--green-main);

  --shadow-sm      : 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md      : 0 4px 12px rgba(0, 0, 0, 0.4);

  --radius-sm      : 6px;
  --radius-md      : 8px;
  --radius-lg      : 12px;
  --radius-full    : 999px;

  --font           : 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --sidebar-w      : 300px;
  --header-h       : 68px;
  --transition     : 0.15s ease;
}

/* Light Theme Variables */
:root[data-theme="light"] {
  --bg             : #f6f8f6;
  --surface        : #ffffff;
  --surface-subtle : #edf1ed;
  --border         : #dbe2dc;
  --border-strong  : #c5d0c6;
  --text-main      : #121613;
  --text-muted     : #526054;
  --text-faint     : #7e8f81;

  --accent         : var(--green-main);
  --accent-hover   : var(--green-hover);
  --accent-text    : #ffffff;

  --header-bg      : #ffffff;
  --header-border  : #dbe2dc;
  --header-text    : #121613;

  --sidebar-bg     : #ffffff;
  --sidebar-border : #dbe2dc;
  --sidebar-text   : #526054;
  --sidebar-hover  : #f0f4f0;
  --sidebar-active : var(--green-subtle);
  --sidebar-active-text: var(--green-dark);

  --shadow-sm      : 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md      : 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Explicit Dark Theme */
:root[data-theme="dark"] {
  --bg             : #0d110e;
  --surface        : #141a15;
  --surface-subtle : #1b231c;
  --border         : #242d25;
  --border-strong  : #313d33;
  --text-main      : #edf2ee;
  --text-muted     : #8b9c8d;
  --text-faint     : #556457;

  --header-bg      : #0e120f;
  --header-border  : #202721;
  --sidebar-bg     : #0a0d0b;
  --sidebar-border : #1b221c;
  --sidebar-text   : #8b9c8d;
  --sidebar-hover  : rgba(255, 255, 255, 0.05);
  --sidebar-active : var(--green-subtle);
  --sidebar-active-text: var(--green-main);
}

/* -- Reset & Global --------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 18px; /* Globally 2px bigger for all rem typography and controls */
  scroll-padding-top: calc(var(--header-h) + 16px);
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Base image & SVG defaults - DO NOT let SVGs blow up */
img {
  display: block;
  max-width: 100%;
}
svg {
  display: inline-block;
  vertical-align: middle;
}

/* -- Logo Handling (Direct, No Boxes or Pill Wrappers) ---- */
.app-logo {
  height: 33px;
  width: auto;
  aspect-ratio: 152 / 40;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}
.header-logo {
  height: 33px;
}
/* Invert logo SVG to white on dark themes */
:root:not([data-theme="light"]) .app-logo,
:root[data-theme="dark"] .app-logo {
  filter: brightness(0) invert(1);
}
:root[data-theme="light"] .app-logo {
  filter: none;
}

.login-logo {
  height: 46px;
  margin: 0 auto;
}

/* -- Typography & Helpers --------------------------------- */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }

/* -- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color var(--transition), border-color var(--transition), color var(--transition);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--surface-subtle);
  color: var(--text-main);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover {
  background: var(--danger-subtle);
}
.btn-block {
  width: 100%;
}

/* -- Form Controls ---------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-main);
  font-family: var(--font);
  font-size: 0.9375rem;
  outline: none;
  transition: border-color var(--transition);
  box-sizing: border-box;
}
.form-control:focus {
  border-color: var(--accent);
}
.form-control::placeholder {
  color: var(--text-faint);
}
select.form-control {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b9c8d' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 14px) center;
  background-size: 16px;
  padding-right: 40px !important;
  cursor: pointer;
}
:root[data-theme="light"] select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23526054' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
.input-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

/* Password Toggle Wrapper */
.pw-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.pw-wrapper .form-control {
  padding-right: 42px;
}
.pw-toggle {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}
.pw-toggle:hover {
  color: var(--text-main);
}

/* File Upload Zone */
.input-file-zone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 22px 16px;
  text-align: center;
  background: var(--surface-subtle);
  cursor: pointer;
  position: relative;
}
.input-file-zone:hover {
  border-color: var(--accent);
}
.input-file-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.input-file-zone svg {
  width: 22px;
  height: 22px;
  margin: 0 auto;
  color: var(--text-muted);
}
.file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
}
.file-item button {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
}

/* -- LOGIN PAGE (Clean, Minimal, Centered) ---------------- */
#page-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 34px 28px;
  box-shadow: var(--shadow-md);
}
.login-logo-header {
  margin-bottom: 22px;
  display: flex;
  justify-content: center;
}
.login-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
  color: var(--text-main);
}
.login-error {
  min-height: 18px;
  font-size: 0.8125rem;
  color: var(--danger);
  font-weight: 500;
  margin-bottom: 12px;
}

/* -- APP HEADER ------------------------------------------- */
.app-header {
  height: var(--header-h);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  color: var(--header-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100; /* Stays above mobile sidebar overlay */
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.menu-toggle {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
}
.menu-toggle:hover {
  background: var(--surface-subtle);
}
.menu-toggle svg {
  width: 26px;
  height: 26px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.theme-toggle {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-sizing: border-box;
  flex-shrink: 0;
  transition: all var(--transition);
}
.theme-toggle:hover {
  border-color: var(--border-strong);
}
.theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* Profile Dropdown */
.profile-dropdown-wrap {
  position: relative;
}
.profile-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 42px;
  padding: 0 16px;
  box-sizing: border-box;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-main);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}
.profile-btn:hover {
  border-color: var(--border-strong);
}
.profile-avatar-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--accent);
}
.profile-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-faint);
}
.profile-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 8px;
  display: none;
  z-index: 110;
}
.profile-dropdown-menu.open {
  display: block;
}
.profile-menu-header {
  padding: 10px 12px 10px;
}
.profile-menu-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}
.profile-menu-dept {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.profile-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0 8px;
}
.profile-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}
.profile-menu-item:hover {
  background: var(--danger-subtle);
}
.profile-menu-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

/* -- App Body & Sidebar ----------------------------------- */
.app-body {
  display: flex;
  flex: 1;
  min-height: calc(100vh - var(--header-h));
}
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.sidebar-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 14px 6px;
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition);
}
.nav-btn:hover {
  background: var(--sidebar-hover);
  color: var(--text-main);
}
.nav-btn.active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-text);
}
.nav-btn svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
}

/* -- Main Content ----------------------------------------- */
.main-content {
  flex: 1;
  padding: 24px 28px;
  min-width: 0;
  background: var(--bg);
}

/* Page Header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.45rem;
  font-weight: 700;
}
.page-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}
.card-body {
  padding: 20px;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}
.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 6px;
}

/* Chart (Clean 14-day timeline & insights) */
.chart-bar-container {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 150px;
  padding: 16px 6px 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.chart-bar-col {
  flex: 1;
  min-width: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  position: relative;
  cursor: default;
}
.chart-bar-col:hover .chart-bar:not(.is-zero) {
  opacity: 0.85;
  filter: brightness(1.1);
}
.chart-bar-col:hover .chart-count {
  color: var(--accent);
}
.chart-bar-track {
  width: 100%;
  max-width: 28px;
  height: 90px;
  display: flex;
  align-items: flex-end;
  background: var(--surface-subtle);
  border-radius: 4px 4px 0 0;
  border-bottom: 2px solid var(--border-strong);
  overflow: hidden;
}
.chart-bar {
  width: 100%;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 0;
  transition: height 0.3s ease;
}
.chart-bar.is-zero {
  height: 2px !important;
  background: var(--border-strong);
  opacity: 0.35;
}
.chart-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 8px;
  white-space: nowrap;
}
.chart-count {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
  height: 16px;
  line-height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.badge-red {
  background: var(--danger-subtle);
  border-color: #fecaca;
  color: var(--danger);
}

/* Filter Bar (Separated Criteria & Export Groups) */
.filter-bar {
  padding: 16px 20px;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.filter-controls-group {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.filter-export-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.export-group-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 2px;
}
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
  margin: 0;
}
.filter-field label,
.filter-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.filter-field .form-control {
  height: 40px;
  box-sizing: border-box;
}
.filter-controls-group .btn,
.filter-export-group .btn {
  height: 40px;
  box-sizing: border-box;
}

/* Tables */
.table-responsive,
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table,
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}
table thead,
.table thead {
  background: var(--surface-subtle);
}
table th,
.table th {
  padding: 12px 16px;
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table th.sortable,
.table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background var(--transition), color var(--transition);
}
table th.sortable:hover,
.table th.sortable:hover {
  background: var(--surface);
  color: var(--text-main);
}
.sort-indicator {
  display: inline-block;
  margin-left: 5px;
  font-size: 0.72rem;
  color: var(--text-faint);
  vertical-align: middle;
}
table th.sort-active,
.table th.sort-active {
  color: var(--accent);
}
table td,
.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  white-space: nowrap;
}
table tr:last-child td,
.table tr:last-child td {
  border-bottom: none;
}

/* Pagination & Records Summary */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  gap: 12px;
  flex-wrap: wrap;
}
.page-info {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
table tbody tr:hover td,
.table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}
:root[data-theme="light"] table tbody tr:hover td,
:root[data-theme="light"] .table tbody tr:hover td {
  background: rgba(0, 0, 0, 0.015);
}
td.primary {
  font-weight: 600;
}
.att-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.att-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
}
.att-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.tab-btn {
  padding: 7px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.tab-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-main);
}
.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* -- EMPTY STATE (Crucial fix for giant medkit bug) ------ */
.empty-state {
  text-align: center;
  padding: 44px 20px;
  color: var(--text-muted);
}
.empty-state svg {
  width: 36px !important;
  height: 36px !important;
  max-width: 36px !important;
  max-height: 36px !important;
  margin: 0 auto 12px auto !important;
  display: block;
  color: var(--text-faint);
  stroke: currentColor;
}
.empty-state h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}
.empty-state p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  place-items: center;
  padding: 20px;
  z-index: 100;
}
.modal-backdrop.open {
  display: grid;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}
.modal-body {
  padding: 20px;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Modal Checkboxes */
.dept-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 6px;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
}
.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Toast Notifications (Modern Centered Floating Pill) */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border-strong);
  font-size: 0.92rem;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 9999;
  max-width: 90vw;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.show {
  display: inline-flex !important;
  opacity: 1 !important;
  transform: translateX(-50%) translateY(0) !important;
}
.toast.toast-error {
  border-color: #ef4444 !important;
  background: #231215 !important;
  color: #ff6b6b !important;
}
:root[data-theme="light"] .toast.toast-error {
  border-color: #f87171 !important;
  background: #fef2f2 !important;
  color: #dc2626 !important;
}
.toast.toast-success {
  border-color: var(--accent) !important;
  background: #112314 !important;
  color: #4ade80 !important;
}
:root[data-theme="light"] .toast.toast-success {
  border-color: #86efac !important;
  background: #f0fdf4 !important;
  color: #16a34a !important;
}

/* Loading */
.loading-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Mobile Responsive */
@media (max-width: 800px) {
  .app-header {
    padding: 0 14px;
  }
  .menu-toggle {
    display: inline-flex;
  }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 88vw;
    z-index: 95;
    transform: translateX(-100%);
    transition: transform 0.22s ease-in-out;
    box-shadow: var(--shadow-md);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 90;
    display: none;
  }
  .sidebar-overlay.open {
    display: block;
  }
  .main-content {
    padding: 16px;
  }
  .filter-bar {
    padding: 14px 16px;
    gap: 14px;
  }
  .filter-controls-group {
    width: 100%;
  }
  .filter-export-group {
    width: 100%;
    justify-content: flex-start;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
  }
  .profile-username {
    display: none;
  }
  .profile-btn {
    padding: 0 12px;
  }
}
