/* ==========================================================================
   Multi-Laboratory SaaS Platform - Professional Design System
   Human-Crafted, Responsive, Medical-Grade UI with Rich Aesthetics & Micro-Interactions
   ========================================================================== */

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

:root {
  /* Core Color Palette - Deep Navy Slate, Electric Indigo & Luminous Cyan */
  --bg-primary: #090e17;       /* Master Background (Deep Midnight Navy) */
  --bg-secondary: #0f172a;     /* Sidebar & Panels (Slate 900) */
  --bg-surface: #172133;       /* Surface Cards (Refined Slate 850) */
  --bg-surface-elevated: #222f46; /* Dropdowns & Floating Elements */
  --bg-surface-hover: #293852;
  --bg-input: #101826;
  
  --text-primary: #f8fafc;     /* Crisp White-Slate */
  --text-secondary: #94a3b8;   /* Slate 400 */
  --text-muted: #64748b;       /* Slate 500 */
  --text-inverse: #090e17;
  
  /* Brand Accents & Gradients */
  --primary: #6366f1;          /* Indigo 500 */
  --primary-hover: #4f46e5;    /* Indigo 600 */
  --primary-light: rgba(99, 102, 241, 0.15);
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  --primary-glow: 0 0 24px rgba(99, 102, 241, 0.35);
  
  --accent: #06b6d4;           /* Cyan 500 */
  --accent-hover: #0891b2;
  --accent-light: rgba(6, 182, 212, 0.14);
  --accent-gradient: linear-gradient(135deg, #06b6d4 0%, #0284c7 100%);
  
  --success: #10b981;          /* Emerald 500 */
  --success-light: rgba(16, 185, 129, 0.14);
  --warning: #f59e0b;          /* Amber 500 */
  --warning-light: rgba(245, 158, 11, 0.14);
  --danger: #ef4444;           /* Rose/Red 500 */
  --danger-light: rgba(239, 68, 68, 0.14);
  --info: #3b82f6;             /* Blue 500 */
  --info-light: rgba(59, 130, 246, 0.14);

  /* Modern Glass & Border Tokens */
  --border-color: rgba(255, 255, 255, 0.09);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-focus: rgba(99, 102, 241, 0.6);
  --card-rim: inset 0 1px 0 rgba(255, 255, 255, 0.08);

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Spacing Scale */
  --space-2xs: 0.125rem; /* 2px */
  --space-xs: 0.25rem;   /* 4px */
  --space-sm: 0.5rem;    /* 8px */
  --space-md: 1rem;      /* 16px */
  --space-lg: 1.5rem;    /* 24px */
  --space-xl: 2rem;      /* 32px */
  --space-2xl: 3rem;     /* 48px */

  /* Borders & Radius */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Elevation Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 14px -1px rgba(0, 0, 0, 0.4), 0 2px 6px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 28px -4px rgba(0, 0, 0, 0.5), 0 4px 10px -2px rgba(0, 0, 0, 0.35);
  --shadow-xl: 0 20px 40px -8px rgba(0, 0, 0, 0.65);

  /* Transitions */
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 150ms var(--ease-spring);
  --transition-normal: 250ms var(--ease-spring);

  /* Layout dimensions */
  --sidebar-width: 260px;
  --header-height: 64px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 10%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(6, 182, 212, 0.05) 0%, transparent 45%);
  background-attachment: fixed;
}

body.sidebar-open, body.modal-open {
  overflow: hidden !important;
  touch-action: none;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: #818cf8;
}

img, svg {
  vertical-align: middle;
  max-width: 100%;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.45);
}

/* ==========================================================================
   Typography
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(1.85rem, 4vw, 2.75rem); font-weight: 800; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 700; }
h3 { font-size: clamp(1.15rem, 2.2vw, 1.45rem); font-weight: 700; }
h4 { font-size: 1.1rem; font-weight: 600; }

p {
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
}

.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }

/* ==========================================================================
   Public Navigation Header
   ========================================================================== */
.public-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(9, 14, 23, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all var(--transition-normal);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.03em;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  list-style: none;
}

.nav-link {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.925rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

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

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.925rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

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

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35), var(--card-rim);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
  color: #ffffff;
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  border-color: var(--text-muted);
}

.btn-accent {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(6, 182, 212, 0.35);
}

.btn-accent:hover:not(:disabled) {
  background: linear-gradient(135deg, #0891b2 0%, #0369a1 100%);
  transform: translateY(-1px);
  color: #ffffff;
}

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.85rem 1.75rem;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}

.btn-block {
  display: flex;
  width: 100%;
}

/* ==========================================================================
   Forms & Input Controls
   Touch-Friendly (>=44px height & >=16px font to prevent iOS Safari auto-zoom)
   ========================================================================== */
.form-group {
  margin-bottom: var(--space-md);
  display: flex;
  flex-direction: column;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-control, .form-select {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.95rem;
  font-size: 1rem; /* 16px to prevent iOS auto-zoom */
  font-family: inherit;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 1.15rem;
  padding-right: 2.5rem;
  cursor: pointer;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
  background-color: #121c2e;
}

.form-control::placeholder {
  color: var(--text-muted);
  opacity: 0.85;
}

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

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  line-height: 1.4;
}

.form-error {
  font-size: 0.825rem;
  color: var(--danger);
  margin-top: 0.35rem;
  display: none;
}

.form-error.active {
  display: block;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
}

/* ==========================================================================
   Cards & Panels
   Glassmorphic Elevation with Soft Ambient Border Highlight
   ========================================================================== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-md), var(--card-rim);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.015em;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

@media (max-width: 640px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: var(--space-lg);
  }
}

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

.dashboard-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: var(--space-lg);
}

@media (max-width: 640px) {
  .dashboard-columns {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
}

.metric-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 1.25rem var(--space-lg);
  background: linear-gradient(180deg, var(--bg-surface) 0%, rgba(20, 28, 43, 0.95) 100%);
}

.metric-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.metric-val {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.metric-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 0.15rem;
}

/* ==========================================================================
   Badges (Pills with Status Indicator Dot)
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-full);
  line-height: 1;
}

.badge::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-pending {
  background: var(--warning-light);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-approved, .badge-active, .badge-paid, .badge-captured {
  background: var(--success-light);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-rejected, .badge-suspended, .badge-failed {
  background: var(--danger-light);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.badge-expired, .badge-past-due {
  background: var(--warning-light);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

/* ==========================================================================
   Data Tables & Responsive Scroll Container
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  margin-bottom: 0.5rem;
}

.table {
  width: 100%;
  min-width: 660px; /* Prevents cramped columns on mobile */
  border-collapse: collapse;
  text-align: left;
  font-size: 0.925rem;
}

.table th {
  background: #111a29;
  padding: 0.85rem 1rem;
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.775rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
  line-height: 1.4;
}

.table tbody tr {
  transition: background-color var(--transition-fast);
}

.table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.025);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* ==========================================================================
   Portal Layout (Lab & Super Admin)
   Responsive Desktop Sidebar & Mobile Off-Canvas Drawer with Backdrop
   ========================================================================== */
.portal-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

.portal-sidebar {
  width: var(--sidebar-width);
  max-width: 85vw;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 95;
  transition: transform 0.3s var(--ease-spring);
  box-shadow: var(--shadow-md);
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md) var(--space-sm);
  list-style: none;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem var(--space-md);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.925rem;
  margin-bottom: 3px;
  transition: all var(--transition-fast);
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  transform: translateX(2px);
}

.sidebar-link.active {
  background: var(--primary-light);
  color: #a5b4fc;
  font-weight: 700;
  border-left: 3px solid var(--primary);
}

.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.15);
}

.user-badge {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 170px;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.725rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Mobile Sidebar Backdrop */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 14, 23, 0.8);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease-spring);
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Portal Main Content Area */
.portal-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
  transition: margin-left 0.3s var(--ease-spring);
}

.portal-topbar {
  min-height: var(--header-height);
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem var(--space-xl);
  position: sticky;
  top: 0;
  z-index: 80;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.portal-content {
  padding: var(--space-xl);
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Mobile Toggle Button */
.mobile-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  font-size: 1.25rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.mobile-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-muted);
}

/* Usage Progress Bar */
.usage-meter {
  background: #101826;
  border-radius: var(--radius-full);
  height: 10px;
  overflow: hidden;
  margin: 0.75rem 0;
  border: 1px solid var(--border-subtle);
}

.usage-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--primary) 100%);
  border-radius: var(--radius-full);
  transition: width 0.5s var(--ease-spring);
}

/* ==========================================================================
   Modals (Responsive Centered Desktop & Native Bottom-Sheet on Mobile)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 14, 23, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.modal-overlay.active {
  display: flex;
}

.modal-content, .modal-card {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 88vh;
  box-shadow: var(--shadow-xl), var(--card-rim);
  display: flex;
  flex-direction: column;
  animation: modalScaleIn 0.25s var(--ease-spring);
  overflow: hidden;
}

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

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

@media (max-width: 768px) {
  .grid-cols-2, .grid-cols-3 {
    grid-template-columns: 1fr;
  }
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 1.25rem var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  padding: 1rem var(--space-lg);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.modal-close {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  cursor: pointer;
  line-height: 1;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

/* ==========================================================================
   Toast Notifications (Desktop Top-Right & Mobile Full-Width Top Docked)
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  pointer-events: none;
  max-width: calc(100vw - 40px);
}

.toast {
  pointer-events: auto;
  background: rgba(23, 33, 51, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.15rem;
  box-shadow: var(--shadow-xl);
  min-width: 280px;
  max-width: 440px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: toastSlideIn 0.3s var(--ease-spring);
  cursor: pointer;
}

.toast-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}

.toast-dismiss {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

.toast-dismiss:hover {
  color: var(--text-primary);
}

.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-danger { border-left: 4px solid var(--danger); }
.toast.toast-warning { border-left: 4px solid var(--warning); }
.toast.toast-info { border-left: 4px solid var(--info); }

@keyframes toastSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   Pricing Cards
   ========================================================================== */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-xl);
  margin-top: var(--space-xl);
}

.plan-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-md), var(--card-rim);
}

.plan-card:hover {
  border-color: rgba(99, 102, 241, 0.5);
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.plan-card.featured {
  border-color: var(--primary);
  box-shadow: 0 0 35px rgba(99, 102, 241, 0.25), var(--card-rim);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.95) 0%, rgba(20, 28, 43, 0.95) 100%);
}

.plan-badge {
  position: absolute;
  top: 16px;
  right: 16px;
}

.plan-price {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: var(--space-md) 0;
  display: flex;
  align-items: baseline;
  gap: 4px;
  letter-spacing: -0.03em;
}

.plan-price-period {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
}

.plan-features {
  list-style: none;
  margin: var(--space-lg) 0;
  flex: 1;
}

.plan-features li {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  color: var(--text-secondary);
  font-size: 0.925rem;
}

.plan-features li::before {
  content: "✓";
  color: var(--success);
  font-weight: 900;
  flex-shrink: 0;
}

/* ==========================================================================
   Responsive Breakpoints (Tablet & Mobile Perfection)
   ========================================================================== */

/* Tablet & Smaller Desktops (<= 1024px) */
@media (max-width: 1024px) {
  .portal-sidebar {
    transform: translateX(-100%);
  }

  .portal-sidebar.active {
    transform: translateX(0);
  }

  .portal-main {
    margin-left: 0;
  }

  .mobile-toggle {
    display: inline-flex;
  }

  .public-nav {
    padding: 0.75rem var(--space-md);
  }

  .portal-topbar {
    padding: 0.75rem var(--space-md);
  }

  .portal-content {
    padding: var(--space-md);
  }
}

/* Mobile Screens (<= 768px) */
@media (max-width: 768px) {
  .public-nav .nav-links {
    display: none; /* Streamlined on mobile */
  }

  .public-nav .nav-cta .btn {
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .card {
    padding: 1.15rem;
  }

  .portal-topbar {
    padding: 0.65rem 0.85rem;
  }

  .portal-content {
    padding: 0.85rem;
  }

  .metric-card {
    padding: 1rem;
    gap: 0.75rem;
  }

  .metric-icon {
    width: 44px;
    height: 44px;
    font-size: 1.25rem;
  }

  .metric-val {
    font-size: 1.45rem;
  }
}

/* Small Smartphone Viewports (<= 640px) - Native Bottom Sheet Modals & Stacked Elements */
@media (max-width: 640px) {
  /* Bottom Sheet Modal Presentation on Phones */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-content, .modal-card {
    max-width: 100%;
    max-height: 92vh;
    border-radius: 22px 22px 0 0;
    border-bottom: none;
    animation: modalSlideUp 0.28s var(--ease-spring);
  }

  @keyframes modalSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .modal-header {
    padding: 1rem 1.25rem;
    position: relative;
  }

  /* Drag indicator handle on phone bottom-sheets */
  .modal-header::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px;
    height: 4px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.2);
  }

  .modal-body {
    padding: 1rem 1.25rem;
  }

  .modal-footer {
    padding: 0.85rem 1.25rem;
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
  }

  /* Toast notification on top docked */
  .toast-container {
    top: 12px;
    left: 12px;
    right: 12px;
    max-width: none;
  }

  .toast {
    min-width: auto;
    max-width: 100%;
    width: 100%;
    animation: toastTopDrop 0.25s var(--ease-spring);
  }

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

  /* Form spacing */
  .form-group {
    margin-bottom: 0.85rem;
  }
}

/* Very Small Screens (<= 400px) */
@media (max-width: 400px) {
  .brand span {
    font-size: 1.1rem;
  }
  
  .portal-topbar h2 {
    font-size: 1.1rem !important;
  }
}
