/* ============================================================
   GRAFOMEM Cloud Portal — Dark-mode Glassmorphism Design
   ============================================================ */

:root {
  /* Colors */
  --bg-deep: #06060b;
  --bg-base: #0a0a12;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.06);
  --bg-input: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);

  --text-primary: #f0f0f5;
  --text-secondary: #8b8b9e;
  --text-muted: #55556a;

  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-glow: rgba(99, 102, 241, 0.2);

  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;

  /* Layout */
  --sidebar-w: 220px;
  --radius: 12px;
  --radius-sm: 8px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   Reset
   ============================================================ */

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ============================================================
   Auth View
   ============================================================ */

.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 60%),
    var(--bg-deep);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  box-shadow:
    0 0 80px rgba(99, 102, 241, 0.06),
    0 20px 60px rgba(0, 0, 0, 0.3);
  animation: fadeUp 0.5s var(--ease);
}

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

.auth-logo {
  text-align: center;
  margin-bottom: 0.25rem;
}

.logo-icon {
  font-size: 1.8rem;
  color: var(--primary);
  margin-right: 0.5rem;
  vertical-align: middle;
}

.logo-text {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--primary), var(--success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-tagline {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

/* Tabs */
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.tab {
  flex: 1;
  padding: 0.6rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.tab.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.tab:hover:not(.active) {
  color: var(--text-primary);
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

input, select {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  outline: none;
}

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

input::placeholder { color: var(--text-muted); }

select option {
  background: var(--bg-base);
  color: var(--text-primary);
}

.error-msg {
  margin-top: 1rem;
  padding: 0.7rem 1rem;
  background: var(--danger-glow);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.85rem;
  display: none;
}

.error-msg.visible { display: block; }

/* SSO Social Login */
.sso-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
}

.sso-divider::before,
.sso-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.sso-divider span {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.sso-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.sso-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s var(--ease);
}

.sso-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.sso-btn svg {
  flex-shrink: 0;
}

.sso-google:hover {
  border-color: rgba(66, 133, 244, 0.5);
  background: rgba(66, 133, 244, 0.08);
  box-shadow: 0 4px 16px rgba(66, 133, 244, 0.15);
}

.sso-microsoft:hover {
  border-color: rgba(0, 164, 239, 0.5);
  background: rgba(0, 164, 239, 0.08);
  box-shadow: 0 4px 16px rgba(0, 164, 239, 0.15);
}

.sso-github:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.08);
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  gap: 0.5rem;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-glow);
}

.btn-full { width: 100%; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

/* ============================================================
   Dashboard Layout
   ============================================================ */

#dashboard-view {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-base);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s var(--ease);
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.logo-icon-sm {
  color: var(--primary);
  font-size: 1.2rem;
  margin-right: 0.3rem;
}

.logo-text-sm {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: linear-gradient(135deg, var(--primary), var(--success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1.5rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  border-left: 3px solid transparent;
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
  color: var(--primary);
  background: var(--primary-glow);
  border-left-color: var(--primary);
}

.nav-icon {
  font-size: 1rem;
  width: 1.2rem;
  text-align: center;
}

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

.user-info {
  margin-bottom: 0.5rem;
}

.user-name {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-plan {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  background: var(--primary-glow);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-top: 0.3rem;
}

.nav-item.logout {
  color: var(--text-muted);
  padding: 0.5rem 0;
  border-left: none;
}

.nav-item.logout:hover { color: var(--danger); }

/* Content area */
.content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 2rem 2.5rem;
  max-width: 1100px;
}

.section-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

/* Mobile menu */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 1.2rem;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  backdrop-filter: blur(12px);
}

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  backdrop-filter: blur(12px);
  transition: border-color 0.2s var(--ease);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

/* ============================================================
   Stats Grid
   ============================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  transition: all 0.2s var(--ease);
}

.stat-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.stat-card.accent {
  border-color: rgba(99, 102, 241, 0.3);
  background: linear-gradient(135deg, var(--bg-card), var(--primary-glow));
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ============================================================
   Quick Start
   ============================================================ */

.quick-start pre {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.2rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.code-comment { color: var(--text-muted); }
.code-highlight { color: var(--warning); font-weight: 600; }

/* ============================================================
   API Key
   ============================================================ */

.key-card .key-display {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.key-code {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  padding: 0.8rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.key-actions { display: flex; gap: 0.5rem; }

.key-warning {
  font-size: 0.8rem;
  color: var(--warning);
  margin-bottom: 1.5rem;
}

.endpoint-url {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 0.6rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
}

.link {
  font-size: 0.9rem;
  font-weight: 500;
}

/* ============================================================
   Usage Grid
   ============================================================ */

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

.usage-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all 0.2s var(--ease);
}

.usage-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.usage-icon {
  font-size: 1.4rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.usage-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

.usage-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.3rem;
}

/* ============================================================
   Compliance
   ============================================================ */

.compliance-hero {
  display: flex;
  justify-content: center;
  margin: 2rem 0;
}

.m8-badge {
  text-align: center;
  padding: 2.5rem 3rem;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 200px;
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s var(--ease);
}

.m8-badge.pass {
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 40px var(--success-glow), 0 0 80px rgba(16, 185, 129, 0.05);
}

.m8-badge.fail {
  border-color: rgba(239, 68, 68, 0.4);
  box-shadow: 0 0 40px var(--danger-glow);
}

.m8-score {
  font-size: 2.4rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-primary);
}

.m8-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.3rem;
}

.m8-status {
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 0.4rem;
}

.capabilities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.6rem;
}

.cap-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: 'JetBrains Mono', monospace;
  transition: background 0.2s var(--ease);
}

.cap-item:hover { background: rgba(0, 0, 0, 0.3); }

.cap-icon { font-size: 1rem; }
.cap-pass { color: var(--success); }
.cap-fail { color: var(--danger); }
.cap-placeholder { color: var(--text-muted); font-size: 0.85rem; }

.badge-preview-area {
  text-align: center;
  padding: 1rem;
  margin-bottom: 1rem;
}

.badge-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

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

/* ============================================================
   Billing / Plans
   ============================================================ */

.billing-current {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.plan-badge {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: capitalize;
  padding: 0.4rem 1rem;
  border-radius: 20px;
  background: var(--primary-glow);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.billing-status-text {
  font-size: 0.85rem;
  color: var(--success);
  font-weight: 500;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.2rem;
  margin-top: 1.5rem;
}

.plan-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem;
  text-align: center;
  transition: all 0.25s var(--ease);
  position: relative;
}

.plan-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.plan-card.featured {
  border-color: rgba(99, 102, 241, 0.4);
  background: linear-gradient(180deg, var(--primary-glow) 0%, var(--bg-card) 100%);
}

.popular-tag {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.8rem;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.plan-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.8rem;
}

.price {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.2rem;
}

.price-period {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-muted);
}

.plan-features {
  list-style: none;
  margin-bottom: 1.5rem;
  text-align: left;
}

.plan-features li {
  padding: 0.4rem 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.plan-features li::before {
  content: '✓ ';
  color: var(--success);
  font-weight: 600;
}

.plan-btn { margin-top: auto; }

/* ============================================================
   Decision Trail / Audit Console
   ============================================================ */

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

/* Filter bar */
.dt-filters {
  padding: 1rem 1.5rem;
}

.dt-filter-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.dt-filter-item {
  flex: 1;
  min-width: 140px;
  margin-bottom: 0;
}

.dt-filter-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding-bottom: 0.15rem;
}

/* Table */
.dt-list-card {
  overflow: hidden;
}

.dt-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.dt-list-header h2 {
  margin-bottom: 0;
}

.dt-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.dt-table-wrap {
  overflow-x: auto;
  margin: 0 -1.5rem;
  padding: 0 1.5rem;
}

.dt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.dt-table thead th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.dt-table tbody tr {
  transition: background 0.15s var(--ease);
  cursor: pointer;
}

.dt-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.05);
}

.dt-table tbody td {
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  vertical-align: middle;
}

.dt-table .dt-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.dt-table .dt-model {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--primary);
  font-weight: 500;
}

.dt-table .dt-query {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dt-table .dt-facts-count {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--text-primary);
}

.dt-table .dt-tokens {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
}

.dt-table .dt-latency {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
}

.dt-signed-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.dt-signed-badge.signed {
  color: var(--success);
  background: var(--success-glow);
}

.dt-signed-badge.unsigned {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
}

.dt-view-btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
}

.dt-empty-row td {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Pagination */
.dt-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.dt-page-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* Detail Panel */
.dt-detail-panel {
  border-color: rgba(99, 102, 241, 0.3);
  background: linear-gradient(180deg, var(--primary-glow) 0%, var(--bg-card) 60%);
  animation: fadeUp 0.3s var(--ease);
}

.dt-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.dt-detail-header h2 {
  margin-bottom: 0;
  color: var(--text-primary);
}

.dt-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.dt-meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  padding: 0.25rem 0.6rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  color: var(--text-secondary);
}

.dt-meta-tag .label {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dt-detail-sections {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.dt-detail-section h3 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.dt-detail-code {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

/* Facts list in detail */
.dt-facts-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dt-fact-item {
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
  padding: 0.7rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  transition: background 0.15s var(--ease);
}

.dt-fact-item:hover {
  background: rgba(0, 0, 0, 0.3);
}

.dt-fact-item.deleted {
  border-left-color: var(--danger);
  opacity: 0.7;
}

.dt-fact-ref {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  min-width: 3rem;
  padding-top: 0.1rem;
}

.dt-fact-content {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
  flex: 1;
}

.dt-fact-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 3rem;
  text-align: right;
}

/* Provenance badge */
.dt-provenance-badge {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.dt-provenance-badge .prov-icon {
  font-size: 1.6rem;
}

.dt-provenance-badge .prov-details {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.dt-provenance-badge .prov-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dt-provenance-badge .prov-hash {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  word-break: break-all;
}

/* ============================================================
   Toast
   ============================================================ */

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1.2rem;
  font-size: 0.85rem;
  color: var(--text-primary);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s var(--ease);
  z-index: 500;
  max-width: 360px;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { border-color: rgba(16, 185, 129, 0.4); }
.toast.error { border-color: rgba(239, 68, 68, 0.4); color: var(--danger); }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dt-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .plans-grid { grid-template-columns: 1fr; }
  .usage-grid { grid-template-columns: repeat(2, 1fr); }
  .dt-filter-row { flex-direction: column; }
  .dt-filter-item { min-width: 100%; }
}

@media (max-width: 700px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu-btn { display: block; }

  .content {
    margin-left: 0;
    padding: 1.2rem;
    padding-top: 3.5rem;
  }

  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dt-stats-grid { grid-template-columns: 1fr 1fr; }
  .usage-grid { grid-template-columns: 1fr 1fr; }

  .key-card .key-display {
    flex-direction: column;
    align-items: stretch;
  }

  .m8-badge { width: 160px; height: 160px; }
  .m8-score { font-size: 1.8rem; }

  .dt-table { font-size: 0.75rem; }
  .dt-table thead th { font-size: 0.68rem; }
}

/* ============================================================
   ORCHESTRATOR
   ============================================================ */

.orch-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 4px;
  border: 1px solid var(--border);
}
.orch-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.orch-tab:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.orch-tab.active { background: var(--primary); color: #fff; }

.orch-panel { animation: fadeIn 0.3s ease; }

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

.items-list .item-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s var(--ease);
}
.items-list .item-card:hover { background: var(--bg-card-hover); }
.items-list .item-card:last-child { border-bottom: none; }
.item-info { flex: 1; }
.item-name { font-weight: 600; color: var(--text-primary); font-size: 0.9rem; }
.item-meta { font-size: 0.78rem; color: var(--text-secondary); margin-top: 3px; }
.item-actions { display: flex; gap: 8px; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-header h2 { margin: 0; font-size: 1.1rem; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 768px) { .form-grid { grid-template-columns: 1fr; } }

.btn-group {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: 1px solid var(--danger);
}
.btn-danger:hover { opacity: 0.85; }

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.status-badge.created { background: var(--bg-card); color: var(--text-secondary); border: 1px solid var(--border); }
.status-badge.running { background: rgba(99,102,241,0.15); color: var(--primary); }
.status-badge.completed { background: var(--success-glow); color: var(--success); }
.status-badge.failed { background: var(--danger-glow); color: var(--danger); }
.status-badge.denied { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-badge.escalated { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-badge.waiting_hitl { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-badge.terminated { background: var(--bg-card); color: var(--text-muted); }

/* Step timeline */
.step-timeline { position: relative; }
.step-card {
  position: relative;
  padding: 16px;
  padding-left: 40px;
  border-bottom: 1px solid var(--border);
}
.step-card::before {
  content: '';
  position: absolute;
  left: 16px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.step-card::after {
  content: attr(data-step);
  position: absolute;
  left: 8px;
  top: 18px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.step-card.denied::after { background: var(--danger); }
.step-card.escalated::after { background: var(--warning); }
.step-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.step-agent { font-weight: 600; font-size: 0.85rem; color: var(--text-primary); }
.step-meta { font-size: 0.72rem; color: var(--text-secondary); }
.step-output {
  background: var(--bg-input);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.8rem;
  font-family: 'JetBrains Mono', monospace;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 8px;
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.step-gov { margin-top: 6px; font-size: 0.72rem; }
.step-gov .gov-allowed { color: var(--success); }
.step-gov .gov-denied { color: var(--danger); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
  font-size: 0.88rem;
}

.provider-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.provider-card:last-child { border-bottom: none; }
.provider-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(99,102,241,0.1);
  color: var(--primary);
  border: 1px solid rgba(99,102,241,0.3);
  margin-left: 8px;
}

/* ============================================================
   LIVE STREAMING TIMELINE
   ============================================================ */

.stream-status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.82rem;
}

.stream-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.stream-dot.live {
  background: var(--success);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.stream-dot.error { background: var(--danger); }

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
}

.stream-label {
  font-weight: 600;
  color: var(--text-primary);
}

.stream-tokens {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--primary);
  margin-left: auto;
}

.stream-elapsed {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Live step card */
.step-card-live {
  position: relative;
  padding: 16px;
  padding-left: 44px;
  border-bottom: 1px solid var(--border);
  animation: slideInStep 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  transition: background 0.2s var(--ease);
}

.step-card-live::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.step-card-live:last-child::before { bottom: 50%; }

.step-card-live::after {
  content: attr(data-step);
  position: absolute;
  left: 10px;
  top: 18px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.step-card-live.running::after {
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.step-card-live.denied::after { background: var(--danger); }
.step-card-live.escalated::after { background: var(--warning); }

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

/* Stage progress pills */
.step-stages {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.68rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all 0.25s var(--ease);
}

.stage-pill.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.3);
}

.stage-pill.done {
  background: var(--success-glow);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.3);
}

.stage-pill.fail {
  background: var(--danger-glow);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.stage-pill .stage-icon { font-size: 0.72rem; }

/* Step header live */
.step-live-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.step-live-agent {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.step-live-role {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.step-live-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.step-live-output {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.78rem;
  font-family: 'JetBrains Mono', monospace;
  white-space: pre-wrap;
  max-height: 160px;
  overflow-y: auto;
  margin-top: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  animation: fadeIn 0.3s ease;
}

/* Workflow complete banner */
.stream-complete-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(16, 185, 129, 0.02) 100%);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-sm);
  margin-top: 16px;
  animation: fadeIn 0.4s ease;
}

.stream-complete-banner.error {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(239, 68, 68, 0.02) 100%);
  border-color: rgba(239, 68, 68, 0.25);
}

.stream-complete-icon { font-size: 1.4rem; }

.stream-complete-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.stream-complete-stats {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: auto;
}

/* ============================================================
   Semantic Manifold Canvas
   ============================================================ */

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

.manifold-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.lens-switcher {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.lens-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.lens-btn.active {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-bottom: 2px solid var(--primary);
}

.zoom-controls {
  display: flex;
  gap: 0.5rem;
}

.manifold-canvas-container {
  width: 100%;
  height: calc(100vh - 180px);
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  cursor: grab;
}

.manifold-canvas-container:active {
  cursor: grabbing;
}

#manifold-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.manifold-tooltip {
  position: absolute;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  color: var(--text-primary);
  font-size: 0.8rem;
  pointer-events: none;
  z-index: 100;
  min-width: 200px;
  max-width: 300px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  transition: opacity 0.1s;
}

.manifold-tooltip h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.85rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

.manifold-tooltip-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.3rem;
}

.manifold-tooltip-label {
  color: var(--text-muted);
}

.manifold-tooltip-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
}
