/* ============================================================
   RADA — app.css
   Design System · Layout · Components · Utilities
   ============================================================ */

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

/* ── 1. CSS Variables ──────────────────────────────────────── */
:root {
  --royal:              #3D1A6E;
  --royal-dark:         #2A0F52;
  --royal-deeper:       #1C0838;
  --royal-deepest:      #0E0420;
  --royal-ink:          #06020D;
  --royal-light:        #F0EAFA;
  --royal-muted:        #7B52B0;
  --royal-rgb:          61, 26, 110;
  --gold:               #C07C00;
  --gold-light:         #FDF4E3;
  --success:            #1A9E4A;
  --success-light:      #E8F7EE;
  --danger:             #DC2626;
  --danger-light:       #FEF2F2;
  --warning:            #D97706;
  --warning-light:      #FFFBEB;
  --info:               #0284C7;
  --info-light:         #E0F2FE;
  --neutral-dark:       #1A1A2E;
  --neutral-mid:        #64748B;
  --neutral-light:      #F1F5F9;
  --white:              #FFFFFF;
  --border:             #E2E8F0;
  --sidebar-w:          260px;
  --topbar-h:       64px;
  --bottom-nav-h:   0px;
  --radius:         10px;
  --radius-sm:      6px;
  --shadow:         0 1px 8px rgba(0,0,0,0.07);
  --shadow-md:      0 4px 20px rgba(0,0,0,0.10);
  --transition:     all 0.2s ease;
}

/* ── 2. Base Reset & Typography ────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  font-family: 'DM Sans', 'Plus Jakarta Sans', sans-serif;
  background-color: var(--neutral-light);
  color: var(--neutral-dark);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3,h4,h5,h6 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  line-height: 1.3;
  color: var(--neutral-dark);
}

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

/* ── 3. Layout ─────────────────────────────────────────────── */
.rada-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Topbar */
.rada-topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 1020;
  gap: 16px;
  transition: left 0.3s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.rada-topbar .topbar-left { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.rada-topbar .topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}

.topbar-brand {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--royal);
  letter-spacing: -0.5px;
}
.topbar-brand span { color: var(--royal-deeper); }

.sidebar-toggle-btn {
  background: none;
  border: none;
  color: var(--neutral-mid);
  font-size: 1.1rem;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.sidebar-toggle-btn:hover {
  background: var(--neutral-light);
  color: var(--royal);
}

.branch-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--royal-light);
  color: var(--royal-deeper);
  border: 1px solid rgba(var(--royal-rgb),0.2);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.branch-pill i { font-size: 0.65rem; color: var(--royal); flex-shrink: 0; }

.rada-topbar .topbar-context {
  min-width: 0;
  flex: 0 1 11rem;
  max-width: 11rem;
  overflow: hidden;
}
.rada-topbar .topbar-context select,
.rada-topbar .topbar-context-label {
  min-width: 0;
  width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--neutral-dark);
  cursor: pointer;
}
.rada-topbar .user-avatar-btn,
.rada-topbar .dropdown { flex-shrink: 0; }

.topbar-search {
  position: relative;
  max-width: 280px;
}
.topbar-search input {
  background: var(--neutral-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px 7px 36px;
  font-size: 0.82rem;
  width: 100%;
  transition: var(--transition);
  color: var(--neutral-dark);
}
.topbar-search input:focus {
  outline: none;
  border-color: var(--royal-muted);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(var(--royal-rgb),0.08);
}
.topbar-search i {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--neutral-mid);
  font-size: 0.8rem;
}

/* User Avatar Dropdown */
.user-avatar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: var(--transition);
}
.user-avatar-btn:hover { background: var(--neutral-light); }

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--royal), var(--royal-deeper));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  font-family: 'Plus Jakarta Sans', sans-serif;
  flex-shrink: 0;
}

.user-info-text .user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--neutral-dark);
  line-height: 1.2;
  display: block;
}
.user-info-text .user-role {
  font-size: 0.7rem;
  color: var(--neutral-mid);
  display: block;
}

/* Sidebar */
.rada-sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  max-height: 100vh;
  background: var(--royal-deeper);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1030;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  overflow: hidden;
}

.rada-sidebar::-webkit-scrollbar { width: 4px; }
.rada-sidebar::-webkit-scrollbar-track { background: transparent; }
.rada-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.sidebar-brand {
  height: var(--topbar-h);
  padding: 0 16px;
  border-bottom: 1px solid rgba(255,255,255,0.14);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  box-sizing: border-box;
}

.sidebar-brand-logo {
  width: 36px;
  height: 36px;
  background: #fff;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  font-family: 'Plus Jakarta Sans', sans-serif;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(var(--royal-rgb),0.4);
  overflow: hidden;
}

.sidebar-brand-logo img,
.sidebar-brand-logo img.org-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
}

.brand-color-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.brand-color-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.brand-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
  padding: 0;
  cursor: pointer;
}
.brand-swatch.is-selected { box-shadow: 0 0 0 2px var(--neutral-dark); }
.brand-color-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.78rem;
  color: var(--neutral-mid);
}
.brand-color-picker input[type="color"] {
  width: 36px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.sidebar-brand-text { min-width: 0; }
.sidebar-brand-text .brand-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  color: #fff;
  letter-spacing: -0.3px;
  line-height: 1.15;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-brand-text .brand-sub {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.72);
  display: block;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-nav { 
  padding: 10px 0; 
  flex: 1; 
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overflow-anchor: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { 
  width: 4px; 
}
.sidebar-nav::-webkit-scrollbar-track { 
  background: transparent; 
}
.sidebar-nav::-webkit-scrollbar-thumb { 
  background: rgba(255,255,255,0.1); 
  border-radius: 2px; 
}

.sidebar-section-label {
  color: rgba(255,255,255,0.55);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 14px 20px 5px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,0.65);
  font-size: 0.825rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  position: relative;
}
.sidebar-link i {
  font-size: 0.9rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
  border-left-color: rgba(255,255,255,0.45);
}
.sidebar-link.active {
  color: #fff;
  background: rgba(255,255,255,0.12);
  border-left-color: var(--gold);
  font-weight: 600;
}
.sidebar-link.active i { color: #fff; }

/* Sidebar collapse sub-nav */
.sidebar-collapse-btn {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  justify-content: space-between;
}
.sidebar-collapse-btn .chevron {
  font-size: 0.65rem;
  transition: transform 0.25s ease;
  color: rgba(255,255,255,0.35);
  margin-left: auto;
}
.sidebar-collapse-btn[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.sidebar-subnav {
  background: rgba(0,0,0,0.15);
  border-left: none;
}
.sidebar-subnav .sidebar-link {
  padding-left: 48px;
  font-size: 0.795rem;
  color: rgba(255,255,255,0.5);
}
.sidebar-subnav .sidebar-link:hover { color: rgba(255,255,255,0.85); }
.sidebar-subnav .sidebar-link.active { color: #fff; background: rgba(255,255,255,0.12); border-left-color: var(--gold); }

.sidebar-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.07);
  margin: 8px 20px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.14);
  flex-shrink: 0;
}
.sidebar-footer .sidebar-link {
  border-radius: 10px;
  border-left: 3px solid transparent;
  padding: 10px 12px;
}
.sidebar-account {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.16) !important;
  color: #fff;
  gap: 10px;
}
.sidebar-account:hover {
  background: rgba(255,255,255,0.12);
  border-left-color: transparent;
}
.sidebar-account-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.sidebar-account-name {
  color: #fff;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-account-role {
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-top: 2px;
}
.sidebar-account-icon {
  color: #fff;
  margin-left: auto;
  font-size: 0.95rem;
}

/* Content Area */
.rada-content {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
  flex: 1;
  transition: margin-left 0.3s ease;
  overflow-x: hidden;
}

.content-inner {
  padding: 28px 28px 48px;
  max-width: 100%;
  overflow-x: hidden;
}

/* Sidebar collapsed state */
body.sidebar-collapsed .rada-sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
body.sidebar-collapsed .rada-topbar { left: 0; }
body.sidebar-collapsed .rada-content { margin-left: 0; }

/* ── 4. Page Header ────────────────────────────────────────── */
.page-header {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: nowrap !important;
  width: 100%;
}
.page-header-left {
  flex: 1 1 auto !important;
  min-width: 0;
  overflow: hidden;
}
.page-header-left .page-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0 0 3px;
  color: var(--neutral-dark);
  font-family: 'Plus Jakarta Sans', sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-header-left .breadcrumb {
  margin: 0;
  padding: 0;
  background: none;
  font-size: 0.77rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-header-left .breadcrumb-item a { color: var(--neutral-mid); }
.page-header-left .breadcrumb-item.active { color: var(--royal); font-weight: 500; }
.page-header-left .breadcrumb-item + .breadcrumb-item::before { color: var(--neutral-mid); }
.page-header-right { 
  display: flex !important; 
  gap: 8px; 
  align-items: center; 
  flex-wrap: nowrap !important;
  flex: 0 0 auto !important;
  max-width: fit-content;
  min-width: fit-content;
}

/* Responsive Page Header */
@media (max-width: 992px) {
  .page-header {
    gap: 12px;
  }
  .page-header-right {
    gap: 6px;
  }
}

@media (max-width: 768px) {
  .page-header {
    gap: 10px;
  }
  .page-header-left .page-title {
    font-size: 1.1rem;
  }
  .page-header-left .breadcrumb {
    font-size: 0.7rem;
  }
  .page-header-right {
    gap: 4px;
  }
  .page-header-right .btn {
    padding: 5px 8px;
    font-size: 0.7rem;
  }
  .page-header-right .branch-filter-bar {
    padding: 6px 10px;
    font-size: 0.7rem;
  }
}

@media (max-width: 576px) {
  .page-header {
    gap: 8px;
  }
  .page-header-left .page-title {
    font-size: 1rem;
  }
  .page-header-left .breadcrumb {
    font-size: 0.65rem;
  }
  .page-header-right {
    gap: 4px;
  }
  .page-header-right .btn {
    padding: 4px 6px;
    font-size: 0.65rem;
  }
  .page-header-right .branch-filter-bar {
    padding: 4px 8px;
    font-size: 0.65rem;
  }
}

/* ── 5. Cards ──────────────────────────────────────────────── */
.rada-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.rada-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.rada-card-header .card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--neutral-dark);
  margin: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rada-card-header .card-title i { color: var(--royal); font-size: 0.85rem; }

.rada-card-body { padding: 20px; }

.rada-chart-card { position: relative; }
.rada-chart-card .rada-card-header {
  align-items: flex-start;
}
.rada-chart-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}
.rada-chart-crumb {
  font-size: 0.72rem;
  color: var(--neutral-mid);
  font-weight: 600;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rada-chart-toolbar .filter-select,
.rada-chart-toolbar .form-select {
  max-width: 140px;
  min-width: 110px;
  font-size: 0.78rem;
}
.rada-chart-toolbar .rada-typeahead {
  min-width: 180px;
  max-width: 240px;
}
.rada-chart-toolbar .rada-typeahead-input {
  height: 34px;
  font-size: 0.78rem;
}
.rada-chart-back {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
}
.rada-chart-custom {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--neutral-mid);
}
.rada-chart-custom .form-control {
  max-width: 132px;
}
.rada-chart-canvas-wrap {
  position: relative;
}
.rada-chart-canvas-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.rada-chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--neutral-mid);
  font-size: 0.85rem;
  text-align: center;
  padding: 16px;
}
.rada-chart-legend {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rada-chart-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}
.rada-chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.rada-chart-legend-label {
  flex: 1;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rada-chart-legend-value {
  font-weight: 700;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.rada-chart-legend-pct {
  min-width: 36px;
  text-align: right;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--neutral-mid);
}
.rada-chart-card.is-loading {
  pointer-events: none;
}
.rada-chart-loading {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 4;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.68);
}
.rada-chart-card.is-loading .rada-chart-loading {
  display: flex;
}

/* Stat Cards */
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: var(--royal);
}
.stat-card.accent::before  { background: var(--gold); }
.stat-card.success::before { background: var(--success); }
.stat-card.info::before    { background: var(--info); }

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  background: var(--royal-light);
  color: var(--royal);
}
.stat-card.accent .stat-icon  { background: var(--gold-light); color: var(--gold); }
.stat-card.success .stat-icon { background: var(--success-light); color: var(--success); }
.stat-card.info .stat-icon    { background: var(--info-light); color: var(--info); }

.stat-body .stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--neutral-mid);
  display: block;
  margin-bottom: 3px;
}
.stat-body .stat-value {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--neutral-dark);
  line-height: 1.1;
  font-family: 'Plus Jakarta Sans', sans-serif;
  display: block;
}
.stat-body .stat-meta {
  font-size: 0.75rem;
  color: var(--neutral-mid);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-meta .up   { color: var(--success); }
.stat-meta .down { color: var(--royal); }

/* Responsive Stat Cards */
@media (max-width: 1024px) {
  .stat-card {
    padding: 16px 14px;
    gap: 12px;
  }
  .stat-icon {
    width: 44px;
    height: 44px;
    font-size: 1rem;
  }
  .stat-body .stat-value {
    font-size: 1.35rem;
  }
}

@media (max-width: 768px) {
  .stat-card {
    padding: 14px 12px;
    gap: 10px;
  }
  .stat-icon {
    width: 38px;
    height: 38px;
    font-size: 0.9rem;
  }
  .stat-body .stat-label {
    font-size: 0.68rem;
  }
  .stat-body .stat-value {
    font-size: 1.2rem;
  }
  .stat-body .stat-meta {
    font-size: 0.7rem;
  }
}

@media (max-width: 767.98px) {
  .row:has(> [class*="col-"] > .stat-card):has(> [class*="col-"]:nth-child(2)) {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-left: 0;
    margin-right: 0;
    padding-bottom: 6px;
  }
  .row:has(> [class*="col-"] > .stat-card):has(> [class*="col-"]:nth-child(2))::-webkit-scrollbar {
    display: none;
  }
  .row:has(> [class*="col-"] > .stat-card):has(> [class*="col-"]:nth-child(2)) > [class*="col-"] {
    flex: 0 0 min(78vw, 280px);
    width: min(78vw, 280px);
    max-width: min(78vw, 280px);
    scroll-snap-align: start;
    scroll-snap-stop: always;
    padding-left: 0;
    padding-right: 0;
  }
  .row:has(> [class*="col-"] > .stat-card):has(> [class*="col-"]:nth-child(2)) > [class*="col-"] > .stat-card {
    height: 100%;
    margin-bottom: 0;
  }
  .flash-metric-grid {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 6px;
  }
  .flash-metric-grid::-webkit-scrollbar { display: none; }
  .flash-metric-grid .flash-metric {
    flex: 0 0 min(78vw, 260px);
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }
}

@media (max-width: 576px) {
  .stat-card {
    padding: 12px 10px;
    gap: 8px;
  }
  .stat-icon {
    width: 34px;
    height: 34px;
    font-size: 0.85rem;
  }
  .stat-body .stat-label {
    font-size: 0.65rem;
  }
  .stat-body .stat-value {
    font-size: 1rem;
  }
  .stat-body .stat-meta {
    font-size: 0.68rem;
  }
}

/* ── 6. Buttons ────────────────────────────────────────────── */
.btn {
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.825rem;
  padding: 8px 16px;
  border: 1.5px solid transparent;
}

.btn-rada-primary {
  background: var(--royal);
  border-color: var(--royal);
  color: #fff;
}
.btn-rada-primary:hover {
  background: var(--royal-dark);
  border-color: var(--royal-dark);
  color: #fff;
  box-shadow: 0 4px 12px rgba(var(--royal-rgb),0.3);
}
.btn-rada-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-rada-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

.btn-rada-outline {
  background: transparent;
  border-color: var(--royal);
  color: var(--royal);
}
.btn-rada-outline:hover {
  background: var(--royal-light);
  color: var(--royal-dark);
}

.btn-rada-ghost {
  background: var(--neutral-light);
  border-color: var(--border);
  color: var(--neutral-dark);
}
.btn-rada-ghost:hover {
  background: var(--border);
  color: var(--neutral-dark);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.765rem;
  gap: 4px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  border: 1.5px solid transparent;
}
.btn-icon.btn-rada-ghost { border-color: var(--border); }
.btn-icon.btn-edit  { background: var(--info-light); color: var(--info); border-color: rgba(2,132,199,0.2); }
.btn-icon.btn-edit:hover { background: var(--info); color: #fff; }
.btn-icon.btn-delete { background: var(--royal-light); color: var(--royal); border-color: rgba(var(--royal-rgb),0.2); }
.btn-icon.btn-delete:hover { background: var(--royal); color: #fff; }
.btn-icon.btn-view  { background: var(--success-light); color: var(--success); border-color: rgba(26,158,74,0.2); }
.btn-icon.btn-view:hover { background: var(--success); color: #fff; }

/* ── 7. Forms ──────────────────────────────────────────────── */
.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--neutral-dark);
  margin-bottom: 5px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.form-control, .form-select {
  font-size: 0.845rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--neutral-dark);
  padding: 9px 13px;
  transition: var(--transition);
  background: var(--white);
}
.form-control:focus, .form-select:focus {
  border-color: var(--royal-muted);
  box-shadow: 0 0 0 3px rgba(var(--royal-rgb),0.1);
  outline: none;
}
.form-control::placeholder { color: var(--neutral-mid); font-size: 0.82rem; }

.form-control.is-invalid { border-color: var(--royal); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(var(--royal-rgb),0.1); }

.input-group .input-group-text {
  background: var(--neutral-light);
  border: 1.5px solid var(--border);
  color: var(--neutral-mid);
  font-size: 0.82rem;
  padding: 9px 12px;
}
.input-group .form-control { border-left: none; }
.input-group .input-group-text:first-child { border-right: none; }

.form-check-input:checked {
  background-color: var(--royal);
  border-color: var(--royal);
}
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(var(--royal-rgb),0.1); }

.form-text { font-size: 0.75rem; color: var(--neutral-mid); }

/* Toggle Switch */
.form-switch .form-check-input { width: 2.5em; height: 1.3em; cursor: pointer; }

/* ── 8. Tables ─────────────────────────────────────────────── */
.rada-table-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--white);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.rada-table td.row-num {
  color: var(--neutral-mid);
  font-size: 0.78rem;
  font-weight: 500;
}

.rada-table-wrap.is-loading {
  pointer-events: none;
}

.rada-table-loading {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 6;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.68);
}

.rada-table-wrap.is-loading .rada-table-loading {
  display: flex;
}

.rada-table-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--royal);
  border-radius: 50%;
  animation: rada-spin 0.7s linear infinite;
}

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

.rada-table {
  margin: 0;
  font-size: 0.83rem;
  width: 100%;
  table-layout: auto;
}

/* Line-entry grids: unit, qty, cost, and date fields keep a usable width.
   The table grows and .table-responsive scrolls instead of crushing the inputs. */
.rada-line-table {
  width: max-content;
  min-width: 100%;
}
.rada-line-table .item-picker-cell {
  min-width: 14rem;
}
.rada-line-table td:not(.item-picker-cell) > .form-control,
.rada-line-table td:not(.item-picker-cell) > .form-select {
  min-width: 10.5rem;
  width: 100%;
  max-width: none;
}
.rada-line-table input[type="date"],
.rada-line-table input[type="datetime-local"] {
  min-width: 11.5rem;
}
.rada-line-table > thead > tr > th.line-col,
.rada-line-table > tbody > tr > td.line-col,
.rada-line-table > tbody > tr > td:not(.item-picker-cell):has(> .form-control),
.rada-line-table > tbody > tr > td:not(.item-picker-cell):has(> .form-select) {
  width: 10.5rem;
  min-width: 10.5rem;
}
.rada-line-table > thead > tr > th.line-col-date,
.rada-line-table > tbody > tr > td:has(> input[type="date"]),
.rada-line-table > tbody > tr > td:has(> input[type="datetime-local"]) {
  width: 11.5rem;
  min-width: 11.5rem;
}
.rada-table thead th {
  background: var(--royal-deeper);
  color: rgba(255,255,255,0.95);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 16px;
  border: none;
  white-space: nowrap;
  font-family: 'Plus Jakarta Sans', sans-serif;
  position: relative;
  vertical-align: middle;
}
.rada-table thead th:first-child { border-radius: 0 0 0 0; }
.rada-table thead th:last-child { border-radius: 0 0 0 0; }
.rada-table thead th.sortable { 
  cursor: pointer; 
  user-select: none; 
  transition: background 0.15s ease;
}
.rada-table thead th.sortable:hover { 
  background: var(--royal-dark); 
}
.rada-table thead th.sortable:active {
  background: var(--royal);
}

/* Sort icons container */
.rada-table thead th .sort-icon { 
  margin-left: 8px; 
  opacity: 0.4; 
  font-size: 0.7rem; 
  transition: all 0.2s ease;
  display: inline-block;
}

/* Sorting states */
.rada-table thead th.sortable:hover .sort-icon {
  opacity: 0.7;
}

.rada-table thead th.sort-asc .sort-icon,
.rada-table thead th.sort-desc .sort-icon { 
  opacity: 1; 
  color: var(--gold);
  transform: scale(1.1);
}

.rada-table thead th.sort-asc .sort-icon {
  transform: rotate(0deg);
}

.rada-table thead th.sort-desc .sort-icon {
  transform: rotate(180deg);
}

/* Active sort column highlight */
.rada-table thead th.sort-asc,
.rada-table thead th.sort-desc {
  background: var(--royal-dark);
  box-shadow: inset 0 2px 0 0 var(--gold);
}

.rada-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease, transform 0.1s ease;
}
.rada-table tbody tr:nth-child(even) {
  background: rgba(241,245,249,0.4);
}
.rada-table tbody tr:last-child { 
  border-bottom: none; 
}
.rada-table tbody tr:hover { 
  background: var(--royal-light); 
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  z-index: 1;
  position: relative;
}
.rada-table tbody tr:active {
  transform: translateY(0);
  transition: transform 0.05s ease;
}
.rada-table tbody td {
  padding: 14px 16px;
  color: var(--neutral-dark);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.83rem;
  line-height: 1.4;
}

/* Column width constraints for better alignment */
.rada-table th:first-child,
.rada-table td:first-child {
  width: 50px;
  text-align: center;
}

.rada-table th.text-center,
.rada-table td.text-center {
  text-align: center;
}

.rada-table th.actions-col,
.rada-table td.actions-col {
  width: 120px;
  min-width: 120px;
}

/* Status and badge alignment */
.rada-table td .badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Number columns alignment */
.rada-table td.numeric,
.rada-table th.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Sticky table header for large datasets */
.rada-table-wrap .table-responsive {
  max-height: calc(100vh - 300px);
  overflow-y: auto;
}

.rada-table-wrap .rada-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

/* Ensure sticky header stays above row hover effects */
.rada-table tbody tr:hover {
  z-index: 1;
}

/* Compact table variant for dense data */
.rada-table.table-compact tbody td {
  padding: 10px 12px;
  font-size: 0.78rem;
}
.rada-table.table-compact thead th {
  padding: 10px 12px;
  font-size: 0.68rem;
}

/* Bordered table variant */
.rada-table.table-bordered {
  border-collapse: separate;
  border-spacing: 0;
}
.rada-table.table-bordered th,
.rada-table.table-bordered td {
  border: 1px solid var(--border);
}
.rada-table.table-bordered th {
  border-bottom-width: 2px;
}
.rada-table tbody tr.row-low-stock { 
  background: #fffbf0; 
}
.rada-table tbody tr.row-low-stock:hover { 
  background: #fff5df; 
}
.rada-table tbody tr.row-inactive { 
  opacity: 0.6; 
  background: var(--neutral-light);
}
.rada-table tbody tr.row-inactive:hover {
  background: #e2e8f0;
}

/* Table responsive wrapper - Bootstrap style */
.table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Table responsive breakpoints */
@media (max-width: 575.98px) {
  .table-responsive {
    border-radius: var(--radius);
    border: 1px solid var(--border);
  }
}

/* Table header section */
.table-header {
  padding: 16px 18px 0;
  border-bottom: none;
}

.table-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--neutral-dark);
  margin: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

/* Table toolbar - Search left, filters right layout */
.table-toolbar {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: linear-gradient(to bottom, #fff, var(--neutral-light));
}

/* Left section: Fixed width search */
.table-toolbar .toolbar-left {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.table-toolbar .toolbar-left .search-wrap {
  position: relative;
  width: 280px;
  max-width: 100%;
}

.table-toolbar .toolbar-left .search-wrap i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--neutral-mid);
  font-size: 0.8rem;
}

.table-toolbar .toolbar-left .search-wrap input {
  padding-left: 34px;
  font-size: 0.82rem;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  transition: all 0.2s ease;
  width: 100%;
}

.table-toolbar .toolbar-left .search-wrap input:focus {
  border-color: var(--royal-muted);
  box-shadow: 0 0 0 3px rgba(var(--royal-rgb),0.08);
}

/* Right section: Filters */
.table-toolbar .toolbar-right {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.table-toolbar .rada-typeahead {
  min-width: 180px;
  max-width: 240px;
  flex: 0 0 auto;
}
.table-toolbar .rada-typeahead-input {
  height: 38px;
}
.item-picker-cell .rada-typeahead {
  min-width: 0;
}
.table-toolbar .filter-select {
  height: 38px;
  font-size: 0.82rem;
  width: auto;
  min-width: 140px;
  max-width: 180px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--white);
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 0 0 auto;
}

/* Keep row action icon groups on one line */
.rada-table .actions-inline {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}
.rada-table .actions-inline form {
  display: inline-flex;
  margin: 0;
}

.sale-ref-link,
.rada-table .delivery-sale-link {
  font-weight: 700;
  color: var(--royal);
  text-decoration: none;
}
.sale-ref-link:hover,
.rada-table .delivery-sale-link:hover {
  text-decoration: underline;
}

.rada-table td.actions-col:has(.delivery-actions) {
  min-width: max-content;
  width: 1%;
  overflow: visible;
}

.rada-table .delivery-actions {
  gap: 6px;
}
.rada-table .delivery-actions .btn {
  height: 34px;
  padding: 0 10px;
  margin: 0;
}
.rada-table .delivery-actions .btn-icon {
  position: relative;
  flex: 0 0 34px;
}
.rada-table .delivery-action-count {
  position: absolute;
  top: -5px;
  right: -5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--royal);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
}
.rada-table .delivery-tip {
  display: inline-flex;
  align-items: center;
  height: 34px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  overflow: hidden;
  flex: 0 0 auto;
}
.rada-table .delivery-tip span {
  padding: 0 7px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--neutral-mid);
  background: var(--neutral-light);
  border-right: 1px solid var(--border);
}
.rada-table .delivery-tip input {
  width: 56px;
  max-width: 56px;
  height: 100%;
  border: 0;
  outline: none;
  text-align: right;
  padding: 0 7px;
  font-size: 0.78rem;
  font-weight: 700;
  background: transparent;
  -moz-appearance: textfield;
}
.rada-table .delivery-tip input::-webkit-outer-spin-button,
.rada-table .delivery-tip input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.rada-table th.actions-col,
.rada-table td.actions-col {
  white-space: nowrap;
  width: 1%;
  overflow: visible;
}
.rada-table .row-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}
.rada-table td > form:not(:has(button, a, select, textarea, input:not([type="hidden"]))) {
  display: none;
}

.table-toolbar .filter-select:hover {
  border-color: var(--royal-muted);
}

.table-toolbar .filter-select:focus {
  border-color: var(--royal-muted);
  box-shadow: 0 0 0 3px rgba(var(--royal-rgb),0.08);
}

.table-toolbar .results-count {
  font-size: 0.8rem;
  color: var(--neutral-mid);
  font-weight: 500;
  white-space: nowrap;
  padding-left: 8px;
}

/* Legacy support - remove conflicting rules */
.table-toolbar .search-wrap:not(.toolbar-left .search-wrap) { display: none; }
.table-toolbar .table-actions-right { display: none; }

/* Table footer / pagination */
.table-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to top, #fff, var(--neutral-light));
  flex-wrap: wrap;
  gap: 16px;
}
.table-footer .table-count { 
  font-size: 0.85rem; 
  color: var(--neutral-mid); 
  font-weight: 500;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

/* Tailwind Pagination Override - Clean layout */
nav[role="navigation"] {
  display: flex !important;
  align-items: center !important;
}

nav[role="navigation"] .inline-flex {
  display: inline-flex !important;
  align-items: center !important;
}

/* Pager scrolls on its own. The table card clips overflow, so a long
   page list (1–10 … last) must not grow the footer past the viewport. */
.table-footer > div {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  flex: 1 1 auto;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.table-footer > div > nav,
.table-footer > div > .pagination {
  margin-left: auto;
  flex: 0 0 auto;
  width: max-content;
  max-width: none;
}

/* Clean pagination button styling for Tailwind */
.table-footer nav .rounded-l-md,
.table-footer nav .rounded-r-md,
.table-footer nav [class*="rounded-"] {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* NEW: Custom FFC Pagination Styles */
.rada-pagination-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: max-content;
  max-width: none;
}

.rada-pagination-wrapper {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.rada-pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 36px;
  padding: 8px 12px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
  background: #fff;
  border: 1px solid #d1d5db;
  text-decoration: none;
  transition: all 0.15s ease;
  line-height: 1;
}

.rada-pagination-btn:first-child {
  border-radius: 6px 0 0 6px;
}

.rada-pagination-btn:last-child {
  border-radius: 0 6px 6px 0;
}

.rada-pagination-btn:not(:first-child) {
  margin-left: -1px;
}

.rada-pagination-page:hover {
  color: #dc2626;
  background: #f9fafb;
  z-index: 1;
  position: relative;
}

.rada-pagination-active {
  color: #fff !important;
  background: #dc2626 !important;
  border-color: #dc2626 !important;
  font-weight: 600;
  z-index: 2;
  position: relative;
}

.rada-pagination-disabled {
  color: #9ca3af;
  background: #f3f4f6;
  cursor: not-allowed;
}

.rada-pagination-dots {
  cursor: default;
  color: #6b7280;
  padding: 8px 10px;
}

/* Enhanced Pagination - Overrides Bootstrap */
.pagination {
  margin: 0 !important;
  display: flex !important;
  gap: 4px !important;
  align-items: center !important;
  flex-wrap: wrap !important;
}
.pagination .page-item {
  display: inline-block !important;
}
.page-link {
  font-size: 0.85rem !important;
  font-weight: 500 !important;
  color: var(--neutral-dark) !important;
  background: var(--white) !important;
  border: 1px solid var(--border) !important;
  padding: 8px 14px !important;
  border-radius: var(--radius-sm) !important;
  transition: all 0.2s ease !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 40px !important;
  height: 38px !important;
  font-family: 'Plus Jakarta Sans', sans-serif !important;
  text-decoration: none !important;
  position: relative !important;
  overflow: hidden !important;
  line-height: 1 !important;
}
.page-link:hover { 
  color: var(--royal) !important; 
  background: var(--royal-light) !important; 
  border-color: var(--royal) !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(var(--royal-rgb), 0.15);
  z-index: 1;
}
.page-item.active .page-link {
  background: var(--royal) !important;
  border-color: var(--royal) !important;
  color: #fff !important;
  font-weight: 600 !important;
  box-shadow: 0 4px 12px rgba(var(--royal-rgb), 0.25);
  z-index: 2;
}
.page-item.disabled .page-link {
  color: var(--neutral-mid) !important;
  background: var(--neutral-light) !important;
  border-color: var(--border) !important;
  cursor: not-allowed !important;
  opacity: 0.6;
}
.page-item.disabled .page-link:hover {
  transform: none;
  box-shadow: none;
}

/* Pagination icons - SVG from Laravel - FORCE SIZE WITH MAXIMUM SPECIFICITY */
.page-link svg,
.page-link .fa-chevron-left,
.page-link .fa-chevron-right,
.page-link [aria-hidden="true"],
.pagination .page-item .page-link svg,
.pagination > li > a svg,
.pagination > li > span svg {
  width: 14px !important;
  min-width: 14px !important;
  max-width: 14px !important;
  height: 14px !important;
  min-height: 14px !important;
  max-height: 14px !important;
  font-size: 0.75rem !important;
  flex-shrink: 0 !important;
  display: inline-block !important;
}

/* Target SVG viewBox and path directly */
.pagination svg,
.pagination svg *,
.page-link > svg,
.page-link svg[viewBox],
.rada-pagination-icon {
  width: 16px !important;
  height: 16px !important;
  min-width: 16px !important;
  min-height: 16px !important;
  max-width: 16px !important;
  max-height: 16px !important;
  display: inline-block !important;
  vertical-align: middle !important;
  overflow: hidden !important;
}

/* First/Last/Prev/Next buttons */
.page-item:first-child .page-link,
.page-item:last-child .page-link {
  padding: 8px 12px !important;
  min-width: 38px !important;
}

/* Responsive pagination */
@media (max-width: 768px) {
  .table-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .table-footer .table-count {
    text-align: center;
    order: 2;
  }
  .table-footer > div {
    width: 100%;
    flex: 1 1 auto;
  }
  .pagination {
    justify-content: flex-start;
    order: 1;
    flex-wrap: nowrap !important;
    width: max-content;
  }
  .page-link {
    padding: 6px 10px !important;
    min-width: 36px !important;
    height: 34px !important;
    font-size: 0.8rem !important;
  }
}

/* ── 9. Badges & Pills ─────────────────────────────────────── */
.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.badge-active  { background: var(--success-light); color: var(--success); }
.badge-inactive { background: var(--neutral-light); color: var(--neutral-mid); border: 1px solid var(--border); }
.badge-danger   { background: var(--royal-light); color: var(--royal); }
.badge-low-stock { background: var(--gold-light); color: #c27a10; }
.badge-manual  { background: var(--info-light); color: var(--info); }
.badge-auto    { background: var(--success-light); color: var(--success); }
.badge-cash    { background: var(--success-light); color: var(--success); }
.badge-bank    { background: var(--info-light); color: var(--info); }
.badge-card    { background: #f3e8ff; color: #7c3aed; }

/* Role badges — Bootstrap .badge defaults to white text; always set colors */
.badge[class*="role-"] {
  background: var(--neutral-light);
  color: var(--neutral-dark);
}
.role-chairman_ceo,
.role-general_manager { background: var(--royal-light); color: var(--royal); }
.role-sales_ops_manager,
.role-sales_manager { background: var(--gold-light); color: #c27a10; }
.role-kitchen_ops_manager,
.role-operations { background: #e0f2fe; color: #0369a1; }
.role-marketing_manager,
.role-revenue_growth_officer { background: #f3e8ff; color: #7c3aed; }
.role-logistics_manager { background: #ecfeff; color: #0e7490; }
.role-procurement_officer { background: #fef3c7; color: #b45309; }
.role-branch_supervisor,
.role-branch_manager { background: #ede9fe; color: #5b21b6; }
.role-data_inventory_clerk,
.role-operator { background: #e0f2fe; color: #0369a1; }
.role-sales_attendant,
.role-sales { background: var(--gold-light); color: #c27a10; }
.role-rider { background: #ecfeff; color: #0e7490; }
.role-finance { background: var(--success-light); color: var(--success); }

/* ── 10. Modals ────────────────────────────────────────────── */
.modal-content {
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}
.modal-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.modal-header .modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--neutral-dark);
  font-family: 'Plus Jakarta Sans', sans-serif;
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-header .modal-title i { color: var(--royal); }
.modal-header .btn-close { opacity: 0.5; }
.modal-header .btn-close:hover { opacity: 1; }

.modal-body { padding: 24px; }
.modal-dialog-scrollable {
  height: auto;
  max-height: calc(100dvh - 2rem);
}
.modal-dialog-scrollable .modal-content {
  display: flex;
  flex-direction: column;
  height: auto;
  max-height: calc(100dvh - 2rem);
  min-height: 0;
  overflow: hidden;
}
.modal-dialog-scrollable .modal-header,
.modal-dialog-scrollable .modal-footer {
  flex-shrink: 0;
}
.modal-dialog-scrollable .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--neutral-light);
  border-radius: 0 0 var(--radius) var(--radius);
  gap: 8px;
}

/* ── 11. Toasts ────────────────────────────────────────────── */
.toast-container-rada {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 9999;
  min-width: 320px;
}
.rada-toast {
  background: var(--white);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  overflow: hidden;
}
.rada-toast .toast-progress {
  height: 3px;
  background: var(--royal);
  animation: toastProgress 4s linear forwards;
}
.rada-toast.toast-success .toast-progress { background: var(--success); }
.rada-toast.toast-warning .toast-progress { background: var(--gold); }
.rada-toast.toast-error   .toast-progress { background: var(--royal); }

@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0%; }
}

.rada-toast .toast-header {
  border-bottom: none;
  padding: 10px 14px 6px;
}
.rada-toast .toast-body {
  padding: 4px 14px 12px;
  font-size: 0.82rem;
  color: var(--neutral-dark);
}

/* ── 12. Alerts ────────────────────────────────────────────── */
.rada-alert {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.82rem;
  border: 1.5px solid;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.rada-alert i { margin-top: 1px; flex-shrink: 0; }
.rada-alert > div { min-width: 0; flex: 1 1 auto; }
.rada-alert-info    { background: var(--info-light); border-color: rgba(2,132,199,0.25); color: #075985; }
.rada-alert-success { background: var(--success-light); border-color: rgba(26,158,74,0.25); color: #145e2d; }
.rada-alert-warning { background: var(--gold-light); border-color: rgba(244,163,64,0.35); color: #92540a; }
.rada-alert-danger  { background: var(--danger-light); border-color: rgba(220,38,38,0.25); color: var(--danger); }

@media (max-width: 991px) {
  .rada-alert.rada-alert-info {
    align-items: center;
    padding: 8px 12px;
  }
  .rada-alert.rada-alert-info > div {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .rada-alert.rada-alert-info > div::-webkit-scrollbar { display: none; }
}

/* ── 13. Charts ────────────────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
}
.chart-period-tabs {
  display: flex;
  gap: 4px;
  background: var(--neutral-light);
  padding: 3px;
  border-radius: 7px;
}
.chart-period-tab {
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 5px;
  border: none;
  background: none;
  color: var(--neutral-mid);
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.chart-period-tab.active {
  background: var(--white);
  color: var(--royal);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* ── 14. Auth Pages ────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  background: var(--white);
}
.auth-panel-left {
  flex: 0 0 42%;
  background: linear-gradient(160deg, var(--royal-deeper) 0%, var(--royal-deepest) 60%, var(--royal-ink) 100%);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-panel-left::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(var(--royal-rgb),0.25) 0%, transparent 70%);
  border-radius: 50%;
}
.auth-panel-left::after {
  content: '';
  position: absolute;
  bottom: -20%;
  left: -10%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(244,163,64,0.12) 0%, transparent 70%);
  border-radius: 50%;
}

.auth-panel-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: #fff;
}
.auth-form-box {
  width: 100%;
  max-width: 400px;
}

.auth-logo-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 8px 16px;
  border-radius: 8px;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.auth-logo-badge span {
  width: 28px;
  height: 28px;
  background: var(--royal);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

.auth-tagline {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.25;
  margin: 0;
}
.auth-tagline em {
  font-style: normal;
  color: var(--royal-muted);
}

.auth-feat-list { list-style: none; padding: 0; margin: 0; }
.auth-feat-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  margin-bottom: 10px;
}
.auth-feat-list li i { color: var(--royal-muted); font-size: 0.8rem; }

/* ── 15. Empty States ──────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-state-icon {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--neutral-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 1.8rem;
  color: var(--neutral-mid);
}
.empty-state h6 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--neutral-dark);
  margin-bottom: 6px;
}
.empty-state p { font-size: 0.82rem; color: var(--neutral-mid); margin: 0; }

/* ── 16. Dropdowns ─────────────────────────────────────────── */
.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 6px;
  font-size: 0.82rem;
}
.dropdown-item {
  border-radius: 5px;
  padding: 7px 12px;
  color: var(--neutral-dark);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}
.dropdown-item:hover {
  background: var(--royal-light);
  color: var(--royal);
}
.dropdown-item i { width: 14px; text-align: center; color: var(--neutral-mid); font-size: 0.78rem; }
.dropdown-item:hover i { color: var(--royal); }
.dropdown-divider { border-color: var(--border); margin: 4px 0; }
.dropdown-item.text-danger:hover { background: var(--royal-light); color: var(--royal); }

/* ── 17. Misc Utilities ────────────────────────────────────── */
.text-rada-primary { color: var(--royal) !important; }
.text-rada-muted   { color: var(--neutral-mid) !important; }
.bg-rada-light     { background: var(--royal-light) !important; }

/* ── Custom Scrollbars (Except Sidebar) ────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--neutral-light);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: var(--neutral-mid);
  border-radius: 3px;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--royal-deeper);
}

::-webkit-scrollbar-corner {
  background: var(--royal-deeper);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--neutral-mid) var(--neutral-light);
}

/* IE/Edge scrollbar */
* {
  -ms-overflow-style: -ms-autohiding-scrollbar;
}

/* Sidebar scrollbar override (keep original) */
.rada-sidebar::-webkit-scrollbar { 
  width: 4px; 
}
.rada-sidebar::-webkit-scrollbar-track { 
  background: transparent; 
}
.rada-sidebar::-webkit-scrollbar-thumb { 
  background: rgba(255,255,255,0.1); 
  border-radius: 2px; 
}
.rada-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

.sidebar-nav::-webkit-scrollbar { 
  width: 4px; 
}
.sidebar-nav::-webkit-scrollbar-track { 
  background: transparent; 
}
.sidebar-nav::-webkit-scrollbar-thumb { 
  background: rgba(255,255,255,0.1); 
  border-radius: 2px; 
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.skeleton {
  background: linear-gradient(90deg, var(--neutral-light) 25%, #e9eef3 50%, var(--neutral-light) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── 18. Responsive ────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .rada-topbar { left: 0; padding: 0 12px; gap: 8px; }
  .rada-topbar .topbar-right { gap: 8px; }
  .rada-content { margin-left: 0; }
  body.has-bottom-nav {
    --bottom-nav-h: calc(56px + env(safe-area-inset-bottom, 0px));
  }
  body.has-bottom-nav .rada-content {
    padding-bottom: var(--bottom-nav-h);
  }
  .rada-sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
    z-index: 1050;
  }
  .rada-sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1040;
  }
  .sidebar-overlay.show { display: block; }
  body.sidebar-collapsed .rada-sidebar { transform: translateX(0); }
  body.sidebar-collapsed .rada-topbar  { left: 0; }
  body.sidebar-collapsed .rada-content { margin-left: 0; }
}

@media (max-width: 767.98px) {
  .content-inner { padding: 20px 16px 40px; }
  .auth-panel-left { display: none; }
  .auth-panel-right { padding: 28px 20px; }
  .stat-card { padding: 14px; }
  .stat-icon { width: 42px; height: 42px; font-size: 1rem; }
  .stat-body .stat-value { font-size: 1.25rem; }
  .topbar-search { display: none; }
  .user-info-text { display: none; }
  .rada-topbar { padding: 0 8px; gap: 6px; }
  .rada-topbar .topbar-right { gap: 6px; }
  .rada-topbar .topbar-context {
    flex: 1 1 0;
    max-width: none;
    padding-left: 8px;
    padding-right: 6px;
  }
  .user-avatar-btn { padding: 2px; gap: 0; }
  .user-avatar-btn .fa-chevron-down { display: none; }
  
  /* Better table handling on mobile */
  .rada-table thead th {
    padding: 10px 12px;
    font-size: 0.68rem;
  }
  .rada-table tbody td {
    padding: 10px 12px;
    font-size: 0.78rem;
  }
  
  /* Ensure sidebar footer stays visible */
  .rada-sidebar {
    display: flex;
    flex-direction: column;
    max-height: 100vh;
  }
  .toast-container-rada { right: 12px; left: 12px; min-width: unset; top: 70px; }
}

/* Responsive toolbar adjustments */
@media (max-width: 991.98px) {
  .table-toolbar .toolbar-left .search-wrap {
    width: 240px;
  }
}

@media (max-width: 767.98px) {
  .table-toolbar {
    gap: 12px;
  }
  
  .table-toolbar .toolbar-left {
    flex: 1 1 100%;
  }
  
  .table-toolbar .toolbar-left .search-wrap {
    width: 100%;
    max-width: none;
  }
  
  .table-toolbar .toolbar-right {
    flex: 1 1 100%;
    justify-content: flex-start;
    gap: 8px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  
  .table-toolbar .filter-select {
    flex: 0 1 auto;
    width: auto;
    min-width: 120px;
    max-width: 180px;
  }
  
  .table-toolbar .results-count {
    flex: 0 0 auto;
    text-align: right;
    padding-left: 0;
    padding-top: 0;
  }
}

@media (max-width: 575.98px) {
  .table-toolbar {
    padding: 12px 14px;
  }
  
  .table-toolbar .toolbar-right {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  
  .table-toolbar .filter-select {
    width: auto;
    flex: 1 1 calc(50% - 8px);
    min-width: 120px;
    max-width: none;
  }
  
  .table-toolbar .results-count {
    flex: 1 1 100%;
    text-align: left;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 4px;
  }
}

/* ── 19. Print ─────────────────────────────────────────────── */
@media print {
  .rada-sidebar, .rada-topbar, .rada-bottom-nav, .no-print { display: none !important; }
  .rada-content { margin-left: 0; padding-top: 0; padding-bottom: 0; }
  .content-inner { padding: 0; }
}

/* ── 20. Install banner (phones) ──────────────────────────── */
/* In-flow under the topbar (not fixed). z-index 1025 reserved if this is ever pinned. */
.pwa-install-bar {
  display: none;
  align-items: center;
  gap: 12px;
  margin: 12px 16px 0;
  padding: 12px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(97, 34, 17, 0.08);
  position: relative;
  z-index: 1025;
}
.pwa-install-bar img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
}
.pwa-install-copy { flex: 1; min-width: 0; }
.pwa-install-copy strong {
  display: block;
  font-size: 0.88rem;
  color: var(--neutral-dark);
}
.pwa-install-copy span {
  display: block;
  font-size: 0.75rem;
  color: var(--neutral-mid);
  line-height: 1.35;
}
.pwa-install-bar [hidden] { display: none !important; }
.pwa-install-dismiss {
  border: 0;
  background: transparent;
  color: var(--neutral-mid);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}
.auth-form-box .pwa-install-bar { margin: 0 0 18px; }
@media (max-width: 991.98px) {
  .pwa-install-bar:not([hidden]) { display: flex; }
}

/* ── 21. Item typeahead (search-as-you-type) ──────────────── */
.rada-typeahead {
  position: relative;
  min-width: 200px;
}
.rada-typeahead-input {
  width: 100%;
  font-size: 0.82rem;
  padding-right: 32px;
}
.rada-typeahead-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--neutral-mid);
  padding: 0;
  width: 22px;
  height: 22px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 4px;
}
.rada-typeahead.has-value .rada-typeahead-clear { display: inline-flex; }
.rada-typeahead-clear:hover { background: var(--neutral-light); color: var(--neutral-dark); }
/* Menu is portaled to <body> so card/table overflow cannot clip it */
.rada-typeahead-menu {
  position: fixed;
  z-index: 2000;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  display: none;
}
.rada-typeahead-menu.is-open { display: block; }
.rada-typeahead-option {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: #fff;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.rada-typeahead-option:last-child { border-bottom: none; }
.rada-typeahead-option:hover,
.rada-typeahead-option.active {
  background: var(--royal-light);
}
.rada-typeahead-option.is-disabled,
.rada-typeahead-option:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  background: var(--neutral-light);
}
.rada-typeahead-option.is-disabled:hover,
.rada-typeahead-option.is-disabled.active,
.rada-typeahead-option:disabled:hover {
  background: var(--neutral-light);
}
.rada-typeahead-option .opt-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--neutral-dark);
}
.rada-typeahead-option .opt-meta {
  display: block;
  font-size: 0.72rem;
  color: var(--neutral-mid);
  margin-top: 2px;
}
.rada-typeahead-option .opt-meta:empty { display: none; }
.rada-typeahead-empty,
.rada-typeahead-loading {
  padding: 12px;
  font-size: 0.8rem;
  color: var(--neutral-mid);
  text-align: center;
}
.rada-typeahead-create {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: #fff;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--royal);
}
.rada-typeahead-create:hover {
  background: var(--royal-light);
}
.rada-typeahead-create-form {
  padding: 12px;
}
.rada-typeahead-create-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--neutral-dark);
  margin-bottom: 8px;
}
.rada-typeahead-create-form .form-label {
  font-size: 0.72rem;
  margin-bottom: 4px;
}
.rada-typeahead-create-form .form-control {
  margin-bottom: 8px;
}

/* Sale details / payment history */
.sale-overview .rada-card-body {
  padding: 20px 22px;
}
.sale-overview-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px 28px;
}
.sale-overview-main {
  flex: 1 1 260px;
  min-width: 0;
}
.sale-overview-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.sale-overview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.8rem;
  color: var(--neutral-mid);
}
.sale-overview-meta i {
  width: 14px;
  margin-right: 6px;
  color: var(--neutral-mid);
}
.sale-overview-note {
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--neutral-dark);
}
.sale-overview-money {
  display: grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  gap: 10px;
  flex: 1 1 300px;
  max-width: 440px;
}
.sale-money {
  background: var(--neutral-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.sale-money-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--neutral-mid);
  margin-bottom: 4px;
}
.sale-money-value {
  display: block;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--neutral-dark);
}
.sale-money.is-paid .sale-money-value { color: var(--success); }
.sale-money.is-due .sale-money-value { color: var(--royal); }
.sale-money.is-clear .sale-money-value { color: var(--neutral-mid); }
.sale-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--neutral-dark);
}
.sale-section-title i { color: var(--royal); font-size: 0.85rem; }
.rada-table-wrap:has(.sale-section-title) .table-header {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.rada-table tfoot .sale-table-total td {
  border-top: 2px solid var(--border);
  font-weight: 700;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.rada-table tfoot .sale-table-paid { color: var(--success); }
@media (max-width: 576px) {
  .sale-overview-money { max-width: none; }
  .sale-money-value { font-size: 0.92rem; }
}

.delivery-notes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 280px;
  overflow: auto;
  padding-right: 2px;
}
.delivery-note {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--neutral-light);
  padding: 10px 12px;
}
.delivery-note-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.delivery-note-reason,
.delivery-note-when {
  color: var(--neutral-mid);
  font-size: 0.75rem;
  font-weight: 600;
}
.delivery-note-when { margin-left: auto; font-weight: 500; }
.delivery-note-body {
  margin: 0;
  font-size: 0.86rem;
  color: var(--neutral-dark);
  white-space: pre-wrap;
}
.delivery-note-who {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--neutral-mid);
}

/* ── 22. Mobile bottom nav ───────────────────────────────────
   Z-index scale (existing → this bar):
     sticky table thead 10 · topbar 1020 · PWA install 1025
     bottom nav 1035          ← above page / sticky toolbars / PWA
     sidebar overlay 1040 · POS mobile bar 1040
     mobile sidebar 1050 · modal backdrop 1050
     confirm/alert modal 1055 · drawers 1060+ · toasts 9999
   Bottom nav stays below every blocking overlay.
──────────────────────────────────────────────────────────── */
.rada-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1035;
  height: calc(56px + env(safe-area-inset-bottom, 0px));
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
  background: var(--white);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
  align-items: stretch;
  justify-content: space-around;
  gap: 2px;
}
.rada-bottom-nav-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: var(--neutral-mid);
  text-decoration: none;
  font-family: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.1;
  padding: 4px 2px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.rada-bottom-nav-item i {
  font-size: 1.05rem;
  line-height: 1;
}
.rada-bottom-nav-item span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rada-bottom-nav-item:hover,
.rada-bottom-nav-item:focus-visible {
  color: var(--royal);
  background: var(--royal-light);
}
.rada-bottom-nav-item.active,
.rada-bottom-nav-item.is-open {
  color: var(--royal);
}
.rada-bottom-nav-item.active i,
.rada-bottom-nav-item.is-open i {
  color: var(--royal);
}

@media (max-width: 991.98px) {
  .rada-bottom-nav { display: flex; }
}

@media (min-width: 992px) {
  .rada-bottom-nav { display: none !important; }
}

/* Academic calendar */
.rada-calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
}
.rada-cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--neutral-dark);
}
.rada-cal-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.rada-cal-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.rada-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.rada-cal-head {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--neutral-mid);
  text-align: center;
  padding: 4px 0 8px;
}
.rada-cal-day {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  min-height: 92px;
  padding: 8px;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  cursor: pointer;
  color: var(--neutral-dark);
  font: inherit;
}
.rada-cal-day.is-outside {
  background: var(--neutral-light);
  color: var(--neutral-mid);
}
.rada-cal-day.is-today {
  box-shadow: inset 0 0 0 2px var(--gold);
}
.rada-cal-day.is-selected {
  border-color: var(--royal);
  box-shadow: 0 0 0 1px var(--royal);
}
.rada-cal-day.is-today.is-selected {
  box-shadow: inset 0 0 0 2px var(--gold), 0 0 0 1px var(--royal);
}
.rada-cal-day:focus-visible {
  outline: 2px solid var(--royal);
  outline-offset: 2px;
}
.rada-cal-num {
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
}
.rada-cal-chip {
  display: inline-flex;
  max-width: 100%;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.3;
  border-radius: 999px;
  padding: 2px 6px;
}
.rada-cal-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rada-cal-chip.teaching,
.rada-cal-swatch.teaching { background: var(--royal-light); color: var(--royal); }
.rada-cal-swatch.teaching { background: var(--royal); }
.rada-cal-chip.revision,
.rada-cal-swatch.revision { background: var(--gold-light); color: var(--gold); }
.rada-cal-swatch.revision { background: var(--gold); }
.rada-cal-chip.mock_exam,
.rada-cal-swatch.mock_exam { background: var(--info-light); color: var(--info); }
.rada-cal-swatch.mock_exam { background: var(--info); }
.rada-cal-chip.term_exam,
.rada-cal-swatch.term_exam { background: var(--danger-light); color: var(--danger); }
.rada-cal-swatch.term_exam { background: var(--danger); }
.rada-cal-chip.break,
.rada-cal-swatch.break { background: var(--neutral-light); color: var(--neutral-mid); }
.rada-cal-swatch.break { background: var(--neutral-mid); }
.rada-cal-chip.holiday,
.rada-cal-swatch.holiday { background: var(--gold-light); color: var(--gold); }
.rada-cal-swatch.holiday { background: var(--gold); }
.rada-cal-chip.event,
.rada-cal-swatch.event { background: var(--info-light); color: var(--info); }
.rada-cal-swatch.event { background: var(--info); }
.rada-cal-chip.deadline,
.rada-cal-swatch.deadline { background: var(--warning-light); color: var(--warning); }
.rada-cal-swatch.deadline { background: var(--warning); }
.rada-cal-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 16px;
  min-height: 180px;
}
.rada-cal-panel-date {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  margin-bottom: 8px;
}
.rada-cal-panel-line {
  font-size: 0.88rem;
  margin-bottom: 6px;
}
.rada-cal-panel-list {
  list-style: none;
  margin: 10px 0 14px;
  padding: 0;
  font-size: 0.84rem;
}
.rada-cal-panel-list li + li { margin-top: 4px; }

@media (max-width: 640px) {
  .rada-calendar-layout { grid-template-columns: 1fr; }
  .rada-cal-day {
    min-height: 52px;
    padding: 4px;
    align-items: center;
  }
  .rada-cal-chip {
    width: 8px;
    height: 8px;
    padding: 0;
    border-radius: 50%;
    font-size: 0;
  }
  .rada-cal-chip-label { display: none; }
}

.rada-scale-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-weight: 600;
  color: var(--royal-dark);
}
.rada-mark-sheet input[type="number"] {
  width: 5.5rem;
  min-width: 0;
  padding-left: 8px;
  padding-right: 4px;
}

.rada-timetable-scroll { overflow-x: auto; }
.rada-timetable {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
}
.rada-timetable th,
.rada-timetable td {
  border: 1px solid rgba(var(--royal-rgb), 0.12);
  padding: 8px;
  vertical-align: top;
  background: #fff;
}
.rada-timetable thead th {
  background: var(--royal);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
}
.rada-timetable th.rada-timetable-period {
  width: 96px;
  background: var(--gold-light);
  color: var(--royal-dark);
  text-align: left;
  font-size: 0.78rem;
}
.rada-timetable th.rada-timetable-period span {
  display: block;
  font-weight: 500;
  font-size: 0.7rem;
}
.rada-timetable td.is-clash { background: var(--danger-light); }
.rada-timetable td.is-selected { outline: 2px solid var(--gold); outline-offset: -2px; }
.rada-timetable-cell {
  display: block;
  min-height: 72px;
  color: inherit;
  text-decoration: none;
}
.rada-timetable-cell:hover { color: inherit; }
.rada-timetable-lesson + .rada-timetable-lesson {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(var(--royal-rgb), 0.12);
}
.rada-timetable-subject {
  font-weight: 700;
  color: var(--royal-dark);
  font-size: 0.84rem;
}
.rada-timetable-meta {
  font-size: 0.75rem;
  color: var(--neutral-mid, #6b6570);
}
.rada-timetable-clash {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--danger);
}
