/* ==========================================================================
   JARS - Joint Assessment and Risk Surveyor
   Design System & Responsive Stylesheet (Clinical Light Theme)
   ========================================================================== */

:root {
  /* Light Theme Palette */
  --bg-dark: #f8fafc;
  --bg-subtle: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-glass: rgba(255, 255, 255, 0.9);
  --border-subtle: #e2e8f0;
  --border-light: #cbd5e1;
  --border-accent: rgba(2, 132, 199, 0.4);

  /* Primary Accent: Clinical Cyan / Sky Blue */
  --primary: #0284c7;
  --primary-glow: rgba(2, 132, 199, 0.18);
  --primary-light: #0ea5e9;
  --primary-dark: #0369a1;

  /* Status Colors (Accessible & High Contrast on Light Backgrounds) */
  --standing-color: #059669;
  --standing-glow: rgba(5, 150, 105, 0.15);
  --sitting-color: #2563eb;
  --sitting-glow: rgba(37, 99, 235, 0.15);
  --alert-color: #e11d48;
  --alert-glow: rgba(225, 29, 72, 0.18);
  --warning-color: #d97706;
  --warning-glow: rgba(217, 119, 6, 0.15);

  /* Text Colors */
  --text-main: #0f172a;
  --text-sub: #334155;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Layout & Elevation */
  --max-width: 1280px;
  --header-height: 72px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.6;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background: 
    radial-gradient(circle at 10% 10%, rgba(2, 132, 199, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 90% 60%, rgba(5, 150, 105, 0.04) 0%, transparent 40%),
    var(--bg-dark);
}

a {
  color: inherit;
  text-decoration: none;
}

/* ==========================================================================
   Navigation Bar
   ========================================================================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  height: var(--header-height);
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.nav-container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
  text-decoration: none;
}

.brand-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
}

.brand-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.5rem;
  background: rgba(2, 132, 199, 0.1);
  border: 1px solid rgba(2, 132, 199, 0.25);
  border-radius: var(--radius-full);
  color: var(--primary-dark);
  margin-left: 0.35rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  list-style: none;
}

.nav-link {
  font-size: 0.925rem;
  font-weight: 500;
  color: var(--text-sub);
  transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
  color: var(--primary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.btn-secondary {
  background: #ffffff;
  border-color: var(--border-light);
  color: var(--text-sub);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.825rem;
}

.btn-text-short {
  display: none;
}

.btn-text-full {
  display: inline;
}

.btn-icon-only {
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}

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

.hamburger {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
}

/* Mobile Nav Drawer */
.mobile-nav {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem;
  gap: 1.5rem;
  transform: translateY(-120%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 99;
  box-shadow: var(--shadow-lg);
}

.mobile-nav.open {
  transform: translateY(0);
}

.mobile-nav-link {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-main);
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-nav-link.active {
  color: var(--primary);
}

/* ==========================================================================
   Hero Section
   ========================================================================== */
.hero {
  padding: 4.5rem 1.5rem 3.5rem;
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 3.5rem;
  align-items: center;
}

.hero-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-full);
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.25);
  color: var(--primary-dark);
  font-size: 0.825rem;
  font-weight: 600;
  width: fit-content;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--standing-color);
  box-shadow: 0 0 8px var(--standing-color);
  animation: pulse 2s infinite;
}

.pulse-dot.offline {
  background-color: var(--text-muted);
  box-shadow: none;
  animation: none;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(5, 150, 105, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

.hero-title {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text-main);
}

.hero-title .gradient-text {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 50%, #7c3aed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  font-size: 1.1rem;
  color: var(--text-sub);
  line-height: 1.7;
}

.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
}

.hero-media {
  position: relative;
}

.hardware-card {
  position: relative;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.hardware-img-wrap {
  width: 100%;
  background: #33383f;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hardware-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  transition: transform 0.5s ease;
}

.hardware-card:hover .hardware-img {
  transform: scale(1.015);
}

.hardware-caption {
  padding: 1rem 1.25rem;
  background: #ffffff;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.caption-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 0.15rem;
}

.caption-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.caption-sub {
  font-size: 0.785rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 0.15rem;
}

/* ==========================================================================
   Section Containers & Card Grid
   ========================================================================== */
.section {
  padding: 3.5rem 1.5rem;
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
}

.section-header {
  margin-bottom: 2.5rem;
}

.section-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.section-title {
  font-size: clamp(1.6rem, 3.5vw, 2.3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.section-desc {
  font-size: 1rem;
  color: var(--text-sub);
  margin-top: 0.5rem;
  max-width: 680px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.75rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.domain-tag {
  display: inline-block;
  font-size: 0.725rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.85rem;
  border: 1px solid transparent;
}

.domain-hr {
  background: rgba(2, 132, 199, 0.08);
  color: var(--primary);
  border-color: rgba(2, 132, 199, 0.2);
}

.domain-posture {
  background: rgba(5, 150, 105, 0.08);
  color: var(--standing-color);
  border-color: rgba(5, 150, 105, 0.2);
}

.domain-duration {
  background: rgba(37, 99, 235, 0.08);
  color: var(--sitting-color);
  border-color: rgba(37, 99, 235, 0.2);
}

.domain-alert {
  background: rgba(225, 29, 72, 0.08);
  color: var(--alert-color);
  border-color: rgba(225, 29, 72, 0.2);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.card-text {
  font-size: 0.925rem;
  color: var(--text-sub);
  line-height: 1.6;
}

.card-meta {
  margin-top: 1.25rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.stat-unit {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Architecture Explainer */
.arch-block {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.arch-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
}

.arch-node {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  transition: var(--transition);
}

.arch-node:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.node-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
  margin-bottom: 0.35rem;
}

.node-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: block;
  margin-bottom: 0.25rem;
}

.node-sub {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.arch-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-weight: bold;
}

.arch-arrow-symbol {
  font-size: 1.4rem;
  line-height: 1;
  color: var(--primary);
}

.desktop-arrow {
  display: inline;
}

.mobile-arrow {
  display: none;
}

.arch-arrow-sub {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.35rem;
  white-space: nowrap;
  text-align: center;
}

/* Research Callout / Disclaimer */
.callout {
  background: #fffbeb;
  border-left: 4px solid var(--warning-color);
  border-radius: var(--radius-sm);
  padding: 1.25rem 1.5rem;
  margin: 2.5rem 0;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
}

.callout-icon {
  font-size: 1.35rem;
  color: var(--warning-color);
  line-height: 1;
}

.callout-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 0.25rem;
}

.callout-text {
  font-size: 0.875rem;
  color: #78350f;
  line-height: 1.55;
}

/* ==========================================================================
   Dashboard Page Specific Styles
   ========================================================================== */
.dashboard-header {
  padding: 1.75rem 1.5rem 1.25rem;
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
}

.dashboard-toolbar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-top: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.85rem;
  width: 100%;
}

.toolbar-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field-trial {
  flex: 1 1 140px;
}

.field-date {
  flex: 1 1 135px;
}

.field-date-actions {
  flex: 0 0 auto;
}

.field-refresh {
  flex: 1 1 190px;
}

.field-export {
  flex: 1 1 210px;
}

.btn-group-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
}

.btn-group-row .form-select,
.btn-group-row .form-input {
  flex: 1 1 auto;
  min-width: 0;
}

.btn-group-row .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.form-select, .form-input {
  background: #ffffff;
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  width: 100%;
  min-width: 0;
  height: 38px;
}

.form-select:focus, .form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.form-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.label-spacer {
  visibility: hidden;
}

/* Date Search Bar */
.date-search-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  width: 100%;
}

.date-preset-btn {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-sub);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.775rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.date-preset-btn:hover, .date-preset-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* Tabs Header Bar & Scroll Affordance */
.tabs-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  margin-bottom: 0.4rem;
  gap: 0.75rem;
}

.tabs-hint-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.tab-scroll-arrows {
  display: flex;
  gap: 0.35rem;
}

.tab-arrow-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: var(--transition);
  font-weight: bold;
}

.tab-arrow-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--primary);
  color: var(--primary);
}

/* Tabs */
.tabs-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border-subtle);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.6rem;
  margin-bottom: 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) #e2e8f0;
}

/* Visible, Obvious Scrollbar */
.tabs-nav::-webkit-scrollbar {
  height: 6px;
  display: block !important;
}

.tabs-nav::-webkit-scrollbar-track {
  background: #e2e8f0;
  border-radius: 9999px;
}

.tabs-nav::-webkit-scrollbar-thumb {
  background: var(--primary-light);
  border-radius: 9999px;
}

.tabs-nav::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.15rem;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: inherit;
  flex-shrink: 0;
}

.tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-subtle);
  border-color: var(--border-light);
}

.tab-btn.active {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 2px 6px var(--primary-glow);
}

.tab-text-short {
  display: none;
}

.tab-text-full {
  display: inline;
}

.tab-badge {
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
  font-size: 0.725rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
}

.tab-btn.active .tab-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.tab-content {
  display: none;
  padding: 1.75rem 0;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

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

/* Metric Cards */
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

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

.metric-badge {
  font-size: 0.725rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}

.badge-standing {
  background: rgba(5, 150, 105, 0.1);
  color: var(--standing-color);
  border: 1px solid rgba(5, 150, 105, 0.25);
}

.badge-sitting {
  background: rgba(37, 99, 235, 0.1);
  color: var(--sitting-color);
  border: 1px solid rgba(37, 99, 235, 0.25);
}

.badge-alert {
  background: rgba(225, 29, 72, 0.1);
  color: var(--alert-color);
  border: 1px solid rgba(225, 29, 72, 0.25);
}

.metric-body {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.metric-number {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
}

.metric-sub {
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Charts */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  position: relative;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.chart-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.85rem;
  font-size: 0.8rem;
  color: var(--text-sub);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.chart-canvas-wrap {
  width: 100%;
  height: 320px;
  position: relative;
}

canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-top: 1rem;
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.data-table th {
  background: var(--bg-subtle);
  color: var(--text-sub);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-sub);
  white-space: nowrap;
}

.data-table tr:hover td {
  background: #f8fafc;
  color: var(--text-main);
}

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

/* Pagination Controls */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.pagination-info {
  font-size: 0.825rem;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-sub);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--bg-subtle);
}

.page-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px var(--primary-glow);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Status Chips & Badges */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.775rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
}

.chip-valid {
  background: rgba(5, 150, 105, 0.12);
  color: #047857;
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.chip-invalid {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
  border: 1px solid rgba(100, 116, 139, 0.2);
}

.chip-alert {
  background: rgba(225, 29, 72, 0.12);
  color: #be123c;
  border: 1px solid rgba(225, 29, 72, 0.2);
}

/* Progress Bars */
.progress-container {
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  height: 10px;
  overflow: hidden;
  margin: 0.75rem 0;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, #059669 100%);
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

/* Spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Raw JSON Inspector */
.json-viewer {
  background: #0f172a;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #93c5fd;
  max-height: 480px;
  overflow: auto;
  line-height: 1.5;
}

/* Footer */
.footer {
  margin-top: auto;
  background: #ffffff;
  border-top: 1px solid var(--border-subtle);
  padding: 2.5rem 1.5rem;
  box-shadow: 0 -1px 3px 0 rgba(0, 0, 0, 0.03);
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.footer-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-sub);
}

.footer-link:hover {
  color: var(--primary);
}

/* ==========================================================================
   Mobile & Responsive Adjustments
   ========================================================================== */
@media (max-width: 992px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
  
  .arch-flow {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .arch-arrow {
    transform: none;
    padding: 0.5rem 0;
    flex-direction: column;
    gap: 0.25rem;
  }

  .desktop-arrow {
    display: none;
  }

  .mobile-arrow {
    display: inline;
  }

  .arch-arrow-sub {
    margin-top: 0;
    white-space: normal;
  }
}

@media (max-width: 768px) {
  .nav-links, .nav-actions .btn-desktop {
    display: none;
  }

  .hamburger {
    display: none;
  }

  .hero {
    padding: 2rem 0.85rem 1.5rem;
  }

  .hero-title {
    font-size: clamp(1.4rem, 5.5vw, 2.1rem);
    line-height: 1.25;
    word-break: normal;
    overflow-wrap: break-word;
  }

  .hero-desc {
    font-size: 0.95rem;
    line-height: 1.55;
  }

  .hero-ctas .btn {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    white-space: normal;
    text-align: center;
    box-sizing: border-box;
  }

  .section {
    padding: 2rem 0.85rem;
  }

  .grid-4, .grid-3, .grid-2 {
    grid-template-columns: 1fr;
  }

  .dashboard-header {
    padding: 1rem 0.85rem 0.75rem;
  }

  .dashboard-toolbar {
    padding: 0.85rem 0.75rem;
    box-sizing: border-box;
    width: 100%;
  }

  .toolbar-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .toolbar-field {
    width: 100%;
    flex: 1 1 100%;
  }

  .label-spacer {
    display: none;
  }

  .btn-group-row {
    display: flex;
    width: 100%;
    gap: 0.4rem;
  }

  .btn-group-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: 100%;
  }

  .btn-group-split .btn {
    width: 100%;
    justify-content: center;
  }

  .btn-group-row .form-select {
    flex: 1 1 auto;
    min-width: 0;
  }

  .btn-group-row .btn {
    flex: 0 0 auto;
  }

  .form-select, .form-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-size: 0.85rem;
    padding: 0.5rem 0.65rem;
  }

  .date-search-card {
    flex-direction: column;
    align-items: stretch;
  }

  .metric-card {
    padding: 1rem 0.85rem;
  }

  .metric-number {
    font-size: 1.85rem;
  }

  .chart-canvas-wrap {
    height: 240px;
  }

  .chart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
  }

  .chart-legend {
    gap: 0.35rem 0.65rem;
    font-size: 0.75rem;
  }

  .legend-item {
    font-size: 0.75rem;
  }

  /* Responsive Text Swapping on Mobile */
  .btn-text-full {
    display: none;
  }
  .btn-text-short {
    display: inline;
  }

  .tab-text-full {
    display: none;
  }
  .tab-text-short {
    display: inline;
  }

  .tab-btn {
    padding: 0.5rem 0.85rem;
    font-size: 0.8rem;
  }

  /* Responsive Navbar */
  .navbar {
    height: auto;
    min-height: 56px;
    padding: 0.4rem 0;
  }

  .nav-container {
    padding: 0 0.85rem;
    gap: 0.5rem;
  }

  .brand-title {
    font-size: 1.15rem;
  }

  .brand-tag {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
  }

  .btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.775rem;
  }

  /* Mobile Pagination */
  .pagination-container {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0.75rem 0.5rem;
    gap: 0.5rem;
  }

  .pagination-controls {
    justify-content: center;
    width: 100%;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .page-btn {
    min-width: 30px;
    height: 30px;
    padding: 0 0.35rem;
    font-size: 0.775rem;
  }

  #hrFirstBtn, #hrLastBtn {
    display: none;
  }

  .footer-container {
    flex-direction: column;
    text-align: center;
  }

  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 360px) {
  .hero {
    padding: 1.5rem 0.65rem 1rem;
  }

  .hero-title {
    font-size: 1.35rem;
  }

  .section {
    padding: 1.5rem 0.65rem;
  }

  .dashboard-header {
    padding: 0.85rem 0.65rem 0.5rem;
  }

  .dashboard-toolbar {
    padding: 0.75rem 0.6rem;
  }

  .chart-legend {
    gap: 0.3rem 0.5rem;
    font-size: 0.7rem;
  }

  .legend-item {
    font-size: 0.7rem;
    gap: 0.3rem;
  }

  .nav-container {
    padding: 0 0.65rem;
  }

  .brand-title {
    font-size: 1.05rem;
  }

  .btn-sm {
    padding: 0.3rem 0.5rem;
    font-size: 0.725rem;
  }
}
