/* GemLooM Diamond Engine R5R1 theme parity layer.
   Dark is the product default. Light and Auto/System are user-selectable. */
:root{
  --gl-bg:#f6f7f9;
  --gl-surface:#ffffff;
  --gl-surface-2:#fafafa;
  --gl-surface-3:#f1f4f7;
  --gl-text:#111827;
  --gl-text-soft:#374151;
  --gl-muted:#6b7280;
  --gl-line:#e5e7eb;
  --gl-input:#fafafa;
  --gl-shadow:0 8px 24px rgba(15,23,42,.08);
  --gl-chart-grid:rgba(17,24,39,.09);
  --gl-chart-text:#111827;
  --gl-accent:#d7c39b;
  --gl-accent-text:#17120b;
  --gl-ok:#22c55e;
  --gl-info:#3b82f6;
  --gl-warn:#f59e0b;
  --gl-bad:#ef4444;
  color-scheme:light;
}
html[data-diamond-theme="dark"]{
  --gl-bg:#090d11;
  --gl-surface:#111820;
  --gl-surface-2:#0d1319;
  --gl-surface-3:#18212b;
  --gl-text:#f2f6f9;
  --gl-text-soft:#d4dee6;
  --gl-muted:#91a1af;
  --gl-line:#2a3641;
  --gl-input:#0c1217;
  --gl-shadow:0 12px 34px rgba(0,0,0,.28);
  --gl-chart-grid:rgba(206,221,232,.13);
  --gl-chart-text:#e7eff5;
  --gl-accent:#d7c39b;
  --gl-accent-text:#17120b;
  --gl-ok:#5bd795;
  --gl-info:#70a7ff;
  --gl-warn:#efc16e;
  --gl-bad:#f09696;
  color-scheme:dark;
}
html[data-diamond-theme="light"]{color-scheme:light}

/* Shell + preserved production UI */
html[data-diamond-theme] body{
  background:var(--gl-bg) !important;
  color:var(--gl-text) !important;
  transition:background-color .18s ease,color .18s ease;
}
html[data-diamond-theme="dark"] body{
  background:
    radial-gradient(circle at 50% -18%,rgba(51,68,82,.52) 0,rgba(18,25,32,.36) 33%,rgba(9,13,17,1) 68%) !important;
}
html[data-diamond-theme] .panel,
html[data-diamond-theme] .kpi,
html[data-diamond-theme] .chart-box,
html[data-diamond-theme] #reportBox,
html[data-diamond-theme] .form-section,
html[data-diamond-theme] .input-section,
html[data-diamond-theme] .section-card{
  background:var(--gl-surface) !important;
  color:var(--gl-text) !important;
  border-color:var(--gl-line) !important;
  box-shadow:var(--gl-shadow) !important;
}
html[data-diamond-theme="dark"] .panel,
html[data-diamond-theme="dark"] .kpi,
html[data-diamond-theme="dark"] .chart-box,
html[data-diamond-theme="dark"] #reportBox{
  border:1px solid var(--gl-line) !important;
}
html[data-diamond-theme] .form-section{background:var(--gl-surface-2) !important}
html[data-diamond-theme] .panel h3,
html[data-diamond-theme] .form-section-title,
html[data-diamond-theme] .warning-box b,
html[data-diamond-theme] .score-value,
html[data-diamond-theme] .decision-box{
  color:var(--gl-text) !important;
}
html[data-diamond-theme] .score-label,
html[data-diamond-theme] .form-section-title span,
html[data-diamond-theme] .form-help,
html[data-diamond-theme] label{
  color:var(--gl-muted) !important;
}
html[data-diamond-theme] input,
html[data-diamond-theme] select,
html[data-diamond-theme] textarea{
  background:var(--gl-input) !important;
  color:var(--gl-text) !important;
  border-color:var(--gl-line) !important;
}
html[data-diamond-theme] input::placeholder,
html[data-diamond-theme] textarea::placeholder{color:var(--gl-muted) !important}
html[data-diamond-theme] button:not(.gl-theme-btn):not(#r5AnalyseBtn){
  background:var(--gl-text) !important;
  color:var(--gl-bg) !important;
}
html[data-diamond-theme="dark"] button:not(.gl-theme-btn):not(#r5AnalyseBtn){
  background:#e8edf1 !important;
  color:#10161b !important;
}
html[data-diamond-theme] .bar{background:var(--gl-surface-3) !important}
html[data-diamond-theme] .big-price{
  background:linear-gradient(90deg,var(--gl-text),var(--gl-muted)) !important;
  -webkit-background-clip:text !important;
  -webkit-text-fill-color:transparent !important;
}
html[data-diamond-theme] .report-table th,
html[data-diamond-theme] .report-table td{border-color:var(--gl-line) !important;color:var(--gl-text-soft) !important}
html[data-diamond-theme] .report-table th{background:var(--gl-surface-3) !important;color:var(--gl-muted) !important}
html[data-diamond-theme] .warning-box{
  background:color-mix(in srgb,var(--gl-warn) 10%,var(--gl-surface)) !important;
  color:var(--gl-text-soft) !important;
  border-color:var(--gl-warn) !important;
}
html[data-diamond-theme] .mode-pill{
  background:color-mix(in srgb,var(--gl-info) 12%,var(--gl-surface)) !important;
  color:var(--gl-info) !important;
}

/* Generated production report/market elements can contain inline white backgrounds. */
html[data-diamond-theme="dark"] #reportBox [style*="background:#fff"],
html[data-diamond-theme="dark"] #reportBox [style*="background: #fff"],
html[data-diamond-theme="dark"] #reportBox [style*="background:white"],
html[data-diamond-theme="dark"] #reportBox [style*="background: white"]{
  background:var(--gl-surface-2) !important;
  color:var(--gl-text) !important;
}
html[data-diamond-theme="dark"] #reportBox table,
html[data-diamond-theme="dark"] #reportBox td,
html[data-diamond-theme="dark"] #reportBox th{
  color:var(--gl-text-soft) !important;
  border-color:var(--gl-line) !important;
}
html[data-diamond-theme="dark"] #reportBox th{background:var(--gl-surface-3) !important;color:var(--gl-muted) !important}

/* R5 scientific sidecar participates in the same theme, instead of being a separate dark island. */
html[data-diamond-theme] #r5IntelligenceMount{color:var(--gl-text) !important}
html[data-diamond-theme] #r5IntelligenceMount .r5-wrap{
  background:var(--gl-surface) !important;
  border-color:var(--gl-line) !important;
  box-shadow:var(--gl-shadow) !important;
}
html[data-diamond-theme] #r5IntelligenceMount .r5-head,
html[data-diamond-theme] #r5IntelligenceMount .r5-section{
  border-color:var(--gl-line) !important;
}
html[data-diamond-theme] #r5IntelligenceMount .r5-card{
  background:var(--gl-surface-2) !important;
  border-color:var(--gl-line) !important;
}
html[data-diamond-theme] #r5IntelligenceMount .r5-title,
html[data-diamond-theme] #r5IntelligenceMount .r5-v,
html[data-diamond-theme] #r5IntelligenceMount .r5-section h4{color:var(--gl-text) !important}
html[data-diamond-theme] #r5IntelligenceMount .r5-sub,
html[data-diamond-theme] #r5IntelligenceMount .r5-k,
html[data-diamond-theme] #r5IntelligenceMount .r5-s,
html[data-diamond-theme] #r5IntelligenceMount .r5-note,
html[data-diamond-theme] #r5IntelligenceMount .r5-field label,
html[data-diamond-theme] #r5IntelligenceMount .r5-table th{color:var(--gl-muted) !important}
html[data-diamond-theme] #r5IntelligenceMount .r5-field select,
html[data-diamond-theme] #r5IntelligenceMount .r5-field input{
  background:var(--gl-input) !important;
  color:var(--gl-text) !important;
  border-color:var(--gl-line) !important;
}
html[data-diamond-theme] #r5IntelligenceMount .r5-table th,
html[data-diamond-theme] #r5IntelligenceMount .r5-table td{border-color:var(--gl-line) !important;color:var(--gl-text-soft) !important}
html[data-diamond-theme] #r5IntelligenceMount .r5-pill{border-color:var(--gl-line) !important;color:var(--gl-text-soft) !important}
html[data-diamond-theme] #r5IntelligenceMount .r5-pill.ok{color:var(--gl-ok) !important}
html[data-diamond-theme] #r5IntelligenceMount .r5-pill.bad{color:var(--gl-bad) !important}

/* Theme selector */
#glDiamondThemeControl{
  position:fixed;
  top:12px;
  right:14px;
  z-index:2147483000;
  display:flex;
  align-items:center;
  gap:4px;
  padding:5px;
  border-radius:999px;
  border:1px solid var(--gl-line);
  background:color-mix(in srgb,var(--gl-surface) 92%,transparent);
  box-shadow:0 10px 30px rgba(0,0,0,.16);
  backdrop-filter:blur(14px);
  -webkit-backdrop-filter:blur(14px);
}
#glDiamondThemeControl .gl-theme-label{
  color:var(--gl-muted);
  font-size:9px;
  font-weight:800;
  letter-spacing:.08em;
  padding:0 4px 0 6px;
  text-transform:uppercase;
}
#glDiamondThemeControl .gl-theme-btn{
  appearance:none;
  -webkit-appearance:none;
  height:27px;
  min-width:46px;
  border:1px solid transparent;
  border-radius:999px;
  padding:0 9px;
  background:transparent;
  color:var(--gl-muted);
  font-size:10px;
  font-weight:800;
  line-height:25px;
  cursor:pointer;
}
#glDiamondThemeControl .gl-theme-btn:hover{color:var(--gl-text);background:var(--gl-surface-3)}
#glDiamondThemeControl .gl-theme-btn[aria-pressed="true"]{
  background:var(--gl-text);
  color:var(--gl-bg);
  border-color:var(--gl-text);
}
html[data-diamond-theme="dark"] #glDiamondThemeControl .gl-theme-btn[aria-pressed="true"]{background:#e8edf1;color:#10161b;border-color:#e8edf1}
#glDiamondThemeControl .gl-theme-icon{font-size:11px;margin-right:3px}
@media(max-width:720px){
  #glDiamondThemeControl{top:6px;right:6px;transform:scale(.9);transform-origin:top right}
  #glDiamondThemeControl .gl-theme-label{display:none}
}

/* Keep charts visible and spacious in both themes. */
html[data-diamond-theme] .chart-box{min-height:320px}
html[data-diamond-theme] canvas{filter:none !important}
