/* ============================================================
   Design Tokens
   ============================================================ */
:root {
  --gradient:          linear-gradient(135deg, #fff967 0%, #FF751f 100%);
  --color-accent:      #FF751f;
  --color-accent-glow: rgba(255, 117, 31, 0.15);

  --color-text:        #111827;
  --color-text-muted:  #6B7280;
  --color-text-label:  #374151;

  --color-border:      #D1D5DB;
  --color-divider:     #E5E7EB;
  --color-surface:     #F3F4F6;

  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;

  --font-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font-base);
  color: var(--color-text);
  background: #F3F4F6;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.8125rem 1.5rem;
  background: var(--gradient);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.15s;
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Secondary / gradient-border variant */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.8125rem 1.5rem;
  background:
    linear-gradient(#fff, #fff) padding-box,
    var(--gradient) border-box;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--color-accent);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.15s;
}

.btn-secondary:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(0);
}

/* ============================================================
   Alerts
   ============================================================ */
.alert {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid;
  margin-bottom: 1rem;
}

.alert[hidden] { display: none; }

.alert-icon {
  flex-shrink: 0;
}

.alert-icon i {
  width: 18px;
  height: 18px;
}

.alert-body {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 0.125rem;
  line-height: 1.3;
}

.alert-message {
  font-size: 0.8375rem;
  line-height: 1.4;
}

/* Success */
.alert-success { background: #F0FDF4; border-color: #BBF7D0; }
.alert-success .alert-icon    { color: #16A34A; }
.alert-success .alert-title   { color: #15803D; }
.alert-success .alert-message { color: #166534; }

/* Warning */
.alert-warning { background: #FFFBEB; border-color: #FDE68A; }
.alert-warning .alert-icon    { color: #D97706; }
.alert-warning .alert-title   { color: #92400E; }
.alert-warning .alert-message { color: #78350F; }

/* Danger */
.alert-danger { background: #FEF2F2; border-color: #FECACA; }
.alert-danger .alert-icon    { color: #DC2626; }
.alert-danger .alert-title   { color: #991B1B; }
.alert-danger .alert-message { color: #7F1D1D; }

/* ============================================================
   Form components
   ============================================================ */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-label);
  margin-bottom: 0.4rem;
}

.field-hint {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--color-text);
  background: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.form-group select {
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  cursor: pointer;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-glow);
}

.form-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.form-options label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--color-text-label);
  cursor: pointer;
}

/* ============================================================
   Links
   ============================================================ */
.link-accent {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 500;
}

.link-accent:hover {
  text-decoration: underline;
}

/* ============================================================
   Divider
   ============================================================ */
.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
  color: #9CA3AF;
  font-size: 0.8125rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-divider);
}

/* ============================================================
   Utility
   ============================================================ */
.text-muted {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.text-center {
  text-align: center;
}

/* ============================================================
   App Shell
   ============================================================ */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border);
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.25s ease;
  position: relative;
  z-index: 10;
}

.sidebar.collapsed { width: 64px; }

.sidebar.collapsed:hover {
  width: 260px;
  box-shadow: 4px 0 16px rgba(0,0,0,0.08);
}

/* Logo area */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.125rem 1rem;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  min-height: 60px;
  flex-shrink: 0;
}

.sidebar-logo img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
  transition: opacity 0.15s, max-width 0.25s;
  overflow: hidden;
  max-width: 200px;
}

.sidebar-logo-text span {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.sidebar.collapsed:not(:hover) .sidebar-logo-text {
  opacity: 0;
  max-width: 0;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  overflow-x: hidden;
}

.nav-section-label {
  font-size: 0.6375rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9CA3AF;
  padding: 0.625rem 0.625rem 0.25rem;
  margin-top: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.15s, max-height 0.25s;
  max-height: 40px;
}

.sidebar.collapsed:not(:hover) .nav-section-label {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.575rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  transition: background 0.15s, color 0.15s, padding 0.25s;
  position: relative;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar.collapsed:not(:hover) .nav-item {
  padding-left: 0;
  padding-right: 0;
  justify-content: center;
  gap: 0;
}

.nav-item i:first-child,
.nav-item svg:first-child { width: 18px; height: 18px; flex-shrink: 0; }

.nav-label {
  overflow: hidden;
  max-width: 200px;
  transition: opacity 0.15s, max-width 0.25s;
  flex: 1;
}

.sidebar.collapsed:not(:hover) .nav-label { opacity: 0; max-width: 0; }

.nav-chevron {
  margin-left: auto;
  width: 14px !important;
  height: 14px !important;
  flex-shrink: 0;
  transition: transform 0.2s, opacity 0.15s, max-width 0.25s;
  max-width: 14px;
}

.sidebar.collapsed:not(:hover) .nav-chevron {
  opacity: 0;
  max-width: 0;
  margin-left: 0;
}

.nav-item:hover { background: #F9FAFB; color: var(--color-text); }

.nav-item.active {
  background: linear-gradient(135deg, rgba(255,249,103,0.15) 0%, rgba(255,117,31,0.12) 100%);
  color: var(--color-accent);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--gradient);
}

/* Collapsible groups */
.nav-group { display: flex; flex-direction: column; }

.nav-sub {
  display: none;
  flex-direction: column;
  gap: 0.125rem;
  padding-left: 0.875rem;
  margin-top: 0.125rem;
}

.nav-group.open .nav-sub { display: flex; }
.nav-group.open > .nav-item .nav-chevron { transform: rotate(180deg); }
.nav-sub .nav-item { font-size: 0.8375rem; padding: 0.425rem 0.75rem; }
.sidebar.collapsed:not(:hover) .nav-sub { display: none !important; }
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--color-accent, #FF751f); color: #fff; font-size: 0.65rem; font-weight: 700; margin-left: 6px; vertical-align: middle; }
.sidebar.collapsed:not(:hover) .nav-badge { position: absolute; top: 2px; right: 6px; margin-left: 0; min-width: 16px; height: 16px; font-size: 0.58rem; padding: 0 4px; }
.sidebar.collapsed:not(:hover) .nav-item:has(.nav-badge) { overflow: visible; }

/* Sidebar footer */
.sidebar-footer {
  padding: 0.75rem 0.5rem;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* ============================================================
   Topbar
   ============================================================ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--color-border);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.topbar-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.topbar-toggle:hover { background: #F3F4F6; color: var(--color-text); }
.topbar-toggle i { width: 20px; height: 20px; }

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  flex: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.topbar-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

.topbar-icon-btn:hover { background: #F3F4F6; color: var(--color-text); }
.topbar-icon-btn i { width: 19px; height: 19px; }

/* .topbar-badge styles moved to Notification Dropdown section */

.topbar-divider {
  width: 1px;
  height: 28px;
  background: var(--color-border);
  margin: 0 0.375rem;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: none;
}

.topbar-user:hover { background: #F3F4F6; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.topbar-user-info { display: flex; flex-direction: column; text-align: left; }

.topbar-user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  line-height: 1.2;
}

.topbar-user-role {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  line-height: 1.2;
}

.topbar-user > svg:last-child { width: 18px; height: 18px; stroke: var(--color-accent); }

.topbar-user-wrap { position: relative; }

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 200px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  overflow: hidden;
  z-index: 100;
}

.user-dropdown.open { display: block; }

.user-dropdown-header {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.user-dropdown-header strong {
  display: block;
  font-size: 0.875rem;
  color: var(--color-text);
}

.user-dropdown-header span {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.user-dropdown-item i { width: 16px; height: 16px; flex-shrink: 0; }
.user-dropdown-item:hover { background: #F9FAFB; color: var(--color-text); }
.user-dropdown-item.danger { color: #B91C1C; }
.user-dropdown-item.danger:hover { background: #FEF2F2; color: #B91C1C; }

.user-dropdown-divider {
  height: 1px;
  background: var(--color-border);
  margin: 0.25rem 0;
}

/* ============================================================
   Notification Dropdown
   ============================================================ */
.notif-bell-wrap { position: relative; }

.notif-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 340px;
  max-height: 440px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  overflow: hidden;
  z-index: 100;
}

.notif-dropdown.open { display: flex; flex-direction: column; }

.notif-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.notif-dropdown-header strong {
  font-size: 0.9rem;
  color: var(--color-text);
}

.notif-dropdown-header button {
  font-size: 0.75rem;
  color: var(--color-accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.notif-dropdown-header button:hover { text-decoration: underline; }

.notif-list {
  flex: 1;
  overflow-y: auto;
  max-height: 360px;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
  border-bottom: 1px solid #f3f4f6;
}

.notif-item:hover { background: #f9fafb; }
.notif-item:last-child { border-bottom: none; }

.notif-item.unread { background: #fffbf0; }

.notif-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.notif-item.unread .notif-item-icon {
  background: #fff2e0;
}

.notif-item-content { flex: 1; min-width: 0; }

.notif-item-title {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
  margin: 0 0 2px 0;
}

.notif-item-body {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.35;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notif-item-time {
  font-size: 0.675rem;
  color: #aaa;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

.notif-item.unread .notif-item-time { color: var(--color-accent); font-weight: 600; }

.notif-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* Badge — enhanced with numeric count */
.topbar-badge {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  background: var(--color-accent);
  border: 2px solid #fff;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

.topbar-badge.has-count { display: flex; }

/* Bell ring animation — only when there are unread notifications */
@keyframes bellRing {
  0%   { transform: rotate(0deg); }
  15%  { transform: rotate(14deg); }
  30%  { transform: rotate(-12deg); }
  45%  { transform: rotate(10deg); }
  60%  { transform: rotate(-8deg); }
  75%  { transform: rotate(4deg); }
  100% { transform: rotate(0deg); }
}

.notif-bell-wrap.has-unread .topbar-icon-btn:hover svg {
  animation: bellRing 0.6s ease-in-out;
  transform-origin: top center;
}

/* ============================================================
   Page Content
   ============================================================ */
.content {
  flex: 1;
  min-height: 0; /* allow flex item to shrink so overflow-y: auto creates a real scroll context */
  overflow-y: auto;
  padding: 1.75rem 2rem;
  display: flex;
  flex-direction: column;
}

.welcome-banner {
  background: var(--gradient);
  border-radius: var(--radius-md);
  padding: 1.5rem 8rem 1.5rem 2rem;
  margin-bottom: 1.75rem;
  position: relative;
}

/* Tighten the gap when a breadcrumb immediately follows the banner */
.welcome-banner + .breadcrumb-wrap {
  margin-top: -1.25rem;
  margin-bottom: 1.25rem;
}

.welcome-banner h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.2rem;
}

.welcome-banner p {
  font-size: 0.875rem;
  color: rgba(0,0,0,0.6);
}

.welcome-banner img {
  position: absolute;
  right: 1.75rem;
  top: 50%;
  transform: translateY(-50%);
  height: 120px;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.18));
}

.content-panel {
  flex: 1;
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  margin-bottom: 1.75rem;
}

.content-footer {
  text-align: center;
  font-size: 0.8rem;
  color: #9CA3AF;
  padding: 1.25rem 0 0.25rem;
  margin-top: auto;
}

.content-footer strong { color: var(--color-text-muted); }

/* ============================================================
   Bottom Nav
   ============================================================ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: #fff;
  border-top: 1px solid var(--color-border);
  z-index: 50;
  justify-content: space-around;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  flex: 1;
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.375rem 0.25rem 0.25rem;
  transition: color 0.15s;
}

.bottom-nav-item i { width: 20px; height: 20px; flex-shrink: 0; }
.bottom-nav-item.active { color: var(--color-accent); }
.bottom-nav-item:hover { color: var(--color-text); }

/* ============================================================
   Nav Overlay
   ============================================================ */
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

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

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
}

.nav-overlay.open { display: flex; }

.nav-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}

.nav-overlay-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease;
}

.nav-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.nav-overlay-logo { display: flex; align-items: center; gap: 0.625rem; }
.nav-overlay-logo img { width: 32px; height: 32px; object-fit: contain; }

.nav-overlay-logo-text {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

.nav-overlay-logo-text span {
  display: block;
  font-size: 0.675rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.nav-overlay-close {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.nav-overlay-close:hover { background: #F3F4F6; color: var(--color-text); }
.nav-overlay-close i { width: 20px; height: 20px; }

.nav-overlay-nav {
  padding: 0.75rem 0.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  overflow-y: auto;
  flex: 1;
}

.nav-overlay-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

/* ============================================================
   Birthday card avatar
   ============================================================ */
.birthday-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient);
  flex-shrink: 0;
  overflow: hidden;
}

.birthday-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.nav-overlay-item i { width: 18px; height: 18px; flex-shrink: 0; }
.nav-overlay-item:hover { background: #F9FAFB; color: var(--color-text); }

.nav-overlay-item.active {
  background: linear-gradient(135deg, rgba(255,249,103,0.15) 0%, rgba(255,117,31,0.12) 100%);
  color: var(--color-accent);
}

.nav-overlay-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; height: 60%; width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--gradient);
}

.nav-overlay-group-label {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem 0.25rem;
  font-size: 0.7875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-top: 0.375rem;
}

.nav-overlay-group-label i { width: 15px; height: 15px; flex-shrink: 0; }

.nav-overlay-sub-item {
  display: flex;
  align-items: center;
  padding: 0.45rem 0.75rem 0.45rem 2.625rem;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.8375rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-overlay-sub-item:hover { background: #F9FAFB; color: var(--color-text); }

.nav-overlay-section {
  font-size: 0.6375rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9CA3AF;
  padding: 0.75rem 0.75rem 0.25rem;
  margin-top: 0.25rem;
}

/* ============================================================
   Responsive — Tablet (768px – 1023px)
   ============================================================ */
@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar,
  .sidebar.collapsed,
  .sidebar:hover,
  .sidebar.collapsed:hover {
    width: 76px !important;
    box-shadow: none !important;
  }
  .sidebar .sidebar-logo-text,
  .sidebar.collapsed:not(:hover) .sidebar-logo-text {
    opacity: 0 !important;
    max-width: 0 !important;
  }
  .sidebar .nav-section-label,
  .sidebar.collapsed:not(:hover) .nav-section-label {
    opacity: 0 !important;
    max-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-top: 0 !important;
  }
  .sidebar .nav-item,
  .sidebar.collapsed:not(:hover) .nav-item {
    flex-direction: column !important;
    padding: 0.5rem 0.25rem !important;
    justify-content: center !important;
    gap: 0.2rem !important;
    align-items: center !important;
  }
  .sidebar .nav-label,
  .sidebar.collapsed:not(:hover) .nav-label {
    opacity: 1 !important;
    max-width: 100% !important;
    font-size: 0.6rem;
    line-height: 1.2;
    text-align: center;
    white-space: normal;
    flex: none;
  }
  .sidebar .nav-chevron,
  .sidebar.collapsed:not(:hover) .nav-chevron { display: none !important; }
  .sidebar .nav-sub,
  .sidebar .nav-group.open .nav-sub { display: none !important; }
  .sidebar .nav-item:has(.nav-badge) { overflow: visible !important; }
  .sidebar .nav-badge { position: absolute; top: -2px; right: 4px; margin-left: 0; min-width: 16px; height: 16px; font-size: 0.58rem; padding: 0 4px; }

  .nav-overlay-panel {
    bottom: auto;
    top: 0;
    right: auto;
    width: 300px;
    max-height: 100vh;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    animation: slideInLeft 0.25s ease;
  }
}

/* ============================================================
   Responsive — Mobile (<768px)
   ============================================================ */
@media (max-width: 767px) {
  .sidebar { display: none; }
  .topbar-toggle { display: none; }
  .topbar-icon-btn { display: none; }
  .notif-bell-wrap { display: flex; }
  .notif-bell-wrap .topbar-icon-btn { display: flex; }
  .notif-dropdown { position: fixed; top: 56px; left: 0; right: 0; width: 100vw; max-width: 100vw; max-height: calc(100vh - 56px - 68px); border-radius: 0; border-left: none; border-right: none; }
  .topbar-divider { display: none; }
  .bottom-nav { display: flex; }
  .content { padding: 1rem 1rem calc(68px + env(safe-area-inset-bottom)); }
  .welcome-banner { padding: 1rem; margin-bottom: 1rem; }
  .welcome-banner img { display: none; }
  .welcome-banner h1 { font-size: 1rem; }
  .welcome-banner + .breadcrumb-wrap { margin-top: 0; margin-bottom: 0.875rem; }
}

/* ============================================================
   Breadcrumb
   ============================================================ */
.breadcrumb-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
  font-size: 0.8125rem;
}

.breadcrumb-wrap a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.breadcrumb-wrap a:hover {
  color: var(--color-accent);
}

.breadcrumb-wrap .bc-sep {
  color: var(--color-border);
  line-height: 1;
  user-select: none;
}

.breadcrumb-wrap > span:not(.bc-sep) {
  color: var(--color-text);
  font-weight: 500;
}

@media (max-width: 767px) {
  .breadcrumb-wrap {
    padding-bottom: 0.25rem;
    font-size: 0.75rem;
  }
}

/* ============================================================
   Nav Dividers
   ============================================================ */
.nav-divider {
  height: 1px;
  background: var(--color-divider);
  margin: 0.5rem 1rem;
  flex-shrink: 0;
}

.sidebar.collapsed:not(:hover) .nav-divider {
  margin-left: 0.5rem;
  margin-right: 0.5rem;
}

.nav-overlay-divider {
  height: 1px;
  background: var(--color-divider);
  margin: 0.5rem 0.75rem;
  flex-shrink: 0;
}

/* ============================================================
   Dashboard — Stats Grid
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  padding: 1.25rem 1.5rem;
}

.stat-card-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.stat-card-label i { width: 14px; height: 14px; }

.stat-card-value {
  font-size: 2rem;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 0.375rem;
}

.stat-card-sub {
  font-size: 0.775rem;
  color: var(--color-text-muted);
}

.stat-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-top: 0.375rem;
}

.stat-breakdown-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.stat-breakdown-row strong {
  color: var(--color-text);
  font-weight: 600;
}

/* ============================================================
   Dashboard — Section Header
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-header h2 i { width: 17px; height: 17px; color: var(--color-accent); }

.section-header a {
  font-size: 0.8125rem;
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 500;
}

.section-header a:hover { text-decoration: underline; }

/* ============================================================
   Dashboard — Birthday Scroll
   ============================================================ */
.birthday-scroll {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  overflow-y: visible;
  padding-top: 14px;
  padding-bottom: 0.5rem;
  scroll-snap-type: x mandatory;
  -ms-overflow-style: none;
  scrollbar-width: none;
  margin-bottom: 1.75rem;
  flex-shrink: 0;
}

.birthday-scroll::-webkit-scrollbar { display: none; }

/* Outer flip container */
.birthday-card {
  min-width: 155px;
  max-width: 155px;
  height: 215px;
  flex-shrink: 0;
  scroll-snap-align: start;
  cursor: pointer;
  perspective: 800px;
  position: relative;
}

/* Inner — the thing that actually rotates */
.birthday-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.birthday-card.flipped .birthday-card-inner {
  transform: rotateY(180deg);
}

/* Shared front/back base */
.birthday-card-front,
.birthday-card-back {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

/* Front face */
.birthday-card-front {
  background: #fff;
  border: 1px solid var(--color-border);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.4rem;
}

.birthday-card:hover .birthday-card-front {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

/* Back face */
.birthday-card-back {
  transform: rotateY(180deg);
  background: #111;
}

.birthday-card-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.birthday-card-back-link {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.birthday-card-back-link:hover {
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
}

/* Text elements (inside front face) */
.birthday-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.birthday-location {
  font-size: 0.725rem;
  color: var(--color-text-muted);
}

.birthday-belt {
  font-size: 0.675rem;
  font-weight: 500;
  padding: 0.175rem 0.5rem;
  border-radius: 99px;
  background: #F3F4F6;
  color: var(--color-text-muted);
}

.birthday-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-accent);
}

/* Past modifier */
.birthday-card--past .birthday-card-front {
  background: #F3F4F6;
  border-color: var(--color-divider);
}

.birthday-card--past .birthday-name,
.birthday-card--past .birthday-location,
.birthday-card--past .birthday-belt {
  opacity: 0.6;
}

.birthday-card--past .birthday-date {
  color: var(--color-text-muted);
}

/* Today modifier */
.birthday-card--today .birthday-card-front {
  border-color: var(--color-accent);
  animation: birthday-pulse 2s ease-in-out infinite;
}

.birthday-card--today::after {
  content: '🎂';
  position: absolute;
  top: -10px;
  right: -8px;
  font-size: 1.25rem;
  line-height: 1;
  pointer-events: none;
  z-index: 1;
}

@keyframes birthday-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 117, 31, 0.2), 0 6px 20px rgba(255, 117, 31, 0.15); }
  50%       { box-shadow: 0 0 0 4px rgba(255, 117, 31, 0.35), 0 8px 28px rgba(255, 117, 31, 0.3); }
}

@media (max-width: 767px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-bottom: 1rem; }
  .stat-card { padding: 1rem; }
  .stat-card-value { font-size: 1.625rem; }
  .birthday-scroll { margin-bottom: 1rem; }
}

/* ============================================================
   Status Tabs
   ============================================================ */
.status-tabs {
  display: flex;
  gap: 0.25rem;
}

.status-tab {
  padding: 0.375rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.status-tab:hover {
  background: #F3F4F6;
  color: var(--color-text);
}

.status-tab.active {
  background: #111827;
  color: #fff;
  font-weight: 600;
}

/* Mobile-only location filter bar — hidden on tablet and up */
.location-filter-bar {
  display: none;
}

@media (max-width: 767px) {
  /* Hide the Active / Inactive / All status tabs on mobile —
     the location filter bar takes their place in the action bar */
  .section-header .status-tabs {
    display: none;
  }

  /* Give the action bar a breathing gap between the filter tabs
     and the New Student button */
  .section-header {
    gap: 0.5rem;
  }

  /* On the student show page, push the action buttons onto their own line
     so they don't crowd the ← Students back link */
  .section-header:has(.student-actions) {
    flex-wrap: wrap;
  }
  .section-header:has(.student-actions) .back-link {
    width: 100%;
  }
  .section-header:has(.student-actions) .student-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-around;
  }
  .section-header:has(.student-actions) .student-actions .btn-action--sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }

  /* Show the location filter as a flex row that fills the available
     space between the left edge and the New Student button */
  .location-filter-bar {
    display: flex;
    flex: 1;
    min-width: 0;   /* allow shrinking inside a flex parent */
    gap: 0.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }

  .location-filter-bar::-webkit-scrollbar {
    display: none;
  }

  /* Prevent individual tabs from shrinking when there are many locations */
  .location-filter-bar .status-tab {
    flex-shrink: 0;
  }
}

/* ============================================================
   Action Button
   ============================================================ */
a.btn-action,
button.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4375rem 1rem;
  background: var(--gradient);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.15s;
  border: none;
  cursor: pointer;
}

a.btn-action:hover,
button.btn-action:hover { opacity: 0.88; color: #fff; text-decoration: none; }
.btn-action i { width: 15px; height: 15px; }

/* ============================================================
   Student Count Bar
   ============================================================ */
.student-count-bar {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

/* ============================================================
   Tabulator Overrides
   ============================================================ */
.tabulator {
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md) !important;
  font-size: 0.875rem;
  font-family: inherit;
}

.tabulator .tabulator-header {
  background: #F9FAFB !important;
  border-bottom: 1px solid var(--color-border) !important;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.tabulator .tabulator-col {
  background: transparent !important;
  border-right: 1px solid var(--color-border) !important;
}

.tabulator .tabulator-col-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tabulator .tabulator-row {
  border-bottom: 1px solid var(--color-divider) !important;
}

.tabulator .tabulator-row:hover {
  background: #F9FAFB !important;
}

.tabulator .tabulator-row .tabulator-cell {
  padding: 0.6875rem 1rem;
  color: var(--color-text);
  border-right: 1px solid var(--color-divider);
}

.tabulator .tabulator-header-filter input {
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-sm) !important;
  padding: 0.2rem 0.4rem !important;
  font-size: 0.75rem !important;
  font-family: inherit !important;
  background: #fff !important;
  width: 100%;
  margin-top: 0.25rem;
}

.tabulator .tabulator-header-filter input:focus {
  outline: none;
  border-color: var(--color-accent) !important;
}

.tabulator-footer {
  border-top: 1px solid var(--color-border) !important;
  background: #F9FAFB !important;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-size: 0.8125rem;
  font-family: inherit;
}

.tabulator-footer .tabulator-page {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.8125rem;
  padding: 0.25rem 0.625rem;
}

.tabulator-footer .tabulator-page.active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

.table-name-link {
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
}

.table-name-link:hover {
  color: var(--color-accent);
}

/* Name cell wrapper (link + photo button) */
.name-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* Preferred-name hint bubble */
.preferred-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  flex-shrink: 0;
  cursor: help;
  margin-left: 4px;
  position: relative;
}
/* Floating tooltip — positioned by JS to avoid cell overflow clipping */
.preferred-tooltip {
  position: fixed;
  background: #1f2937;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 99999;
  transform: translateX(-50%);
}

/* Camera button inside name cell */
.photo-peek-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.photo-peek-btn:hover {
  background: var(--color-accent-glow);
  color: var(--color-accent);
  border-color: var(--color-accent);
}

/* Photo modal overlay */
.photo-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.photo-modal-overlay.open {
  display: flex;
}

.photo-modal {
  background: #fff;
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-width: 340px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

.photo-modal-img {
  width: 100%;
  display: block;
  max-height: 400px;
  object-fit: cover;
}

.photo-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.125rem;
  gap: 0.5rem;
}

.photo-modal-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--color-text);
}

.photo-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--color-surface);
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.photo-modal-close:hover {
  background: #E5E7EB;
  color: var(--color-text);
}

/* Responsive column visibility is handled in JS via table.showColumn() / hideColumn()
   Breakpoints: <768px = Name+Grade only | 768-1023px = +Location+Age | 1024px+ = all */

/* ============================================================
   Student Show Page
   ============================================================ */

/* ── btn-action variants ─────────────────────────────────── */
.btn-action--sm {
  padding: 0.3125rem 0.6875rem;
  font-size: 0.8125rem;
}

a.btn-action--warning,
button.btn-action--warning {
  background: #fff;
  color: #dc2626;
  border: 1.5px solid #dc2626;
}
a.btn-action--warning:hover,
button.btn-action--warning:hover { background: #dc2626; color: #fff; opacity: 1; }

/* Photo — white fill, orange accent border, orange text */
a.btn-action--photo,
button.btn-action--photo {
  background: #fff;
  border: 1.5px solid var(--color-accent);
  color: var(--color-accent);
}
a.btn-action--photo:hover,
button.btn-action--photo:hover {
  background: #fff7ed;
  opacity: 1;
  color: var(--color-accent);
  text-decoration: none;
}

/* Reactivate — white fill, green border, green text */
a.btn-action--reactivate,
button.btn-action--reactivate {
  background: #fff;
  border: 1.5px solid #86efac;
  color: #166534;
}
a.btn-action--reactivate:hover,
button.btn-action--reactivate:hover {
  background: #f0fdf4;
  opacity: 1;
  color: #166534;
  text-decoration: none;
}

/* Deactivate — white fill, orange accent border, red text */
a.btn-action--deactivate,
button.btn-action--deactivate {
  background: #fff;
  border: 1.5px solid var(--color-accent);
  color: #dc2626;
}
a.btn-action--deactivate:hover,
button.btn-action--deactivate:hover {
  background: #fff5f5;
  opacity: 1;
  color: #b91c1c;
  text-decoration: none;
}

.btn-action--success {
  background: #f0fdf4;
  color: #166534;
  border: 1.5px solid #86efac;
}
.btn-action--success:hover { background: #dcfce7; opacity: 1; color: #166534; }

.btn-action--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1.5px solid var(--color-border);
}
.btn-action--ghost:hover { background: var(--color-surface); opacity: 1; color: var(--color-text); }

/* Outline — white fill, gradient border, accent text (small-scale .btn-secondary) */
a.btn-action--outline,
button.btn-action--outline {
  background:
    linear-gradient(#fff, #fff) padding-box,
    var(--gradient) border-box;
  border: 2px solid transparent;
  color: var(--color-accent);
}
a.btn-action--outline:hover,
button.btn-action--outline:hover { opacity: 0.85; color: var(--color-accent); }

/* ── Modal / inline-form buttons (cm-btn-*) ─────────────── */
.cm-btn-primary {
  background: var(--gradient); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 9px 20px; font-size: 0.9375rem;
  font-weight: 600; cursor: pointer; letter-spacing: 0.02em;
  transition: opacity 0.2s, transform 0.15s;
}
.cm-btn-primary:hover { opacity: 0.92; transform: translateY(-1px); }
.cm-btn-primary:active { transform: translateY(0); }
.cm-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.cm-btn-save {
  background: var(--gradient); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 9px 20px; font-size: 0.9375rem;
  font-weight: 600; cursor: pointer;
  transition: opacity 0.15s;
}
.cm-btn-save:hover { opacity: 0.92; }
.cm-btn-save:disabled { opacity: 0.6; cursor: not-allowed; }

.cm-btn-cancel {
  background: linear-gradient(#fff, #fff) padding-box,
              var(--gradient) border-box;
  color: var(--color-accent); border: 2px solid transparent;
  border-radius: var(--radius-sm); padding: 9px 20px; font-size: 0.9375rem;
  font-weight: 600; cursor: pointer; letter-spacing: 0.02em;
  transition: opacity 0.2s, transform 0.15s;
}
.cm-btn-cancel:hover { opacity: 0.85; transform: translateY(-1px); }
.cm-btn-cancel:active { transform: translateY(0); }

.cm-btn-danger {
  background: #ef4444; color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 9px 20px; font-size: 0.9375rem;
  font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.cm-btn-danger:hover { background: #dc2626; }
.cm-btn-danger:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Form inputs (cm-input) ─────────────────────────────── */
.cm-input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--color-text, #1a1a1a);
  background: #fff;
  border: 1px solid var(--color-border, #ddd);
  border-radius: var(--radius-sm, 6px);
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.cm-input:focus {
  outline: none;
  border-color: var(--color-accent, #FF751f);
  box-shadow: 0 0 0 3px rgba(255, 117, 31, 0.12);
}
.cm-input::placeholder { color: var(--color-text-muted, #888); }
select.cm-input { appearance: none; -webkit-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='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; cursor: pointer; }
textarea.cm-input { resize: vertical; min-height: 70px; }
.cm-input:disabled { background: var(--color-bg-subtle, #f6f6f6); opacity: 0.7; cursor: not-allowed; }

/* ── Modal overlay & card ───────────────────────────────── */
.cm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cm-modal-card {
  background: #fff;
  border-radius: var(--radius-lg, 12px);
  padding: 28px 24px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.cm-modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 8px;
}
.cm-modal-body {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 20px;
}
.cm-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ── Toast notifications ────────────────────────────────── */
.cm-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--radius-md, 8px);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
.cm-toast--show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.cm-toast--success { background: var(--color-accent); }
.cm-toast--error { background: #d32f2f; }

/* ── Accreditation rows (entity profile card) ───────────── */
.acr-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.875rem;
}
.acr-row:last-child { border-bottom: none; }
.acr-row-type { font-weight: 600; flex: 1; min-width: 0; }
.acr-row-dates {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}
.acr-state-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.acr-state--valid { background: #dcfce7; color: #166534; }
.acr-state--expiring { background: #fef3c7; color: #92400e; }
.acr-state--expired { background: #fee2e2; color: #991b1b; }
.acr-state--none { background: var(--color-bg-subtle); color: var(--color-text-muted); }
.acr-row-actions {
  display: flex;
  gap: 4px;
}
.acr-row-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  color: var(--color-text-muted);
  transition: color 0.15s;
}
.acr-row-btn:hover { color: var(--color-accent); }
.acr-row-btn--danger:hover { color: #d32f2f; }
.acr-cert-icon { color: var(--color-accent); }
.acr-cert-icon:hover { opacity: 0.7; }
.acr-empty-msg {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 8px 0;
}
.acr-cert-upload-input { display: none; }
@media (max-width: 600px) {
  .acr-row { flex-wrap: wrap; }
  .acr-row-dates { width: 100%; }
}

/* ── Modal form labels (reusable) ───────────────────────── */
.cm-form-group { text-align: left; margin-bottom: 14px; }
.cm-form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ── Back link ───────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.back-link:hover { color: var(--color-text); }
.back-link i { width: 14px; height: 14px; }

/* ── Student action button row ───────────────────────────── */
.student-actions {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}

/* ── Profile card ────────────────────────────────────────── */
.student-profile-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.student-profile-photo-wrap { flex-shrink: 0; }

.student-profile-photo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  border: 2px solid var(--color-border);
  display: block;
}

.student-profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
}
.student-profile-avatar i { width: 40px; height: 40px; }

.student-profile-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.student-profile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.profile-badge {
  display: inline-block;
  padding: 0.1875rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.profile-badge--grade    { background: var(--color-accent-glow); color: var(--color-accent); }
.profile-badge--active   { background: #dcfce7; color: #166534; }
.profile-badge--inactive { background: #fee2e2; color: #991b1b; }
.profile-badge--birthday { background: #fef9c3; color: #854d0e; }

/* ── Details two-column layout (info left, photo right) ─── */
.student-details-body {
  display: flex;
  gap: 1.5rem;
  align-items: stretch; /* right column matches full height of left column */
}

.student-details-left  { flex: 1; min-width: 0; max-width: 480px; }
.student-details-right {
  flex: 1;                 /* fill remaining space so there's room to centre within */
  display: flex;
  align-items: center;     /* vertical centre */
  justify-content: center; /* horizontal centre */
}

.student-detail-photo {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  border: 2px solid var(--color-border);
  display: block;
  cursor: pointer;
  transition: opacity 0.15s;
}
.student-detail-photo:hover { opacity: 0.88; }
.student-detail-photo--placeholder { cursor: default; pointer-events: none; }
/* Hide the whole photo column when there's no real photo */
.student-details-right:has(.student-detail-photo--placeholder) { display: none; }

.student-detail-avatar {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
}
.student-detail-avatar i { width: 80px; height: 80px; }

/* name + badges sit above the detail rows, inside the left column */
.student-profile-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.375rem;
}
.student-aka {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.student-profile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

@media (max-width: 767px) {
  .student-details-body   { flex-direction: column-reverse; }
  .student-details-right  { align-self: center; }
  .student-detail-photo,
  .student-detail-avatar  { width: 120px; height: 120px; }
  .student-detail-avatar i { width: 48px; height: 48px; }
}

/* ── Info card (generic card used on show page) ──────────── */
.info-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 0.625rem;
  overflow: hidden;
  flex-shrink: 0; /* prevent flex-column parent from collapsing cards */
}

.info-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.875rem;
  border-bottom: 1px solid var(--color-divider);
}

.info-card-title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}
.info-card-title i { width: 16px; height: 16px; color: var(--color-accent); }

/* Help button — gradient circle with ? */
.info-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 0.2rem;
  position: relative;
  line-height: 1;
}

.info-help-btn:focus { outline: none; }

/* Help tooltip */
.info-help-tooltip {
  position: fixed;
  z-index: 100;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  padding: 0.6rem 0.75rem;
  max-width: 220px;
  font-size: 0.78rem;
  color: var(--color-text);
  line-height: 1.5;
  pointer-events: none;
}

.info-card-link {
  font-size: 0.8125rem;
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 500;
}
.info-card-link:hover { text-decoration: underline; }

.info-card-body { padding: 0.5rem 0.875rem; }

/* ── Detail grid ─────────────────────────────────────────── */
.detail-grid {
  display: flex;
  flex-direction: column;
}

.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--color-divider);
}
.detail-row:last-child { border-bottom: none; }

.detail-label {
  flex-shrink: 0;
  width: 140px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-label);
  padding-top: 0.0625rem;
}

.detail-value {
  flex: 1;
  font-size: 0.875rem;
  color: var(--color-text);
  min-width: 0;
}

.detail-muted {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  margin-left: 0.2rem;
}

.detail-periods {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.375rem;
}

@media (max-width: 767px) {
  .detail-row    { flex-direction: column; gap: 0.125rem; }
  .detail-label  { width: auto; }
}

/* ── Period badges ───────────────────────────────────────── */
.period-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}
.period-badge--current { background: #dcfce7; color: #166534; }
.period-badge--past    { background: #f1f5f9; color: #475569; }

/* ── Licence badge ───────────────────────────────────────── */
.licence-badge {
  display: inline-block;
  padding: 0.1875rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
}
.licence-badge--ok     { background: #dcfce7; color: #166534; }
.licence-badge--warn   { background: #fef3c7; color: #92400e; }
.licence-badge--danger { background: #fee2e2; color: #991b1b; }

.renewal-link {
  margin-left: 0.5rem;
  font-size: 0.8125rem;
  color: var(--color-accent);
  text-decoration: none;
}
.renewal-link:hover { text-decoration: underline; }

/* ── Bool badge ──────────────────────────────────────────── */
.bool-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.bool-badge--yes { background: #dcfce7; color: #166534; }
.bool-badge--no  { background: #fee2e2; color: #991b1b; }

/* ── Tag pills (detail card) ─────────────────────────────── */
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.tag-pill {
  --tag-color: grey;
  display: inline-block;
  padding: 0.1875rem 0.5625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: color-mix(in srgb, var(--tag-color) 15%, white);
  color: color-mix(in srgb, var(--tag-color) 70%, black);
}
.tag-pill a         { color: inherit; text-decoration: none; }
.tag-pill--hidden   { display: none; }

.tag-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1875rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tag-edit-btn:hover { background: var(--color-surface); color: var(--color-text); }

/* ── Assignment toggles ──────────────────────────────────── */
.assignment-group { margin-bottom: 0.75rem; }
.assignment-group:last-child { margin-bottom: 0; }

.assignment-group-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  margin-bottom: 0.3rem;
}

.assignment-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.assignment-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
  line-height: 1.4;
}
.assignment-btn:disabled { opacity: 0.5; cursor: wait; }

.assignment-btn--on {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}
.assignment-btn--on:hover  { background: #bbf7d0; }

.assignment-btn--off {
  background: var(--color-surface);
  color: var(--color-text-muted);
  border-color: var(--color-border);
}
.assignment-btn--off:hover { background: #e5e7eb; color: var(--color-text); }

/* Tag-colour overrides — placed after --on so they win the specificity race */
.assignment-btn--coloured {
  background: color-mix(in srgb, var(--tag-color) 15%, white);
  color: color-mix(in srgb, var(--tag-color) 70%, black);
  border-color: color-mix(in srgb, var(--tag-color) 30%, white);
}
.assignment-btn--coloured:hover {
  background: color-mix(in srgb, var(--tag-color) 25%, white);
}

/* ── Attendance calendar ─────────────────────────────────── */
.attendance-calendar-grid {
  display: flex;
  flex-wrap: nowrap;          /* single row */
  gap: 0.75rem;
  overflow-x: auto;
  overflow-y: visible;
  -ms-overflow-style: none;   /* IE/Edge */
  scrollbar-width: none;      /* Firefox */
}
.attendance-calendar-grid::-webkit-scrollbar { display: none; } /* Chrome/Safari */

.calendar-month {
  flex-shrink: 0;             /* never compress — scroll instead */
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
}

.calendar-month-header {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  margin-bottom: 0.4rem;
}

.calendar-dow-row,
.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 24px); /* fixed cell width → compact, not stretchy */
  gap: 2px;
}
.calendar-dow-row { margin-bottom: 2px; }

.calendar-dow-row span {
  text-align: center;
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: 2px 0;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  border-radius: 4px;
  color: var(--color-text-muted);
  position: relative;
}

/* today — subtle highlight when not attended */
.calendar-day--today:not(.calendar-day--attended) {
  background: var(--color-accent-glow);
  color: var(--color-accent);
  font-weight: 700;
}

/* attended — gradient fill */
.calendar-day--attended {
  background: var(--gradient);
  color: #fff;
  font-weight: 600;
}

/* promoted — purple inset ring (distinct from the orange/yellow gradient) */
.calendar-day--promoted {
  box-shadow: inset 0 0 0 3px #7c3aed;
  background: #f5f3ff;  /* subtle purple tint so the ring has contrast */
  color: #5b21b6;
  font-weight: 700;
}
.calendar-day--attended.calendar-day--promoted {
  box-shadow: inset 0 0 0 3px #7c3aed;
  background: var(--gradient); /* keep gradient */
  color: #fff;
}

/* late — red circle badge in top-right corner */
.calendar-day--late::after {
  content: '!';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  font-size: 7px;
  font-weight: 900;
  line-height: 9px;
  text-align: center;
}
.calendar-day--attended.calendar-day--late::after {
  background: #dc2626; /* keep red badge regardless of gradient */
  outline: 1.5px solid rgba(255,255,255,0.7); /* small white outline to lift off the gradient */
}

/* month stats row */
.calendar-month-stats {
  display: flex;
  gap: 0.625rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--color-divider);
}

.cal-stat {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.cal-stat strong                { font-weight: 700; color: var(--color-text); }
.cal-stat--late strong          { color: #dc2626; }
.cal-stat--promotion strong     { color: var(--color-accent); }

/* ── Promotions list ─────────────────────────────────────── */
.promotion-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-divider);
  font-size: 0.875rem;
}
.promotion-row:last-child { border-bottom: none; }

.promotion-belt-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;   /* clips flex children to the circle */
  position: relative; /* anchors ::after */
  display: flex;
}
/* Two flex children each get exactly half the width */
.promotion-belt-swatch > span {
  flex: 1;
  min-width: 0;
}
/* Ring rendered on top of children so it's always visible, even over white halves */
.promotion-belt-swatch::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  z-index: 1;
}

.promotion-grade-name { font-weight: 600; }
.promotion-belt-label { color: var(--color-text-muted); }
.promotion-date       { color: var(--color-text-muted); margin-left: auto; }
.promotion-serial     { font-size: 0.75rem; color: var(--color-text-muted); }
.promotion-row--revoked { opacity: 0.45; }
.promotion-revoked-pill {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fef2f2;
  color: #dc2626;
}

/* ── Notes list ──────────────────────────────────────────── */
.note-row {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-divider);
}
.note-row:last-child { border-bottom: none; }

.note-meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.note-body {
  font-size: 0.875rem;
  color: var(--color-text);
}

/* ── Promote modal ───────────────────────────────────────── */
.promote-modal { max-width: 420px; width: calc(100vw - 2rem); }

.promote-modal-body {
  padding: 1.25rem 1.125rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.promote-modal-body .form-group { margin-bottom: 0; }

/* ── Award accolade modal (two-stage picker) ─────────────── */
.award-modal { max-width: 460px; width: calc(100vw - 2rem); }

.award-stage-body {
  padding: 0.75rem 1.125rem 1.25rem;
}

.award-tile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  max-height: 340px;
  overflow-y: auto;
  margin-top: 0.625rem;
  -webkit-overflow-scrolling: touch;
}

.award-tile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.award-tile:hover  { border-color: var(--color-accent); background: #f5f8ff; }
.award-tile:active { background: #eaf0ff; }

.award-tile__icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.award-tile__icon img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.award-tile__name {
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
}

.award-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* Selected accolade banner (stage 2) */
.award-selected {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}
.award-selected-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.award-selected-icon img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}
.award-selected-name {
  font-weight: 600;
  font-size: 0.875rem;
  flex: 1;
  min-width: 0;
}
.award-change-btn {
  background: none;
  border: none;
  color: var(--color-accent);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}
.award-change-btn:hover { text-decoration: underline; }

@media (max-width: 400px) {
  .award-tile-grid { grid-template-columns: 1fr; }
}

/* ── Colour swatch picker (award accolade modal) ─────────── */
.colour-swatch-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.125rem 0;
}

.colour-swatch-label {
  display: block;
  cursor: pointer;
}

.colour-swatch-label input[type="radio"] {
  display: none;
}

.colour-swatch {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid transparent;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color 0.15s;
}

.colour-swatch-label input[type="radio"]:checked + .colour-swatch {
  outline-color: var(--color-accent);
}

.colour-swatch--random {
  background: #fff;
  border-color: var(--color-border);
  text-align: center;
  line-height: 22px; /* 28px height − 3px border top − 3px border bottom */
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--color-text-muted);
}

/* ── Tags modal ──────────────────────────────────────────── */
.tags-modal { max-width: 420px; width: calc(100vw - 2rem); }

.tags-modal-body {
  padding: 1rem 1.125rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-align: center;
  padding: 0.75rem 0;
}

/* ── Member portal notice banner ────────────────────────── */
.member-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: linear-gradient(135deg, #fff8f0, #fff3e6);
  border: 1px solid #ffd9b3;
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  color: var(--color-text);
  line-height: 1.5;
}

.member-notice > i {
  width: 18px;
  height: 18px;
  color: var(--color-accent);
  flex-shrink: 0;
  margin-top: 0.15rem;
}

@media (max-width: 640px) {
  .member-notice > svg { display: none; }
  .member-notice { padding: 0.75rem 0.875rem; }
}

.member-notice p { margin: 0; }
.member-notice strong { color: var(--color-accent); font-weight: 600; }

/* ── Member cards (member portal homepage) ───────────────── */
.member-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.member-cards-grid--single {
  grid-template-columns: minmax(0, 480px);
}

/* Empty state — no members linked */
.member-empty-state {
  grid-column: 1 / -1;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 2.5rem 2rem;
  text-align: center;
}

.member-empty-state-header i {
  width: 48px;
  height: 48px;
  color: var(--color-accent);
  margin-bottom: 0.75rem;
}

.member-empty-state-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 0.5rem;
}

.member-empty-state-header p {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin: 0 0 2rem;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.member-empty-state-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.member-empty-state-feature {
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  position: relative;
  background: linear-gradient(var(--color-surface), var(--color-surface)) padding-box,
              linear-gradient(135deg, #fff967 0%, #FF751f 100%) border-box;
  border: 2px solid transparent;
}

.member-empty-state-feature i {
  width: 28px;
  height: 28px;
  color: var(--color-accent);
  margin-bottom: 0.5rem;
}

.member-empty-state-feature h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 0.35rem;
}

.member-empty-state-feature p {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.5;
}

.member-empty-state-contact {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin: 0;
}

.member-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: box-shadow 0.2s, border-color 0.2s;
  position: relative;
}

.member-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  border-color: var(--color-accent);
}

.member-card--birthday {
  border-color: var(--color-accent);
  animation: birthday-pulse 2s infinite;
}

.member-card--birthday::after {
  content: '🎂';
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 1.4rem;
  z-index: 1;
}

.member-card-top {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.member-card-photo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  border: 2px solid var(--color-border);
  flex-shrink: 0;
}

.member-card-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.member-card-avatar i { width: 32px; height: 32px; }

.member-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.member-card-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-card-grade,
.member-card-location,
.member-card-since {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.member-card-grade i,
.member-card-location i,
.member-card-since i { width: 13px; height: 13px; flex-shrink: 0; }

.member-card-swatch {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.member-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.875rem;
  border-top: 1px solid var(--color-divider);
}

.member-card-lessons {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.member-card-lessons strong {
  color: var(--color-text);
  font-weight: 700;
  font-size: 1rem;
}

.member-card-link {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-accent);
  text-decoration: none;
}

.member-card-link:hover { text-decoration: underline; }
.member-card-link i { width: 13px; height: 13px; }

/* ── Member profile page ─────────────────────────────────── */
.member-profile-hero {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  padding: 1.25rem;
  margin-bottom: 0.625rem;
}

.member-profile-photo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.member-profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.member-profile-avatar svg { width: 44px; height: 44px; color: var(--color-text-muted); }

.member-profile-info {
  flex: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.member-profile-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
}

.member-profile-grade {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}

.member-profile-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.member-profile-meta svg { width: 13px; height: 13px; flex-shrink: 0; }

/* Mobile stats card — hidden on desktop */
.member-profile-stats-card {
  display: none;
}

.member-profile-stats-card-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.625rem 1.25rem 0;
}

.member-profile-stats-card-body {
  display: flex;
}

.member-profile-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-left: 1.25rem;
  border-left: 1px solid var(--color-border);
  align-self: center;
}

.member-profile-stat strong {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.member-profile-stat span {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Info row layout (belt history / accolades / achievements) */
.member-info-row {
  display: flex;
  gap: 0.625rem;
  margin-bottom: 0.625rem;
}

.member-info-row > * {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

@media (max-width: 768px) {
  .member-info-row { flex-direction: column; }
  .member-info-row > * { flex: none; height: auto; }
}

/* Belt history timeline — gap is set inline by PHP based on item count */
.member-belt-history {
  display: flex;
  flex-direction: column;
  gap: 0.75rem; /* fallback only */
  justify-content: flex-start;
}

/* Divider between items — padding-top matches the gap via the CSS variable set inline */
.member-belt-item + .member-belt-item {
  border-top: 1px solid var(--color-border);
  padding-top: var(--belt-gap, 0.75rem);
}

.member-belt-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}


.member-belt-detail {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  flex: 1;
}

.member-belt-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
}

.member-belt-date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* Attendance heatmap */
/* ---- Accolade booklet ---- */

.booklet-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* The open-book container; perspective set here for child 3D transforms */
.booklet-container {
  position: relative;
  display: flex;
  align-items: stretch;
  perspective: 1400px;
  perspective-origin: 50% 50%;
}

/* Individual page */
.booklet-page {
  width: 114px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  padding: 0.625rem 0.625rem 1.375rem;
  position: relative;
  box-shadow: 2px 2px 5px rgba(0,0,0,0.07);
  display: flex;
  flex-direction: column;
}

/* Spine between the two pages */
.booklet-spine {
  width: 6px;
  flex-shrink: 0;
  background: linear-gradient(to right, #c8c8c8, #e8e8e8, #c8c8c8);
  box-shadow: inset 0 0 3px rgba(0,0,0,0.12);
}

/* Page number */
.booklet-pnum {
  position: absolute;
  bottom: 0.375rem;
  font-size: 0.6rem;
  color: var(--color-text-muted);
  font-style: italic;
}
.booklet-pnum--left  { left:  0.5rem; }
.booklet-pnum--right { right: 0.5rem; }

/* Grid inside a booklet page: 2 columns of 44px */
.booklet-page .accolade-grid {
  display: grid;
  grid-template-columns: repeat(2, 44px);
  gap: 0.35rem;
}

/* Slots inside booklet pages */
.booklet-page .accolade-slot {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--color-border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Stamp inside a slot — border intentionally kept */

/* Rubber stamp worn-ink effect — patches of the icon are simply absent,
   like a well-used stamp that didn't fully transfer. No blur, just gaps. */
.booklet-page .accolade-slot.has-stamp svg,
.booklet-leaf-front .accolade-slot.has-stamp svg,
.booklet-leaf-back  .accolade-slot.has-stamp svg,
.booklet-page .accolade-slot.has-stamp .custom-stamp-icon,
.booklet-leaf-front .accolade-slot.has-stamp .custom-stamp-icon,
.booklet-leaf-back  .accolade-slot.has-stamp .custom-stamp-icon {
  width: 62%;
  height: 62%;
  flex-shrink: 0;
  filter: url(#rubber-stamp);
  opacity: 0.92;
}

/* Custom uploaded stamp icons */
.custom-stamp-icon {
  display: block;
  object-fit: contain;
}


/* ---- Turning leaf ---- */
.booklet-leaf {
  display: none;
  position: absolute;
  top: 0;
  transform-style: preserve-3d;
  z-index: 10;
}

.booklet-leaf-front,
.booklet-leaf-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  padding: 0.625rem 0.625rem 1.375rem;
  box-sizing: border-box;
  box-shadow: 2px 2px 5px rgba(0,0,0,0.07);
  display: flex;
  flex-direction: column;
}

.booklet-leaf-back {
  transform: rotateY(180deg);
}

/* Grid / slots mirror booklet-page inside the leaf faces */
.booklet-leaf-front .accolade-grid,
.booklet-leaf-back  .accolade-grid {
  display: grid;
  grid-template-columns: repeat(2, 44px);
  gap: 0.35rem;
}

.booklet-leaf-front .accolade-slot,
.booklet-leaf-back  .accolade-slot {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--color-border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Leaf stamp slots — border intentionally kept */

.booklet-leaf-front .accolade-slot.has-stamp svg,
.booklet-leaf-back  .accolade-slot.has-stamp svg {
  width: 62%;
  height: 62%;
  flex-shrink: 0;
}

/* ---- Navigation ---- */
.booklet-nav {
  display: flex;
  gap: 0.5rem;
}

.booklet-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.booklet-btn svg { width: 13px; height: 13px; }

.booklet-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.booklet-btn:not(:disabled):hover {
  background: var(--color-border);
}

/* ---- Stamp detail tooltip ---- */
.booklet-wrap {
  position: relative; /* tooltip positioned inside here */
}

.accolade-tooltip {
  position: absolute;
  z-index: 20;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  padding: 0.75rem;
  min-width: 140px;
  max-width: 210px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.accolade-tooltip-name {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
  margin-bottom: 0.35rem;
}

.accolade-tooltip-date {
  display: block;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  line-height: 1;
}

.accolade-tooltip-comment {
  display: block;
  font-size: 0.72rem;
  color: var(--color-text);
  padding-top: 0.5rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--color-border);
  line-height: 1.4;
}

/* Stamp slots — same weight, slightly darker border + clickable */
.accolade-slot.has-stamp {
  border: 1px dashed #aaa;
  cursor: pointer;
}

.member-attendance {
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

@media (max-width: 560px) {
  .member-profile-photo,
  .member-profile-avatar { width: 72px; height: 72px; }
  .member-profile-avatar svg { width: 34px; height: 34px; }
  .member-profile-name { font-size: 1.0625rem; }

  /* Hide inline stats from hero on mobile */
  .member-profile-stat--desktop { display: none; }

  /* Show the dedicated stats card */
  .member-profile-stats-card {
    display: block;
    margin-bottom: 0.625rem;
    padding-bottom: 1rem;
  }

  .member-profile-stats-card-body {
    display: flex;
    gap: 0;
    padding: 0.5rem 1.25rem 0;
  }

  /* Stats sit side-by-side, dividers between them */
  .member-profile-stats-card .member-profile-stat {
    flex: 1;
    text-align: center;
    align-self: auto;
    padding-left: 0;
    border-left: none;
    border-right: 1px solid var(--color-border);
  }

  .member-profile-stats-card .member-profile-stat:last-child {
    border-right: none;
  }
}


/* ============================================================
   Auth pages — login · forgot-password · reset-password
   ============================================================ */

.auth-container {
    display: flex;
    height: 100vh;
}

/* Left panel */
.auth-panel-left {
    flex: 1;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-panel-left img {
    max-width: 80%;
    max-height: 75vh;
    width: 100%;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.18));
}

/* Right panel */
.auth-panel-right {
    flex: 1;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-form-wrapper {
    width: 100%;
    max-width: 400px;
}

.auth-logo {
    width: 96px;
    height: 96px;
    margin-bottom: 1.75rem;
}

.auth-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.auth-form-wrapper h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.auth-form-wrapper p.subtitle {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}

.auth-form-wrapper .form-options a {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 500;
}

.auth-form-wrapper .form-options a:hover {
    text-decoration: underline;
}

.auth-signup-prompt {
    text-align: center;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    font-style: italic;
    margin-top: 1.5rem;
}

.btn-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Hidden on desktop, shown on mobile */
.auth-mobile-welcome {
    display: none;
}

/* ── Auth: tablet landscape ── */
@media (min-width: 769px) and (max-width: 1199px) and (orientation: landscape) {
    .auth-panel-left {
        padding: 0.75rem;
    }
    .auth-panel-left img {
        max-width: 98%;
        max-height: 96vh;
    }
}

/* ── Auth: mobile + tablet portrait ── */
@media (max-width: 768px), (max-width: 1199px) and (orientation: portrait) {
    .auth-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .auth-panel-left {
        flex: none;
        height: auto;
        padding: 2rem 2rem 3rem;
        justify-content: center;
        align-items: center;
    }

    /* Hide the illustration on mobile */
    .auth-panel-left > img {
        display: none;
    }

    .auth-mobile-welcome {
        display: block;
        color: #fff;
        text-align: center;
    }

    .auth-mobile-welcome h2 {
        font-size: 1.625rem;
        font-weight: 700;
        margin-bottom: 0.375rem;
        text-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    }

    .auth-mobile-welcome p {
        font-size: 0.9375rem;
        opacity: 0.85;
    }

    .auth-panel-right {
        flex: 1;
        align-items: flex-start;
        padding: 0 1.5rem 3rem;
    }

    .auth-form-wrapper {
        max-width: 100%;
        padding-top: 0;
    }

    .auth-form-wrapper h1,
    .auth-form-wrapper p.subtitle {
        display: none;
    }

    .auth-logo {
        width: 72px;
        height: 72px;
        margin-top: -36px;
        margin-bottom: 1.5rem;
        filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.15));
    }
}

/* ── Auth: tablet portrait — taller gradient banner ── */
@media (min-width: 769px) and (max-width: 1199px) and (orientation: portrait) {
    .auth-panel-left {
        min-height: 25vh;
        padding: 2rem 2rem 3rem;
        flex-direction: column;
        justify-content: flex-end;
    }
    .auth-mobile-welcome h2 {
        font-size: 2.25rem;
    }
    .auth-mobile-welcome p {
        font-size: 1.125rem;
    }
    .auth-logo {
        width: 88px;
        height: 88px;
        margin-top: -44px;
    }
    .auth-panel-right {
        align-items: center;
        padding-top: 2rem;
    }
}
