/* ============================================================
   TOPSCAN INSPECTIONS — DESIGN SYSTEM v2.0
   app.css — Core design tokens, layout, components, utilities
   ============================================================ */

/* ── GOOGLE FONTS ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS CUSTOM PROPERTIES (DESIGN TOKENS) ────────────────── */
:root {
  /* Brand Colors */
  --brand-primary:    #1e40af;
  --brand-secondary:  #0ea5e9;
  --brand-accent:     #06b6d4;

  /* Semantic Colors */
  --color-success:    #10b981;
  --color-warning:    #f59e0b;
  --color-danger:     #ef4444;
  --color-info:       #3b82f6;

  /* Sidebar */
  --sidebar-bg:        #0f172a;
  --sidebar-hover:     #1e293b;
  --sidebar-active:    #1e40af;
  --sidebar-text:      #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-border:    #1e293b;
  --sidebar-width:     260px;
  --sidebar-collapsed: 72px;

  /* Topbar */
  --topbar-bg:         #ffffff;
  --topbar-height:     64px;
  --topbar-border:     #e2e8f0;
  --topbar-shadow:     0 1px 3px rgba(0,0,0,0.07);

  /* Page */
  --page-bg:           #f1f5f9;
  --page-bg-alt:       #f8fafc;

  /* Cards */
  --card-bg:           #ffffff;
  --card-border:       #e2e8f0;
  --card-radius:       14px;
  --card-shadow:       0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 4px 20px rgba(0,0,0,0.12);

  /* Text */
  --text-primary:      #0f172a;
  --text-secondary:    #475569;
  --text-muted:        #94a3b8;
  --text-inverse:      #ffffff;

  /* Borders */
  --border-color:      #e2e8f0;
  --border-radius:     10px;
  --border-radius-sm:  6px;
  --border-radius-lg:  16px;
  --border-radius-xl:  24px;
  --border-radius-pill:9999px;

  /* Spacing */
  --space-xs:    4px;
  --space-sm:    8px;
  --space-md:    16px;
  --space-lg:    24px;
  --space-xl:    32px;
  --space-2xl:   48px;

  /* Typography */
  --font-family:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs:  11px;
  --font-size-sm:  12px;
  --font-size-base: 14px;
  --font-size-md:  15px;
  --font-size-lg:  16px;
  --font-size-xl:  18px;
  --font-size-2xl: 22px;
  --font-size-3xl: 28px;
  --font-size-4xl: 36px;

  /* Transitions */
  --transition-fast:   all 0.15s ease;
  --transition-base:   all 0.25s ease;
  --transition-slow:   all 0.4s ease;

  /* Z-index */
  --z-sidebar:   1000;
  --z-topbar:    900;
  --z-modal:     1050;
  --z-tooltip:   1100;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--page-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; color: inherit; }
a:hover { color: var(--brand-primary); }
img { max-width: 100%; }
ul { list-style: none; }

/* ── LAYOUT ───────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ──────────────────────────────────────────────── */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: var(--transition-base);
  overflow: hidden;
}

/* Sidebar brand area */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 20px var(--space-md);
  height: var(--topbar-height);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-sm);
  object-fit: contain;
  flex-shrink: 0;
  background: var(--brand-primary);
  padding: 4px;
}

.sidebar-brand-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-inverse);
  letter-spacing: 0.5px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand-text span {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--sidebar-text);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Sidebar nav scroll */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-md) 0;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

/* Section label */
.sidebar-section-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #475569;
  padding: var(--space-md) var(--space-md) var(--space-xs);
  white-space: nowrap;
}

/* Nav items */
.sidebar-item {
  position: relative;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px var(--space-md);
  color: var(--sidebar-text);
  font-size: var(--font-size-base);
  font-weight: 500;
  border-radius: 0;
  transition: var(--transition-fast);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

.sidebar-link.active {
  background: linear-gradient(90deg, rgba(30,64,175,0.5) 0%, rgba(30,64,175,0.15) 100%);
  color: var(--sidebar-text-active);
  border-left: 3px solid var(--brand-secondary);
}

.sidebar-link .sidebar-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-link.active .sidebar-icon,
.sidebar-link:hover .sidebar-icon {
  opacity: 1;
}

.sidebar-link .sidebar-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-link .sidebar-chevron {
  font-size: 11px;
  transition: transform 0.2s;
  opacity: 0.5;
}

.sidebar-link[aria-expanded="true"] .sidebar-chevron {
  transform: rotate(90deg);
  opacity: 1;
}

/* Submenu */
.sidebar-submenu {
  background: rgba(0,0,0,0.2);
  overflow: hidden;
}

.sidebar-submenu .sidebar-link {
  padding: 8px var(--space-md) 8px 48px;
  font-size: var(--font-size-sm);
  font-weight: 400;
}

.sidebar-submenu .sidebar-link::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  margin-right: -8px;
  opacity: 0.5;
}

/* Public Form pill button inside sidebar submenu */
.public-form-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f97316;
  color: #fff !important;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
}
.public-form-btn:hover {
  background: #ea580c;
  color: #fff !important;
  transform: translateY(-1px);
}

/* Sidebar footer */
.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.1);
}

.sidebar-user-avatar-placeholder {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-user-name {
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 10px;
  color: var(--sidebar-text);
  text-transform: capitalize;
}

.sidebar-signout {
  width: 28px;
  height: 28px;
  border-radius: var(--border-radius-sm);
  background: rgba(239,68,68,0.15);
  color: #f87171;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.sidebar-signout:hover {
  background: rgba(239,68,68,0.3);
  color: #fca5a5;
}

/* ── MAIN CONTENT ─────────────────────────────────────────── */
.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-base);
}

/* ── TOPBAR ───────────────────────────────────────────────── */
.app-topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  box-shadow: var(--topbar-shadow);
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
  gap: var(--space-md);
  z-index: var(--z-topbar);
}

.topbar-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 18px;
  transition: var(--transition-fast);
}

.topbar-toggle:hover {
  background: var(--page-bg);
  color: var(--text-primary);
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-base);
  color: var(--text-muted);
  flex: 1;
}

.topbar-breadcrumb .current {
  color: var(--text-primary);
  font-weight: 600;
}

.topbar-breadcrumb i { font-size: 10px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Topbar action buttons */
.topbar-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--border-radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 16px;
  transition: var(--transition-fast);
  position: relative;
}

.topbar-btn:hover {
  background: var(--page-bg);
  color: var(--text-primary);
}

.topbar-btn .badge-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-danger);
  border: 2px solid white;
}

/* Topbar user avatar */
.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--border-radius);
  transition: var(--transition-fast);
  border: none;
  background: transparent;
}

.topbar-user:hover { background: var(--page-bg); }

.topbar-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-color);
}

.topbar-user-avatar-placeholder {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
}

.topbar-user-info { text-align: left; }

.topbar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.topbar-user-role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* ── PAGE CONTENT ─────────────────────────────────────────── */
.app-content {
  flex: 1;
  padding: var(--space-lg);
}

/* Page header */
.page-header {
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.page-header-left {}

.page-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: 4px;
}

.page-header-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* ── CARDS ────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: var(--transition-base);
}

.card:hover { box-shadow: var(--card-shadow-hover); }

.card-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
  background: var(--card-bg);
}

.card-title {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: var(--space-lg); }

.card-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--card-border);
  background: var(--page-bg-alt);
}

/* ── STAT CARDS ───────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: var(--space-lg);
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  transition: var(--transition-base);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
}

.stat-card.blue::before   { background: var(--brand-primary); }
.stat-card.teal::before   { background: var(--brand-accent); }
.stat-card.green::before  { background: var(--color-success); }
.stat-card.orange::before { background: var(--color-warning); }
.stat-card.red::before    { background: var(--color-danger); }
.stat-card.purple::before { background: #8b5cf6; }
.stat-card.sky::before    { background: var(--brand-secondary); }
.stat-card.pink::before   { background: #ec4899; }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-card.blue   .stat-icon { background: #dbeafe; color: var(--brand-primary); }
.stat-card.teal   .stat-icon { background: #cffafe; color: var(--brand-accent); }
.stat-card.green  .stat-icon { background: #d1fae5; color: var(--color-success); }
.stat-card.orange .stat-icon { background: #fef3c7; color: var(--color-warning); }
.stat-card.red    .stat-icon { background: #fee2e2; color: var(--color-danger); }
.stat-card.purple .stat-icon { background: #ede9fe; color: #8b5cf6; }
.stat-card.sky    .stat-icon { background: #e0f2fe; color: var(--brand-secondary); }
.stat-card.pink   .stat-icon { background: #fce7f3; color: #ec4899; }

.stat-body { flex: 1; }

.stat-value {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

.stat-trend {
  font-size: var(--font-size-xs);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

.stat-trend.up    { color: var(--color-success); }
.stat-trend.down  { color: var(--color-danger); }

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--border-radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:focus { outline: 2px solid var(--brand-secondary); outline-offset: 2px; }

.btn-primary {
  background: var(--brand-primary);
  color: white;
  border-color: var(--brand-primary);
}
.btn-primary:hover {
  background: #1d3899;
  color: white;
  border-color: #1d3899;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30,64,175,0.3);
}

.btn-secondary {
  background: var(--brand-secondary);
  color: white;
  border-color: var(--brand-secondary);
}
.btn-secondary:hover {
  background: #0284c7;
  color: white;
  transform: translateY(-1px);
}

.btn-success {
  background: var(--color-success);
  color: white;
  border-color: var(--color-success);
}
.btn-success:hover {
  background: #059669;
  color: white;
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--color-danger);
  color: white;
  border-color: var(--color-danger);
}
.btn-danger:hover {
  background: #dc2626;
  color: white;
  transform: translateY(-1px);
}

.btn-warning {
  background: var(--color-warning);
  color: white;
  border-color: var(--color-warning);
}
.btn-warning:hover { background: #d97706; color: white; }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
}
.btn-outline:hover {
  background: var(--page-bg);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}
.btn-ghost:hover { background: var(--page-bg); color: var(--text-primary); }

.btn-sm {
  padding: 5px 12px;
  font-size: var(--font-size-xs);
  border-radius: var(--border-radius-sm);
}

.btn-lg {
  padding: 12px 28px;
  font-size: var(--font-size-md);
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--border-radius-sm);
  justify-content: center;
}

.btn-icon.btn-sm { width: 28px; height: 28px; }

/* ── FORMS ────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--space-md); }

.form-label {
  display: block;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-label .required { color: var(--color-danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px 13px;
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  transition: var(--transition-fast);
  line-height: 1.5;
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(30,64,175,0.12);
}

.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled { background: var(--page-bg); cursor: not-allowed; opacity: 0.7; }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 100px; }

.form-text { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: var(--font-size-xs); color: var(--color-danger); margin-top: 4px; }

.form-row {
  display: grid;
  gap: var(--space-md);
}

.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── TABLES ───────────────────────────────────────────────── */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.table thead th {
  padding: 12px var(--space-md);
  background: var(--page-bg);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  text-align: left;
}

.table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition-fast);
}

.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child { border-bottom: none; }

.table tbody td {
  padding: 12px var(--space-md);
  color: var(--text-primary);
  vertical-align: middle;
}

.table tbody td.muted { color: var(--text-muted); }

/* ── BADGES ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--border-radius-pill);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge-blue    { background: #dbeafe; color: #1d4ed8; }
.badge-green   { background: #d1fae5; color: #065f46; }
.badge-red     { background: #fee2e2; color: #991b1b; }
.badge-orange  { background: #fef3c7; color: #92400e; }
.badge-purple  { background: #ede9fe; color: #5b21b6; }
.badge-gray    { background: #f1f5f9; color: #475569; }
.badge-teal    { background: #cffafe; color: #0e7490; }

/* ── ALERTS & FLASH MESSAGES ──────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-md);
}

.alert i { margin-top: 1px; flex-shrink: 0; }

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-danger, .alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* ── MODALS ───────────────────────────────────────────────── */
.modal-backdrop { background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); }

.modal-content {
  border: none;
  border-radius: var(--card-radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  font-family: var(--font-family);
}

.modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body { padding: var(--space-lg); }

.modal-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-color);
  gap: var(--space-sm);
}

/* ── DROPZONE ─────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius);
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
  cursor: pointer;
  transition: var(--transition-base);
  background: var(--page-bg-alt);
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--brand-primary);
  background: #eff6ff;
}

.dropzone-icon {
  font-size: 40px;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.dropzone-title {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--text-secondary);
}

.dropzone-subtitle { font-size: var(--font-size-sm); color: var(--text-muted); }

/* ── PAGINATION ───────────────────────────────────────────── */
.pagination-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) 0;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.pagination-info { font-size: var(--font-size-sm); color: var(--text-muted); }

.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
}

.page-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: white;
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

.page-btn:hover { background: var(--page-bg); color: var(--text-primary); }
.page-btn.active { background: var(--brand-primary); color: white; border-color: var(--brand-primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── TOOLTIPS ─────────────────────────────────────────────── */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: white;
  padding: 5px 10px;
  border-radius: var(--border-radius-sm);
  font-size: var(--font-size-xs);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: var(--z-tooltip);
}

[data-tooltip]:hover::after { opacity: 1; }

/* ── LOADING SPINNER ──────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── DATATABLE OVERRIDES ──────────────────────────────────── */
.dataTables_wrapper {
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
}

.dataTables_length select,
.dataTables_filter input {
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 6px 10px;
  color: var(--text-primary);
  background: white;
}

.dataTables_filter input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(30,64,175,0.12);
}

.dataTables_info,
.dataTables_length,
.dataTables_filter { font-size: var(--font-size-sm); color: var(--text-muted); }

.dataTables_paginate .paginate_button {
  border-radius: var(--border-radius-sm) !important;
  padding: 4px 10px !important;
  font-size: var(--font-size-sm) !important;
  font-family: var(--font-family) !important;
}

.dataTables_paginate .paginate_button.current,
.dataTables_paginate .paginate_button.current:hover {
  background: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
  color: white !important;
}

table.dataTable thead th {
  font-size: var(--font-size-xs) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  font-weight: 600 !important;
  color: var(--text-secondary) !important;
  padding: 12px var(--space-md) !important;
  background: var(--page-bg) !important;
  border-bottom: 2px solid var(--border-color) !important;
}

table.dataTable tbody tr:hover { background: #f8fafc !important; }
table.dataTable tbody td { padding: 11px var(--space-md) !important; vertical-align: middle !important; }

/* ── EMPTY STATE ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
}

.empty-state-icon {
  font-size: 56px;
  color: var(--border-color);
  margin-bottom: var(--space-md);
}

.empty-state-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.empty-state-subtitle { font-size: var(--font-size-sm); color: var(--text-muted); }

/* ── UTILITY CLASSES ──────────────────────────────────────── */
.d-flex   { display: flex; }
.d-grid   { display: grid; }
.d-none   { display: none; }
.d-block  { display: block; }
.d-inline { display: inline; }

.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

.text-center   { text-align: center; }
.text-right    { text-align: right; }
.text-muted    { color: var(--text-muted); }
.text-primary  { color: var(--brand-primary); }
.text-success  { color: var(--color-success); }
.text-danger   { color: var(--color-danger); }
.text-warning  { color: var(--color-warning); }
.text-sm       { font-size: var(--font-size-sm); }
.text-xs       { font-size: var(--font-size-xs); }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

.w-100  { width: 100%; }
.rounded { border-radius: var(--border-radius); }
.rounded-pill { border-radius: var(--border-radius-pill); }

.overflow-hidden { overflow: hidden; }
.position-relative { position: relative; }

/* ── SIDEBAR COLLAPSED STATE ──────────────────────────────── */
body.sidebar-collapsed .app-sidebar {
  width: var(--sidebar-collapsed);
}

body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .sidebar-chevron,
body.sidebar-collapsed .sidebar-section-label,
body.sidebar-collapsed .sidebar-user-info,
body.sidebar-collapsed .sidebar-signout {
  opacity: 0;
  pointer-events: none;
  width: 0;
  overflow: hidden;
}

body.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding: 10px;
}

body.sidebar-collapsed .sidebar-user { justify-content: center; }
body.sidebar-collapsed .app-main { margin-left: var(--sidebar-collapsed); }

/* ── SWAL OVERRIDES ───────────────────────────────────────── */
.swal2-popup {
  font-family: var(--font-family) !important;
  border-radius: var(--card-radius) !important;
}

.swal2-title { font-size: 20px !important; font-weight: 700 !important; }
.swal2-html-container { font-size: var(--font-size-sm) !important; }

/* ── PRINT STYLES ─────────────────────────────────────────── */
@media print {
  .app-sidebar,
  .app-topbar,
  .page-header-actions,
  .btn,
  .no-print { display: none !important; }

  .app-main { margin-left: 0 !important; }
  .app-content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(-100%);
    z-index: var(--z-sidebar);
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .app-main { margin-left: 0; }
  .app-content { padding: var(--space-md); }

  .stat-grid { grid-template-columns: 1fr 1fr; }

  .page-header { flex-direction: column; }

  .form-row-2,
  .form-row-3 { grid-template-columns: 1fr; }

  .topbar-user-info { display: none; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: calc(var(--z-sidebar) - 1);
  backdrop-filter: blur(2px);
}

@media (max-width: 768px) {
  body.sidebar-open .sidebar-overlay { display: block; }
}

/* ── ANIMATIONS ───────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

.animate-fade-in  { animation: fadeIn 0.3s ease forwards; }
.animate-slide-in { animation: slideInLeft 0.3s ease forwards; }

/* Stagger for stat cards */
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.10s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.20s; }
.stat-card:nth-child(5) { animation-delay: 0.25s; }
.stat-card:nth-child(6) { animation-delay: 0.30s; }


/* ============================================================
   DARK THEME
   Bootstrap 5 honours data-bs-theme="dark"; this block retunes
   the custom tokens so the app shell matches.
   ============================================================ */
[data-bs-theme="dark"] {
  --page-bg:           #0b1220;
  --page-bg-alt:       #0f172a;
  --card-bg:           #111a2e;
  --card-border:       #1e2a44;
  --border-color:      #22304d;

  --text-primary:      #e7eefb;
  --text-secondary:    #a8b7d1;
  --text-muted:        #6b7c9b;

  --topbar-bg:         #0f172a;
  --topbar-border:     #1e2a44;
  --topbar-shadow:     0 1px 3px rgba(0,0,0,0.4);

  --card-shadow:       0 1px 4px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.25);
  --card-shadow-hover: 0 4px 20px rgba(0,0,0,0.45);

  color-scheme: dark;
}

[data-bs-theme="dark"] body { background: var(--page-bg); }

[data-bs-theme="dark"] .card { background: var(--card-bg); }
[data-bs-theme="dark"] .card-header { background: var(--card-bg) !important; border-color: var(--card-border) !important; }
[data-bs-theme="dark"] .card-title { color: var(--text-primary); }
[data-bs-theme="dark"] .card-footer { background: var(--page-bg-alt) !important; }

[data-bs-theme="dark"] .table thead th { background: #16203a; color: var(--text-secondary); border-bottom-color: var(--border-color); }
[data-bs-theme="dark"] .table tbody td { color: var(--text-primary); border-bottom-color: var(--card-border); }
[data-bs-theme="dark"] .table tbody tr:hover { background: #16203a !important; }

[data-bs-theme="dark"] table.dataTable thead th { background: #16203a !important; border-bottom-color: var(--border-color) !important; }
[data-bs-theme="dark"] table.dataTable tbody tr:hover { background: #16203a !important; }

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] select.form-control,
[data-bs-theme="dark"] .form-select {
  background-color: #0d1526;
  border-color: var(--border-color);
  color: var(--text-primary);
}
[data-bs-theme="dark"] .form-control::placeholder { color: var(--text-muted); }
[data-bs-theme="dark"] .form-control:focus { border-color: var(--brand-secondary); }
[data-bs-theme="dark"] .form-control:disabled { background: #0d1526; }

[data-bs-theme="dark"] .btn-outline { border-color: var(--border-color); color: var(--text-secondary); }
[data-bs-theme="dark"] .btn-outline:hover { background: #1a2540; color: var(--text-primary); }
[data-bs-theme="dark"] .btn-ghost { color: var(--text-secondary); }
[data-bs-theme="dark"] .btn-ghost:hover { background: #1a2540; color: var(--text-primary); }

[data-bs-theme="dark"] .badge-gray { background: #1a2540; color: #a8b7d1; }

[data-bs-theme="dark"] .alert-success { background: #071f17; color: #6ee7b7; border-color: #14532d; }
[data-bs-theme="dark"] .alert-danger,
[data-bs-theme="dark"] .alert-error { background: #250e12; color: #fca5a5; border-color: #7f1d1d; }
[data-bs-theme="dark"] .alert-warning { background: #271a05; color: #fcd34d; border-color: #78350f; }
[data-bs-theme="dark"] .alert-info { background: #0a1f3d; color: #93c5fd; border-color: #1e3a8a; }

[data-bs-theme="dark"] .dropzone { background: var(--page-bg-alt); }
[data-bs-theme="dark"] .dropzone:hover,
[data-bs-theme="dark"] .dropzone.drag-over { background: #12203d; }

[data-bs-theme="dark"] .page-header-actions .btn-outline { border-color: var(--border-color); }

[data-bs-theme="dark"] .dataTables_length select,
[data-bs-theme="dark"] .dataTables_filter input {
  background: #0d1526;
  border-color: var(--border-color);
  color: var(--text-primary);
}

[data-bs-theme="dark"] .page-btn { background: var(--card-bg); border-color: var(--border-color); color: var(--text-secondary); }
[data-bs-theme="dark"] .page-btn:hover { background: #1a2540; }

[data-bs-theme="dark"] .bg-light { background: var(--page-bg-alt) !important; }
[data-bs-theme="dark"] .text-dark { color: var(--text-primary) !important; }
[data-bs-theme="dark"] .border-light { border-color: var(--card-border) !important; }

[data-bs-theme="dark"] .topbar-user:hover { background: #1a2540; }

/* Theme toggle icon visibility */
.theme-icon-sun { display: none; }
.theme-icon-moon { display: inline; }
[data-bs-theme="dark"] .theme-icon-sun { display: inline; }
[data-bs-theme="dark"] .theme-icon-moon { display: none; }

/* Page-header actions sit inside a white card; keep contrast in dark mode */
[data-bs-theme="dark"] .page-header .btn-outline { border-color: var(--border-color); }


/* ============================================================
   NOTIFICATIONS DROPDOWN
   ============================================================ */
.notif-menu {
  width: 360px;
  max-width: calc(100vw - 2rem);
  padding: 0;
  border-radius: var(--card-radius);
  overflow: hidden;
}

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 700;
}

.notif-mark-all {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary, #2563eb);
  text-decoration: none;
  white-space: nowrap;
}
.notif-mark-all:hover {
  text-decoration: underline;
}

.notif-body {
  max-height: 340px;
  overflow-y: auto;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  text-decoration: none;
  color: inherit;
  transition: var(--transition-fast);
}

.notif-item:hover { background: var(--page-bg); }
.notif-item:last-child { border-bottom: none; }

.notif-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-sm);
  background: var(--page-bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.notif-text { flex: 1; min-width: 0; }
.notif-title { font-weight: 600; font-size: var(--font-size-sm); color: var(--text-primary); }
.notif-subtitle { font-size: var(--font-size-xs); color: var(--text-muted); }

.notif-time {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.notif-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.notif-empty i { font-size: 32px; display: block; margin-bottom: 8px; }
.notif-empty p { margin: 0; font-size: var(--font-size-sm); }


/* ============================================================
   BREADCRUMB
   ============================================================ */
.topbar-breadcrumb a.breadcrumb-home,
.topbar-breadcrumb a.breadcrumb-section {
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition-fast);
}

.topbar-breadcrumb a.breadcrumb-home:hover,
.topbar-breadcrumb a.breadcrumb-section:hover {
  color: var(--brand-primary);
}

[data-bs-theme="dark"] .topbar-breadcrumb a.breadcrumb-home:hover,
[data-bs-theme="dark"] .topbar-breadcrumb a.breadcrumb-section:hover {
  color: var(--brand-secondary);
}

.topbar-breadcrumb a.breadcrumb-home i { font-size: 13px; }


/* ============================================================
   DROPZONE POLISH
   ============================================================ */
.dropzone-icon { transition: var(--transition-base); }
.dropzone:hover .dropzone-icon { color: var(--brand-primary); transform: translateY(-2px); }

.dropzone-file-list { margin-top: var(--space-md); }

.dropzone-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  background: var(--card-bg);
  margin-bottom: 8px;
  font-size: var(--font-size-sm);
}

.dropzone-file .file-icon { color: var(--brand-primary); font-size: 18px; }
.dropzone-file .file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone-file .file-size { color: var(--text-muted); font-size: var(--font-size-xs); }
.dropzone-file .file-remove {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--border-radius-sm);
  transition: var(--transition-fast);
}
.dropzone-file .file-remove:hover { color: var(--color-danger); background: #fef2f2; }
[data-bs-theme="dark"] .dropzone-file .file-remove:hover { background: #250e12; }


/* ============================================================
   QUICK ACCESS LINKS (dashboard)
   ============================================================ */
.quick-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  background: var(--page-bg-alt);
  text-decoration: none;
  transition: var(--transition-base);
}

.quick-link:hover {
  border-color: var(--brand-primary);
  box-shadow: var(--card-shadow);
  transform: translateY(-1px);
}

.quick-link-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-sm);
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--card-shadow);
  flex-shrink: 0;
}

.quick-link-title { margin: 0; font-size: var(--font-size-md); font-weight: 600; color: var(--text-primary); }
.quick-link-sub { margin: 0; font-size: var(--font-size-xs); color: var(--text-muted); }

.quick-link .chev { margin-left: auto; color: var(--text-muted); }


/* ============================================================
   DATATABLES BUTTON GROUP SPACING
   ============================================================ */
div.dt-buttons { margin-left: 8px; }
div.dt-buttons .btn { margin-right: 4px; }
.dataTables_wrapper .dt-buttons .btn-outline { border-color: var(--border-color); color: var(--text-secondary); }
.dataTables_wrapper .dt-buttons .btn-outline:hover { color: var(--text-primary); }

/* Index column should look like a plain counter, not a sortable heading */
table.dataTable th.col-index { color: var(--text-muted) !important; }

/* ============================================================
   MULTI-FILE UPLOADER QUEUE (.ts-uploader in assets/js/uploader.js)
   ============================================================ */
.ts-dropzone { cursor: pointer; }
.ts-dropzone.is-drag { border-color: var(--brand-primary) !important; background: var(--page-bg-alt); }
.ts-queue { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.ts-queue:empty { display: none; }
.ts-file { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px;
  border: 1px solid var(--border-color); border-radius: var(--border-radius); background: var(--page-bg-alt); }
.ts-file-icon { font-size: 22px; color: var(--brand-primary); flex-shrink: 0; }
.ts-file-body { flex: 1; min-width: 0; }
.ts-file-top { display: flex; justify-content: space-between; gap: 8px; font-size: var(--font-size-sm); }
.ts-file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-file-meta { color: var(--text-muted); white-space: nowrap; font-size: var(--font-size-xs); }
.ts-progress { height: 8px; margin-top: 6px; }
.ts-file-msg { font-size: var(--font-size-xs); color: var(--color-danger); margin-top: 4px; }
.ts-file-msg:empty { display: none; }
.ts-file.is-done { border-color: var(--color-success); }
.ts-file.is-error { border-color: var(--color-danger); }
.ts-file-state { font-size: 18px; flex-shrink: 0; }

/* ============================================================
   MOBILE POLISH (phones & small tablets)
   One place for every page: tables, toolbars, topbar, tabs.
   ============================================================ */
img { max-width: 100%; height: auto; }

/* Action button clusters inside tables must wrap instead of overflowing. */
.table .btn-group { flex-wrap: wrap; gap: 4px; }
.table td .d-flex.gap-2 { flex-wrap: wrap; }

/* DataTables child-row toggle (Responsive extension). */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {
  background-color: var(--brand-primary);
}
/* Never let the child row itself cause sideways scroll. */
.dataTables_wrapper { max-width: 100%; }
table.dataTable > tbody > tr.child ul.dtr-details { width: 100%; }

@media (max-width: 768px) {
  /* Cards that wrap tables: tight padding so tables get full width. */
  .table-responsive.p-4 { padding: 0.75rem !important; }
  .table-responsive.p-3 { padding: 0.5rem !important; }
  .card-body.p-4 { padding: 1rem !important; }

  /* DataTables toolbar: search + export buttons stack full-width. */
  .dataTables_wrapper .row > [class*="col-"] { width: 100%; }
  .dataTables_wrapper .dataTables_filter { text-align: left !important; margin-top: 0.5rem; }
  .dataTables_wrapper .dataTables_filter label,
  .dataTables_wrapper .dataTables_filter input { width: 100% !important; }
  div.dt-buttons { margin: 0.5rem 0 0; display: flex; flex-wrap: wrap; gap: 4px; }
  div.dt-buttons .btn { margin-right: 0; }

  /* Settings + any long tab bar scrolls sideways instead of squashing. */
  .nav-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav-tabs .nav-link { white-space: nowrap; }

  /* Topbar: tighter, breadcrumb truncates instead of pushing icons off. */
  .app-topbar { padding: 0 var(--space-md); gap: var(--space-sm); }
  .topbar-breadcrumb { min-width: 0; overflow: hidden; }
  .topbar-breadcrumb .current {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    display: inline-block; max-width: 38vw; vertical-align: bottom;
  }

  /* Header action buttons + modal footers go full-width and stack. */
  .page-header-actions .btn { flex: 1 1 auto; }
  .modal-footer .btn { flex: 1; }

  /* Page-info banner stays compact. */
  .page-info { padding: 12px; }
  .page-info ul.pi-points { font-size: 0.78rem; }

  /* Stat cards: 2-up is already handled; tighten padding. */
  .stat-card { padding: var(--space-md); }
}

@media (max-width: 480px) {
  /* Hide the middle breadcrumb crumb; keep Home + current page. */
  .topbar-breadcrumb .breadcrumb-section,
  .topbar-breadcrumb .mx-1 { display: none; }
  .topbar-breadcrumb .current { max-width: 52vw; }

  /* Tables: smaller cell padding buys ~20% more room. */
  .table thead th, .table tbody td { padding: 8px 10px; }

  /* Login/lockup headings scale down. */
  .page-title { font-size: 1.35rem; }
}
