/* ==========================================================================
   WIRADIFIT MAKMUR SEJAHTERA — HOLDING DASHBOARD DESIGN SYSTEM
   Theme Inspired by Marsella Nuryanti (https://marsellanuryanti.github.io)
   Mobile-First & Touch-Optimized Clean Cyber-Chic Design
   Strict Compliance with `kill-ai-slop` and `stop-slop`
   ========================================================================== */

:root {
  /* Color Tokens */
  --bg-primary: #0b0f19;
  --bg-surface: #111827;
  --card-bg: rgba(17, 24, 39, 0.95);
  --bg-subtle: #1f2937;

  /* Ink & Typography */
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  /* Vibrant Creative Accents */
  --accent-coral: #ff385c;
  --accent-coral-subtle: rgba(255, 56, 92, 0.12);

  --accent-electric: #2563eb;
  --accent-electric-subtle: rgba(37, 99, 235, 0.12);

  --accent-violet: #6366f1;
  --accent-violet-subtle: rgba(99, 102, 241, 0.12);

  --accent-emerald: #10b981;
  --accent-emerald-subtle: rgba(16, 185, 129, 0.12);

  --accent-amber: #f59e0b;
  --accent-amber-subtle: rgba(245, 158, 11, 0.12);

  /* Hairline Clean Borders */
  --card-border: rgba(255, 255, 255, 0.08);
  --card-border-strong: rgba(255, 255, 255, 0.16);

  /* Typography */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Code', monospace;

  /* Touch & Spacing */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-pill: 9999px;
  --touch-target: 44px;
  --transition-fast: 0.15s ease;
  --transition-smooth: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset & Box Sizing */
*, *::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 {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
}

/* App Container (Mobile First Layout) */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0.75rem;
  max-width: 1600px;
  margin: 0 auto;
  gap: 1rem;
}

@media (min-width: 768px) {
  .app-container {
    padding: 1.25rem 2rem;
    gap: 1.25rem;
  }
}

/* ==========================================================================
   TOP NAVIGATION HEADER (Mobile Optimized)
   ========================================================================== */
.top-header {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: var(--card-bg);
  border: var(--card-border-strong);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

@media (min-width: 1024px) {
  .top-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
  }
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-badge {
  position: relative;
  width: 40px;
  height: 40px;
  background: var(--accent-coral);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px rgba(255, 56, 92, 0.3);
  flex-shrink: 0;
}

.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

@media (min-width: 768px) {
  .brand-text h1 {
    font-size: 1.2rem;
  }
}

.badge-live {
  background: var(--accent-coral);
  color: #ffffff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}

.domain-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.online {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
}

.header-metrics {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;

  /* Smooth Mobile Horizontal Scroll */
  -webkit-overflow-scrolling: touch;
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.35rem 0.65rem;
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  white-space: nowrap;
  flex-shrink: 0;
}

.metric-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.metric-value.highlight { color: var(--accent-coral); }
.metric-value.green { color: var(--accent-emerald); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.btn-header-action {
  background: var(--bg-subtle);
  border: 1px solid var(--card-border-strong);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  min-height: var(--touch-target);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all var(--transition-fast);
}

.btn-header-action:hover, .btn-header-action:active {
  background: var(--accent-electric);
  border-color: var(--accent-electric);
  color: #ffffff;
}

.btn-logout:hover, .btn-logout:active {
  background: var(--accent-coral);
  border-color: var(--accent-coral);
  color: #ffffff;
}

/* Tabular Numbers Utility */
.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ==========================================================================
   DASHBOARD LAYOUT SECTIONS (Telemetry, Task Center, Command Workspace)
   ========================================================================== */
.telemetry-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 1024px) {
  .telemetry-row {
    grid-template-columns: 1.35fr 1fr;
    gap: 1.25rem;
  }
}

.task-row {
  width: 100%;
  margin-top: 1rem;
}

@media (min-width: 768px) {
  .task-row {
    margin-top: 1.25rem;
  }
}

.dashboard-widget {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

@media (min-width: 768px) {
  .dashboard-widget {
    padding: 1.25rem 1.5rem;
    gap: 1rem;
  }
}

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.widget-title {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.title-icon { font-size: 1.25rem; margin-top: 0.05rem; }

.widget-title h2 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  text-wrap: balance;
}

.telemetry-subtitle {
  font-size: 0.7rem;
  color: var(--accent-emerald);
  font-weight: 500;
  display: block;
  margin-top: 0.2rem;
  text-wrap: balance;
}

.badge-reset {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: var(--accent-amber-subtle);
  color: var(--accent-amber);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(245, 158, 11, 0.3);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Token Main Gauge */
.token-main-gauge {
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.gauge-info {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.gauge-number {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-coral);
}

@media (min-width: 768px) {
  .gauge-number { font-size: 1.8rem; }
}

.gauge-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.gauge-bar-wrapper {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.gauge-bar-fill {
  height: 100%;
  background: var(--accent-coral);
  border-radius: 4px;
  transition: width 0.5s ease-in-out;
}

.gauge-footer-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Allowance Buckets */
.allowance-buckets {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

@media (min-width: 480px) {
  .allowance-buckets {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
}

.allowance-card {
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.allowance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.allowance-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.allowance-val {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.allowance-bar-bg {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.allowance-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease-in-out;
}

.allowance-bar-fill.free { background: var(--accent-electric); }
.allowance-bar-fill.paid { background: var(--accent-emerald); }

.btn-model-catalog {
  background: var(--bg-subtle);
  border: 1px solid var(--card-border-strong);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  min-height: var(--touch-target);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
  text-align: center;
}

.btn-model-catalog:hover, .btn-model-catalog:active {
  background: var(--accent-electric);
  border-color: var(--accent-electric);
  color: #ffffff;
}

/* Subsidiary Grid */
.subsidiary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

@media (min-width: 480px) {
  .subsidiary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
}

.sub-card {
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sub-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sub-name {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.sub-badge {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
}

.sub-badge.green { background: var(--accent-emerald-subtle); color: var(--accent-emerald); }
.sub-badge.blue { background: var(--accent-electric-subtle); color: var(--accent-electric); }
.sub-badge.amber { background: var(--accent-amber-subtle); color: var(--accent-amber); }
.sub-badge.purple { background: var(--accent-coral-subtle); color: var(--accent-coral); }

.sub-val {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sub-bar-bg {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.sub-bar-fill { height: 100%; border-radius: 2px; transition: width 0.5s ease-in-out; }
.sub-bar-fill.software { background: var(--accent-violet); }
.sub-bar-fill.social { background: var(--accent-electric); }
.sub-bar-fill.financial { background: var(--accent-amber); }
.sub-bar-fill.news { background: var(--accent-coral); }

.sub-meta {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* ==========================================================================
   SERVER HEALTH MONITOR WIDGET
   ========================================================================== */
.health-metrics-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

.health-card {
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.health-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}

.health-label {
  font-weight: 700;
  color: var(--text-secondary);
}

.health-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.75rem;
}

.health-bar-wrapper {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.health-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease-in-out;
}

.health-bar-fill.mem { background: var(--accent-electric); }
.health-bar-fill.cpu { background: var(--accent-coral); }
.health-bar-fill.disk { background: var(--accent-emerald); }

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

.services-status-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.service-pill {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-secondary);
}

.service-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.service-pill.online .dot { background: var(--accent-emerald); box-shadow: 0 0 6px var(--accent-emerald); }
.service-pill.timer .dot { background: var(--accent-electric); box-shadow: 0 0 6px var(--accent-electric); }

/* ==========================================================================
   TASK CENTER WIDGET
   ========================================================================== */
.task-tabs {
  display: flex;
  gap: 0.3rem;
  background: var(--bg-subtle);
  padding: 0.2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  min-height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex: 1;
  transition: all var(--transition-fast);
}

.tab-btn.active {
  background: var(--accent-electric);
  color: #ffffff;
}

/* Company Filter Bar */
.company-filter-bar {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 0.3rem;
  -webkit-overflow-scrolling: touch;
}

.company-pill {
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.company-pill:hover,
.company-pill.active {
  background: var(--accent-coral-subtle);
  border-color: var(--accent-coral);
  color: var(--accent-coral);
}

.task-empty {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 1.5rem 1rem;
}

.task-content-area {
  max-height: 380px;
  overflow-y: auto;
  padding-right: 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.task-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .task-list {
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 0.85rem;
  }
}

.task-card {
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color var(--transition-fast);
}

.task-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.4rem;
}

.task-card-title {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.task-card-title h3 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.task-card-badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
}

.task-card-badge.company { background: var(--accent-electric-subtle); color: var(--accent-electric); width: fit-content; }
.task-card-badge.status { background: var(--accent-amber-subtle); color: var(--accent-amber); }
.task-card-badge.completed { background: var(--accent-emerald-subtle); color: var(--accent-emerald); }

.task-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.task-progress-wrapper {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.task-progress-fill {
  height: 100%;
  background: var(--accent-electric);
  border-radius: 2px;
}

/* ==========================================================================
   MAIN WORKSPACE: AGENTS ROSTER & CHAT STREAM
   ========================================================================== */
.main-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  flex: 1;
}

@media (min-width: 1024px) {
  .main-content {
    grid-template-columns: 1fr 1.5fr;
    gap: 1.25rem;
  }
}

.agents-column, .chat-column {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

@media (min-width: 768px) {
  .agents-column, .chat-column {
    padding: 1.25rem 1.5rem;
    gap: 1rem;
  }
}

.column-header, .chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.column-header h2, .chat-title-group h2 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.btn-org-chart, .btn-action {
  background: var(--bg-subtle);
  border: 1px solid var(--card-border-strong);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  min-height: 36px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-org-chart:hover, .btn-action:hover {
  background: var(--accent-electric);
  border-color: var(--accent-electric);
  color: #ffffff;
}

.action-buttons {
  display: flex;
  gap: 0.35rem;
}

/* Agents Grid Roster */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.6rem;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 0.2rem;
  -webkit-overflow-scrolling: touch;
}

.agent-card {
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color var(--transition-fast);
}

.agent-card:hover {
  border-color: var(--accent-electric);
}

.agent-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.agent-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.agent-identity {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.agent-name {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-role {
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-indicator.online { background: var(--accent-emerald); box-shadow: 0 0 6px var(--accent-emerald); }
.status-indicator.thinking { background: var(--accent-amber); box-shadow: 0 0 6px var(--accent-amber); }

.agent-card-body {
  font-size: 0.7rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.agent-model-tag {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  background: rgba(0, 0, 0, 0.4);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
}

/* Chat Messages Stream */
.chat-messages {
  flex: 1;
  min-height: 320px;
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-right: 0.35rem;
  -webkit-overflow-scrolling: touch;
}

.chat-message-group {
  display: flex;
  gap: 0.6rem;
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
}

.chat-message-group.user-group {
  border-color: rgba(37, 99, 235, 0.3);
  background: rgba(37, 99, 235, 0.05);
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.msg-content-block {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.msg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.msg-author {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.msg-author-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.8rem;
}

.msg-role-tag {
  font-size: 0.6rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
}

.msg-timestamp {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.msg-content {
  font-size: 0.8rem;
  color: var(--text-primary);
  line-height: 1.45;
}

.msg-thought {
  background: rgba(0, 0, 0, 0.3);
  border: 1px dashed var(--card-border-strong);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.msg-thought-header {
  font-weight: 600;
  color: var(--accent-amber);
  margin-bottom: 0.15rem;
}

.msg-tags {
  display: flex;
  gap: 0.3rem;
}

.tag-pill {
  font-size: 0.6rem;
  color: var(--text-muted);
}

/* Chat Input Area (Mobile Touch Ready) */
.chat-input-area {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg-subtle);
  border: 1px solid var(--card-border-strong);
  border-radius: var(--radius-md);
  padding: 0.5rem;
}

@media (min-width: 480px) {
  .chat-input-area {
    flex-direction: row;
  }
}

.input-user-role {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
}

.input-user-role input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  width: 100%;
}

.input-user-role input:focus { outline: none; }

.input-field-wrapper {
  display: flex;
  flex: 1;
  gap: 0.4rem;
}

.input-field-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0.4rem;
}

.input-field-wrapper input:focus { outline: none; }

.btn-send {
  background: var(--accent-coral);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  min-height: var(--touch-target);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: transform var(--transition-fast);
}

/* ==========================================================================
   AUTHENTICATION & MODALS (Mobile Optimized)
   ========================================================================== */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 25, 0.96);
  backdrop-filter: blur(12px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card-bg);
  border: 1px solid var(--card-border-strong);
  border-radius: var(--radius-xl);
  padding: 1.75rem 1.25rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (min-width: 480px) {
  .auth-card {
    padding: 2.5rem 2rem;
    gap: 1.5rem;
  }
}

.auth-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.auth-logo {
  font-size: 1.8rem;
  width: 52px;
  height: 52px;
  background: var(--accent-coral);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(255, 56, 92, 0.4);
}

.auth-header h2 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.auth-header p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input {
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  min-height: var(--touch-target);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  transition: border-color var(--transition-fast);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-electric);
}

.auth-error { color: var(--accent-coral); font-size: 0.75rem; font-weight: 600; min-height: 1rem; }
.auth-success { color: var(--accent-emerald); font-size: 0.75rem; font-weight: 600; min-height: 1rem; }

.btn-auth-submit {
  background: var(--accent-coral);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.5rem;
  min-height: var(--touch-target);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: transform var(--transition-fast);
}

.auth-footer {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 25, 0.88);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 0.75rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open,
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--card-border-strong);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 1050px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.modal-sm { max-width: 440px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--card-border);
}

.modal-title h2 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
}

.modal-title p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.btn-close-modal {
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.modal-body {
  padding: 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
  .modal-body { padding: 1.5rem; }
}

/* Model Catalog Tables (Mobile Horizontal Scrollable) */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.model-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  text-align: left;
  white-space: nowrap;
}

.model-table th {
  padding: 0.55rem 0.65rem;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  border-bottom: 1px solid var(--card-border-strong);
}

.model-table td {
  padding: 0.6rem 0.65rem;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-primary);
}

.tier-pill {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
}

.tier-pill.free { background: var(--accent-electric-subtle); color: var(--accent-electric); }
.tier-pill.paid { background: var(--accent-emerald-subtle); color: var(--accent-emerald); }

.font-mono { font-family: var(--font-mono); }
.font-mono.strong { font-weight: 700; }
.font-mono.text-muted { color: var(--text-muted); font-size: 0.7rem; }
.font-mono.text-green { color: var(--accent-emerald); font-weight: 600; }

.context-pill {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  background: rgba(0, 0, 0, 0.4);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: var(--accent-electric);
  border: 1px solid var(--card-border);
}

/* Full-Width Workspace & Main Org Chart Action Button */
.main-workspace {
  width: 100%;
  margin-top: 1.25rem;
}

.chat-column.full-width {
  width: 100%;
}

.btn-org-chart-primary {
  background: var(--accent-coral);
  border: 1px solid var(--accent-coral);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  min-height: var(--touch-target);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 12px rgba(255, 56, 92, 0.3);
}

.btn-org-chart-primary:hover,
.btn-org-chart-primary:active {
  background: #e02e4c;
  transform: translateY(-1px);
}

/* Modal Extra Large */
.modal-xl {
  max-width: 1280px;
  width: 95vw;
}

.org-company-tabs {
  display: flex;
  gap: 0.4rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--card-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.org-tab-btn {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.org-tab-btn:hover,
.org-tab-btn.active {
  background: var(--accent-electric);
  border-color: var(--accent-electric);
  color: #ffffff;
}

.org-body {
  padding: 1.25rem;
  max-height: 80vh;
  overflow-y: auto;
}

.org-tree-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.org-branch-section {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.branch-header h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.branch-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--card-border);
}

.node-company {
  font-size: 0.6rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Org Chart Tree Nodes */
.diagram-tree {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: center;
}

.tree-level {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.tree-node {
  background: var(--bg-subtle);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 170px;
  max-width: 220px;
  text-align: center;
}

.tree-node.ceo { border-top: 3px solid var(--accent-coral); min-width: 230px; }
.tree-node.holding { border-top: 3px solid var(--accent-violet); }
.tree-node.software { border-top: 3px solid var(--accent-electric); }
.tree-node.social { border-top: 3px solid var(--accent-coral); }
.tree-node.financial { border-top: 3px solid var(--accent-amber); }
.tree-node.news { border-top: 3px solid var(--accent-emerald); }

.node-icon { font-size: 1.2rem; }
.node-title { font-family: var(--font-heading); font-weight: 700; font-size: 0.85rem; }
.node-role { font-size: 0.7rem; color: var(--text-secondary); }
.node-model { font-family: var(--font-mono); font-size: 0.6rem; color: var(--text-muted); background: rgba(0,0,0,0.3); padding: 0.15rem 0.4rem; border-radius: 4px; }
