:root{
  --bg0:#f7f9fc;
  --bg1:#ffffff;
  --bg2:#f1f5f9;
  --text0:#0b1220;
  --text1:#334155;
  --muted:#64748b;
  --border:#e2e8f0;
  --shadow:0 12px 30px rgba(2, 6, 23, .08);
  --accent:#0ea5e9; /* xvalue-ish cyan/blue */
  --accent2:#22c55e;
  --danger:#ef4444;
  --radius:16px;
}

html, body{
  height:100%;
  background:
    radial-gradient(1200px 700px at 20% 0%, rgba(14,165,233,.18), transparent 55%),
    radial-gradient(900px 650px at 85% 10%, rgba(34,197,94,.10), transparent 50%),
    linear-gradient(180deg, #ffffff 0%, var(--bg0) 60%, #ffffff 100%);
  color:var(--text0);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  position: relative;
}

/* Watermark logo */
html::before {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 85vw;
  height: 85vh;
  background-image: url('./logo.png');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.15;
  z-index: 1;
  filter: grayscale(50%);
  pointer-events: none;
}

*{ box-sizing:border-box; }

/* Ensure main containers don't block watermark */
#react-entry-point,
#_dash-app-content,
body > div {
  position: relative;
  z-index: 2;
}

a{ color:var(--accent); }

.app-shell{
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.topbar{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:16px;
  margin-bottom:14px;
}

.title{
  margin:0;
  font-size: 22px;
  letter-spacing: .2px;
}

.subtitle{
  margin:6px 0 0 0;
  color:var(--text1);
  font-size: 13px;
  line-height: 1.35;
  max-width: 760px;
}

.pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,.75);
  color: var(--muted);
  font-size: 12px;
}

.grid{
  display:grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
}

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

.card{
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(255,255,255,.80));
  border: 1px solid rgba(226,232,240,.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.card-header{
  padding: 12px 12px 6px;
  border-bottom: 1px solid rgba(226,232,240,.9);
}

.card-title{
  margin: 0;
  font-size: 14px;
  letter-spacing: .2px;
}

.card-body{
  padding: 12px;
}

.section-label{
  font-size: 12px;
  color: var(--text0);
  font-weight: 600;
  margin: 10px 0 6px;
}

.small-note{
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.btn-primary{
  background: #0ea5e9;
  color: #ffffff;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary:hover{
  background: #0284c7;
}
.equation-item{
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,.7);
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text0);
}

.components-grid{
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.builder-header{
  margin-bottom: 18px;
}
.title-input{
  width: 100%;
  font-size: 22px;
  font-weight: 700;
  border: none;
  border-bottom: 2px solid #e2e8f0;
  background: transparent;
  padding: 6px 0 8px;
  outline: none;
}
.main-grid{
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}
.builder-panel{
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 14px;
  padding: 20px;
}
.parameters-box{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 10px 0;
}
.parameter-item{
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255,255,255,.85);
}
.parameter-header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.parameter-name-input{
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
}
.parameter-weight{
  font-size: 12px;
  font-weight: 600;
  color: #0ea5e9;
  margin: 6px 0;
}
.add-parameter-btn{
  width: 100%;
  padding: 10px;
  background: rgba(14,165,233,.08);
  border: 1px dashed rgba(14,165,233,.5);
  border-radius: 10px;
  color: #0ea5e9;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}
.action-buttons{
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.btn{
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
  border: none;
}
.summary-panel{
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.summary-card{
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 14px;
  padding: 14px;
}
.summary-title{
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text0);
  margin-bottom: 8px;
  font-weight: 700;
}
.summary-stat{
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 6px 0;
}
.summary-stat-label{ color: var(--text1); font-weight: 500; }
.summary-stat-value{ font-weight: 700; }
.total-weight-bar{
  width: 100%;
  height: 6px;
  background: rgba(0,0,0,.06);
  border-radius: 999px;
  overflow: hidden;
}
.total-weight-fill{
  height: 100%;
  background: #0ea5e9;
}
.filter-row{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.builder-left{
  min-height: 420px;
}
.text-input{
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.params-stack{
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.param-card{
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.9);
  padding: 10px;
}
.param-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.param-title{
  font-weight: 700;
  font-size: 13px;
}

/* Enhanced Parameter Card Styling */
.parameter-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 24px;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  animation: slideUp 0.4s ease-out both;
}

.parameter-card:hover {
  border-color: rgba(96, 165, 250, 0.3);
  background: rgba(255, 255, 255, 0.06);
}

.parameter-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 12px;
}

.parameter-name {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.parameter-weight-badge {
  font-size: 14px;
  font-weight: 700;
  color: #60a5fa;
  font-family: 'JetBrains Mono', monospace;
  background: rgba(96, 165, 250, 0.15);
  padding: 6px 12px;
  border-radius: 6px;
  min-width: 55px;
  text-align: center;
  white-space: nowrap;
}

.remove-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-weight: 600;
}

.remove-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
}

.filter-label {
  font-size: 12px;
  font-weight: 500;
  color: #8b92a6;
  margin-bottom: 8px;
  display: block;
}

.filter-input, .filter-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: #e4e8f1;
  font-family: 'Outfit', sans-serif;
  transition: all 0.3s ease;
}

.filter-select {
  cursor: pointer;
}

.filter-input:focus, .filter-select:focus {
  outline: none;
  border-color: #60a5fa;
  background: rgba(96, 165, 250, 0.1);
}
.btn-secondary{
  background: #e2e8f0;
  color: #1f2937;
  border: none;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary:hover{
  background: #cbd5e1;
}
.subparam-card{
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 8px;
  background: rgba(248,250,252,.8);
  margin-bottom: 6px;
}
.subparam-header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
@media (max-width: 980px){
  .builder-grid{
    grid-template-columns: 1fr;
  }
}
.component-card{
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.85);
  padding: 10px;
  min-height: 80px;
}
.component-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.component-remove{
  border: none;
  background: transparent;
  font-size: 16px;
  color: #94a3b8;
  cursor: pointer;
}
.component-remove:hover{
  color: #0f172a;
}
.component-title{
  font-size: 13px;
  font-weight: 700;
  color: var(--text0);
  margin-bottom: 4px;
}

/* Modal */
.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(15,23,32,.25);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 120px;
  z-index: 999;
}
.modal-card{
  width: 360px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(2,6,23,.18);
  padding: 14px;
  position: relative;
}
.modal-title{
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 10px;
}
.modal-close{
  position: absolute;
  right: 10px;
  top: 8px;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: #64748b;
}
.modal-section-title{
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #94a3b8;
  margin: 10px 0 6px;
}
.modal-items{
  display: grid;
  gap: 6px;
}
.modal-item{
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  text-align: left;
  cursor: pointer;
}
.modal-item:hover{
  background: #eef6ff;
  border-color: rgba(14,165,233,.45);
}
.modal-item-title{
  font-size: 13px;
  font-weight: 600;
  color: var(--text0);
}
.modal-item-desc{
  font-size: 11px;
  color: #64748b;
}

/* Workspace layout */
.workspace{
  margin-top: 12px;
}
.workspace-grid{
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  grid-template-rows: minmax(220px, auto) minmax(220px, auto);
  gap: 14px;
}
.panel--equation{
  grid-column: 1 / 2;
  grid-row: 1 / 3;
  min-height: 520px;
}
.panel--profile{
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  min-height: 220px;
}
.panel--radar{
  grid-column: 2 / 3;
  grid-row: 2 / 3;
  min-height: 220px;
}
.panel--extra{
  grid-column: 1 / 3;
  grid-row: 3 / 4;
  min-height: 240px;
}
@media (max-width: 980px){
  .workspace-grid{
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }
  .panel--equation,
  .panel--profile,
  .panel--radar,
  .panel--extra{
    grid-column: auto;
    grid-row: auto;
    min-height: 200px;
  }
}

/* ========================================
   IMPROVED BROWSER-STYLE TABS
   ======================================== */

.tabs{
  margin: 6px 0 0;
  padding: 10px 12px 0;
  background: linear-gradient(180deg, #dde3eb 0%, #e7ebf0 100%);
  border: 1px solid #c5cdd8;
  border-bottom: none;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  display: flex;
  gap: 2px;
  align-items: flex-end;
  overflow-x: auto;
  overflow-y: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.3),
    0 -2px 8px rgba(0,0,0,.03);
  position: relative;
}

/* Scrollbar styling for tabs */
.tabs::-webkit-scrollbar{
  height: 6px;
}
.tabs::-webkit-scrollbar-track{
  background: transparent;
}
.tabs::-webkit-scrollbar-thumb{
  background: rgba(100,116,139,.3);
  border-radius: 3px;
}
.tabs::-webkit-scrollbar-thumb:hover{
  background: rgba(100,116,139,.5);
}

.tab{
  padding: 10px 36px 11px 16px !important;
  background: linear-gradient(180deg, #d0d8e2 0%, #cbd4df 100%) !important;
  border: 1px solid #b8c2ce !important;
  border-bottom: none !important;
  color: #475569 !important;
  font-weight: 500 !important;
  font-size: 13px !important;
  border-top-left-radius: 10px !important;
  border-top-right-radius: 10px !important;
  margin-right: 0 !important;
  position: relative;
  max-width: 260px;
  min-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.25),
    0 2px 4px rgba(0,0,0,.08);
}

.tab:hover:not(.tab--active){
  background: linear-gradient(180deg, #d8e0e9 0%, #d3dbe5 100%) !important;
  border-color: #adb9c7 !important;
  color: #334155 !important;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.35),
    0 3px 6px rgba(0,0,0,.1);
  transform: translateY(-1px);
}

.tab-button{
  border: none;
  background: transparent;
  color: inherit;
  font-weight: inherit;
  font-size: inherit;
  cursor: pointer;
  padding: 0;
  flex: 1;
  text-align: left;
  overflow: hidden;
}

.tab-label{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  overflow: hidden;
}

.tab-icon{
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  opacity: 0.9;
  background-image: url('./logo.png');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  display: inline-block;
  filter: brightness(0.8);
}

.tab-text{
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.tab-close{
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: rgba(100,116,139,.08);
  color: #64748b;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.15s ease;
}

.tab:hover .tab-close{
  opacity: 1;
}

.tab-close:hover{
  background: rgba(239,68,68,.12);
  color: #ef4444;
}

.tab-close:active{
  transform: translateY(-50%) scale(0.9);
}

/* Active tab state */
.tab--active{
  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%) !important;
  border: 1px solid #b8c2ce !important;
  border-bottom: none !important;
  color: #0b1220 !important;
  font-weight: 600 !important;
  box-shadow:
    0 -4px 12px rgba(0,0,0,.08),
    0 2px 0 #ffffff,
    inset 0 1px 0 rgba(255,255,255,.8) !important;
  z-index: 10;
  transform: translateY(0) !important;
}

.tab--active::after{
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: #ffffff;
  z-index: 11;
}

.tab--active .tab-icon{
  opacity: 1;
}

.tab--active .tab-close{
  opacity: 1;
  background: rgba(100,116,139,.06);
}

/* Add new tab button */
.tab--add{
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  min-width: auto !important;
  max-width: none !important;
  box-shadow: none !important;
  margin-left: 4px;
}

.tab--add .tab-button{
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,.4);
  border: 1px solid rgba(184,194,206,.5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  color: #64748b;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,.06);
}

.tab--add .tab-button:hover{
  background: rgba(14,165,233,.12);
  border-color: rgba(14,165,233,.3);
  color: #0ea5e9;
  box-shadow: 0 3px 8px rgba(14,165,233,.15);
  transform: translateY(-1px) scale(1.05);
}

.tab--add .tab-button:active{
  transform: translateY(0) scale(0.98);
}

/* Dash core controls */
.Select-control, .Select-menu-outer{
  background-color: rgba(255,255,255,.92) !important;
  border-color: rgba(226,232,240,.95) !important;
  color: var(--text0) !important;
}
.Select-value-label, .Select-placeholder, .Select-input input{
  color: var(--text0) !important;
}
.is-focused:not(.is-open) > .Select-control{
  box-shadow: 0 0 0 3px rgba(14,165,233,.18) !important;
  border-color: rgba(14,165,233,.65) !important;
}

/* DataTable */
.dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner{
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

/* ========================================
   ADDITIONAL BROWSER-LIKE ENHANCEMENTS
   ======================================== */

/* Tab separator (subtle dividers between inactive tabs) */
.tab:not(.tab--active):not(:hover)::before{
  content: '';
  position: absolute;
  right: -1px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(100,116,139,.15), transparent);
  opacity: 0.5;
}

.tab:not(.tab--active):last-of-type::before,
.tab--active + .tab::before,
.tab:hover + .tab::before{
  opacity: 0;
}

/* Loading indicator for tab (optional, can be added via JS) */
.tab--loading::after{
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: tabLoading 1.5s infinite;
}

@keyframes tabLoading{
  0%{ transform: translateX(-100%); }
  100%{ transform: translateX(100%); }
}

/* Favicon/icon placeholder */
.tab-favicon{
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}

/* Audio/playing indicator (optional) */
.tab--playing .tab-icon::after{
  content: '🔊';
  position: absolute;
  font-size: 10px;
}

/* Pinned tab state (optional) */
.tab--pinned{
  min-width: 48px !important;
  max-width: 48px !important;
  padding: 10px 12px !important;
  justify-content: center;
}

.tab--pinned .tab-text,
.tab--pinned .tab-close{
  display: none;
}

/* Tab group separator (optional) */
.tab-group-separator{
  width: 1px;
  height: 28px;
  background: linear-gradient(180deg, transparent, rgba(100,116,139,.25), transparent);
  margin: 0 8px;
  align-self: center;
}

/* Responsive improvements */
@media (max-width: 768px){
  .tabs{
    padding: 8px 8px 0;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
  }

  .tab{
    min-width: 120px;
    max-width: 200px;
    padding: 9px 32px 10px 12px !important;
    font-size: 12px !important;
  }

  .tab--add .tab-button{
    width: 28px;
    height: 28px;
  }
}

/* Loading spinner overlay */
.dash-loading .dash-spinner-container {
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

._dash-loading-callback {
  min-height: 300px;
}
