/* ============================================================
   ATLAS DESIGN SYSTEM — v1.0
   Single source of truth for all Atlas surfaces.
   No inline styles. No frameworks. No preprocessors.
   ============================================================ */

/* --- 1. CSS Custom Properties (Tokens) --- */

:root {
  /* 2.1 Background Layers */
  --atlas-bg-base:        #0a0a0a;
  --atlas-bg-surface:     #111111;
  --atlas-bg-elevated:    #1a1a1a;
  --atlas-bg-overlay:     rgba(0, 0, 0, 0.7);
  --atlas-bg-input:       #161616;

  /* 2.2 Text Colors */
  --atlas-text-primary:   #f5f5f5;
  --atlas-text-secondary: #a3a3a3;
  --atlas-text-tertiary:  #6b6b6b;
  --atlas-text-disabled:  #404040;

  /* 2.3 Accent / Brand — "Islay Amber" */
  --atlas-accent:         #d4a04a;
  --atlas-accent-hover:   #e0b060;
  --atlas-accent-pressed: #b8882e;
  --atlas-accent-subtle:  rgba(212, 160, 74, 0.10);
  --atlas-accent-border:  rgba(212, 160, 74, 0.25);

  /* 2.4 Status Colors */
  --atlas-status-success:        #22c55e;
  --atlas-status-success-bg:     rgba(34, 197, 94, 0.10);
  --atlas-status-success-border: rgba(34, 197, 94, 0.25);

  --atlas-status-warning:        #eab308;
  --atlas-status-warning-bg:     rgba(234, 179, 8, 0.10);
  --atlas-status-warning-border: rgba(234, 179, 8, 0.25);

  --atlas-status-danger:         #ef4444;
  --atlas-status-danger-bg:      rgba(239, 68, 68, 0.10);
  --atlas-status-danger-border:  rgba(239, 68, 68, 0.25);

  --atlas-status-info:           #60a5fa;
  --atlas-status-info-bg:        rgba(96, 165, 250, 0.10);
  --atlas-status-info-border:    rgba(96, 165, 250, 0.25);

  /* 2.5 Borders */
  --atlas-border-default: #1f1f1f;
  --atlas-border-subtle:  #161616;
  --atlas-border-strong:  #2a2a2a;

  /* 2.6 Chart / Data Palette */
  --atlas-chart-1: #d4a04a;
  --atlas-chart-2: #60a5fa;
  --atlas-chart-3: #a78bfa;
  --atlas-chart-4: #34d399;
  --atlas-chart-5: #f472b6;
  --atlas-chart-6: #fbbf24;
  --atlas-chart-7: #94a3b8;

  /* 3.1 Font Stack */
  --atlas-font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display",
                       "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --atlas-font-mono:   "SF Mono", ui-monospace, "Cascadia Code",
                       "Fira Code", monospace;

  /* 3.2 Type Scale */
  --text-xs:   0.6875rem;
  --text-sm:   0.8125rem;
  --text-base: 0.9375rem;
  --text-lg:   1.0625rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  2rem;
  --text-4xl:  3rem;

  /* 3.3 Font Weights */
  --weight-normal:   400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  /* 3.4 Line Heights */
  --leading-tight:  1.2;
  --leading-normal: 1.5;
  --leading-loose:  1.7;

  /* 3.5 Letter Spacing */
  --tracking-tight:  -0.01em;
  --tracking-normal:  0;
  --tracking-wide:    0.04em;

  /* 4. Spacing System (4px base) */
  --space-1:   4px;
  --space-2:   8px;
  --space-3:   12px;
  --space-4:   16px;
  --space-5:   20px;
  --space-6:   24px;
  --space-8:   32px;
  --space-10:  40px;
  --space-12:  48px;
  --space-16:  64px;

  /* 7.2 Duration Scale */
  --duration-fast:   100ms;
  --duration-normal: 200ms;
  --duration-slow:   300ms;
  --duration-data:   400ms;

  /* 7.3 Easing */
  --ease-default: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out:     cubic-bezier(0, 0, 0.2, 1);
  --ease-in:      cubic-bezier(0.4, 0, 1, 1);
}


/* --- 2. Base Reset --- */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--atlas-bg-base);
  color: var(--atlas-text-primary);
  font-family: var(--atlas-font-family);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
}

a {
  color: var(--atlas-accent);
  text-decoration: none;
}

a:hover {
  color: var(--atlas-accent-hover);
}

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

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

ul, ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  width: 100%;
}


/* --- 3. Focus & Accessibility --- */

:focus-visible {
  outline: 2px solid var(--atlas-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}


/* --- 4. Atlas Logomark --- */

.atlas-logo {
  display: inline-block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M12 2L3 7v10l9 5 9-5V7l-9-5z' stroke='%23d4a04a' stroke-width='1.5' fill='none'/%3E%3Cpath d='M12 6l-5 3v6l5 3 5-3V9l-5-3z' fill='%23d4a04a' opacity='0.3'/%3E%3Cpath d='M12 8.5l-3 1.8v3.4l3 1.8 3-1.8v-3.4l-3-1.8z' fill='%23d4a04a'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.atlas-logo--sm {
  width: 16px;
  height: 16px;
}


/* --- 5. Surface Layout --- */

.atlas-surface {
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  min-height: 100vh;
  min-height: 100dvh;
}

.atlas-content {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-4);
  padding-bottom: calc(var(--space-16) + env(safe-area-inset-bottom));
}

.atlas-content--wide {
  max-width: 1200px;
}

.atlas-content--full {
  max-width: 100%;
}

.atlas-content--medium {
  max-width: 960px;
}

.atlas-content--chat {
  max-width: 768px;
}


/* --- 6. Top Navigation --- */

.atlas-top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 44px;
  padding-top: env(safe-area-inset-top);
  background: var(--atlas-bg-base);
  border-bottom: 1px solid var(--atlas-border-subtle);
  display: flex;
  align-items: center;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  gap: var(--space-1);
}

.atlas-top-nav::-webkit-scrollbar {
  display: none;
}

.atlas-top-nav__logo {
  display: flex;
  align-items: center;
  margin-right: var(--space-3);
  flex-shrink: 0;
}

.atlas-top-nav__item {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--atlas-text-tertiary);
  white-space: nowrap;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color var(--duration-fast) var(--ease-default),
              border-color var(--duration-fast) var(--ease-default);
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
}

/* Unread dot on nav link (set via data-unread attribute) */
.atlas-top-nav__item[data-unread]::after {
  content: '';
  position: absolute;
  top: 7px;
  right: 3px;
  width: 7px;
  height: 7px;
  background: var(--atlas-status-danger);
  border-radius: 50%;
  border: 1.5px solid var(--atlas-bg-base);
}

.atlas-top-nav__item:hover {
  color: var(--atlas-text-secondary);
}

.atlas-top-nav__item--active {
  color: var(--atlas-accent);
  border-bottom-color: var(--atlas-accent);
}

.atlas-top-nav__more {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 44px;
  font-size: var(--text-lg);
  color: var(--atlas-text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
}

.atlas-top-nav__more:hover {
  color: var(--atlas-text-secondary);
}


/* --- 7. Surface Header --- */

.atlas-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 0;
}

.atlas-header__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  color: var(--atlas-text-primary);
  line-height: var(--leading-tight);
}

.atlas-header__subtitle {
  font-size: var(--text-sm);
  color: var(--atlas-text-tertiary);
  margin-left: auto;
}


/* --- 8. Card --- */

.atlas-card {
  background: var(--atlas-bg-surface);
  border: 1px solid var(--atlas-border-default);
  border-radius: 12px;
  padding: var(--space-4);
}

.atlas-card--interactive {
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-default);
}

.atlas-card--interactive:hover {
  border-color: var(--atlas-border-strong);
}

.atlas-card--active {
  border-color: var(--atlas-accent-border);
}

.atlas-card--flush {
  padding: 0;
}


/* --- 9. Stat Card --- */

.atlas-stat {
  background: var(--atlas-bg-surface);
  border: 1px solid var(--atlas-border-default);
  border-radius: 12px;
  padding: var(--space-4);
  min-height: 80px;
  position: relative;
}

.atlas-stat--interactive {
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-default);
}

.atlas-stat--interactive:hover {
  border-color: var(--atlas-border-strong);
}

.atlas-stat__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--atlas-text-secondary);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-bottom: var(--space-1);
}

.atlas-stat__value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--atlas-text-primary);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

.atlas-stat__delta {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.atlas-stat__delta--positive {
  color: var(--atlas-status-success);
}

.atlas-stat__delta--negative {
  color: var(--atlas-status-danger);
}

.atlas-stat__delta--neutral {
  color: var(--atlas-text-tertiary);
}


/* --- 10. Stat Grid --- */

.atlas-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
}


/* --- 11. Data Table --- */

.atlas-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.atlas-table {
  width: 100%;
  border-collapse: collapse;
}

.atlas-table thead th {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--atlas-text-secondary);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--atlas-border-strong);
  white-space: nowrap;
}

.atlas-table tbody td {
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  color: var(--atlas-text-primary);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--atlas-border-subtle);
  min-height: 48px;
  vertical-align: middle;
}

.atlas-table tbody tr {
  transition: background var(--duration-fast) var(--ease-default);
}

.atlas-table tbody tr:hover {
  background: var(--atlas-bg-elevated);
}

.atlas-table tbody tr.atlas-table__row--active {
  border-left: 3px solid var(--atlas-accent);
  background: var(--atlas-accent-subtle);
}

.atlas-table--sticky-col td:first-child,
.atlas-table--sticky-col th:first-child {
  position: sticky;
  left: 0;
  background: var(--atlas-bg-surface);
  z-index: 1;
}


/* --- 12. Buttons --- */

.atlas-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  min-width: 40px;
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  border-radius: 12px;
  border: none;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-default),
              color var(--duration-fast) var(--ease-default),
              border-color var(--duration-fast) var(--ease-default);
  -webkit-tap-highlight-color: transparent;
}

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

.atlas-btn--primary {
  border: 1.5px solid var(--atlas-accent);
  color: var(--atlas-accent);
}

.atlas-btn--primary:hover {
  background: var(--atlas-accent-subtle);
  color: var(--atlas-accent-hover);
}

.atlas-btn--primary:active {
  background: rgba(212, 160, 74, 0.15);
  color: var(--atlas-accent-pressed);
}

.atlas-btn--secondary {
  border: 1px solid var(--atlas-border-strong);
  color: var(--atlas-text-secondary);
}

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

.atlas-btn--ghost {
  color: var(--atlas-text-secondary);
}

.atlas-btn--ghost:hover {
  color: var(--atlas-text-primary);
}

.atlas-btn--danger {
  border: 1.5px solid var(--atlas-status-danger);
  color: var(--atlas-status-danger);
}

.atlas-btn--danger:hover {
  background: var(--atlas-status-danger-bg);
}

.atlas-btn--sm {
  min-height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  border-radius: 8px;
}

.atlas-btn--block {
  width: 100%;
}


/* --- 13. Badge / Pill --- */

.atlas-badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--atlas-border-default);
  background: var(--atlas-bg-elevated);
  color: var(--atlas-text-secondary);
  white-space: nowrap;
}

.atlas-badge--success {
  color: var(--atlas-status-success);
  background: var(--atlas-status-success-bg);
  border-color: var(--atlas-status-success-border);
}

.atlas-badge--warning {
  color: var(--atlas-status-warning);
  background: var(--atlas-status-warning-bg);
  border-color: var(--atlas-status-warning-border);
}

.atlas-badge--danger {
  color: var(--atlas-status-danger);
  background: var(--atlas-status-danger-bg);
  border-color: var(--atlas-status-danger-border);
}

.atlas-badge--info {
  color: var(--atlas-status-info);
  background: var(--atlas-status-info-bg);
  border-color: var(--atlas-status-info-border);
}

.atlas-badge--accent {
  color: var(--atlas-accent);
  background: var(--atlas-accent-subtle);
  border-color: var(--atlas-accent-border);
}


/* --- 14. Form Inputs --- */

.atlas-input {
  width: 100%;
  height: 44px;
  padding: 0 var(--space-3);
  background: var(--atlas-bg-input);
  border: 1px solid var(--atlas-border-default);
  border-radius: 8px;
  color: var(--atlas-text-primary);
  font-size: var(--text-base);
  transition: border-color var(--duration-fast) var(--ease-default),
              box-shadow var(--duration-fast) var(--ease-default);
}

.atlas-input::placeholder {
  color: var(--atlas-text-tertiary);
}

.atlas-input:focus {
  outline: none;
  border-color: var(--atlas-accent);
  box-shadow: 0 0 0 2px var(--atlas-accent-subtle);
}

.atlas-input--error {
  border-color: var(--atlas-status-danger);
  box-shadow: 0 0 0 2px var(--atlas-status-danger-bg);
}

.atlas-textarea {
  width: 100%;
  min-height: 88px;
  padding: var(--space-3);
  background: var(--atlas-bg-input);
  border: 1px solid var(--atlas-border-default);
  border-radius: 8px;
  color: var(--atlas-text-primary);
  font-size: var(--text-base);
  resize: vertical;
  transition: border-color var(--duration-fast) var(--ease-default),
              box-shadow var(--duration-fast) var(--ease-default);
}

.atlas-textarea:focus {
  outline: none;
  border-color: var(--atlas-accent);
  box-shadow: 0 0 0 2px var(--atlas-accent-subtle);
}

.atlas-select {
  width: 100%;
  height: 44px;
  padding: 0 var(--space-3);
  background: var(--atlas-bg-input);
  border: 1px solid var(--atlas-border-default);
  border-radius: 8px;
  color: var(--atlas-text-primary);
  font-size: var(--text-base);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6b6b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-default);
}

.atlas-select:focus {
  outline: none;
  border-color: var(--atlas-accent);
  box-shadow: 0 0 0 2px var(--atlas-accent-subtle);
}

.atlas-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--atlas-text-secondary);
  margin-bottom: var(--space-1);
}


/* --- 15. Bottom Tab Bar (In-Tool Navigation) --- */

.atlas-bottom-tabs {
  position: fixed;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 12px;
  right: 12px;
  height: 48px;
  background: var(--atlas-bg-elevated);
  border: 1px solid var(--atlas-border-default);
  border-radius: 16px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-2);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  z-index: 90;
  gap: var(--space-1);
}

.atlas-bottom-tabs::-webkit-scrollbar {
  display: none;
}

.atlas-bottom-tabs__item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--atlas-text-tertiary);
  white-space: nowrap;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--duration-fast) var(--ease-default),
              background var(--duration-fast) var(--ease-default);
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  border: none;
  background: transparent;
}

.atlas-bottom-tabs__item:hover {
  color: var(--atlas-text-secondary);
}

.atlas-bottom-tabs__item--active {
  color: var(--atlas-accent);
  background: var(--atlas-accent-subtle);
}


/* --- 16. Modal / Sheet --- */

.atlas-scrim {
  position: fixed;
  inset: 0;
  background: var(--atlas-bg-overlay);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-slow) var(--ease-default);
}

.atlas-scrim--visible {
  opacity: 1;
  pointer-events: auto;
}

.atlas-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--atlas-bg-elevated);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  padding: var(--space-5) var(--space-4);
  padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
  max-height: 85vh;
  overflow-y: auto;
  z-index: 201;
  transform: translateY(100%);
  transition: transform var(--duration-slow) var(--ease-out);
}

.atlas-sheet--visible {
  transform: translateY(0);
}

.atlas-sheet__handle {
  width: 40px;
  height: 4px;
  background: var(--atlas-border-strong);
  border-radius: 2px;
  margin: 0 auto var(--space-4);
}

.atlas-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--atlas-bg-elevated);
  border: 1px solid var(--atlas-border-default);
  border-radius: 16px;
  padding: var(--space-6);
  max-width: 480px;
  width: calc(100% - var(--space-8));
  max-height: 80vh;
  overflow-y: auto;
  z-index: 201;
}


/* --- 17. Progress Bar --- */

.atlas-progress {
  width: 100%;
}

.atlas-progress__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-1);
}

.atlas-progress__label {
  font-size: var(--text-sm);
  color: var(--atlas-text-secondary);
}

.atlas-progress__value {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--atlas-text-primary);
}

.atlas-progress__track {
  height: 6px;
  background: var(--atlas-bg-input);
  border-radius: 3px;
  overflow: hidden;
}

.atlas-progress__fill {
  height: 100%;
  border-radius: 3px;
  background: var(--atlas-accent);
  transition: width var(--duration-data) var(--ease-out);
}

.atlas-progress__fill--success {
  background: var(--atlas-status-success);
}

.atlas-progress__fill--warning {
  background: var(--atlas-status-warning);
}

.atlas-progress__fill--danger {
  background: var(--atlas-status-danger);
}


/* --- 18. Health Dot --- */

.atlas-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.atlas-dot--success {
  background: var(--atlas-status-success);
}

.atlas-dot--warning {
  background: var(--atlas-status-warning);
}

.atlas-dot--danger {
  background: var(--atlas-status-danger);
}

.atlas-dot--glow {
  /* Glow removed — color alone communicates status */
}


/* --- 19. Chat Interface --- */

.atlas-chat {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

.atlas-chat__sidebar {
  width: 300px;
  background: var(--atlas-bg-surface);
  border-right: 1px solid var(--atlas-border-default);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.atlas-chat__thread-item {
  padding: var(--space-3);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-default);
}

.atlas-chat__thread-item:hover {
  background: var(--atlas-bg-elevated);
}

.atlas-chat__thread-item--active {
  border-left: 3px solid var(--atlas-accent);
  background: var(--atlas-accent-subtle);
}

.atlas-chat__thread-preview {
  font-size: var(--text-base);
  color: var(--atlas-text-primary);
}

.atlas-chat__thread-meta {
  font-size: var(--text-xs);
  color: var(--atlas-text-tertiary);
}

.atlas-chat__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.atlas-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}

.atlas-chat__bubble {
  max-width: 80%;
  padding: var(--space-3) var(--space-4);
  border-radius: 12px;
  margin-bottom: var(--space-3);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}

.atlas-chat__bubble--user {
  background: var(--atlas-accent-subtle);
  border: 1px solid var(--atlas-accent-border);
  margin-left: auto;
}

.atlas-chat__bubble--assistant {
  background: var(--atlas-bg-surface);
  border: 1px solid var(--atlas-border-default);
}

.atlas-chat__input-area {
  padding: var(--space-3) var(--space-4);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  background: var(--atlas-bg-elevated);
  border-top: 1px solid var(--atlas-border-default);
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
}

@media (max-width: 767px) {
  .atlas-chat__sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform var(--duration-normal) var(--ease-out);
  }

  .atlas-chat__sidebar--open {
    transform: translateX(0);
  }
}


/* --- 20. Chart Container --- */

.atlas-chart {
  background: var(--atlas-bg-surface);
  border: 1px solid var(--atlas-border-default);
  border-radius: 12px;
  padding: var(--space-4) 0;
}

.atlas-chart__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--atlas-text-primary);
  padding: 0 var(--space-4);
  margin-bottom: var(--space-3);
}

.atlas-chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4) 0;
}

.atlas-chart__legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--atlas-text-secondary);
}

.atlas-chart__legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}


/* --- 21. Section & Spacing --- */

.atlas-section {
  margin-bottom: var(--space-6);
}

.atlas-section__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--atlas-text-primary);
  margin-bottom: var(--space-3);
}

.atlas-section__subtitle {
  font-size: var(--text-sm);
  color: var(--atlas-text-tertiary);
  margin-bottom: var(--space-3);
}

.atlas-divider {
  border: none;
  border-top: 1px solid var(--atlas-border-default);
  margin: var(--space-4) 0;
}


/* --- 22. Skeleton Loading --- */

.atlas-skeleton {
  background: var(--atlas-bg-elevated);
  border-radius: 12px;
  animation: atlas-pulse 1.5s ease-in-out infinite;
}

@keyframes atlas-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

.atlas-skeleton--text {
  height: 16px;
  border-radius: 4px;
  margin-bottom: var(--space-2);
}

.atlas-skeleton--stat {
  height: 80px;
}

.atlas-skeleton--card {
  height: 120px;
}


/* --- 23. Utility Classes --- */

.atlas-text-primary   { color: var(--atlas-text-primary); }
.atlas-text-secondary { color: var(--atlas-text-secondary); }
.atlas-text-tertiary  { color: var(--atlas-text-tertiary); }
.atlas-text-accent    { color: var(--atlas-accent); }
.atlas-text-success   { color: var(--atlas-status-success); }
.atlas-text-warning   { color: var(--atlas-status-warning); }
.atlas-text-danger    { color: var(--atlas-status-danger); }
.atlas-text-info      { color: var(--atlas-status-info); }

.atlas-text-xs   { font-size: var(--text-xs); }
.atlas-text-sm   { font-size: var(--text-sm); }
.atlas-text-base { font-size: var(--text-base); }
.atlas-text-lg   { font-size: var(--text-lg); }
.atlas-text-xl   { font-size: var(--text-xl); }
.atlas-text-2xl  { font-size: var(--text-2xl); }
.atlas-text-3xl  { font-size: var(--text-3xl); }
.atlas-text-4xl  { font-size: var(--text-4xl); }

.atlas-font-mono  { font-family: var(--atlas-font-mono); }

.atlas-weight-normal   { font-weight: var(--weight-normal); }
.atlas-weight-medium   { font-weight: var(--weight-medium); }
.atlas-weight-semibold { font-weight: var(--weight-semibold); }
.atlas-weight-bold     { font-weight: var(--weight-bold); }

.atlas-uppercase {
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

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

.atlas-flex        { display: flex; }
.atlas-flex-col    { display: flex; flex-direction: column; }
.atlas-flex-wrap   { flex-wrap: wrap; }
.atlas-items-center { align-items: center; }
.atlas-justify-between { justify-content: space-between; }
.atlas-gap-1  { gap: var(--space-1); }
.atlas-gap-2  { gap: var(--space-2); }
.atlas-gap-3  { gap: var(--space-3); }
.atlas-gap-4  { gap: var(--space-4); }

.atlas-grid { display: grid; }

.atlas-mt-1 { margin-top: var(--space-1); }
.atlas-mt-2 { margin-top: var(--space-2); }
.atlas-mt-3 { margin-top: var(--space-3); }
.atlas-mt-4 { margin-top: var(--space-4); }
.atlas-mb-1 { margin-bottom: var(--space-1); }
.atlas-mb-2 { margin-bottom: var(--space-2); }
.atlas-mb-3 { margin-bottom: var(--space-3); }
.atlas-mb-4 { margin-bottom: var(--space-4); }

.atlas-p-0  { padding: 0; }
.atlas-p-3  { padding: var(--space-3); }
.atlas-p-4  { padding: var(--space-4); }
.atlas-px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.atlas-py-3 { padding-top: var(--space-3); padding-bottom: var(--space-3); }

.atlas-hidden  { display: none; }
.atlas-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;
}


/* --- 24. Surface Accent Overrides --- */

.atlas-vitals {
  --atlas-accent:         #22c55e;
  --atlas-accent-hover:   #2dd96b;
  --atlas-accent-pressed: #1aab4d;
  --atlas-accent-subtle:  rgba(34, 197, 94, 0.10);
  --atlas-accent-border:  rgba(34, 197, 94, 0.25);
}


/* --- 25. Responsive Grid Presets --- */

.atlas-grid--stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
}

.atlas-grid--cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-3);
}

.atlas-grid--launchpad {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
}


/* --- 26. Action List (Command queues, planner items) --- */

.atlas-action-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--atlas-border-subtle);
}

.atlas-action-item:last-child {
  border-bottom: none;
}

.atlas-action-item__text {
  flex: 1;
  font-size: var(--text-base);
  color: var(--atlas-text-primary);
  min-width: 0;
}

.atlas-action-item__meta {
  font-size: var(--text-xs);
  color: var(--atlas-text-tertiary);
  margin-top: var(--space-1);
}

.atlas-action-item__actions {
  display: flex;
  gap: var(--space-1);
  flex-shrink: 0;
}


/* --- 27. Empty State --- */

.atlas-empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--atlas-text-tertiary);
}

.atlas-empty__icon {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-3);
}

.atlas-empty__text {
  font-size: var(--text-base);
}


/* --- 28. Scrollbar Styling --- */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--atlas-border-strong);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--atlas-text-disabled);
}


/* --- 29. Thinking Dots Animation --- */

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 1em;
}
.thinking-dots span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--atlas-text-tertiary);
  animation: thinking-bounce 1.3s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes thinking-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-6px); opacity: 1; }
}


/* --- 30. Markdown Message Content --- */

.atlas-markdown {
  white-space: normal !important;
}
.atlas-markdown p { margin: 0 0 0.5em; }
.atlas-markdown p:last-child { margin-bottom: 0; }
.atlas-markdown h1, .atlas-markdown h2, .atlas-markdown h3 {
  font-weight: var(--weight-semibold); margin: 0.75em 0 0.25em;
  color: var(--atlas-text-primary); line-height: 1.3;
}
.atlas-markdown h1 { font-size: var(--text-xl); }
.atlas-markdown h2 { font-size: var(--text-lg); }
.atlas-markdown h3 { font-size: var(--text-base); }
.atlas-markdown ul, .atlas-markdown ol {
  padding-left: 1.4em; margin: 0.25em 0 0.5em;
}
.atlas-markdown li { margin: 0.2em 0; }
.atlas-markdown code {
  background: var(--atlas-bg-raised); padding: 1px 5px;
  border-radius: 3px; font-family: var(--atlas-font-mono);
  font-size: 0.85em; color: var(--atlas-accent);
}
.atlas-markdown pre {
  background: var(--atlas-bg-raised); border: 1px solid var(--atlas-border-strong);
  border-radius: 6px; padding: 12px; margin: 0.5em 0;
  overflow-x: auto;
}
.atlas-markdown pre code {
  background: none; padding: 0; color: var(--atlas-text-primary);
  font-size: var(--text-sm);
}
.atlas-markdown blockquote {
  border-left: 3px solid var(--atlas-border-strong);
  margin: 0.5em 0; padding: 2px 12px;
  color: var(--atlas-text-secondary);
}
.atlas-markdown strong { font-weight: var(--weight-semibold); }
.atlas-markdown em { font-style: italic; }
.atlas-markdown hr {
  border: none; border-top: 1px solid var(--atlas-border-default); margin: 0.75em 0;
}
.atlas-markdown a { color: var(--atlas-accent); }
.atlas-markdown table {
  border-collapse: collapse; width: 100%; margin: 0.5em 0; font-size: var(--text-sm);
}
.atlas-markdown th, .atlas-markdown td {
  border: 1px solid var(--atlas-border-strong); padding: 4px 8px; text-align: left;
}
.atlas-markdown th { background: var(--atlas-bg-raised); font-weight: var(--weight-semibold); }


/* --- 30. Responsive Breakpoint Helpers --- */

@media (min-width: 768px) {
  .atlas-content {
    padding: var(--space-6);
    padding-bottom: calc(var(--space-16) + env(safe-area-inset-bottom));
  }
}

@media (max-width: 479px) {
  .atlas-stat__value {
    font-size: var(--text-2xl);
  }
}
