/* =========================================================================
   Relata CVM & CPC 10 Regulatory Engine — Smeargle "Cashmere & Jewel" Design System
   ========================================================================= */
:root {
  /* Nude & Cashmere Surfaces */
  --bg-canvas: #FAF6F0;
  --bg-surface-1: #F3ECE1;
  --bg-surface-2: #EAE0D2;
  --bg-surface-3: #DFD2C0;
  --bg-elevated: #FCF9F5;
  --bg-glass: rgba(250, 246, 240, 0.86);

  /* Legacy alias mappings */
  --bg-primary: var(--bg-canvas);
  --bg-surface: var(--bg-surface-1);
  --bg-card: var(--bg-elevated);
  --bg-card-hover: var(--bg-surface-1);
  --bg-input: var(--bg-surface-1);
  --bg-code: var(--bg-surface-2);

  /* Cashmere Hairlines & Borders */
  --border-subtle: #E2D7C7;
  --border-strong: #C9B9A6;
  --border-focus: #0F5238;
  --border-active: #0F5238;
  --border-emerald: rgba(15, 82, 56, 0.25);
  --border-rose: rgba(140, 29, 46, 0.25);

  /* Warm Espresso Typography */
  --text-primary: #1E1915;
  --text-secondary: #574C43;
  --text-muted: #8A7D71;
  --text-on-jewel: #FAF6F0;

  /* Jewel Accents */
  --jewel-emerald: #0F5238;
  --jewel-emerald-hover: #0A3D29;
  --jewel-emerald-subtle: rgba(15, 82, 56, 0.10);
  --jewel-emerald-border: rgba(15, 82, 56, 0.25);

  --jewel-sapphire: #16325B;
  --jewel-sapphire-hover: #0E2240;
  --jewel-sapphire-subtle: rgba(22, 50, 91, 0.09);
  --jewel-sapphire-border: rgba(22, 50, 91, 0.24);

  --jewel-amber: #B4690E;
  --jewel-amber-hover: #8F5108;
  --jewel-amber-subtle: rgba(180, 105, 14, 0.12);
  --jewel-amber-border: rgba(180, 105, 14, 0.28);

  --jewel-ruby: #8C1D2E;
  --jewel-ruby-hover: #6B1422;
  --jewel-ruby-subtle: rgba(140, 29, 46, 0.10);
  --jewel-ruby-border: rgba(140, 29, 46, 0.25);

  /* Legacy accent aliases */
  --accent-emerald: var(--jewel-emerald);
  --accent-blue: var(--jewel-emerald);
  --accent-blue-hover: var(--jewel-emerald-hover);
  --accent-cyan: var(--jewel-sapphire);
  --accent-rose: var(--jewel-ruby);
  --accent-amber: var(--jewel-amber);
  --accent-purple: var(--jewel-sapphire);

  --font-display: 'Newsreader', 'Instrument Serif', 'Playfair Display', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(30, 25, 21, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(30, 25, 21, 0.08), 0 2px 6px -1px rgba(30, 25, 21, 0.04);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.topbar {
  background-color: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-strong);
  transition: all 0.15s ease;
}

.back-btn:hover {
  background: var(--bg-surface-3);
  border-color: var(--jewel-emerald);
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: var(--jewel-emerald);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-on-jewel);
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-title span {
  color: var(--jewel-emerald);
}

.version-pill {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: var(--jewel-sapphire-subtle);
  color: var(--jewel-sapphire);
  border: 1px solid var(--jewel-sapphire-border);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-mcp {
  background: var(--jewel-emerald-subtle);
  color: var(--jewel-emerald);
  border: 1px solid var(--jewel-emerald-border);
}

.badge-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--jewel-emerald);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
  font-family: var(--font-sans);
}

.btn-primary {
  background: var(--jewel-emerald);
  color: var(--text-on-jewel);
}
.btn-primary:hover {
  background: var(--jewel-emerald-hover);
}

.btn-outline {
  background: var(--bg-surface-2);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-outline:hover {
  background: var(--bg-surface-3);
  border-color: var(--text-secondary);
}

.btn-emerald {
  background: var(--jewel-emerald);
  color: var(--text-on-jewel);
}
.btn-emerald:hover {
  background: var(--jewel-emerald-hover);
}

.btn-sm {
  padding: 5px 11px;
  font-size: 0.78rem;
}

/* Tab Navigation */
.tab-bar {
  background: var(--bg-surface-1);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.tab-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  padding: 0 24px;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-2);
}

.tab-btn.active {
  color: var(--jewel-emerald);
  border-bottom-color: var(--jewel-emerald);
  background: var(--jewel-emerald-subtle);
}

/* Main Container */
.main-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px;
  width: 100%;
  flex: 1;
}

/* Tab Panes */
.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

/* Section Header */
.pane-header {
  margin-bottom: 24px;
}
.pane-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.pane-desc {
  color: var(--text-secondary);
  font-size: 0.92rem;
  max-width: 900px;
  line-height: 1.6;
}

/* Two-column layout */
.grid-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 1024px) {
  .grid-split {
    grid-template-columns: 1fr;
  }
}

/* Card */
.surface-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-md);
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-primary);
}

/* Form Controls */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-label span.badge-stat {
  font-family: var(--font-mono);
  color: var(--jewel-sapphire);
}

.input-box {
  width: 100%;
  background: var(--bg-surface-1);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-box:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--jewel-emerald-subtle);
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

textarea.input-box {
  resize: vertical;
  min-height: 140px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.45;
}

/* Math Telemetry Metric Pills */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.metric-pill {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.metric-pill.highlight {
  border-color: var(--jewel-sapphire-border);
  background: linear-gradient(180deg, var(--jewel-sapphire-subtle) 0%, var(--bg-elevated) 100%);
}

.metric-pill.success {
  border-color: var(--jewel-emerald-border);
  background: linear-gradient(180deg, var(--jewel-emerald-subtle) 0%, var(--bg-elevated) 100%);
}

.metric-pill.danger {
  border-color: var(--jewel-ruby-border);
  background: linear-gradient(180deg, var(--jewel-ruby-subtle) 0%, var(--bg-elevated) 100%);
}

.metric-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.metric-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-value.cyan {
  color: var(--jewel-sapphire);
}
.metric-value.emerald {
  color: var(--jewel-emerald);
}
.metric-value.rose {
  color: var(--jewel-ruby);
}
.metric-value.purple {
  color: var(--jewel-sapphire);
}

/* Audit Telemetry Banner */
.audit-banner {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  border: 1px solid transparent;
}

.audit-banner.valid {
  background: var(--jewel-emerald-subtle);
  border-color: var(--jewel-emerald-border);
  color: var(--jewel-emerald);
}

.audit-banner.invalid {
  background: var(--jewel-ruby-subtle);
  border-color: var(--jewel-ruby-border);
  color: var(--jewel-ruby);
}

.audit-banner-title {
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin-top: 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: left;
}

table.data-table th {
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

table.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

table.data-table tr:hover td {
  background: var(--bg-surface-1);
}

/* Code Viewer */
.code-block {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-primary);
  max-height: 480px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Progress Bar */
.progress-bar {
  height: 8px;
  background: var(--bg-surface-3);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-fill {
  height: 100%;
  background: var(--jewel-emerald);
  width: 0%;
  transition: width 0.3s ease;
}

/* Footer */
.app-footer {
  margin-top: auto;
  background: var(--bg-surface-1);
  border-top: 1px solid var(--border-subtle);
  padding: 20px 24px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.footer-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-links {
  display: flex;
  gap: 16px;
}
.footer-links a {
  color: var(--jewel-sapphire);
  font-weight: 600;
  text-decoration: none;
}
.footer-links a:hover {
  text-decoration: underline;
}
