/* ═══════════════════════════════════════════════════════════════
   COMMON — common.css
   ───────────────────────────────────────────────────────────────
   Shared layout and component styles used across ALL pages.
   This file handles: reset, app shell, sidebar, topbar, cards,
   buttons, forms, tables, badges, modals, toasts, responsive.
   
   RULES:
   - Never put colors/fonts here — use var(--xxx) from theme.css
   - Module-specific styles go in css/modules/module-name.css
   - This file is loaded on EVERY page
   ═══════════════════════════════════════════════════════════════ */


/* ════════════════════════════════════════════════════════════════
   RESET & BASE
   ════════════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100vh;
}

a {
  color: var(--text-link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Scrollbar styling (Webkit) */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }


/* ════════════════════════════════════════════════════════════════
   APP SHELL — the three-part layout
   .app > .sidebar + .main > .topbar + .content
   ════════════════════════════════════════════════════════════════ */
.app {
  display: flex;
  height: 100vh;
  width: 100%;
}


/* ════════════════════════════════════════════════════════════════
   SIDEBAR
   Fixed-width navigation panel on the left.
   Dark background, light text. Scrollable nav area.
   ════════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  overflow: hidden;
}

/* Sidebar header — logo + app name */
.sidebar-header {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: var(--sp-3);
  flex-shrink: 0;
}
.sidebar-logo {
  width: 26px;
  height: 26px;
  background: var(--brand-accent-solid);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--fs-xs);
  color: white;
  flex-shrink: 0;
}
.sidebar-title {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text-sidebar-active);
  white-space: nowrap;
}

/* Sidebar navigation */
.sidebar-nav {
  flex: 1;
  padding: var(--sp-2);
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 10px; }

/* Section labels */
.nav-label {
  font-size: 9px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.25);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: var(--sp-4) var(--sp-3) var(--sp-1);
}

/* Navigation items */
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 7px var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: var(--fs-sm);
  font-weight: 450;
  cursor: pointer;
  position: relative;
  margin-bottom: 1px;
}
.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
  text-decoration: none;
}
.nav-item.active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
  font-weight: 500;
}
/* Active indicator bar */
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--brand-accent-solid);
  border-radius: 0 3px 3px 0;
}

/* Nav icons */
.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.6;
}
.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
  opacity: 1;
}

/* Nav badge (notification count) */
.nav-badge {
  margin-left: auto;
  background: var(--brand-accent-solid);
  color: white;
  font-size: 9px;
  font-weight: 600;
  padding: 0 6px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
  line-height: 16px;
}

/* Sidebar footer — user profile */
.sidebar-footer {
  padding: var(--sp-2);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.sidebar-user:hover {
  background: var(--bg-sidebar-hover);
}
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-primary-lighter);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 11px;
  color: white;
  flex-shrink: 0;
}
.user-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.user-name {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-sidebar-active);
}
.user-role {
  font-size: var(--fs-xs);
  color: var(--text-sidebar);
}


/* ════════════════════════════════════════════════════════════════
   MAIN CONTENT AREA
   Everything to the right of the sidebar.
   ════════════════════════════════════════════════════════════════ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}


/* ════════════════════════════════════════════════════════════════
   TOPBAR
   Horizontal bar at the top: breadcrumb, search, actions.
   ════════════════════════════════════════════════════════════════ */
.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-5);
  gap: var(--sp-4);
  z-index: var(--z-topbar);
}

/* Breadcrumb */
.topbar-bread {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.topbar-bread span {
  color: var(--text-primary);
  font-weight: 500;
}
.topbar-bread a {
  color: var(--text-secondary);
  text-decoration: none;
}
.topbar-bread a:hover {
  color: var(--text-link);
}
.bread-sep {
  color: var(--text-tertiary);
  font-size: var(--fs-xs);
}

/* Search box */
.topbar-center {
  flex: 1;
  max-width: 420px;
  margin: 0 auto;
}
.search-box {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--r-md);
  padding: 6px var(--sp-3);
}
.search-box:focus-within {
  border-color: var(--border-focus);
  box-shadow: var(--focus-ring);
  background: var(--bg-input-focus);
}
.search-box input {
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  width: 100%;
}
.search-box input::placeholder {
  color: var(--text-placeholder);
}
.search-key {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-tertiary);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

/* Top bar action buttons */
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.top-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.top-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}
.notif-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  background: var(--color-danger);
  border-radius: 50%;
  border: 2px solid var(--bg-topbar);
}

/* Theme toggle button */
.theme-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-btn:hover {
  border-color: var(--brand-primary-lighter);
  color: var(--brand-primary-lighter);
}


/* ════════════════════════════════════════════════════════════════
   CONTENT AREA
   Scrollable main content below the topbar.
   ════════════════════════════════════════════════════════════════ */
.content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5);
}


/* ════════════════════════════════════════════════════════════════
   GRID SYSTEM
   Simple responsive grids for dashboard and module layouts.
   ════════════════════════════════════════════════════════════════ */
.grid-1 { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 340px; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); margin-bottom: var(--sp-4); }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-full { grid-column: 1 / -1; }


/* ════════════════════════════════════════════════════════════════
   CARDS
   The primary content container across all modules.
   ════════════════════════════════════════════════════════════════ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--r-lg);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.card:hover {
  box-shadow: var(--card-shadow-hover);
}

/* Card header */
.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-light);
}
.card-t {
  font-size: var(--fs-base);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-t-icon {
  font-size: 15px;
}
.card-a {
  font-size: var(--fs-xs);
  color: var(--text-link);
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
}
.card-a:hover {
  text-decoration: underline;
}

/* Card body */
.card-b {
  padding: var(--sp-3) var(--sp-4);
}

/* Card footer */
.card-f {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}


/* ════════════════════════════════════════════════════════════════
   BUTTONS
   Consistent button styles across the platform.
   ════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Primary — filled brand color */
.btn-primary {
  background: var(--brand-primary);
  color: var(--text-on-primary);
  border-color: var(--brand-primary);
}
.btn-primary:hover {
  background: var(--brand-primary-light);
  border-color: var(--brand-primary-light);
}

/* Secondary — outlined */
.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--text-tertiary);
}

/* Danger — red for destructive actions */
.btn-danger {
  background: var(--color-danger);
  color: white;
  border-color: var(--color-danger);
}
.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

/* Ghost — text only, no border/bg */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* Success — green for confirmations */
.btn-success {
  background: var(--color-success);
  color: white;
  border-color: var(--color-success);
}
.btn-success:hover {
  background: #16a34a;
  border-color: #16a34a;
}

/* Button sizes */
.btn-sm { padding: 4px 10px; font-size: var(--fs-xs); }
.btn-lg { padding: 10px 20px; font-size: var(--fs-base); }
.btn-block { width: 100%; }

/* Disabled state */
.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Icon-only button (square) */
.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
}


/* ════════════════════════════════════════════════════════════════
   FORM ELEMENTS
   Inputs, selects, textareas, checkboxes, etc.
   ════════════════════════════════════════════════════════════════ */

/* Form group — label + input pair */
.form-group {
  margin-bottom: var(--sp-4);
}
.form-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--sp-1);
}
.form-label.required::after {
  content: ' *';
  color: var(--color-danger);
}
.form-hint {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin-top: var(--sp-1);
}

/* Text input & select */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px var(--sp-3);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  line-height: 1.5;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--focus-ring);
  background: var(--bg-input-focus);
}
.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-placeholder);
}

/* Error state */
.form-input.is-error,
.form-select.is-error,
.form-textarea.is-error {
  border-color: var(--color-danger);
}
.form-error {
  font-size: var(--fs-xs);
  color: var(--color-danger);
  margin-top: var(--sp-1);
}

/* Textarea */
.form-textarea {
  min-height: 80px;
  resize: vertical;
}

/* Select arrow */
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  font-size: var(--fs-sm);
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-primary);
  cursor: pointer;
}

/* Form row — side by side inputs */
.form-row {
  display: flex;
  gap: var(--sp-3);
}
.form-row > * {
  flex: 1;
}


/* ════════════════════════════════════════════════════════════════
   TABLES
   Used in admin views, reports, lists.
   ════════════════════════════════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.table th {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.table td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.table tr:last-child td {
  border-bottom: none;
}
.table tr:hover td {
  background: var(--bg-surface-hover);
}

/* Sortable column header */
.table th.sortable {
  cursor: pointer;
  user-select: none;
}
.table th.sortable:hover {
  color: var(--text-primary);
}


/* ════════════════════════════════════════════════════════════════
   BADGES & TAGS
   Small labels for status, priority, categories.
   ════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-info    { background: var(--color-info-bg); color: var(--color-info); }
.badge-purple  { background: var(--color-purple-bg); color: var(--color-purple); }
.badge-neutral { background: var(--bg-badge); color: var(--text-secondary); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand-accent-solid);
  background: var(--brand-accent);
  padding: 1px 6px;
  border-radius: 2px;
}

/* Priority badges */
.pri-high { background: var(--color-danger-bg); color: var(--color-danger); }
.pri-med  { background: var(--color-warning-bg); color: var(--color-warning); }
.pri-low  { background: var(--color-info-bg); color: var(--color-info); }


/* ════════════════════════════════════════════════════════════════
   LIST ITEMS
   Generic list item pattern used across multiple cards.
   ════════════════════════════════════════════════════════════════ */
.li {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border-light);
}
.li:last-child {
  border-bottom: none;
}
.li-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.li-dot.g { background: var(--color-success); }
.li-dot.y { background: var(--color-warning); }
.li-dot.r { background: var(--color-danger); }
.li-dot.b { background: var(--color-info); }
.li-info {
  flex: 1;
  min-width: 0;
}
.li-title {
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.li-meta {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
}
.li-right {
  flex-shrink: 0;
  text-align: right;
}

/* Progress bar (mini) */
.prog { width: 70px; }
.prog-bar { height: 3px; background: var(--bg-input); border-radius: 2px; overflow: hidden; }
.prog-fill { height: 100%; border-radius: 2px; }
.prog-fill.g { background: var(--color-success); }
.prog-fill.y { background: var(--color-warning); }
.prog-fill.b { background: var(--color-info); }
.prog-lbl { font-size: 9px; color: var(--text-tertiary); text-align: right; margin-top: 1px; }


/* ════════════════════════════════════════════════════════════════
   AVATAR
   User avatar circles used throughout the platform.
   ════════════════════════════════════════════════════════════════ */
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  background: var(--brand-primary-lighter);
}
.avatar-sm { width: 24px; height: 24px; font-size: 9px; }
.avatar-md { width: 30px; height: 30px; font-size: 11px; }
.avatar-lg { width: 38px; height: 38px; font-size: 13px; }
.avatar-xl { width: 48px; height: 48px; font-size: 16px; }
.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* Avatar stack (overlapping) */
.avatar-stack {
  display: flex;
}
.avatar-stack .avatar {
  margin-left: -8px;
  border: 2px solid var(--bg-surface);
}
.avatar-stack .avatar:first-child {
  margin-left: 0;
}


/* ════════════════════════════════════════════════════════════════
   MODALS
   Centered overlay modals for forms, confirmations, etc.
   ════════════════════════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-modal-overlay);
  align-items: center;
  justify-content: center;
}
.modal-overlay.show {
  display: flex;
}
.modal {
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--modal-shadow);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  z-index: var(--z-modal);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border-light);
}
.modal-title {
  font-size: var(--fs-lg);
  font-weight: 600;
}
.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  font-size: 18px;
}
.modal-close:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}
.modal-body {
  padding: var(--sp-4);
}
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-light);
}


/* ════════════════════════════════════════════════════════════════
   DROPDOWN MENU
   Context menus, action menus, select dropdowns.
   ════════════════════════════════════════════════════════════════ */
.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 160px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--r-md);
  box-shadow: var(--dropdown-shadow);
  z-index: var(--z-dropdown);
  padding: var(--sp-1) 0;
  margin-top: var(--sp-1);
}
.dropdown-menu.show {
  display: block;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
}
.dropdown-item:hover {
  background: var(--bg-surface-hover);
}
.dropdown-item.danger {
  color: var(--color-danger);
}
.dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: var(--sp-1) 0;
}


/* ════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   Slide-in notifications at bottom-right.
   ════════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: var(--sp-5);
  right: var(--sp-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}
.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--r-md);
  box-shadow: var(--dropdown-shadow);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 280px;
  max-width: 400px;
  font-size: var(--fs-sm);
  pointer-events: all;
}
.toast-success { border-left: 3px solid var(--color-success); }
.toast-warning { border-left: 3px solid var(--color-warning); }
.toast-danger  { border-left: 3px solid var(--color-danger); }
.toast-info    { border-left: 3px solid var(--color-info); }


/* ════════════════════════════════════════════════════════════════
   PAGINATION
   Standard pagination controls (max 50 records per page).
   ════════════════════════════════════════════════════════════════ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: var(--sp-4) 0;
}
.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 var(--sp-2);
  border: 1px solid var(--border-color);
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-family: var(--font-body);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.page-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}
.page-btn.active {
  background: var(--brand-primary);
  color: var(--text-on-primary);
  border-color: var(--brand-primary);
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.page-info {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  padding: 0 var(--sp-2);
}


/* ════════════════════════════════════════════════════════════════
   EMPTY STATE
   When a card/list has no data yet.
   ════════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: var(--sp-8) var(--sp-4);
  color: var(--text-tertiary);
}
.empty-state-icon {
  font-size: 32px;
  margin-bottom: var(--sp-2);
  opacity: 0.5;
}
.empty-state-text {
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-3);
}


/* ════════════════════════════════════════════════════════════════
   LOADING / SKELETON STATES
   Shown while data is being fetched.
   ════════════════════════════════════════════════════════════════ */
.skeleton {
  border-radius: var(--r-sm);
  background: var(--bg-input);
}
.skeleton-text {
  height: 12px;
  margin-bottom: var(--sp-2);
}
.skeleton-text:last-child {
  width: 60%;
}
.skeleton-circle {
  border-radius: 50%;
}
.skeleton-card {
  height: 120px;
}

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--brand-primary-lighter);
  border-radius: 50%;
}


/* ════════════════════════════════════════════════════════════════
   ALERT / FLASH MESSAGES
   Session flash messages at top of content area.
   ════════════════════════════════════════════════════════════════ */
.alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.alert-success { background: var(--color-success-bg); color: var(--color-success); border: 1px solid var(--color-success); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid var(--color-warning); }
.alert-danger  { background: var(--color-danger-bg); color: var(--color-danger); border: 1px solid var(--color-danger); }
.alert-info    { background: var(--color-info-bg); color: var(--color-info); border: 1px solid var(--color-info); }
.alert-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.7;
}
.alert-dismiss:hover {
  opacity: 1;
}


/* ════════════════════════════════════════════════════════════════
   UTILITY CLASSES
   Common helpers used everywhere.
   ════════════════════════════════════════════════════════════════ */

/* Text */
.text-xs    { font-size: var(--fs-xs) !important; }
.text-sm    { font-size: var(--fs-sm) !important; }
.text-base  { font-size: var(--fs-base) !important; }
.text-lg    { font-size: var(--fs-lg) !important; }
.text-xl    { font-size: var(--fs-xl) !important; }
.text-2xl   { font-size: var(--fs-2xl) !important; }
.text-bold  { font-weight: 600 !important; }
.text-mono  { font-family: var(--font-mono) !important; }
.text-muted { color: var(--text-secondary) !important; }
.text-dim   { color: var(--text-tertiary) !important; }
.text-link  { color: var(--text-link) !important; cursor: pointer; }
.text-success { color: var(--color-success) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-danger  { color: var(--color-danger) !important; }
.text-center  { text-align: center !important; }
.text-right   { text-align: right !important; }
.text-nowrap  { white-space: nowrap !important; }
.text-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Spacing */
.mt-1 { margin-top: var(--sp-1) !important; }
.mt-2 { margin-top: var(--sp-2) !important; }
.mt-3 { margin-top: var(--sp-3) !important; }
.mt-4 { margin-top: var(--sp-4) !important; }
.mb-1 { margin-bottom: var(--sp-1) !important; }
.mb-2 { margin-bottom: var(--sp-2) !important; }
.mb-3 { margin-bottom: var(--sp-3) !important; }
.mb-4 { margin-bottom: var(--sp-4) !important; }
.ml-auto { margin-left: auto !important; }
.p-0 { padding: 0 !important; }
.p-2 { padding: var(--sp-2) !important; }
.p-3 { padding: var(--sp-3) !important; }
.p-4 { padding: var(--sp-4) !important; }
.px-3 { padding-left: var(--sp-3) !important; padding-right: var(--sp-3) !important; }
.py-2 { padding-top: var(--sp-2) !important; padding-bottom: var(--sp-2) !important; }
.gap-2 { gap: var(--sp-2) !important; }
.gap-3 { gap: var(--sp-3) !important; }

/* Display */
.d-none { display: none !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.items-center { align-items: center !important; }
.justify-between { justify-content: space-between !important; }
.justify-center { justify-content: center !important; }
.flex-1 { flex: 1 !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-col { flex-direction: column !important; }
.shrink-0 { flex-shrink: 0 !important; }

/* Misc */
.rounded { border-radius: var(--r-md) !important; }
.rounded-full { border-radius: var(--r-full) !important; }
.shadow { box-shadow: var(--card-shadow) !important; }
.border { border: 1px solid var(--border-color) !important; }
.border-b { border-bottom: 1px solid var(--border-light) !important; }
.cursor-pointer { cursor: pointer !important; }
.overflow-hidden { overflow: hidden !important; }
.w-full { width: 100% !important; }
.h-full { height: 100% !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}


/* ════════════════════════════════════════════════════════════════
   MOBILE NAVIGATION
   Hamburger button + sidebar overlay for small screens.
   ════════════════════════════════════════════════════════════════ */
.mobile-menu-btn {
  display: none !important;
  width: 34px;
  height: 34px;
  border: none;
  background: none;
  color: var(--text-primary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: calc(var(--z-sidebar) - 1);
}
.mobile-overlay.show {
  display: block;
}


/* ════════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   All responsive rules for the shell live here.
   Module-specific responsive rules go in their own CSS files.
   ════════════════════════════════════════════════════════════════ */

/* Tablet landscape & smaller desktop */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 > :last-child { grid-column: span 2; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* Tablet portrait */
@media (max-width: 850px) {
  /* Sidebar becomes overlay */
  .sidebar {
    position: fixed;
    left: -260px;
    height: 100%;
    z-index: var(--z-sidebar);
  }
  .sidebar.open {
    left: 0;
  }
  .mobile-menu-btn {
    display: flex !important;
  }

  /* Grid adjustments */
  .grid-3 { grid-template-columns: 1fr; }
  .grid-3 > :last-child { grid-column: span 1; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2-1 { grid-template-columns: 1fr; }
  .grid-1-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .span-2, .span-3 { grid-column: span 1; }

  /* Quick actions scroll */
  .quick-bar {
    flex-wrap: nowrap;
  }
}

/* Phone */
@media (max-width: 600px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .topbar-center { display: none; }
  .content { padding: var(--sp-3); }

  /* Modal full-width on phone */
  .modal {
    width: 100%;
    max-width: none;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    max-height: 90vh;
  }

  /* Toast full-width */
  .toast-container {
    left: var(--sp-3);
    right: var(--sp-3);
    bottom: var(--sp-3);
  }
  .toast {
    min-width: 0;
    max-width: none;
  }

  /* Table scroll */
  .table-wrap {
    margin: 0 calc(var(--sp-4) * -1);
    padding: 0 var(--sp-4);
  }
}

/* Very small phone */
@media (max-width: 380px) {
  .grid-4 { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
}
