/* ═══════════════════════════════════════════════════════════════
   AchaWaqat Medical Calculator Suite — Renovated Design System
   Version: 2.0 | Stitch-Inspired Premium Medical UI
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── Color Tokens ─── */
:root {
  /* Primary */
  --primary: #0d4a6f;
  --primary-dark: #09354f;
  --primary-light: #e8f4f8;
  --primary-alpha: rgba(13, 74, 111, 0.08);

  /* Semantic */
  --success: #2d6a4f;
  --success-light: #d8f3dc;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #be123c;
  --danger-light: #ffe4e6;
  --info: #0e7490;
  --info-light: #cffafe;

  /* Neutrals */
  --white: #ffffff;
  --surface: #f8fafc;
  --surface-elevated: #f1f5f9;
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --text-inverse: #f8fafc;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgb(15 23 42 / 0.04);
  --shadow-sm: 0 1px 3px 0 rgb(15 23 42 / 0.08), 0 1px 2px -1px rgb(15 23 42 / 0.06);
  --shadow-md: 0 4px 6px -1px rgb(15 23 42 / 0.08), 0 2px 4px -2px rgb(15 23 42 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(15 23 42 / 0.08), 0 4px 6px -4px rgb(15 23 42 / 0.06);
  --shadow-xl: 0 20px 25px -5px rgb(15 23 42 / 0.08), 0 8px 10px -6px rgb(15 23 42 / 0.06);
  --shadow-glow: 0 0 0 3px var(--primary-light);

  /* Radii */
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-md: 0.625rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.25rem;
  --radius-full: 9999px;

  /* Layout */
  --max-width: 1280px;
  --header-height: 68px;
  --section-gap: 2.5rem;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Dark Mode ─── */
:root[data-theme="dark"] {
  --primary: #38bdf8;
  --primary-dark: #7dd3fc;
  --primary-light: rgba(56, 189, 248, 0.12);
  --primary-alpha: rgba(56, 189, 248, 0.08);

  --success: #4ade80;
  --success-light: rgba(74, 222, 128, 0.12);
  --warning: #fbbf24;
  --warning-light: rgba(251, 191, 36, 0.12);
  --danger: #fb7185;
  --danger-light: rgba(251, 113, 133, 0.12);
  --info: #22d3ee;
  --info-light: rgba(34, 211, 238, 0.12);

  --white: #0f172a;
  --surface: #0f172a;
  --surface-elevated: #1e293b;
  --border: #334155;
  --border-subtle: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-tertiary: #64748b;
  --text-inverse: #0f172a;

  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #38bdf8;
    --primary-dark: #7dd3fc;
    --primary-light: rgba(56, 189, 248, 0.12);
    --primary-alpha: rgba(56, 189, 248, 0.08);
    --success: #4ade80;
    --success-light: rgba(74, 222, 128, 0.12);
    --warning: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.12);
    --danger: #fb7185;
    --danger-light: rgba(251, 113, 133, 0.12);
    --info: #22d3ee;
    --info-light: rgba(34, 211, 238, 0.12);
    --white: #0f172a;
    --surface: #0f172a;
    --surface-elevated: #1e293b;
    --border: #334155;
    --border-subtle: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-tertiary: #64748b;
    --text-inverse: #0f172a;
    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.4);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.5);
  }
}

/* ─── Base Reset ─── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--surface);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── Theme Toggle ─── */
.theme-toggle {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.125rem;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
}

.theme-toggle:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* ─── Header ─── */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  backdrop-filter: blur(12px);
  background-color: rgba(255, 255, 255, 0.92);
}

:root[data-theme="dark"] .site-header {
  background-color: rgba(15, 23, 42, 0.92);
}

@media (prefers-color-scheme: dark) {
  .site-header {
    background-color: rgba(15, 23, 42, 0.92);
  }
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: 1rem;
}

.logo {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary), #2d6a4f);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
}

/* ─── Search ─── */
.header-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.header-search input {
  width: 100%;
  padding: 0.625rem 1rem 0.625rem 2.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  font-family: inherit;
}

.header-search input::placeholder { color: var(--text-tertiary); }

.header-search input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--white);
  box-shadow: var(--shadow-glow);
}

.header-search::before {
  content: "🔍";
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  opacity: 0.5;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 420px;
  overflow-y: auto;
  display: none;
  z-index: 200;
}

.search-dropdown.active { display: block; animation: fadeIn 150ms ease; }

.search-dropdown a {
  display: block;
  padding: 0.875rem 1rem;
  text-decoration: none;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.875rem;
  transition: background var(--transition-fast);
}

.search-dropdown a:hover { background: var(--surface); }

.search-dropdown a small {
  display: block;
  color: var(--text-tertiary);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.search-dropdown a strong {
  color: var(--text-primary);
  font-weight: 600;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Mobile Menu ─── */
.mobile-menu-btn {
  display: none;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 40px;
  height: 40px;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-secondary);
  align-items: center;
  justify-content: center;
}

/* ─── Category Navigation ─── */
.cat-nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.cat-nav::-webkit-scrollbar { display: none; }

.cat-nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  gap: 0.25rem;
  padding: 0 1.5rem;
}

.cat-nav a {
  padding: 0.875rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2.5px solid transparent;
  transition: all var(--transition-fast);
  position: relative;
}

.cat-nav a:hover { color: var(--primary); }

.cat-nav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ─── Main Layout ─── */
.main-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ─── Hero Section ─── */
.hero-section {
  text-align: center;
  padding: 3.5rem 0 2.5rem;
  position: relative;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -2rem;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 300px;
  background: radial-gradient(ellipse at center, var(--primary-light) 0%, transparent 70%);
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}

:root[data-theme="dark"] .hero-section::before {
  background: radial-gradient(ellipse at center, rgba(56, 189, 248, 0.08) 0%, transparent 70%);
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.hero-title .gradient-text {
  background: linear-gradient(135deg, var(--primary) 0%, #2d6a4f 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

:root[data-theme="dark"] .hero-title .gradient-text {
  background: linear-gradient(135deg, #38bdf8 0%, #4ade80 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: 1.125rem;
  max-width: 680px;
  margin: 0 auto 2rem;
  line-height: 1.7;
}

.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.hero-cta .btn-lg {
  padding: 0.875rem 2rem;
  font-size: 1rem;
}

.hero-cta .btn-secondary {
  background: var(--white);
}

/* ─── Stats Bar ─── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  max-width: 900px;
  margin: 0 auto 3rem;
  padding: 1.25rem;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 1;
}

:root[data-theme="dark"] .stats-bar {
  background: var(--surface-elevated);
}

.stat-item {
  text-align: center;
  padding: 0.5rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.25rem;
}

.stat-divider {
  width: 1px;
  background: var(--border);
  align-self: stretch;
  margin: 0.5rem 0;
}

/* ─── Features Section ─── */
.features-section {
  padding: 3rem 0;
  margin-bottom: 1rem;
}

.features-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.features-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.features-header p {
  color: var(--text-secondary);
  font-size: 1rem;
  max-width: 500px;
  margin: 0 auto;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  max-width: 1000px;
  margin: 0 auto;
}

.feature-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem 1.5rem;
  text-align: center;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-xs);
}

:root[data-theme="dark"] .feature-card {
  background: var(--surface-elevated);
}

.feature-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.feature-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 1.25rem;
  background: var(--primary-light);
}

.feature-card:nth-child(1) .feature-icon { background: var(--primary-light); }
.feature-card:nth-child(2) .feature-icon { background: var(--success-light); }
.feature-card:nth-child(3) .feature-icon { background: var(--info-light); }

.feature-card h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.feature-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ─── Category Hero ─── */
.category-hero {
  position: relative;
  padding: 3rem 1.5rem;
  margin: -2rem -1.5rem 2rem;
  overflow: hidden;
}

.category-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--cat-accent, var(--primary)) 0%, var(--cat-accent-dark, var(--primary-dark)) 100%);
  opacity: 0.08;
}

:root[data-theme="dark"] .category-hero::before {
  opacity: 0.12;
}

.category-hero-content {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.category-hero-icon {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.25rem;
  background: linear-gradient(135deg, var(--cat-accent, var(--primary)), var(--cat-accent-dark, var(--primary-dark)));
  color: white;
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
}

.category-hero-text h1 {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.375rem;
}

.category-hero-text p {
  color: var(--text-secondary);
  font-size: 1rem;
  max-width: 600px;
  line-height: 1.6;
}

.category-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.875rem;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--cat-accent, var(--primary));
  color: white;
  margin-top: 0.75rem;
}

/* ─── Category Filter ─── */
.category-filter {
  max-width: 480px;
  margin: 0 0 1.5rem;
  position: relative;
}

.category-filter input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.9375rem;
  background: var(--white);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  font-family: inherit;
}

:root[data-theme="dark"] .category-filter input {
  background: var(--surface-elevated);
}

.category-filter input::placeholder { color: var(--text-tertiary); }

.category-filter input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.category-filter::before {
  content: "🔍";
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  opacity: 0.5;
}

/* ─── Related Categories ─── */
.related-categories {
  margin: var(--section-gap) 0;
}

.related-categories h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-bottom: 1.25rem;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.related-cat-card {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1rem 1.25rem;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

:root[data-theme="dark"] .related-cat-card {
  background: var(--surface-elevated);
}

.related-cat-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.related-cat-card .related-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: var(--cat-bg, var(--primary-alpha));
  flex-shrink: 0;
}

.related-cat-card span {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ─── Hero Section ─── */
.hero-section {
  text-align: center;
  padding: 2.5rem 0 2rem;
}

.page-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 1.0625rem;
  max-width: 640px;
  margin: 0 auto 1.75rem;
  line-height: 1.6;
}

.badge-row {
  display: flex;
  gap: 0.625rem;
  justify-content: center;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.875rem;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: transform var(--transition-fast);
}

.badge:hover { transform: translateY(-1px); }

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info { background: var(--info-light); color: var(--info); }

/* ─── Ad Containers ─── */
.ad-container {
  background: var(--surface-elevated);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin: var(--section-gap) 0;
  text-align: center;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

.ad-container.sidebar {
  position: sticky;
  top: calc(var(--header-height) + 1rem);
  margin: 0;
}

/* ─── Breadcrumbs ─── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.breadcrumbs a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: opacity var(--transition-fast);
}

.breadcrumbs a:hover { opacity: 0.8; text-decoration: underline; }

/* ─── Calculator Card Grid ─── */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  margin: var(--section-gap) 0;
}

.calc-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}

.calc-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--cat-accent, var(--primary));
  opacity: 0.8;
}

.calc-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.calc-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.375rem;
  margin-bottom: 1rem;
  background: var(--cat-bg, var(--primary-alpha));
  color: var(--cat-accent, var(--primary));
  transition: transform var(--transition-fast);
}

.calc-card:hover .calc-card-icon {
  transform: scale(1.08);
}

.calc-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.375rem;
  letter-spacing: -0.01em;
}

.calc-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.calc-card .calc-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* ─── Category Section on Hub ─── */
.category-section {
  margin-bottom: 3rem;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1.25rem;
}

.category-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.category-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
}

/* ─── Calculator Header ─── */
.calc-header {
  position: relative;
  padding: 1.5rem 1.75rem;
  margin: -1.75rem -1.75rem 1.5rem;
  background: linear-gradient(135deg, var(--cat-accent, var(--primary)) 0%, var(--cat-accent-dark, var(--primary-dark)) 100%);
  color: white;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.calc-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  letter-spacing: -0.01em;
}

.calc-header p {
  font-size: 0.875rem;
  opacity: 0.9;
  line-height: 1.5;
}

/* ─── Calculator Page Layout ─── */
.calc-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
  align-items: start;
}

.calc-main { min-width: 0; }

.calc-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ─── Calculator Form ─── */
.calc-form {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.calc-form::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--cat-accent, var(--primary)), var(--cat-accent-dark, var(--primary-dark)));
  opacity: 0.8;
}

:root[data-theme="dark"] .calc-form::before {
  opacity: 0.6;
}

/* ─── Result Highlight ─── */
.result-highlight {
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.result-highlight.accent {
  background: linear-gradient(135deg, var(--cat-accent, var(--primary)), var(--cat-accent-dark, var(--primary-dark)));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Result Actions ─── */
.result-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.result-actions .btn {
  font-size: 0.8125rem;
  padding: 0.5rem 1rem;
  min-height: 36px;
}

/* ─── Notes Section ─── */
.notes-section {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  margin-top: 1.25rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.notes-section h3 {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.875rem;
  letter-spacing: -0.01em;
}

.notes-section ul {
  padding-left: 1.25rem;
  margin-bottom: 0.75rem;
}

.notes-section ul li {
  margin-bottom: 0.375rem;
}

.notes-section p {
  margin-top: 0.75rem;
}

/* ─── Sticky Mobile Actions ─── */
.sticky-actions {
  display: none;
}

@media (max-width: 968px) {
  .sticky-actions {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.875rem 1rem;
    background: var(--white);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
    gap: 0.75rem;
    z-index: 90;
    justify-content: center;
  }
  
  :root[data-theme="dark"] .sticky-actions {
    background: var(--surface-elevated);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.3);
  }
  
  .sticky-actions .btn {
    flex: 1;
    max-width: 200px;
  }
  
  body {
    padding-bottom: 72px;
  }
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group:last-child { margin-bottom: 0; }

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group .help-text {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  margin-top: 0.375rem;
  line-height: 1.5;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  transition: all var(--transition-fast);
  background: var(--white);
  color: var(--text-primary);
  font-family: inherit;
  min-height: 44px;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.form-control::placeholder { color: var(--text-tertiary); }

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1.25em 1.25em;
  padding-right: 2.75rem;
}

.input-unit-group {
  display: flex;
  gap: 0;
}

.input-unit-group .form-control {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  border-right: none;
}

.input-unit-group .unit-select {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  border-left: none;
  background: var(--surface-elevated);
  min-width: 90px;
  padding: 0.75rem 0.625rem;
  font-size: 0.8125rem;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  font-family: inherit;
}

/* ─── Checkbox/Radio Groups ─── */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1.5px solid transparent;
}

.checkbox-item:hover {
  background: var(--surface);
  border-color: var(--border);
}

.checkbox-item input[type="checkbox"],
.checkbox-item input[type="radio"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-item label {
  margin: 0;
  cursor: pointer;
  font-weight: 400;
  font-size: 0.9375rem;
  color: var(--text-primary);
  text-transform: none;
  letter-spacing: 0;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  font-family: inherit;
  letter-spacing: -0.01em;
  min-height: 44px;
}

.btn-primary {
  background: var(--primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--white);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-elevated);
  border-color: var(--text-tertiary);
}

.btn-success {
  background: var(--success);
  color: var(--white);
}

.btn-success:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
}

.btn-ghost:hover {
  background: var(--primary-light);
}

.btn-block { width: 100%; }

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
}

/* ─── Results Panel ─── */
.results-panel {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
  display: none;
  box-shadow: var(--shadow-sm);
  animation: slideUp 300ms ease;
}

.results-panel.active { display: block; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.results-panel.risk-low { border-left: 4px solid var(--success); background: var(--success-light); }
.results-panel.risk-moderate { border-left: 4px solid var(--warning); background: var(--warning-light); }
.results-panel.risk-high { border-left: 4px solid var(--danger); background: var(--danger-light); }
.results-panel.risk-info { border-left: 4px solid var(--info); background: var(--info-light); }

.result-main {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.result-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.result-interpretation {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
  font-size: 0.9375rem;
  font-weight: 500;
}

.result-interpretation.low { background: var(--success-light); color: var(--success); }
.result-interpretation.moderate { background: var(--warning-light); color: var(--warning); }
.result-interpretation.high { background: var(--danger-light); color: var(--danger); }
.result-interpretation.info { background: var(--info-light); color: var(--info); }

.result-details {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.result-details dt {
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 0.875rem;
}

.result-details dd { margin-left: 0; margin-top: 0.25rem; }

/* ─── Score Display ─── */
.score-display {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.score-circle {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.875rem;
  font-weight: 800;
  flex-shrink: 0;
  border: 3px solid transparent;
  font-variant-numeric: tabular-nums;
}

.score-circle.low { background: var(--success-light); color: var(--success); border-color: var(--success); }
.score-circle.moderate { background: var(--warning-light); color: var(--warning); border-color: var(--warning); }
.score-circle.high { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }
.score-circle.info { background: var(--info-light); color: var(--info); border-color: var(--info); }

.score-text h4 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  letter-spacing: -0.01em;
}

.score-text p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ─── Tables ─── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
  margin: 1.25rem 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1.5px solid var(--border);
}

.data-table th,
.data-table td {
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
  font-weight: 600;
  color: var(--text-primary);
  background: var(--surface-elevated);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tbody tr:hover { background: var(--surface); }

.data-table tbody tr:last-child td { border-bottom: none; }

/* ─── References Section ─── */
.references {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  margin-top: 1.25rem;
}

.references h3 {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

.references ol {
  padding-left: 1.5rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.references li { margin-bottom: 0.625rem; line-height: 1.6; }

.references a { color: var(--primary); word-break: break-all; font-weight: 500; }

/* ─── Disclaimer ─── */
.disclaimer {
  background: var(--warning-light);
  border: 1.5px solid rgba(217, 119, 6, 0.3);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin: var(--section-gap) 0;
  font-size: 0.8125rem;
  color: #92400e;
  line-height: 1.6;
}

:root[data-theme="dark"] .disclaimer {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.3);
}

.disclaimer strong { font-weight: 700; }

/* ─── Related Calculators ─── */
.related-cals {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.related-cals h3 {
  font-size: 0.9375rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.related-cals a {
  display: block;
  padding: 0.625rem 0;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  border-bottom: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.related-cals a:hover {
  padding-left: 0.5rem;
  text-decoration: underline;
}

.related-cals a:last-child { border-bottom: none; }

/* ─── Footer ─── */
.site-footer {
  background: var(--text-primary);
  color: var(--text-tertiary);
  padding: 3rem 1.5rem 2rem;
  margin-top: 4rem;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2.5rem;
  margin-bottom: 2.5rem;
}

.footer-section h4 {
  color: var(--text-inverse);
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

.footer-section a {
  display: block;
  color: var(--text-tertiary);
  text-decoration: none;
  font-size: 0.8125rem;
  padding: 0.375rem 0;
  transition: color var(--transition-fast);
}

.footer-section a:hover { color: var(--text-inverse); }

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 2rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

/* ─── Print Styles ─── */
@media print {
  .site-header, .cat-nav, .ad-container, .calc-sidebar, .site-footer, .btn, .theme-toggle, .mobile-menu-btn { display: none !important; }
  .calc-layout { grid-template-columns: 1fr !important; }
  .results-panel { display: block !important; border: 1px solid #000 !important; }
  body { background: white !important; color: black !important; }
}

/* ─── Responsive ─── */
@media (max-width: 968px) {
  .calc-layout { grid-template-columns: 1fr; gap: 1.5rem; }
  .calc-sidebar { order: -1; }
  .ad-container.sidebar { position: static; }
  .form-row { grid-template-columns: 1fr; }
  .main-container { padding: 1.5rem 1rem; }
  .header-inner { padding: 0 1rem; }
  .features-grid { grid-template-columns: 1fr; max-width: 480px; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .stat-divider:nth-of-type(2) { display: none; }
}

@media (max-width: 640px) {
  .mobile-menu-btn { display: flex; }
  .header-search { max-width: 160px; }
  .calc-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 1.625rem; }
  .result-main { font-size: 2.25rem; }
  .cat-nav-inner { gap: 0; padding: 0 1rem; }
  .cat-nav a { padding: 0.75rem 0.625rem; font-size: 0.75rem; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .calc-form { padding: 1.25rem; }
  .hero-section { padding: 1.5rem 0 1rem; }
  .stats-bar { grid-template-columns: 1fr 1fr; gap: 0.75rem; padding: 1rem; }
  .stat-value { font-size: 1.375rem; }
  .stat-divider { display: none; }
  .features-grid { gap: 1rem; }
  .feature-card { padding: 1.5rem 1.25rem; }
  .hero-cta { flex-direction: column; width: 100%; }
  .hero-cta .btn { width: 100%; }
  .category-hero { padding: 2rem 1rem; margin: -1.5rem -1rem 1.5rem; }
  .category-hero-content { flex-direction: column; text-align: center; gap: 1rem; }
  .category-hero-icon { width: 56px; height: 56px; font-size: 1.75rem; }
  .related-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .header-search { display: none; }
  .cat-nav a { padding: 0.625rem 0.5rem; font-size: 0.6875rem; }
  .footer-grid { grid-template-columns: 1fr; }
  .score-display { flex-direction: column; text-align: center; }
  .related-grid { grid-template-columns: 1fr; }
}

/* ─── Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ─── Recently Used & Favorites ─── */
.recent-section {
  margin: var(--section-gap) 0;
}

.recent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.recent-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.recent-clear {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.recent-clear:hover {
  color: var(--danger);
  background: var(--danger-light);
}

.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.recent-card {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1rem 1.25rem;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

:root[data-theme="dark"] .recent-card {
  background: var(--surface-elevated);
}

.recent-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.recent-card .recent-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: var(--cat-bg, var(--primary-alpha));
  flex-shrink: 0;
}

.recent-card .recent-info {
  min-width: 0;
}

.recent-card .recent-info h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-card .recent-info span {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ─── Favorite Button ─── */
.fav-btn {
  position: fixed;
  top: calc(var(--header-height) + 1rem);
  right: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--white);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  z-index: 50;
  transition: all var(--transition-fast);
}

:root[data-theme="dark"] .fav-btn {
  background: var(--surface-elevated);
}

.fav-btn:hover {
  transform: scale(1.1);
  border-color: var(--warning);
}

.fav-btn.active {
  background: var(--warning-light);
  border-color: var(--warning);
}

@media (max-width: 968px) {
  .fav-btn {
    top: calc(var(--header-height) + 0.5rem);
    right: 1rem;
    width: 40px;
    height: 40px;
    font-size: 1.125rem;
  }
}

/* ─── Utility Classes ─── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.text-center { text-align: center; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-2 { margin-top: 1rem; }
.hidden { display: none !important; }
