/* ============================================================
   EBILABO — DESIGN SYSTEM  (Mobile-First)
   Primary: #00929f  |  Crimson Pro + DM Sans
   Breakpoints:
     Mobile  : default (< 640px)
     Tablet  : @media (min-width: 640px)
     Desktop : @media (min-width: 1024px)
   ============================================================ */

/* ── Custom Properties ──────────────────────────────────── */
:root {
  --primary:       #00929f;
  --primary-dark:  #006e78;
  --primary-light: #e0f6f8;
  --primary-mid:   #33aab5;
  --accent:        #f4a32a;
  --danger:        #e03e3e;
  --success:       #1fad6c;
  --warn:          #f4a32a;
  --text:          #1a2a2d;
  --text-muted:    #5a7276;
  --border:        #cce8eb;
  --surface:       #ffffff;
  --surface-alt:   #f4fbfc;

  /* Layout */
  --sidebar-w:     240px;
  --topbar-h:      56px;   /* slightly slimmer on mobile */

  /* Tokens */
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 2px 12px rgba(0,146,159,0.10);
  --shadow-lg:     0 8px 32px rgba(0,146,159,0.14);

  /* Typography */
  --font-display:  'Crimson Pro', Georgia, serif;
  --font-body:     'DM Sans', system-ui, sans-serif;

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

@media (min-width: 640px) {
  :root { --topbar-h: 60px; }
}

/* ══════════════════════════════════════════════════════════
   BASE / RESET
══════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  /* Prevent horizontal overflow at the root level */
  min-width: 0;
}

html {
  font-size: 14px;          /* mobile base */
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

@media (min-width: 640px)  { html { font-size: 14.5px; } }
@media (min-width: 1024px) { html { font-size: 15px;   } }

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface-alt);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

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

/* Prevent inputs from blowing out containers on iOS */
input, select, textarea, button {
  font-family: var(--font-body);
  max-width: 100%;
}

/* ══════════════════════════════════════════════════════════
   TOPBAR
══════════════════════════════════════════════════════════ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  height: var(--topbar-h);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  gap: var(--space-sm);
}

/* Hamburger — visible on mobile only */
.topbar-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: rgba(255,255,255,0.12);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
}
.topbar-hamburger span {
  display: block;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.25s;
}
/* Animate to X when sidebar is open */
body.sidebar-open .topbar-hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.sidebar-open .topbar-hamburger span:nth-child(2) { opacity: 0; }
body.sidebar-open .topbar-hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (min-width: 1024px) {
  .topbar-hamburger { display: none; }
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
  justify-content: center;
  min-width: 0;
}

.topbar-logo-mark{
  display: flex;
  justify-content: center;  /* horizontal center */
  align-items: center;      /* vertical center */
  flex-shrink: 0;
  line-height: 0;            /* removes extra inline spacing */
}

/* Control the logo size here */
.topbar-logo-mark img{
  display: block;            /* prevents baseline gap */
  height: 40px;              /* mobile size */
  width: auto;               /* keep aspect ratio */
  max-width: 100%;
  object-fit: contain;
}

/* Tablet */
@media (min-width: 640px){
  .topbar-logo-mark img{ height: 40px; }
}


/* Desktop */
@media (min-width: 1024px){
  .topbar-logo-mark img{ height: 48px; }

}

.topbar-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (min-width: 640px) { .topbar-title { font-size: 1.45rem; } }

.topbar-tagline {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.75);
  letter-spacing: 0.04em;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Hide tagline on very small screens to save space */
@media (max-width: 400px) { .topbar-tagline { display: none; } }
@media (min-width: 640px) { .topbar-tagline { font-size: 0.68rem; } }

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

.topbar-badge {
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
/* Hide role badge on small mobiles */
@media (max-width: 480px) { .topbar-badge { display: none; } }
@media (min-width: 640px) { .topbar-badge { font-size: 0.7rem; padding: 3px 10px; } }

.topbar-user {
  color: rgba(255,255,255,0.9);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
/* Hide username text on small mobiles — icon still shows via btn-logout */
@media (max-width: 480px) { .topbar-user { display: none; } }
@media (min-width: 640px) { .topbar-user { font-size: 0.9rem; max-width: none; } }

.btn-logout {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  transition: background 0.2s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.btn-logout:hover { background: rgba(255,255,255,0.28); color: #fff; }
/* Show icon only on mobile */
@media (max-width: 480px) {
  .btn-logout .logout-text { display: none; }
  .btn-logout { padding: 6px 9px; }
}
@media (min-width: 640px) { .btn-logout { padding: 6px 14px; font-size: 0.85rem; } }

/* ══════════════════════════════════════════════════════════
   OVERLAY (behind sidebar on mobile/tablet)
══════════════════════════════════════════════════════════ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0,0,0,0.38);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
body.sidebar-open .sidebar-overlay { display: block; }

@media (min-width: 1024px) {
  .sidebar-overlay { display: none !important; }
}

/* ══════════════════════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════════════════════ */
.app-shell {
  display: flex;
  padding-top: var(--topbar-h);
  min-height: 100vh;
}

/* ══════════════════════════════════════════════════════════
   SIDEBAR  (off-canvas on mobile/tablet, fixed on desktop)
══════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  /* Off-canvas by default (mobile & tablet) */
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-overflow-scrolling: touch;
}

/* Slide in when open */
body.sidebar-open .sidebar { transform: translateX(0); }

@media (min-width: 1024px) {
  /* Always visible on desktop */
  .sidebar {
    transform: none !important;
    transition: none;
  }
}

.sidebar-inner { padding: 20px 0 60px; }

.sidebar-section-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 16px 20px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  /* Make whole row tappable */
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.nav-item:hover,
.nav-item:focus-visible {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-left-color: var(--primary);
}
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
  border-left-color: var(--primary);
}
.nav-item i {
  width: 18px;
  text-align: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.nav-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ══════════════════════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════════════════════ */
.main-content {
  flex: 1;
  /* On mobile: full width, sidebar is off-canvas */
  margin-left: 0;
  padding: var(--space-md) var(--space-md);
  min-height: calc(100vh - var(--topbar-h));
  /* Prevent children from overflowing */
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

@media (min-width: 640px) {
  .main-content {
    padding: var(--space-lg) var(--space-lg);
  }
}

@media (min-width: 1024px) {
  .main-content {
    margin-left: var(--sidebar-w);
    padding: var(--space-xl) 28px;
  }
}

/* ══════════════════════════════════════════════════════════
   FLASH MESSAGES
══════════════════════════════════════════════════════════ */
.flash {
  position: fixed;
  top: calc(var(--topbar-h) + 10px);
  left: var(--space-md);
  right: var(--space-md);
  z-index: 300;
  padding: 12px 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  animation: slideDown 0.3s ease;
}

@media (min-width: 640px) {
  .flash {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    min-width: 320px;
    max-width: 560px;
  }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (min-width: 640px) {
  @keyframes slideDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
  }
}

.flash-success { background: var(--success); color: #fff; }
.flash-danger  { background: var(--danger);  color: #fff; }
.flash-warning { background: var(--warn);    color: #fff; }
.flash-info    { background: var(--primary); color: #fff; }
.flash button {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
  padding: 0 4px;
}

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

.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

@media (min-width: 640px) { .page-header h1 { font-size: 1.7rem; } }
@media (min-width: 1024px) { .page-header h1 { font-size: 1.9rem; } }

.page-header .subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.5;
}

/* Page header actions stack vertically on small screens */
.page-header > div:last-child,
.page-header > a {
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════
   STAT CARDS
══════════════════════════════════════════════════════════ */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;   /* 2-col on mobile */
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

@media (min-width: 640px) {
  .stat-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

@media (min-width: 1024px) {
  .stat-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 18px;
  }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

@media (min-width: 640px) { .stat-card { padding: 20px 18px; } }
@media (min-width: 1024px) { .stat-card { padding: 22px 20px; } }

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

.stat-card:hover,
.stat-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.stat-card .stat-icon {
  font-size: 1.3rem;
  color: var(--primary);
  margin-bottom: 2px;
}

@media (min-width: 640px) { .stat-card .stat-icon { font-size: 1.6rem; } }

.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  word-break: break-word;
}

@media (min-width: 640px)  { .stat-card .stat-value { font-size: 1.7rem; } }
@media (min-width: 1024px) { .stat-card .stat-value { font-size: 1.9rem; } }

.stat-card .stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@media (min-width: 640px) { .stat-card .stat-label { font-size: 0.78rem; } }
@media (min-width: 1024px) { .stat-card .stat-label { font-size: 0.82rem; } }

.stat-card .stat-sub {
  font-size: 0.75rem;
  color: var(--primary);
  margin-top: 2px;
}

/* ── Stat Dropdown ──────────────────────────────────────── */
.stat-dropdown { display: none; }
.stat-dropdown.open {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm);
  margin: var(--space-sm) 0 var(--space-lg);
  animation: fadeIn 0.25s ease;
}

@media (min-width: 640px) {
  .stat-dropdown.open {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-md);
    margin: var(--space-md) 0 var(--space-lg);
  }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.18s, transform 0.1s, box-shadow 0.18s;
  white-space: nowrap;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  /* Minimum touch target */
  min-height: 40px;
}

.btn:active { transform: scale(0.97); }

@media (min-width: 640px) {
  .btn { padding: 9px 18px; font-size: 0.88rem; }
}

.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-outline   { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover  { background: var(--primary-light); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover   { background: #b52e2e; }
.btn-success   { background: var(--success); color: #fff; }
.btn-accent    { background: var(--accent); color: #fff; }
.btn-accent:hover   { background: #d4891e; }

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
  min-height: 32px;
  gap: 4px;
}

/* Full-width buttons on mobile (form actions) */
.btn-block { width: 100%; }

/* ══════════════════════════════════════════════════════════
   TABLES  — horizontal scroll wrapper on mobile
══════════════════════════════════════════════════════════ */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* Allow horizontal scroll on small screens */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow);
  /* Prevent double-scroll with outer */
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  /* Don't collapse — let overflow-x handle it */
  min-width: 480px;
}

thead th {
  background: var(--primary);
  color: #fff;
  padding: 10px 12px;
  font-size: 0.78rem;
  text-align: left;
  letter-spacing: 0.04em;
  font-weight: 600;
  white-space: nowrap;
}

@media (min-width: 640px) {
  thead th { padding: 12px 14px; font-size: 0.82rem; }
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
tbody tr:hover  { background: var(--primary-light); }

tbody td {
  padding: 9px 12px;
  font-size: 0.83rem;
  vertical-align: middle;
  /* Prevent very long words from stretching columns */
  word-break: break-word;
  max-width: 260px;
}

@media (min-width: 640px) { tbody td { padding: 11px 14px; font-size: 0.88rem; } }

.actions-cell {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
}

/* ══════════════════════════════════════════════════════════
   FILTER BAR
══════════════════════════════════════════════════════════ */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  display: flex;
  flex-direction: column;   /* stack on mobile */
  gap: var(--space-sm);
  align-items: stretch;
}

@media (min-width: 640px) {
  .filter-bar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-md);
    padding: var(--space-md) 20px;
  }
}

.filter-bar input,
.filter-bar select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 0.88rem;
  font-family: var(--font-body);
  background: var(--surface-alt);
  color: var(--text);
  transition: border 0.18s;
  /* Prevent zoom on focus in iOS */
  font-size: max(16px, 0.88rem);
}

@media (min-width: 640px) {
  .filter-bar input,
  .filter-bar select {
    flex: 1;
    min-width: 140px;
    width: auto;
    font-size: 0.88rem;
  }
}

.filter-bar input:focus,
.filter-bar select:focus {
  outline: none;
  border-color: var(--primary);
}

.filter-bar .btn {
  width: 100%;
}

@media (min-width: 640px) {
  .filter-bar .btn { width: auto; }
}

/* ══════════════════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════════════════ */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  box-shadow: var(--shadow);
  /* Allow wide form-cards to be set via inline style max-width */
  width: 100%;
}

@media (min-width: 640px) {
  .form-card { padding: var(--space-lg); }
}

@media (min-width: 1024px) {
  .form-card { padding: 28px; }
}

.form-section-heading {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 2px solid var(--primary-light);
  padding-bottom: 8px;
  margin: var(--space-lg) 0 var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

@media (min-width: 640px) { .form-section-heading { font-size: 1.1rem; } }
@media (min-width: 1024px) { .form-section-heading { font-size: 1.15rem; } }

.form-section-heading:first-child { margin-top: 0; }

/* Single-column on mobile, multi on larger screens */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

@media (min-width: 640px) {
  .form-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (min-width: 1024px) {
  .form-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  /* Prevent zoom on focus in iOS Safari (must be ≥16px) */
  font-size: max(16px, 0.9rem);
  font-family: var(--font-body);
  background: var(--surface-alt);
  color: var(--text);
  transition: border 0.18s;
  /* Ensure inputs don't overflow their container */
  max-width: 100%;
}

@media (min-width: 640px) {
  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 0.9rem;
  }
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

.form-group textarea { min-height: 88px; resize: vertical; }

/* Form actions — stacked on mobile, inline on tablet+ */
.form-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

@media (min-width: 640px) {
  .form-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-md);
    align-items: center;
  }
}

.form-actions .btn {
  width: 100%;
}

@media (min-width: 640px) {
  .form-actions .btn {
    width: auto;
    min-width: 130px;
  }
}

/* ══════════════════════════════════════════════════════════
   PAGINATION
══════════════════════════════════════════════════════════ */
.pagination {
  display: flex;
  gap: 5px;
  align-items: center;
  margin-top: var(--space-md);
  flex-wrap: wrap;
}

.pagination a,
.pagination span {
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-size: 0.82rem;
  color: var(--primary);
  background: var(--surface);
  transition: background 0.15s;
  /* Minimum tap target */
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pagination a:hover     { background: var(--primary-light); }
.pagination .current    { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ══════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════ */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  background: linear-gradient(
    135deg,
    var(--primary-dark) 0%,
    var(--primary)      50%,
    var(--primary-mid)  100%
  );
  position: relative;
  overflow: hidden;
}

.login-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(255,255,255,0.07) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.07) 0%, transparent 50%);
  pointer-events: none;
}

.login-card {
  background: #fff;
  border-radius: 18px;
  padding: var(--space-lg) var(--space-md);
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25);
  position: relative;
  z-index: 1;
}

@media (min-width: 640px) {
  .login-card { padding: 36px 32px; }
}

@media (min-width: 1024px) {
  .login-card { padding: 44px 40px; }
}

.login-logo {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.login-logo .mark {
  font-size: 2.4rem;
  color: var(--primary);
  display: block;
}

@media (min-width: 640px) { .login-logo .mark { font-size: 2.8rem; } }

.login-logo h1 {
  font-family: var(--font-display);
  font-size: 1.9rem;
  color: var(--primary);
  font-weight: 700;
}

@media (min-width: 640px) { .login-logo h1 { font-size: 2.2rem; } }

.login-logo p {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

.login-card .form-group {
  margin-bottom: var(--space-md);
}

.login-card .form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}

.login-card .form-group input,
.login-card .form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: max(16px, 0.95rem);
  background: var(--surface-alt);
  transition: border 0.2s;
  font-family: var(--font-body);
}

.login-card .form-group input:focus,
.login-card .form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.login-btn {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: var(--space-sm);
  font-family: var(--font-body);
  /* Minimum tap target */
  min-height: 48px;
}

.login-btn:hover   { background: var(--primary-dark); }
.login-btn:active  { transform: scale(0.98); }

.login-error {
  background: #fde;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 0.88rem;
  margin-bottom: var(--space-md);
  display: none;
}
.login-error.visible { display: block; }

/* ══════════════════════════════════════════════════════════
   BADGES
══════════════════════════════════════════════════════════ */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.73rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: #d1f5e6; color: var(--success); }
.badge-danger  { background: #fde;    color: var(--danger);  }
.badge-warn    { background: #fff3cd; color: #b07c00;        }

/* ══════════════════════════════════════════════════════════
   OPTIONAL FIELD TAG  (new_member.php)
══════════════════════════════════════════════════════════ */
.optional-tag {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1px 6px;
  text-transform: none;
  letter-spacing: 0;
  vertical-align: middle;
  white-space: nowrap;
}

.required-note {
  margin-top: var(--space-lg);
  padding: 10px 14px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.83rem;
  color: var(--text-muted);
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  line-height: 1.5;
}
.required-note i { color: var(--primary); margin-top: 2px; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════
   UTILITY CLASSES
══════════════════════════════════════════════════════════ */
.no-print { /* used by print stylesheets in page files */ }

/* Visually hide but keep accessible */
.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;
}

/* Truncate long text */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* ══════════════════════════════════════════════════════════
   SCROLLBAR STYLING  (WebKit)
══════════════════════════════════════════════════════════ */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.table-wrap::-webkit-scrollbar { height: 5px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ══════════════════════════════════════════════════════════
   PRINT BASELINE
   (Individual pages add their own @media print on top)
══════════════════════════════════════════════════════════ */
@media print {
  .topbar,
  .sidebar,
  .sidebar-overlay,
  .topbar-hamburger,
  .no-print,
  .pagination,
  .filter-bar,
  .form-actions { display: none !important; }

  .app-shell { display: block; padding-top: 0; }
  .main-content { margin-left: 0 !important; padding: 10px !important; }
  body { background: #fff; font-size: 12px; }
  table { font-size: 11px; min-width: 0; }
  .table-wrap { box-shadow: none; border: 1px solid #ccc; overflow: visible; }
  .stat-card { box-shadow: none; break-inside: avoid; }
}
