:root{
  --bg0:#070B14;
  --bg1:#0B1020;
  --panel:#0E1630;
  --text:#E7ECFF;
  --muted:#A9B3D1;
  --accent:#2EE6A6;
  --accent2:#2D7DFF;
  --danger:#FF4D6D;
  --warn:#FFB020;
  --border:rgba(231,236,255,0.10);
  --shadow:0 10px 30px rgba(0,0,0,0.35);
  --radius:14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  --z-tray: 1040;
  --z-navbar: 2000;
  --z-dropdown: 10500;
  --z-navbar-dropdown: 10550;
  --z-toast: 10600;
}

html, body{
  background: radial-gradient(1200px 800px at 20% 10%, rgba(45,125,255,0.20), transparent 55%),
              radial-gradient(900px 700px at 80% 30%, rgba(46,230,166,0.14), transparent 60%),
              linear-gradient(180deg, var(--bg0), var(--bg1));
  color: var(--text);
  font-family: var(--sans);
}

.app-shell{
  padding: 18px 20px 28px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Main app shell: fixed viewport column — navbar pinned, page area scrolls. */
html, body{
  height: 100%;
}
.app-shell--main{
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 18px 20px 0;
  box-sizing: border-box;
  overflow: hidden;
}
/* Navbar stays at the top of the column; never scrolls away. */
.app-shell--main > .navbar{
  flex: 0 0 auto;
}

/* Page shell + route loader: see assets/motion.css */

/* Shell job tray: fixed geometry (inline min() + flex ancestors were collapsing width on some setups) */
.job-progress-tray-shell{
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1040;
  box-sizing: border-box;
  min-width: 280px;
  width: 380px;
  max-width: 94vw;
  max-height: 55vh;
  flex-shrink: 0;
}
.job-progress-tray-shell.job-progress-tray--hidden{
  display: none !important;
}
.job-progress-tray-shell.job-progress-tray--collapsed{
  width: 218px;
  min-width: 218px; /* override base min-width so folded tray is visibly narrower */
  max-height: none;
}

/* Tray header: avoid Bootstrap text-muted on dark card (unreadable). */
.job-progress-tray-shell .job-tray-summary,
.job-progress-tray-shell .job-tray-summary-label{
  color: var(--text);
}

.job-progress-tray-inner{
  width: 100%;
  min-width: inherit;
}
.job-progress-tray-card{
  min-width: 0; /* flex child of inner; outer shell enforces width */
  width: 100%;
}

.panel{
  background: rgba(14,22,48,0.72);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
}

.kpi-card{
  padding: 14px 16px;
}

.kpi-label{
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--mono);
}

.kpi-value{
  font-size: 26px;
  margin-top: 6px;
  font-family: var(--mono);
}

.subtle{
  color: var(--muted);
}

/* Cube spinner */
.cube-spinner-wrap{
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 26px 0;
}

.cube-spinner{
  width: 26px;
  height: 26px;
  position: relative;
  transform-style: preserve-3d;
  animation: cubeSpin 1.1s infinite ease-in-out;
}
.cube-spinner::before,
.cube-spinner::after{
  content:"";
  position:absolute;
  inset:0;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  opacity:0.85;
}
.cube-spinner::after{
  transform: translateZ(-14px) rotateY(180deg);
  opacity:0.50;
}

@keyframes cubeSpin{
  0%{ transform: rotateX(0deg) rotateY(0deg); }
  50%{ transform: rotateX(180deg) rotateY(180deg); }
  100%{ transform: rotateX(360deg) rotateY(360deg); }
}

/* Route transition loader (scoped to #sci-page-shell — see motion.css) */
.sci-route-spinner{
  position: relative;
  width: 56px;
  height: 56px;
}

.sci-route-spinner__ring{
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
}

.sci-route-spinner__ring--outer{
  border-top-color: var(--accent);
  border-right-color: rgba(46, 230, 166, 0.28);
  filter: drop-shadow(0 0 10px rgba(46, 230, 166, 0.35));
  animation: sciRouteSpin 0.9s cubic-bezier(0.45, 0.05, 0.25, 0.95) infinite;
}

.sci-route-spinner__ring--inner{
  inset: 9px;
  border-bottom-color: var(--accent2);
  border-left-color: rgba(45, 125, 255, 0.32);
  filter: drop-shadow(0 0 8px rgba(45, 125, 255, 0.28));
  animation: sciRouteSpinRev 1.15s linear infinite;
}

.sci-route-spinner__core{
  position: absolute;
  inset: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, var(--accent), var(--accent2));
  box-shadow:
    0 0 18px rgba(46, 230, 166, 0.45),
    0 0 28px rgba(45, 125, 255, 0.25);
  animation: sciRoutePulse 1.6s ease-in-out infinite;
}

.sci-page-route-loader__label{
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

@keyframes sciRouteSpin{
  to { transform: rotate(360deg); }
}

@keyframes sciRouteSpinRev{
  to { transform: rotate(-360deg); }
}

@keyframes sciRoutePulse{
  0%, 100% { transform: scale(0.9); opacity: 0.62; }
  50%      { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce){
  .sci-route-spinner__ring--outer,
  .sci-route-spinner__ring--inner{
    animation-duration: 1.6s;
  }
  .sci-route-spinner__core{
    animation: none;
    opacity: 0.85;
  }
}

/* Dash AG Grid dark tweaks */
.ag-theme-alpine-dark{
  --ag-background-color: rgba(11,16,32,0.40);
  --ag-odd-row-background-color: rgba(11,16,32,0.20);
  --ag-header-background-color: rgba(14,22,48,0.95);
  --ag-header-foreground-color: var(--text);
  --ag-foreground-color: var(--text);
  --ag-border-color: rgba(231,236,255,0.10);
  --ag-row-border-color: rgba(231,236,255,0.07);
  --ag-font-family: var(--mono);
}

/* Derived list row muted style */
.row-derived{
  color: rgba(231,236,255,0.72) !important;
  background: rgba(231,236,255,0.04) !important;
}

/* Cube loading overlay (Dash emits data-dash-is-loading=true on loading targets) */
.cube-loading{
  position: relative;
  min-height: 40px;
  min-width: 0; /* flex children: allow ECharts/Dash width:100% to resolve real width */
  width: 100%;
}
.cube-loading-content{
  min-width: 0;
  width: 100%;
}
.cube-loading-spinner{
  display:none;
  position:absolute;
  inset:0;
  align-items:center;
  justify-content:center;
  background: rgba(7,11,20,0.35);
  border-radius: var(--radius);
}
.cube-loading[data-dash-is-loading="true"] .cube-loading-spinner{
  display:flex;
}
/* Dim content only on in-page refresh AFTER route reveal — never during pageEnter (see motion.css) */
#_pages_content[data-page-revealed="1"] .cube-loading[data-dash-is-loading="true"] .cube-loading-content{
  opacity: 0.35;
  filter: blur(0.4px);
  pointer-events: none;
}

/* Overlay stacking: date pickers + Dash 4 dropdown (Radix popover, default z-index 500) */
.DateRangePicker_picker,
.SingleDatePicker_picker{
  position: fixed !important;
  z-index: var(--z-dropdown) !important;
}
.dash-dropdown-content,
[data-radix-popper-content-wrapper] .dash-dropdown-content{
  z-index: var(--z-dropdown) !important;
}
[data-radix-popper-content-wrapper]{
  position: fixed !important;
  z-index: var(--z-dropdown) !important;
}
/* Legacy react-select (Dash < 4) — harmless if unused */
.Select-menu-outer,
.dash-dropdown .Select-menu-outer,
.dash-dropdown .Select-menu{
  position: fixed !important;
  z-index: var(--z-dropdown) !important;
}
.VirtualizedSelectFocusedOption{
  background-color: rgba(45,125,255,0.25) !important;
}

/* Bootstrap navbar dropdowns */
.dropdown-menu{
  z-index: var(--z-dropdown) !important;
}
.navbar .dropdown-menu{
  z-index: var(--z-navbar-dropdown) !important;
}
.sci-nav-links{
  position: relative;
  z-index: calc(var(--z-navbar) + 1);
}

/* Bootstrap columns: no z-index ladder — it trapped dropdown menus behind sibling cols */
.app-shell .row > [class*="col"]{
  position: relative;
  min-width: 0; /* flex: charts with width:100% get real width instead of compressed intrinsic */
}

/* Panels with dropdowns: allow menus to escape without clipping */
.panel--dropdown-host{
  overflow: visible;
}

/* Settings page */
.settings-page__header{
  padding: 16px 18px;
}
.settings-page__title{
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
}
.settings-page__subtitle{
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 12px;
}

.settings-section{
  padding: 16px 18px;
  height: 100%;
}
.settings-section__title{
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.settings-section__subtitle{
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-family: var(--mono);
  margin-bottom: 2px;
}
.settings-section__divider{
  margin: 14px 0 6px;
  border: none;
  border-top: 1px solid var(--border);
  opacity: 0.85;
}
.settings-section__note{
  font-size: 12px;
  line-height: 1.45;
}
.settings-section__actions{
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-top: 4px;
}
.settings-section__output{
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.4;
}

.settings-field{
  margin-bottom: 4px;
}
.settings-field__label{
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
  font-family: var(--mono);
}
.settings-field__help{
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.4;
}
.settings-field--narrow .form-control{
  max-width: 220px;
}
.settings-field--switch{
  padding-top: 2px;
}
.settings-field__switch .form-check-label{
  color: var(--text);
  font-size: 13px;
}
.settings-field__checkbox .form-check-label{
  color: var(--text);
  font-size: 13px;
}

.settings-section .form-control,
.settings-section .input-group .form-control,
.settings-save-bar .form-control{
  background: rgba(7,11,20,0.55);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
}
.settings-section .form-control::placeholder,
.settings-save-bar .form-control::placeholder{
  color: rgba(169,179,209,0.55);
}
.settings-section .form-control:focus,
.settings-save-bar .form-control:focus{
  background: rgba(7,11,20,0.7);
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(45,125,255,0.18);
  color: var(--text);
}
.settings-section .input-group .btn{
  border-radius: 0 10px 10px 0;
  white-space: nowrap;
  font-size: 12px;
}
.settings-section .input-group .form-control{
  border-radius: 10px 0 0 10px;
}

.settings-save-bar{
  position: sticky;
  bottom: 12px;
  z-index: 50;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.settings-save-bar__out{
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
}

/* In-app docs browser (/docs) */
.docs-nav-link{
  color: var(--text) !important;
  padding: 3px 6px;
  border-radius: 6px;
  font-size: 13px;
}
.docs-nav-link:hover{
  background: rgba(45,125,255,0.12);
}
.docs-markdown-body{
  line-height: 1.6;
}
.docs-markdown-body h1,
.docs-markdown-body h2,
.docs-markdown-body h3{
  margin-top: 1.2em;
}
.docs-markdown-body h1:first-child{
  margin-top: 0;
}
.docs-markdown-body code{
  font-family: var(--mono);
  font-size: 0.9em;
}
.docs-markdown-body table{
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
}
.docs-markdown-body th,
.docs-markdown-body td{
  border: 1px solid rgba(169,179,209,0.25);
  padding: 6px 10px;
  text-align: left;
}
.docs-markdown-body blockquote{
  border-left: 3px solid var(--accent2);
  padding-left: 12px;
  margin-left: 0;
  color: rgba(169,179,209,0.9);
}

