/* ============================================================
   Saude Thalis — Design System v2
   Blue & White clinical palette · Refined typography & motion
   Typography: Outfit (display) + DM Sans (body)
   ============================================================ */

/* --- CSS Variables ----------------------------------------- */
:root {
  --color-bg: #f0f4f8;
  --color-bg-warm: #f5f8fc;
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-primary-glow: rgba(37, 99, 235, 0.15);
  --color-accent: #3b82f6;
  --color-accent-light: #eff6ff;
  --color-success: #10b981;
  --color-success-light: #d1fae5;
  --color-warning: #f59e0b;
  --color-warning-light: #fef3c7;
  --color-danger: #ef4444;
  --color-danger-light: #fee2e2;
  --color-white: #ffffff;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-card-shadow: rgba(0, 0, 0, 0.04);
  --sidebar-width: 270px;
  --sidebar-collapsed: 72px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-display: 'Outfit', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.10);
  --shadow-glow: 0 8px 32px rgba(37, 99, 235, 0.20);
}

body[data-theme="dark"] {
  --color-bg: #08111f;
  --color-bg-warm: #0f1b2d;
  --color-primary: #60a5fa;
  --color-primary-dark: #3b82f6;
  --color-primary-light: rgba(96, 165, 250, 0.16);
  --color-primary-glow: rgba(96, 165, 250, 0.22);
  --color-accent: #38bdf8;
  --color-accent-light: rgba(56, 189, 248, 0.14);
  --color-success-light: rgba(16, 185, 129, 0.14);
  --color-warning-light: rgba(245, 158, 11, 0.14);
  --color-danger-light: rgba(239, 68, 68, 0.14);
  --color-text: #e5edf7;
  --color-text-muted: #9fb0c7;
  --color-border: rgba(148, 163, 184, 0.22);
  --color-card-shadow: rgba(0, 0, 0, 0.28);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.22), 0 1px 2px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 14px 46px rgba(0, 0, 0, 0.34);
  --shadow-xl: 0 20px 64px rgba(0, 0, 0, 0.42);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
}

body.modal-open {
  overflow: hidden;
}

body.mobile-menu-open {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

/* Subtle grain texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.025;
  pointer-events: none;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--color-primary-dark);
}

img {
  max-width: 100%;
  display: block;
}

ul, ol {
  list-style: none;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

h1 { font-size: 1.85rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

/* --- Stagger Animation System ----------------------------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

.app-page > *,
.ia-page > * {
  animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.app-page > *:nth-child(1),
.ia-page > *:nth-child(1) { animation-delay: 0.05s; }
.app-page > *:nth-child(2),
.ia-page > *:nth-child(2) { animation-delay: 0.12s; }
.app-page > *:nth-child(3),
.ia-page > *:nth-child(3) { animation-delay: 0.19s; }
.app-page > *:nth-child(4),
.ia-page > *:nth-child(4) { animation-delay: 0.26s; }
.app-page > *:nth-child(5),
.ia-page > *:nth-child(5) { animation-delay: 0.33s; }

/* --- Login Page -------------------------------------------- */
.login-bg {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(37, 99, 235, 0.18) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.14) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 80%, rgba(37, 99, 235, 0.10) 0%, transparent 50%),
    linear-gradient(160deg, #1e3a5f 0%, #1a2f4e 30%, #162340 70%, #1e293b 100%);
}

.login-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.03;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px;
}

.login-bg::after {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  bottom: -200px;
  right: -100px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.1) 0%, transparent 70%);
  pointer-events: none;
}

.login-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  padding: 2.75rem 2.5rem 2.25rem;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  animation: scaleIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) backwards 0.2s;
}

.login-card .login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-brand {
  text-align: center;
  margin-bottom: -0.5rem;
  animation: fadeInUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.login-brand img {
  width: 220px;
  height: auto;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.3));
}

.login-card .login-title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.03em;
}

.login-card .login-subtitle {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.login-card .login-error {
  background: var(--color-danger-light);
  color: var(--color-danger);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: none;
  border-left: 3px solid var(--color-danger);
  animation: fadeInUp 0.3s ease;
}

.login-card .login-error.show {
  display: block;
}

.auth-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0.35rem;
  border-radius: 16px;
  background: rgba(37, 99, 235, 0.08);
  margin-bottom: 1.25rem;
}

.auth-switch button {
  border: none;
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-display);
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.auth-switch button.active {
  background: var(--color-white);
  color: var(--color-primary-dark);
  box-shadow: var(--shadow-sm);
}

.auth-helper {
  margin-top: -0.35rem;
  margin-bottom: 1rem;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* --- Sidebar ----------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-white);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: var(--transition);
  overflow: hidden;
  border-right: 1px solid var(--color-border);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-logo {
  width: 100%;
  transition: var(--transition);
}

.sidebar-logo img {
  width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  filter: none;
}

.sidebar.collapsed .sidebar-logo img {
  border-radius: 6px;
}

.sidebar-brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--color-text);
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar-brand-text {
  opacity: 0;
  pointer-events: none;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1.35rem;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
  position: relative;
}

.sidebar-nav a:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.sidebar-nav a.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-left-color: var(--color-primary);
  font-weight: 600;
}

.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  border-radius: 3px 0 0 3px;
  background: var(--color-primary);
}

.sidebar-nav a svg {
  width: 20px;
  height: 20px;
  min-width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s ease;
}

.sidebar-nav a:hover svg {
  transform: scale(1.08);
}

.sidebar-nav .nav-label {
  opacity: 1;
  transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar-nav .nav-label {
  opacity: 0;
  pointer-events: none;
}

.sidebar-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--color-border);
}

.sidebar-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
  font-family: var(--font-body);
}

.sidebar-toggle:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  transition: transform 0.3s ease;
}

.sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-toggle .toggle-label {
  display: none;
}

/* --- Top Bar ----------------------------------------------- */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: 68px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  z-index: 90;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.sidebar.collapsed ~ .topbar,
.sidebar.collapsed ~ .page-wrapper .topbar {
  left: var(--sidebar-collapsed);
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.topbar-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 14px;
  background: rgba(37, 99, 235, 0.06);
  color: var(--color-primary);
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.topbar-menu-toggle:hover {
  background: var(--color-primary-light);
  transform: translateY(-1px);
}

.topbar-menu-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-mobile-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  border: none;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(3px);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-profile-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid transparent;
  border-radius: 16px;
  background: transparent;
  cursor: pointer;
  transition: var(--transition);
}

.topbar-profile-trigger:hover {
  background: rgba(37, 99, 235, 0.06);
  border-color: rgba(37, 99, 235, 0.1);
}

.topbar-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--color-primary), #1d4ed8);
  color: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
  overflow: hidden;
  position: relative;
}

.topbar-avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.topbar-avatar-initials {
  display: inline-flex;
}

.topbar-username {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--color-text);
}

.topbar-role {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.topbar-user-copy {
  text-align: left;
}

.topbar-logout {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.45rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: flex;
  align-items: center;
}

.topbar-logout:hover {
  background: var(--color-danger-light);
  color: var(--color-danger);
  transform: scale(1.05);
}

.topbar-logout svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.topbar-theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: var(--radius-sm);
  background: rgba(37, 99, 235, 0.06);
  color: var(--color-primary);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.82rem;
  font-weight: 700;
}

.topbar-theme-toggle:hover {
  background: var(--color-primary-light);
  transform: translateY(-1px);
}

#syncToken {
  min-height: 120px;
}

.topbar-theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Page Layout ------------------------------------------- */
.page-content {
  margin-left: var(--sidebar-width);
  padding: 92px 2rem 2.5rem;
  min-height: 100vh;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: calc(100% - var(--sidebar-width));
}

.sidebar.collapsed ~ .page-content {
  margin-left: var(--sidebar-collapsed);
  max-width: calc(100% - var(--sidebar-collapsed));
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.page-header p {
  color: var(--color-text-muted);
  margin-top: 0.25rem;
  font-size: 0.925rem;
}

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

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.3s ease;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.03), rgba(59, 130, 246, 0.02));
  pointer-events: none;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

.card:hover::before {
  opacity: 1;
}

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

.card-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
}

/* KPI Cards */
.card-kpi {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.35rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: 1px solid var(--color-border);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.card-kpi::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card-kpi:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.card-kpi:hover::after {
  opacity: 1;
}

.card-kpi.kpi-success::after { background: var(--color-success); }
.card-kpi.kpi-warning::after { background: var(--color-warning); }
.card-kpi.kpi-danger::after  { background: var(--color-danger); }

.card-kpi .kpi-label {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-kpi .kpi-value {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--color-text);
  letter-spacing: -0.03em;
}

.card-kpi .kpi-trend {
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.card-kpi .kpi-trend.up   { color: var(--color-success); }
.card-kpi .kpi-trend.down { color: var(--color-danger); }

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  background: linear-gradient(135deg, #1e3a5f, #1d4ed8);
  color: var(--color-white);
  padding: 0.8rem 1rem;
  font-family: var(--font-display);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

thead th:first-child { border-radius: var(--radius-md) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-md) 0 0; }

tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

tbody tr {
  transition: background 0.2s ease;
}

tbody tr:nth-child(even) {
  background: var(--color-bg-warm);
}

tbody tr:hover {
  background: var(--color-primary-light);
}

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

tbody tr:last-child td:first-child { border-radius: 0 0 0 var(--radius-md); }
tbody tr:last-child td:last-child  { border-radius: 0 0 var(--radius-md) 0; }

/* --- Filter Bar -------------------------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.filter-group label {
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-group select,
.filter-group input[type="text"],
.filter-group input[type="date"],
.filter-group input[type="search"] {
  padding: 0.55rem 0.8rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--color-white);
  min-width: 160px;
  transition: var(--transition);
}

.filter-group select:focus,
.filter-group input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

/* --- Forms ------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}

.form-group label {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.form-group .form-hint {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.form-control {
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--color-text);
  background: var(--color-white);
  transition: var(--transition);
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
  background: var(--color-white);
}

.form-control::placeholder {
  color: #9ca3af;
}

.form-control:disabled {
  background: var(--color-bg);
  cursor: not-allowed;
  opacity: 0.7;
}

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

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

/* --- Buttons ----------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.35rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
  line-height: 1.4;
  letter-spacing: -0.01em;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.btn:hover::after {
  opacity: 1;
}

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

.btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), #1d4ed8);
  color: var(--color-white);
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--color-primary-dark), #1e3a5f);
  border-color: var(--color-primary-dark);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, var(--color-success), #047857);
  color: var(--color-white);
  border-color: var(--color-success);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
  background: linear-gradient(135deg, #047857, #065f46);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.25);
}

.btn-danger {
  background: linear-gradient(135deg, var(--color-danger), #b91c1c);
  color: var(--color-white);
  border-color: var(--color-danger);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #b91c1c, #991b1b);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.25);
}

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border-color: rgba(37, 99, 235, 0.3);
}

.btn-outline:hover {
  background: var(--color-primary);
  color: var(--color-white);
  box-shadow: var(--shadow-glow);
}

.btn-outline-danger {
  background: transparent;
  color: var(--color-danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-outline-danger:hover {
  background: var(--color-danger);
  color: var(--color-white);
}

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

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

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* --- Badges ------------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-primary {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.badge-success {
  background: var(--color-success-light);
  color: var(--color-success);
}

.badge-warning {
  background: var(--color-warning-light);
  color: #92400e;
}

.badge-danger {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.badge-muted {
  background: #f0f4f8;
  color: var(--color-text-muted);
}

/* --- Charts ------------------------------------------------ */
.chart-container {
  position: relative;
  width: 100%;
  padding: 1rem 0;
}

.chart-container canvas {
  width: 100% !important;
  max-height: 360px;
}

/* --- IA Page ----------------------------------------------- */
.ia-page {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.ia-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.95fr);
  gap: 1.25rem;
  padding: 1.75rem;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(ellipse at 10% 80%, rgba(37, 99, 235, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 20%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
    linear-gradient(135deg, #eff6ff 0%, var(--color-bg-warm) 58%, #eff6ff 100%);
  border: 1px solid rgba(37, 99, 235, 0.1);
  overflow: hidden;
  position: relative;
}

.ia-hero::after {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  top: -130px;
  right: -80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.1) 0%, transparent 70%);
  pointer-events: none;
}

.ia-hero-copy,
.ia-status-card {
  position: relative;
  z-index: 1;
}

.ia-hero-badge {
  margin-bottom: 0.9rem;
}

.ia-hero-copy h1 {
  max-width: 12ch;
  font-size: clamp(2rem, 3vw, 2.75rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.ia-hero-copy p {
  max-width: 62ch;
  margin-top: 1rem;
  color: var(--color-text-muted);
  font-size: 1rem;
}

.ia-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.ia-status-card {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
}

.ia-status-head,
.ia-status-indicator,
.ia-section-head,
.chat-composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.ia-status-indicator {
  justify-content: flex-start;
}

.ia-status-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #d1d5db;
  box-shadow: 0 0 0 5px rgba(209, 213, 219, 0.3);
  transition: all 0.4s ease;
}

.ia-status-dot.is-ready {
  background: var(--color-success);
  box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.15);
}

.ia-status-dot.is-loading {
  background: var(--color-accent);
  box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.15);
  animation: status-pulse 1.3s ease-in-out infinite;
}

.ia-status-dot.is-offline {
  background: var(--color-danger);
  box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.12);
}

.ia-status-label,
.ia-section-kicker {
  display: block;
  margin-bottom: 0.18rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary);
}

.ia-status-title {
  display: block;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.ia-status-description {
  margin-top: 0.9rem;
  color: var(--color-text-muted);
  font-size: 0.92rem;
}

.ia-provider-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.ia-provider-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--color-primary-dark);
  border: 1px solid rgba(37, 99, 235, 0.1);
  font-size: 0.8rem;
  font-weight: 600;
  transition: var(--transition);
}

.ia-provider-pill strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-primary-dark);
  font-size: 0.72rem;
  font-weight: 800;
}

.ia-provider-pill small {
  color: var(--color-text-muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.ia-provider-pill em {
  font-style: normal;
  color: var(--color-success);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ia-provider-pill.is-preferred {
  background: var(--color-success-light);
  color: #065f46;
  border-color: rgba(16, 185, 129, 0.18);
}

.ia-provider-pill.is-preferred strong {
  background: rgba(16, 185, 129, 0.12);
  color: #065f46;
}

.ia-provider-pill.is-loading {
  background: var(--color-warning-light);
  color: #92400e;
  border-color: rgba(245, 158, 11, 0.15);
}

.ia-provider-pill.is-warning {
  background: var(--color-danger-light);
  color: #991b1b;
  border-color: rgba(239, 68, 68, 0.15);
}

.ia-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(290px, 0.85fr);
  gap: 1.25rem;
  align-items: start;
}

.ia-main,
.ia-sidebar {
  display: grid;
  gap: 1.25rem;
}

.ia-analysis-card,
.ia-chat-card,
.ia-side-card {
  border-color: rgba(37, 99, 235, 0.06);
}

.ia-section-copy {
  margin-top: 0.35rem;
  color: var(--color-text-muted);
  font-size: 0.92rem;
}

.analysis-content {
  min-height: 210px;
}

.analysis-prose h2,
.analysis-prose h3,
.analysis-prose h4,
.chat-bubble .bubble-content h2,
.chat-bubble .bubble-content h3,
.chat-bubble .bubble-content h4 {
  margin: 1rem 0 0.45rem;
  font-weight: 700;
  line-height: 1.3;
}

.analysis-prose h2:first-child,
.analysis-prose h3:first-child,
.analysis-prose h4:first-child,
.chat-bubble .bubble-content h2:first-child,
.chat-bubble .bubble-content h3:first-child,
.chat-bubble .bubble-content h4:first-child {
  margin-top: 0;
}

.analysis-prose p,
.chat-bubble .bubble-content p {
  margin: 0 0 0.75rem;
}

.analysis-prose p:last-child,
.chat-bubble .bubble-content p:last-child {
  margin-bottom: 0;
}

.analysis-prose ul,
.analysis-prose ol,
.chat-bubble .bubble-content ul,
.chat-bubble .bubble-content ol {
  margin: 0.6rem 0;
  padding-left: 1.25rem;
}

.analysis-prose ul,
.chat-bubble .bubble-content ul {
  list-style: disc;
}

.analysis-prose ol,
.chat-bubble .bubble-content ol {
  list-style: decimal;
}

.analysis-prose li,
.chat-bubble .bubble-content li {
  margin-bottom: 0.35rem;
}

.analysis-prose code,
.chat-bubble .bubble-content code {
  background: rgba(37, 99, 235, 0.06);
  border-radius: 6px;
  padding: 0.12rem 0.4rem;
  font-size: 0.88em;
}

.analysis-prose strong,
.chat-bubble .bubble-content strong {
  font-weight: 700;
}

.analysis-meta,
.ia-analysis-footer {
  margin-top: 1rem;
}

.analysis-provider {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-size: 0.78rem;
  font-weight: 700;
}

.ia-analysis-footer {
  padding-top: 0.9rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0 1.15rem;
}

.quick-prompt {
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 999px;
  background: #eff6ff;
  color: var(--color-primary-dark);
  padding: 0.6rem 1rem;
  font-family: var(--font-display);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.quick-prompt:hover {
  background: var(--color-primary);
  color: var(--color-white);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

/* --- Chat -------------------------------------------------- */
.chat-container {
  display: flex;
  flex-direction: column;
  min-height: 620px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(37, 99, 235, 0.04) 0%, transparent 60%),
    linear-gradient(180deg, #f8fbff 0%, #eff6ff 100%);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid rgba(37, 99, 235, 0.08);
}

.chat-container-advanced {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-empty-state {
  margin: auto;
  max-width: 440px;
  text-align: center;
  padding: 2.5rem;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.9);
  border: 1px dashed rgba(37, 99, 235, 0.2);
  box-shadow: var(--shadow-lg);
}

.chat-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-primary), #1d4ed8);
  color: var(--color-white);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
}

.chat-empty-state p {
  margin-top: 0.6rem;
  color: var(--color-text-muted);
}

.chat-message-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: chat-rise 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-message-row.is-user {
  flex-direction: row-reverse;
}

.chat-message-stack {
  width: min(100%, 760px);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.chat-message-row.is-user .chat-meta {
  justify-content: flex-end;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}

.chat-avatar.is-ai {
  background: linear-gradient(135deg, var(--color-primary-light), #bfdbfe);
  color: var(--color-primary-dark);
}

.chat-avatar.is-user {
  background: linear-gradient(135deg, var(--color-primary), #1d4ed8);
  color: var(--color-white);
}

.chat-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  padding: 0 0.15rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.chat-provider-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.48rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--color-primary-dark);
  font-weight: 700;
}

.chat-bubble {
  max-width: 100%;
  padding: 1rem 1.15rem;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  line-height: 1.65;
  word-break: break-word;
  box-shadow: var(--shadow-md);
}

.chat-bubble.user {
  background: linear-gradient(135deg, var(--color-primary), #1d4ed8);
  color: var(--color-white);
  border-bottom-right-radius: 6px;
}

.chat-bubble.ai {
  background: rgba(255, 255, 255, 0.96);
  color: var(--color-text);
  border: 1px solid rgba(37, 99, 235, 0.1);
  border-bottom-left-radius: 6px;
}

.bubble-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.85rem;
}

.copy-response-button {
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  border-radius: 999px;
  padding: 0.42rem 0.7rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.copy-response-button:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: #eff6ff;
}

.chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 16px;
  border: 1px solid rgba(37, 99, 235, 0.1);
  box-shadow: var(--shadow-sm);
}

.chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-primary);
  animation: typing 1.4s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-5px); }
}

@keyframes status-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes chat-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-input {
  padding: 1rem 1rem 1.1rem;
  border-top: 1px solid rgba(37, 99, 235, 0.08);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.chat-composer {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-composer textarea {
  width: 100%;
  min-height: 60px;
  max-height: 160px;
  resize: none;
  padding: 0.9rem 1rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-warm);
  color: var(--color-text);
  line-height: 1.55;
  transition: var(--transition);
  font-family: var(--font-body);
}

.chat-composer textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--color-primary-glow);
  background: var(--color-white);
}

.chat-composer textarea::placeholder {
  color: #9ca3af;
}

.chat-composer.is-busy textarea {
  opacity: 0.72;
}

.chat-composer-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.ia-side-card h3 {
  margin: 0.35rem 0 0.85rem;
  font-size: 1.05rem;
}

.ia-tip-list,
.ia-check-list {
  display: grid;
  gap: 0.85rem;
}

.ia-tip-list li,
.ia-check-list li {
  position: relative;
  padding-left: 1.4rem;
  color: var(--color-text-muted);
  font-size: 0.92rem;
}

.ia-tip-list li::before,
.ia-check-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.46rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.ia-tip-list li::before {
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
}

.ia-check-list li::before {
  background: var(--color-success);
}

/* --- Shared Page Sections --------------------------------- */
.app-page {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.app-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.95fr);
  gap: 1.25rem;
  padding: 1.75rem;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(ellipse at 10% 80%, rgba(37, 99, 235, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 20%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
    linear-gradient(135deg, #eff6ff 0%, var(--color-bg-warm) 58%, #eff6ff 100%);
  border: 1px solid rgba(37, 99, 235, 0.1);
  overflow: hidden;
  position: relative;
}

.app-hero::after {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  top: -130px;
  right: -80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.1) 0%, transparent 70%);
  pointer-events: none;
}

.app-hero-compact .app-hero-copy h1 {
  max-width: 13ch;
  font-size: clamp(1.9rem, 3vw, 2.55rem);
}

.app-hero-copy,
.hero-summary-card {
  position: relative;
  z-index: 1;
}

.app-hero-copy h1 {
  margin-top: 0.85rem;
  font-size: clamp(2rem, 3vw, 2.8rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.app-hero-copy p {
  max-width: 62ch;
  margin-top: 1rem;
  color: var(--color-text-muted);
  font-size: 0.98rem;
}

.app-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.hero-summary-card {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
}

.hero-summary-label {
  display: block;
  margin-bottom: 0.9rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary);
}

.hero-summary-copy {
  margin-top: 0.85rem;
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.hero-summary-grid,
.summary-grid,
.stats-strip {
  display: grid;
  gap: 0.95rem;
}

.hero-summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hero-summary-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(240, 253, 250, 0.7);
  border: 1px solid rgba(37, 99, 235, 0.08);
  transition: var(--transition);
}

.hero-summary-item:hover {
  background: rgba(240, 253, 250, 0.95);
  transform: translateY(-1px);
}

.hero-summary-item strong {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--color-text);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.hero-summary-item span {
  color: var(--color-text-muted);
  font-size: 0.78rem;
}

.registro-recommendation-card {
  min-width: min(100%, 32rem);
}

.registro-recommendations {
  display: grid;
  gap: 0.7rem;
}

.registro-recommendation-item {
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(37, 99, 235, 0.1);
  background: rgba(239, 246, 255, 0.78);
  color: var(--color-text);
  font-size: 0.88rem;
  line-height: 1.45;
}

.registro-recommendation-item.info {
  border-color: rgba(37, 99, 235, 0.18);
  background: rgba(239, 246, 255, 0.84);
}

.registro-recommendation-item.success {
  border-color: rgba(16, 185, 129, 0.24);
  background: rgba(236, 253, 245, 0.9);
}

.registro-recommendation-item.warning {
  border-color: rgba(245, 158, 11, 0.28);
  background: rgba(255, 251, 235, 0.92);
}

.registro-recommendation-item.danger {
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(254, 242, 242, 0.92);
}

body[data-theme="dark"] .sidebar,
body[data-theme="dark"] .topbar,
body[data-theme="dark"] .card,
body[data-theme="dark"] .card-kpi,
body[data-theme="dark"] .filter-bar,
body[data-theme="dark"] .summary-card,
body[data-theme="dark"] .chart-card,
body[data-theme="dark"] .ia-analysis-card,
body[data-theme="dark"] .ia-chat-card,
body[data-theme="dark"] .ia-side-card,
body[data-theme="dark"] .hero-summary-card,
body[data-theme="dark"] .profile-modal {
  background: rgba(15, 27, 45, 0.94);
  border-color: var(--color-border);
}

body[data-theme="dark"] .topbar {
  background: rgba(8, 17, 31, 0.9);
}

body[data-theme="dark"] .app-hero,
body[data-theme="dark"] .ia-hero,
body[data-theme="dark"] .login-card {
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.16), transparent 36%),
    linear-gradient(135deg, #0f1b2d 0%, #08111f 100%);
  border-color: var(--color-border);
}

body[data-theme="dark"] .form-control,
body[data-theme="dark"] .filter-group select,
body[data-theme="dark"] .filter-group input[type="text"],
body[data-theme="dark"] .filter-group input[type="date"],
body[data-theme="dark"] .filter-group input[type="search"] {
  background: rgba(8, 17, 31, 0.86);
  border-color: var(--color-border);
  color: var(--color-text);
}

body[data-theme="dark"] .form-control:focus {
  background: rgba(8, 17, 31, 0.96);
}

body[data-theme="dark"] .form-control::placeholder {
  color: #64748b;
}

body[data-theme="dark"] tbody tr:nth-child(even),
body[data-theme="dark"] .hero-summary-item {
  background: rgba(30, 41, 59, 0.46);
}

body[data-theme="dark"] tbody tr:hover,
body[data-theme="dark"] .sidebar-nav a:hover,
body[data-theme="dark"] .sidebar-nav a.active {
  background: rgba(96, 165, 250, 0.16);
}

body[data-theme="dark"] .registro-recommendation-item.info {
  border-color: rgba(96, 165, 250, 0.3);
  background: rgba(30, 64, 175, 0.18);
}

body[data-theme="dark"] .registro-recommendation-item.success {
  border-color: rgba(16, 185, 129, 0.32);
  background: rgba(6, 95, 70, 0.24);
}

body[data-theme="dark"] .registro-recommendation-item.warning {
  border-color: rgba(245, 158, 11, 0.36);
  background: rgba(120, 53, 15, 0.28);
}

body[data-theme="dark"] .registro-recommendation-item.danger {
  border-color: rgba(248, 113, 113, 0.36);
  background: rgba(127, 29, 29, 0.28);
}

.section-shell {
  display: grid;
  gap: 1rem;
}

.section-shell-head,
.chart-card-head,
.form-section-head,
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
}

.section-shell-head h2,
.table-toolbar h2,
.form-section-head h2 {
  font-size: 1.18rem;
}

.section-shell-kicker {
  display: block;
  margin-bottom: 0.24rem;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-primary);
  opacity: 0.85;
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.summary-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.summary-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  opacity: 0;
  transition: opacity 0.3s ease;
}

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

.summary-card:hover::before {
  opacity: 1;
}

.summary-label {
  display: inline-block;
  margin-bottom: 0.45rem;
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary);
}

.summary-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.55rem;
  line-height: 1.05;
  color: var(--color-text);
  letter-spacing: -0.03em;
}

.summary-card p {
  margin-top: 0.5rem;
  font-size: 0.86rem;
  color: var(--color-text-muted);
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.03);
  padding: 0.3rem;
  border-radius: var(--radius-md);
}

.periodo-btn {
  border-color: transparent !important;
  background: transparent !important;
  color: var(--color-text-muted) !important;
  border-radius: var(--radius-sm) !important;
}

.periodo-btn:hover {
  background: rgba(37, 99, 235, 0.06) !important;
  color: var(--color-primary) !important;
}

.periodo-btn.active {
  background: var(--color-primary) !important;
  color: var(--color-white) !important;
  box-shadow: var(--shadow-glow) !important;
}

.chart-grid {
  align-items: stretch;
}

.chart-card {
  border-radius: var(--radius-xl);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

.chart-card:hover {
  box-shadow: var(--shadow-md);
}

.chart-card p,
.form-section-head p,
.table-toolbar p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.chart-card-tall {
  min-height: 460px;
}

.chart-container-lg {
  min-height: 260px;
}

.chart-container-xl {
  min-height: 340px;
}

.stats-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card-kpi {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-kpi .kpi-value {
  margin-top: 0.15rem;
}

.kpi-subtext {
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

.empty-shell {
  display: grid;
}

.empty-panel {
  text-align: center;
  padding: 2.5rem 2rem;
  border-radius: var(--radius-xl);
  border: 2px dashed rgba(37, 99, 235, 0.15);
  box-shadow: none;
  background: var(--color-bg-warm);
}

.empty-panel h3 {
  font-size: 1.2rem;
}

.empty-panel p {
  max-width: 44ch;
  margin: 0.75rem auto 1.2rem;
  color: var(--color-text-muted);
}

.filter-shell {
  border-radius: var(--radius-xl);
  border-color: var(--color-border);
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.filter-bar-modern {
  padding: 0;
  margin-bottom: 0;
  box-shadow: none;
  background: transparent;
}

.filter-group-wide {
  flex: 1 1 280px;
}

.table-card {
  border-radius: var(--radius-xl);
  border-color: var(--color-border);
}

.table-toolbar {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1rem;
}

.table-toolbar p {
  margin: 0;
}

.table-empty-cell {
  text-align: center;
  color: var(--color-text-muted);
  padding: 1.3rem !important;
}

.data-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.data-badge.is-dose {
  background: #eff6ff;
  color: var(--color-primary-dark);
}

.data-badge.is-appetite {
  background: #eff6ff;
  color: #92400e;
}

.effect-snippet {
  display: inline-block;
  max-width: 280px;
  color: var(--color-text-muted);
}

.table-actions-cell {
  min-width: 150px;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.metric-card {
  padding: 1.25rem;
}

.metric-card strong {
  display: block;
  margin: 0.5rem 0 0.35rem;
  font-size: 1.05rem;
  color: var(--text-strong, #14213d);
}

.metric-card p {
  margin: 0;
  color: var(--text-muted, #52607a);
}

.stack-list {
  display: grid;
  gap: 0.75rem;
}

.contact-list-item {
  display: grid;
  gap: 0.3rem;
  width: 100%;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(20, 33, 61, 0.12);
  border-radius: 18px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.contact-list-item:hover,
.contact-list-item.active {
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.contact-list-item strong,
.contact-list-item span,
.contact-list-item small,
.contact-list-item em {
  display: block;
}

.contact-list-item span,
.contact-list-item small {
  color: var(--text-muted, #52607a);
}

.contact-list-item em {
  color: #b45309;
  font-style: normal;
  font-weight: 700;
}

.chat-messages-compact {
  min-height: 260px;
  max-height: 520px;
  padding: 1rem;
  border: 1px solid rgba(20, 33, 61, 0.08);
  border-radius: 22px;
  background: rgba(248, 250, 252, 0.7);
  overflow-y: auto;
}

.form-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.75fr);
  gap: 1.25rem;
  align-items: start;
}

.form-layout-single {
  display: block;
}

.form-main,
.form-sidebar {
  display: grid;
  gap: 1.25rem;
}

.form-section-card {
  border-radius: var(--radius-xl);
  border-color: var(--color-border);
}

.form-section-head {
  margin-bottom: 1rem;
}

.form-section-head p {
  margin: 0;
  max-width: 44ch;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 0.2rem;
}

.sticky-card {
  position: sticky;
  top: 88px;
}

/* --- Profile Modal ---------------------------------------- */
.profile-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(10px);
}

.profile-modal {
  width: min(920px, 100%);
  max-height: calc(100vh - 3rem);
  overflow: auto;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow-xl);
  padding: 1.5rem;
}

.profile-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.profile-modal-head p,
.profile-card-copy {
  color: var(--color-text-muted);
  font-size: 0.92rem;
  margin-top: 0.35rem;
}

.profile-modal-close {
  border: 1px solid var(--color-border);
  background: var(--color-white);
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}

.profile-modal-close:hover {
  color: var(--color-text);
  border-color: rgba(37, 99, 235, 0.25);
  background: var(--color-bg-warm);
}

.profile-modal-alert {
  margin-bottom: 1rem;
}

.profile-modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 1rem;
}

.profile-card {
  border-radius: var(--radius-xl);
}

.profile-form-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.profile-photo-section,
.profile-fields-section,
.profile-password-form {
  display: grid;
  gap: 1rem;
}

.profile-photo-preview {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.14), rgba(29, 78, 216, 0.04));
  border: 1px dashed rgba(37, 99, 235, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.profile-photo-preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-photo-preview-initials {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 800;
  color: var(--color-primary-dark);
  letter-spacing: -0.06em;
}

/* --- Alerts ------------------------------------------------ */
.alert {
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-left: 4px solid transparent;
  animation: fadeInUp 0.3s ease;
}

.alert-success {
  background: var(--color-success-light);
  color: #065f46;
  border-left-color: var(--color-success);
}

.alert-danger {
  background: var(--color-danger-light);
  color: #991b1b;
  border-left-color: var(--color-danger);
}

.alert-warning {
  background: var(--color-warning-light);
  color: #92400e;
  border-left-color: var(--color-warning);
}

.alert-info {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  border-left-color: var(--color-primary);
}

/* --- Grid Layouts ------------------------------------------ */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }

  .app-hero,
  .ia-hero,
  .ia-layout {
    grid-template-columns: 1fr;
  }

  .summary-grid,
  .stats-strip,
  .form-layout,
  .profile-modal-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ia-sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .summary-grid,
  .stats-strip,
  .form-layout,
  .profile-modal-body,
  .profile-form-grid {
    grid-template-columns: 1fr;
  }

  .ia-sidebar {
    grid-template-columns: 1fr;
  }

  .chat-container {
    min-height: 560px;
  }

  .sticky-card {
    position: static;
  }
}

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

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.3);
  }

  .topbar-menu-toggle {
    display: inline-flex;
  }

  .topbar {
    left: 0 !important;
    padding: 0 1rem;
  }

  .page-content {
    margin-left: 0 !important;
    max-width: 100% !important;
    padding: 84px 1rem 1.5rem;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .login-card {
    margin: 1rem;
    padding: 2rem 1.5rem;
  }

  .ia-hero {
    padding: 1.25rem;
    border-radius: var(--radius-lg);
  }

  .app-hero {
    padding: 1.25rem;
    border-radius: var(--radius-lg);
  }

  .hero-summary-grid {
    grid-template-columns: 1fr;
  }

  .app-hero-copy h1,
  .ia-hero-copy h1 {
    max-width: 100%;
  }

  .app-hero-actions,
  .ia-hero-actions,
  .ia-status-head,
  .ia-section-head,
  .chat-composer-footer,
  .section-shell-head,
  .chart-card-head,
  .form-section-head,
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .profile-modal {
    padding: 1.1rem;
  }

  .profile-modal-head {
    flex-direction: column;
  }

  .topbar-profile-trigger {
    min-width: 0;
  }

  .topbar-user-copy {
    display: none;
  }

  .quick-prompts {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.3rem;
  }

  .quick-prompt {
    flex: 0 0 auto;
  }

  .chat-container {
    min-height: 520px;
  }

  .chat-message-row,
  .chat-message-row.is-user {
    flex-direction: column;
  }

  .chat-message-row.is-user .chat-meta {
    justify-content: flex-start;
  }

  .chat-message-stack {
    width: 100%;
  }

  .chat-input {
    padding: 0.9rem;
  }

  .filter-actions,
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-composer .btn {
    width: 100%;
  }

  .app-hero .btn,
  .form-actions .btn,
  .filter-actions .btn {
    width: 100%;
  }
}

/* --- Loading Skeleton -------------------------------------- */
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f0f4f8 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
  border-radius: var(--radius-sm);
  min-height: 1rem;
}

.skeleton-text {
  height: 0.9rem;
  margin-bottom: 0.5rem;
  width: 100%;
}

.skeleton-text:last-child {
  width: 65%;
}

.skeleton-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-card {
  height: 120px;
}

/* --- Utilities --------------------------------------------- */
.text-primary { color: var(--color-primary) !important; }
.text-success { color: var(--color-success) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-danger  { color: var(--color-danger) !important; }
.text-muted   { color: var(--color-text-muted) !important; }
.text-white   { color: var(--color-white) !important; }

.bg-primary-light { background: var(--color-primary-light) !important; }
.bg-success-light { background: var(--color-success-light) !important; }
.bg-warning-light { background: var(--color-warning-light) !important; }
.bg-danger-light  { background: var(--color-danger-light) !important; }

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.fs-sm   { font-size: 0.82rem; }
.fs-base { font-size: 0.925rem; }
.fs-lg   { font-size: 1.1rem; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.35rem !important; }
.mt-2 { margin-top: 0.75rem !important; }
.mt-3 { margin-top: 1.25rem !important; }
.mt-4 { margin-top: 2rem !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.35rem !important; }
.mb-2 { margin-bottom: 0.75rem !important; }
.mb-3 { margin-bottom: 1.25rem !important; }
.mb-4 { margin-bottom: 2rem !important; }

.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }

.p-0 { padding: 0 !important; }
.p-1 { padding: 0.35rem !important; }
.p-2 { padding: 0.75rem !important; }
.p-3 { padding: 1.25rem !important; }
.p-4 { padding: 2rem !important; }

.d-flex { display: flex; }
.d-grid { display: grid; }
.d-none { display: none; }
.d-block { display: block; }

.align-center  { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.35rem; }
.gap-2 { gap: 0.75rem; }
.gap-3 { gap: 1.25rem; }

.text-center { text-align: center; }
.text-right  { text-align: right; }

.w-100 { width: 100%; }
.rounded { border-radius: var(--radius-md); }
.shadow  { box-shadow: var(--shadow-sm); }
.border  { border: 1px solid var(--color-border); }

.overflow-auto { overflow: auto; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* --- Scrollbar --------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* --- Print ------------------------------------------------- */
@media print {
  .sidebar,
  .topbar,
  .filter-bar,
  .btn,
  .chat-container {
    display: none !important;
  }

  .page-content {
    margin-left: 0 !important;
    padding: 0 !important;
  }

  body {
    background: white;
  }

  body::before {
    display: none;
  }
}

.sleep-hero {
  background:
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.16), transparent 34%),
    radial-gradient(circle at left bottom, rgba(37, 99, 235, 0.1), transparent 28%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(239, 246, 255, 0.96));
}

.sleep-side-card {
  border-radius: var(--radius-xl);
}

.sleep-history-card {
  border-radius: var(--radius-xl);
  display: grid;
  gap: 1rem;
}

.activity-hero {
  background:
    radial-gradient(circle at top left, rgba(16, 185, 129, 0.14), transparent 34%),
    radial-gradient(circle at right center, rgba(59, 130, 246, 0.14), transparent 32%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(236, 253, 245, 0.96));
}

.activity-side-card {
  border-radius: var(--radius-xl);
}

.activity-history-item {
  border-color: rgba(16, 185, 129, 0.16);
}

body[data-theme="dark"] .activity-hero {
  background:
    radial-gradient(circle at top left, rgba(16, 185, 129, 0.16), transparent 34%),
    radial-gradient(circle at right center, rgba(56, 189, 248, 0.14), transparent 32%),
    linear-gradient(135deg, rgba(15, 27, 45, 0.96), rgba(8, 17, 31, 0.98));
}

body[data-theme="dark"] .activity-history-item {
  border-color: rgba(52, 211, 153, 0.18);
}

.sleep-history-list {
  display: grid;
  gap: 0.9rem;
}

.sleep-history-item {
  border: 1px solid rgba(37, 99, 235, 0.14);
  border-radius: 20px;
  padding: 1rem;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(255, 255, 255, 0.98));
  display: grid;
  gap: 0.75rem;
}

.sleep-history-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.sleep-history-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem 0.9rem;
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.sleep-history-metrics strong {
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 0.95rem;
}

.sleep-history-notes {
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.sleep-history-empty {
  border: 1px dashed rgba(37, 99, 235, 0.18);
  border-radius: 18px;
  padding: 1rem;
  text-align: center;
  color: var(--color-text-muted);
  background: var(--color-bg-warm);
}

body[data-theme="dark"] .sleep-hero {
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.16), transparent 34%),
    radial-gradient(circle at left bottom, rgba(96, 165, 250, 0.12), transparent 26%),
    linear-gradient(135deg, rgba(15, 27, 45, 0.96), rgba(8, 17, 31, 0.96));
}

body[data-theme="dark"] .sleep-history-item {
  background: linear-gradient(180deg, rgba(15, 27, 45, 0.92), rgba(8, 17, 31, 0.98));
  border-color: rgba(96, 165, 250, 0.18);
}

@media (max-width: 768px) {
  .sleep-history-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .sleep-history-metrics {
    grid-template-columns: 1fr;
  }
}
