﻿/* ============================================================
   MindLab Health Admin Panel — Main Stylesheet
   Design tokens, sidebar, typography, component utilities
   ============================================================ */

/* ── CSS Custom Properties (ml-* tokens) ─────────────────── */
:root {
  --ml-sidebar:          #2E7D32;
  --ml-sidebar-active:   #1B5E20;
  --ml-primary:          #2E7D32;
  --ml-primary-dark:     #1B5E20;
  --ml-primary-light:    #66BB6A;
  --ml-accent:           #FF6F00;
  --ml-accent-light:     #FFA000;
  --ml-bg:               #F5F5F5;
  --ml-surface:          #FFFFFF;
  --ml-surface-2:        #F9FAFB;
  --ml-border:           #E5E7EB;
  --ml-text:             #212121;
  --ml-text-primary:     #111827;
  --ml-text-secondary:   #757575;
  --ml-text-muted:       #9CA3AF;
  --ml-divider:          #BDBDBD;
  --ml-success:          #4CAF50;
  --ml-warning:          #FFC107;
  --ml-error:            #F44336;
  --ml-info:             #2196F3;

  /* Spacing & radius */
  --ml-radius-sm:  4px;
  --ml-radius:     8px;
  --ml-radius-lg:  12px;
  --ml-radius-xl:  16px;

  /* Shadows */
  --ml-shadow-sm:  0 1px 2px 0 rgb(0 0 0 / 0.05);
  --ml-shadow:     0 1px 3px 0 rgb(0 0 0 / 0.10), 0 1px 2px -1px rgb(0 0 0 / 0.10);
  --ml-shadow-md:  0 4px 6px -1px rgb(0 0 0 / 0.10), 0 2px 4px -2px rgb(0 0 0 / 0.10);
  --ml-shadow-lg:  0 10px 15px -3px rgb(0 0 0 / 0.10), 0 4px 6px -4px rgb(0 0 0 / 0.10);

  /* Sidebar dimensions — 15rem matches w-60 at 13px base font */
  --ml-sidebar-width:    15rem;
  --ml-header-height:    64px;
}

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

html { font-size: 13px; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--ml-bg);
  color: var(--ml-text-primary);
  font-size: 0.9231rem; /* 12px at 13px base */
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

/* ── App Shell Layout ─────────────────────────────────────── */
.ml-app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
/* Ensure sidebar mount always shows green — no Tailwind dependency */
#ml-sidebar-mount {
  background-color: var(--ml-sidebar);
  width: var(--ml-sidebar-width);
  overflow: hidden;   /* allow inner .ml-nav flex:1 to scroll */
  flex-direction: column;
}
/* Show only on non-auth pages — auth pages mark mount as hidden */
#ml-sidebar-mount:not(.hidden) {
  display: flex;
}

.ml-sidebar {
  width: var(--ml-sidebar-width);
  background-color: var(--ml-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

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

.ml-sidebar-logo {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.ml-sidebar-logo .ml-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ml-sidebar-logo h1 {
  color: #FFFFFF;
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
}

.ml-sidebar-logo p {
  color: rgba(255,255,255,0.6);
  font-size: 0.6rem;
  margin: 2px 0 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

/* ── Navigation ───────────────────────────────────────────── */
.ml-nav {
  padding: 12px 0;
  flex: 1;
  min-height: 0;      /* required for overflow-y:auto to work inside flex container */
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

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

/* Level 1 — category header */
.ml-nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 8px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease;
  border-radius: 0;
}

.ml-nav-section-header:hover { background-color: rgba(255,255,255,0.06); }

.ml-nav-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.7);
  font-size: 0.7rem;     /* ~9px at 13px base */
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.ml-nav-section-title i { font-size: 0.875rem; color: rgba(255,255,255,0.6); width: 16px; text-align: center; }

.ml-nav-chevron {
  color: rgba(255,255,255,0.4);
  font-size: 0.625rem;
  transition: transform 0.2s ease;
}

.ml-nav-section.open .ml-nav-chevron { transform: rotate(180deg); }

/* Level 2 — nav links */
.ml-nav-items { display: none; padding-bottom: 4px; }
.ml-nav-section.open .ml-nav-items { display: block; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 20px 7px 36px;
  color: rgba(255,255,255,0.65);
  font-size: 0.846rem;   /* ~11px at 13px base */
  font-weight: 400;
  text-decoration: none;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
  position: relative;
}

.nav-link:hover {
  color: #FFFFFF;
  background-color: rgba(255,255,255,0.08);
}

.nav-link i { font-size: 0.875rem; width: 16px; text-align: center; flex-shrink: 0; }

/* Active state */
.sidebar-active,
.nav-link.sidebar-active {
  background-color: var(--ml-sidebar-active) !important;
  border-left: 3px solid var(--ml-accent) !important;
  color: #FFFFFF !important;
  font-weight: 500 !important;
}

.sidebar-active i, .nav-link.sidebar-active i { color: rgba(255,255,255,0.9) !important; }

/* Level 3 — sub-items */
.ml-nav-subitems { display: none; }
.nav-link.open + .ml-nav-subitems { display: block; }

.ml-nav-sublink {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 20px 6px 52px;
  color: rgba(255,255,255,0.55);
  font-size: 0.769rem;   /* ~10px at 13px base */
  text-decoration: none;
  transition: all 0.15s ease;
}

.ml-nav-sublink:hover { color: rgba(255,255,255,0.9); background-color: rgba(255,255,255,0.05); }
.ml-nav-sublink.sidebar-active { color: #FFFFFF; background-color: rgba(255,255,255,0.1); }

/* ── Main Content Area ────────────────────────────────────── */
.ml-main {
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top Header ───────────────────────────────────────────── */
.ml-header {
  height: var(--ml-header-height);
  background-color: var(--ml-surface);
  border-bottom: 1px solid var(--ml-border);
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.ml-header-title {
  font-size: 0.923rem;   /* ~12px at 13px base */
  font-weight: 500;
  color: var(--ml-text-primary);
}

.ml-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Page Content ─────────────────────────────────────────── */
.ml-content {
  padding: 24px;
  flex: 1;
}

/* ── Cards ────────────────────────────────────────────────── */
.ml-card {
  background-color: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius-lg);
  box-shadow: var(--ml-shadow-sm);
  overflow: hidden;
}

.ml-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--ml-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ml-card-title {
  font-size: 0.846rem;   /* ~11px at 13px base */
  font-weight: 500;
  color: var(--ml-text-primary);
}

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

/* ── KPI Stat Cards ───────────────────────────────────────── */
.ml-stat {
  background: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius-lg);
  padding: 20px;
  box-shadow: var(--ml-shadow-sm);
}

.ml-stat-value {
  font-size: 1.538rem;   /* ~20px at 13px base */
  font-weight: 500;
  color: var(--ml-text-primary);
  line-height: 1.1;
}

.ml-stat-label {
  font-size: 0.692rem;   /* ~9px at 13px base */
  color: var(--ml-text-secondary);
  margin-top: 4px;
}

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

/* ── Buttons ──────────────────────────────────────────────── */
.ml-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--ml-radius);
  font-size: 0.769rem;   /* ~10px at 13px base */
  font-weight: 400;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  text-decoration: none;
  line-height: 1;
}

.ml-btn-primary {
  background-color: var(--ml-primary);
  color: #FFFFFF;
  border-color: var(--ml-primary);
}
.ml-btn-primary:hover { background-color: var(--ml-primary-dark); border-color: var(--ml-primary-dark); }

.ml-btn-secondary {
  background-color: transparent;
  color: var(--ml-primary);
  border-color: var(--ml-primary);
}
.ml-btn-secondary:hover { background-color: rgba(46,125,50,0.06); }

.ml-btn-ghost {
  background-color: transparent;
  color: var(--ml-text-secondary);
  border-color: var(--ml-border);
}
.ml-btn-ghost:hover { background-color: var(--ml-surface-2); color: var(--ml-text-primary); }

.ml-btn-danger {
  background-color: var(--ml-error);
  color: #FFFFFF;
  border-color: var(--ml-error);
}
.ml-btn-danger:hover { background-color: #D32F2F; }

.ml-btn-sm { padding: 5px 10px; font-size: 0.692rem; }
.ml-btn-lg { padding: 9px 20px;  font-size: 0.846rem; }

/* ── Badges / Chips ───────────────────────────────────────── */
.ml-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.615rem;   /* ~8px at 13px base */
  font-weight: 400;
  line-height: 1;
}

.ml-badge-success { background-color: #E8F5E9; color: #2E7D32; }
.ml-badge-warning { background-color: #FFF8E1; color: #F57F17; }
.ml-badge-error   { background-color: #FFEBEE; color: #C62828; }
.ml-badge-info    { background-color: #E3F2FD; color: #1565C0; }
.ml-badge-neutral { background-color: #F5F5F5; color: #616161; }
.ml-badge-primary { background-color: #E8F5E9; color: #1B5E20; }

/* ── Tables ───────────────────────────────────────────────── */
.ml-table-wrapper {
  overflow-x: auto;
  border-radius: var(--ml-radius-lg);
  border: 1px solid var(--ml-border);
}

.ml-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.769rem;   /* ~10px at 13px base */
}

.ml-table thead tr {
  background-color: var(--ml-surface-2);
  border-bottom: 1px solid var(--ml-border);
}

.ml-table th {
  padding: 9px 14px;
  text-align: left;
  font-size: 0.615rem;   /* ~8px at 13px base */
  font-weight: 500;
  color: var(--ml-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.ml-table td {
  padding: 9px 14px;
  color: var(--ml-text-primary);
  border-bottom: 1px solid var(--ml-border);
}

.ml-table tbody tr:last-child td { border-bottom: none; }
.ml-table tbody tr:hover { background-color: var(--ml-surface-2); }

/* ── Forms ────────────────────────────────────────────────── */
.ml-form-group { margin-bottom: 20px; }

.ml-label {
  display: block;
  font-size: 0.692rem;   /* ~9px at 13px base */
  font-weight: 400;
  color: var(--ml-text-primary);
  margin-bottom: 5px;
}

.ml-input,
.ml-select,
.ml-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
  font-family: inherit;
  font-size: 0.769rem;   /* ~10px at 13px base */
  color: var(--ml-text-primary);
  background-color: var(--ml-surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}

.ml-input:focus,
.ml-select:focus,
.ml-textarea:focus {
  border-color: var(--ml-primary);
  box-shadow: 0 0 0 3px rgba(46,125,50,0.12);
}

.ml-input::placeholder,
.ml-textarea::placeholder { color: var(--ml-text-muted); }

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

/* ── Search Bar ───────────────────────────────────────────── */
.ml-search {
  position: relative;
  display: flex;
  align-items: center;
}

.ml-search i {
  position: absolute;
  left: 12px;
  color: var(--ml-text-muted);
  font-size: 0.875rem;
  pointer-events: none;
}

.ml-search input {
  padding-left: 32px;
  border-radius: 9999px;
  font-size: 0.769rem;   /* ~10px at 13px base */
  border: 1px solid var(--ml-border);
  background: var(--ml-surface-2);
  color: var(--ml-text-primary);
  outline: none;
  width: 220px;
  height: 32px;
  transition: all 0.15s ease;
}

.ml-search input:focus {
  border-color: var(--ml-primary);
  box-shadow: 0 0 0 2px rgba(46,125,50,0.12);
  background: var(--ml-surface);
  width: 260px;
}

/* ── Avatars ──────────────────────────────────────────────── */
.ml-avatar {
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
  background-color: var(--ml-primary-light);
  color: var(--ml-sidebar);
}

.ml-avatar-sm  { width: 28px; height: 28px; font-size: 0.6875rem; }
.ml-avatar-md  { width: 36px; height: 36px; font-size: 0.875rem; }
.ml-avatar-lg  { width: 48px; height: 48px; font-size: 1.125rem; }
.ml-avatar-xl  { width: 64px; height: 64px; font-size: 1.5rem; }

/* ── Utility: Divider ─────────────────────────────────────── */
.ml-divider {
  border: none;
  border-top: 1px solid var(--ml-border);
  margin: 20px 0;
}

/* ── Utility: Section Header ──────────────────────────────── */
.ml-section-title {
  font-size: 0.615rem;   /* ~8px at 13px base */
  font-weight: 400;
  color: var(--ml-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

/* ── Alert / Toast ────────────────────────────────────────── */
.ml-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--ml-radius);
  font-size: 0.769rem;   /* ~10px at 13px base */
  border-left: 3px solid;
  margin-bottom: 12px;
}

.ml-alert-success { background: #F1F8F1; border-color: var(--ml-success); color: #1B5E20; }
.ml-alert-warning { background: #FFFBF0; border-color: var(--ml-warning); color: #7B5800; }
.ml-alert-error   { background: #FFF5F5; border-color: var(--ml-error);   color: #B71C1C; }
.ml-alert-info    { background: #EBF5FF; border-color: var(--ml-info);    color: #0D47A1; }

/* ── Dropdown / Menu ──────────────────────────────────────── */
.ml-dropdown {
  position: relative;
  display: inline-block;
}

.ml-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
  box-shadow: var(--ml-shadow-lg);
  z-index: 50;
  overflow: hidden;
  display: none;
}

.ml-dropdown.open .ml-dropdown-menu { display: block; }

.ml-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 0.769rem;   /* ~10px at 13px base */
  color: var(--ml-text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.1s;
}

.ml-dropdown-item:hover { background-color: var(--ml-surface-2); }
.ml-dropdown-item.danger { color: var(--ml-error); }
.ml-dropdown-item.danger:hover { background-color: #FFF5F5; }

/* ── Pagination ───────────────────────────────────────────── */
.ml-pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ml-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--ml-radius);
  border: 1px solid var(--ml-border);
  background: var(--ml-surface);
  color: var(--ml-text-secondary);
  font-size: 0.692rem;   /* ~9px at 13px base */
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.ml-page-btn:hover { background: var(--ml-surface-2); color: var(--ml-text-primary); }
.ml-page-btn.active { background: var(--ml-primary); color: #FFFFFF; border-color: var(--ml-primary); }
.ml-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Tabs ─────────────────────────────────────────────────── */
.ml-tabs {
  display: flex;
  border-bottom: 2px solid var(--ml-border);
  gap: 0;
  margin-bottom: 24px;
}

.ml-tab {
  padding: 8px 16px;
  font-size: 0.769rem;   /* ~10px at 13px base */
  font-weight: 500;
  color: var(--ml-text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s ease;
  text-decoration: none;
}

.ml-tab:hover { color: var(--ml-primary); }
.ml-tab.active { color: var(--ml-primary); border-bottom-color: var(--ml-primary); font-weight: 500; }

/* ── Sidebar footer ───────────────────────────────────────── */
.ml-sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.ml-user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--ml-radius);
  cursor: pointer;
  transition: background-color 0.15s;
}

.ml-user-pill:hover { background-color: rgba(255,255,255,0.08); }

.ml-user-pill-name {
  color: #FFFFFF;
  font-size: 0.769rem;   /* ~10px at 13px base */
  font-weight: 400;
  line-height: 1.2;
}

.ml-user-pill-role {
  color: rgba(255,255,255,0.55);
  font-size: 0.615rem;   /* ~8px at 13px base */
}

/* ── Notification dot ─────────────────────────────────────── */
.ml-notif-dot {
  position: relative;
  display: inline-block;
}

.ml-notif-dot::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 7px;
  height: 7px;
  background: var(--ml-error);
  border-radius: 50%;
  border: 1.5px solid var(--ml-surface);
}

/* ── Empty state ──────────────────────────────────────────── */
.ml-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--ml-text-secondary);
}

.ml-empty i { font-size: 1.75rem; margin-bottom: 10px; color: var(--ml-text-muted); }
.ml-empty h3 { font-size: 0.846rem; font-weight: 500; color: var(--ml-text-primary); margin: 0 0 4px; }
.ml-empty p  { font-size: 0.769rem; margin: 0 0 16px; max-width: 300px; }

/* ── Loading skeleton ─────────────────────────────────────── */
.ml-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: ml-shimmer 1.5s infinite;
  border-radius: var(--ml-radius-sm);
}

@keyframes ml-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ── Responsive sidebar toggle ────────────────────────────── */

/* Overlay backdrop — always in DOM, hidden by default */
.ml-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 39;
  cursor: pointer;
}
.ml-sidebar-overlay.open { display: block; }

@media (max-width: 1024px) {
  /* Sidebar becomes a fixed overlay that slides in from the left */
  #ml-sidebar-mount,
  aside.w-60 {
    position: fixed !important;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
  }
  #ml-sidebar-mount.ml-open,
  aside.w-60.ml-open {
    transform: translateX(0);
  }

  /* Main content takes full width when sidebar is overlaid */
  .ml-main { margin-left: 0; }

  /* Content padding tighter on mobile */
  .ml-content { padding: 16px; }

  /* Stat cards: single column on mobile */
  .ml-stat-grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  /* Narrow mobile: single column everything */
  .ml-stat-grid-4 { grid-template-columns: 1fr; }

  /* Header search hidden on very small screens */
  .ml-header-search { display: none; }

  /* Tighter header on mobile */
  header.bg-white { min-height: 48px; padding-left: 12px; padding-right: 12px; }
}

/* ── Header responsive scaling ────────────────────────────── */
/* Ensure injected header adapts cleanly across breakpoints   */
header .ml-header-search { flex: 1; min-width: 0; }

@media (max-width: 1024px) {
  /* Show hamburger, hide search on tablet */
  header .ml-header-search { display: none; }
}

@media (min-width: 1025px) {
  /* Desktop: hamburger hidden, search visible */
  #ml-mobile-menu-btn { display: none !important; }
}

/* ── Minimalistic Typography — global overrides ───────────── */
/* Cap Tailwind font-weight utilities so no text appears heavy */
.font-black,
.font-extrabold,
.font-bold      { font-weight: 500 !important; }
.font-semibold  { font-weight: 500 !important; }

/* Headings stay readable but not heavy */
h1, h2, h3, h4, h5, h6 { font-weight: 500; }

/* Inline bold/strong should not be heavy */
strong, b { font-weight: 500; }

/* Tailwind text size helpers keep normal weight */
.text-xs, .text-sm, .text-base, .text-lg, .text-xl,
.text-2xl, .text-3xl, .text-4xl { font-weight: inherit; }

/* Remove star / sparkle icons globally (display:none as safety net) */
i.fa-star, i[class*="fa-star"],
i.fa-sparkles, i[class*="fa-sparkles"] { display: none !important; }

/* Hide decorative trend arrows that render as broken X boxes */
i.fa-arrow-trend-up,
i.fa-arrow-trend-down,
i[class*="fa-arrow-trend-up"],
i[class*="fa-arrow-trend-down"] { display: none !important; }

/* Hide decorative file/audit indicator icons in stat chips */
i.fa-file-pen,
i[class*="fa-file-pen"] { display: none !important; }

/* ── Minimalistic Font Size Scale ─────────────────────────────────── */
/* html base is 13px. text-xs→~10px, text-sm→~11px naturally.        */
/* Only cap the large utilities (text-3xl+) and oversized px values.  */

/* Cap large Tailwind text utilities */
.text-3xl  { font-size: 1.385rem !important; } /* 18px  (natural: 24px) */
.text-4xl  { font-size: 1.538rem !important; } /* 20px  (natural: 29px) */
.text-5xl  { font-size: 1.846rem !important; } /* 24px  (natural: 39px) */
.text-6xl  { font-size: 2.154rem !important; } /* 28px  (natural: 49px) */
.text-7xl  { font-size: 2.308rem !important; } /* 30px  (natural: 59px) */
.text-8xl  { font-size: 2.462rem !important; } /* 32px  (natural: 78px) */
.text-9xl  { font-size: 2.769rem !important; } /* 36px  (natural:104px) */

/* Arbitrary px size overrides — cap oversized values */
.text-\[14px\]  { font-size: 11px !important; }
.text-\[16px\]  { font-size: 12px !important; }
.text-\[18px\]  { font-size: 13px !important; }
.text-\[20px\]  { font-size: 13px !important; }
.text-\[22px\]  { font-size: 14px !important; }
.text-\[24px\]  { font-size: 14px !important; }
.text-\[28px\]  { font-size: 16px !important; }
.text-\[54px\]  { font-size: 22px !important; }
.text-\[100px\] { font-size: 36px !important; }
.text-\[120px\] { font-size: 40px !important; }
.text-\[200px\] { font-size: 52px !important; }
.text-\[300px\] { font-size: 60px !important; }

/* Arbitrary rem overrides */
.text-\[3\.5rem\]    { font-size: 1.846rem !important; } /* 24px */
.text-\[0\.6875rem\] { font-size: 0.692rem !important; } /* ~9px */
/* ── Responsive Utilities ─────────────────────────────────── */

/* Tables: always scrollable on small screens */
.overflow-x-auto,
table { -webkit-overflow-scrolling: touch; }

@media (max-width: 1024px) {
  /* Full-width sidebar mount on mobile */
  #ml-sidebar-mount {
    width: var(--ml-sidebar-width) !important;
  }

  /* Ensure main page content fills viewport when sidebar overlays */
  .flex-1.flex.flex-col.overflow-hidden {
    min-width: 0;
  }

  /* Tighten page-level padding on tablet */
  .p-6 { padding: 1rem !important; }
  .p-8 { padding: 1.25rem !important; }
  .px-6 { padding-left: 1rem !important; padding-right: 1rem !important; }
  .px-8 { padding-left: 1.25rem !important; padding-right: 1.25rem !important; }
}

@media (max-width: 640px) {
  /* Stack common multi-column grids on phone */
  .grid-cols-2:not([class*="sm:grid-cols"]):not([class*="md:grid-cols"]) {
    grid-template-columns: 1fr !important;
  }
  .grid-cols-3:not([class*="sm:grid-cols"]):not([class*="md:grid-cols"]) {
    grid-template-columns: 1fr !important;
  }
  .grid-cols-4:not([class*="sm:grid-cols"]):not([class*="md:grid-cols"]) {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Very tight padding on phone */
  .p-6 { padding: 0.75rem !important; }
  .px-6 { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }

  /* Cards: remove side margins that cause overflow */
  .ml-card { border-radius: 0.5rem; }

  /* Buttons: allow wrapping in tight spaces */
  .flex.gap-2, .flex.gap-3 { flex-wrap: wrap; }
}

/* ── Hardcoded-Width Mobile Overrides ────────────────────────
   Overrides Tailwind arbitrary width/min-width classes that
   would cause horizontal overflow on tablet & mobile.
   ──────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  /* Very wide fixed containers → full width */
  .w-\[1400px\], .w-\[1600px\], .w-\[1200px\], .w-\[900px\], .w-\[800px\] {
    width: 100% !important;
  }
  /* Wide min-widths — let content shrink naturally */
  .min-w-\[1000px\], .min-w-\[800px\], .min-w-\[720px\] {
    min-width: 0 !important;
  }
}

@media (max-width: 640px) {
  /* Medium fixed widths → full width on phone */
  .w-\[560px\], .w-\[480px\], .w-\[450px\], .w-\[440px\], .w-\[400px\] {
    width: 100% !important;
  }
  /* Medium min-widths → shrinkable on phone */
  .min-w-\[640px\], .min-w-\[560px\], .min-w-\[480px\], .min-w-\[460px\] {
    min-width: 0 !important;
  }
  /* Allow any arbitrary min-width tables to scroll inside their wrapper */
  .overflow-x-auto [class*="min-w-["] {
    min-width: max-content;
  }
}

/* ── Tailwind Custom Color Fallbacks ─────────────────────────
   These ensure bg-ml-*, text-ml-*, border-ml-* Tailwind utility
   classes work even when the CDN does not generate them.
   ──────────────────────────────────────────────────────────── */
.bg-ml-primary          { background-color: #2E7D32; }
.bg-ml-primary-dark     { background-color: #1B5E20; }
.bg-ml-primary-light    { background-color: #66BB6A; }
.bg-ml-accent           { background-color: #FF6F00; }
.bg-ml-accent-light     { background-color: #FFA000; }
.bg-ml-bg               { background-color: #F5F5F5; }
.bg-ml-surface          { background-color: #FFFFFF; }
.bg-ml-surface-2        { background-color: #F9FAFB; }
.bg-ml-sidebar          { background-color: #2E7D32; }
.bg-ml-sidebar-active   { background-color: #1B5E20; }

.text-ml-primary        { color: #2E7D32; }
.text-ml-primary-dark   { color: #1B5E20; }
.text-ml-accent         { color: #FF6F00; }
.text-ml-text           { color: #212121; }
.text-ml-text-primary   { color: #111827; }

.border-ml-primary      { border-color: #2E7D32; }
.border-ml-accent       { border-color: #FF6F00; }

.hover\:bg-ml-primary:hover       { background-color: #2E7D32; }
.hover\:bg-ml-primary-dark:hover  { background-color: #1B5E20; }
.hover\:text-ml-primary:hover     { color: #2E7D32; }

/* ── ml-primary opacity variants (Tailwind slash syntax unsupported for custom colors) ── */
.bg-ml-primary-5   { background-color: rgba(46,125,50,0.05); }
.bg-ml-primary-8   { background-color: rgba(46,125,50,0.08); }
.bg-ml-primary-10  { background-color: rgba(46,125,50,0.10); }
.bg-ml-primary-15  { background-color: rgba(46,125,50,0.15); }
.bg-ml-primary-20  { background-color: rgba(46,125,50,0.20); }
.bg-ml-primary-25  { background-color: rgba(46,125,50,0.25); }
.bg-ml-primary-30  { background-color: rgba(46,125,50,0.30); }
.bg-ml-primary-40  { background-color: rgba(46,125,50,0.40); }
.bg-ml-primary-50  { background-color: rgba(46,125,50,0.50); }
.bg-ml-primary-60  { background-color: rgba(46,125,50,0.60); }
.bg-ml-primary-70  { background-color: rgba(46,125,50,0.70); }
.bg-ml-primary-80  { background-color: rgba(46,125,50,0.80); }
.bg-ml-primary-90  { background-color: rgba(46,125,50,0.90); }
.border-ml-primary-5   { border-color: rgba(46,125,50,0.05); }
.border-ml-primary-8   { border-color: rgba(46,125,50,0.08); }
.border-ml-primary-10  { border-color: rgba(46,125,50,0.10); }
.border-ml-primary-15  { border-color: rgba(46,125,50,0.15); }
.border-ml-primary-20  { border-color: rgba(46,125,50,0.20); }
.border-ml-primary-25  { border-color: rgba(46,125,50,0.25); }
.border-ml-primary-30  { border-color: rgba(46,125,50,0.30); }
.border-ml-primary-40  { border-color: rgba(46,125,50,0.40); }
.border-ml-primary-50  { border-color: rgba(46,125,50,0.50); }
.border-ml-primary-60  { border-color: rgba(46,125,50,0.60); }
