/* ---- stc Forward corporate typeface (self-hosted) ---- */
@font-face { font-family: 'STC Forward'; src: url('/fonts/STCForward-Thin.ttf') format('truetype'); font-weight: 100; font-style: normal; font-display: swap; }
@font-face { font-family: 'STC Forward'; src: url('/fonts/STCForward-ThinItalic.ttf') format('truetype'); font-weight: 100; font-style: italic; font-display: swap; }
@font-face { font-family: 'STC Forward'; src: url('/fonts/STCForward-Light.ttf') format('truetype'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'STC Forward'; src: url('/fonts/STCForward-LightItalic.ttf') format('truetype'); font-weight: 300; font-style: italic; font-display: swap; }
@font-face { font-family: 'STC Forward'; src: url('/fonts/STCForward-Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'STC Forward'; src: url('/fonts/STCForward-Italic.ttf') format('truetype'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'STC Forward'; src: url('/fonts/STCForward-Medium.ttf') format('truetype'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'STC Forward'; src: url('/fonts/STCForward-MediumItalic.ttf') format('truetype'); font-weight: 500; font-style: italic; font-display: swap; }
@font-face { font-family: 'STC Forward'; src: url('/fonts/STCForward-Bold.ttf') format('truetype'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'STC Forward'; src: url('/fonts/STCForward-BoldItalic.ttf') format('truetype'); font-weight: 700; font-style: italic; font-display: swap; }
@font-face { font-family: 'STC Forward'; src: url('/fonts/STCForward-ExtraBold.ttf') format('truetype'); font-weight: 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'STC Forward'; src: url('/fonts/STCForward-ExtraBoldItalic.ttf') format('truetype'); font-weight: 800; font-style: italic; font-display: swap; }

:root {
  --stc-purple: #4f2d7f;
  --stc-magenta: #c8378c;
  --bg: #f5f4f8;
  --card: #ffffff;
  --ink: #23202b;
  --muted: #6f6a7d;
  --green: #1a9e54;
  --amber: #d99400;
  --red: #d43a3a;
  --border: #e3e0ea;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'STC Forward', "Segoe UI", system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--ink); }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; background: var(--stc-purple); color: #fff; }
.brand { display: flex; gap: 14px; align-items: center; }
.logo { background: var(--stc-magenta); font-weight: 800; font-size: 20px; padding: 8px 12px; border-radius: 8px; }
h1 { font-size: 18px; margin: 0; }
.sub { margin: 2px 0 0; font-size: 12px; opacity: .8; }
.actions { display: flex; gap: 8px; }
.btn { border: 1px solid rgba(255,255,255,.4); background: transparent; color: #fff; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.btn.primary { background: var(--stc-magenta); border-color: var(--stc-magenta); font-weight: 600; }
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .5; cursor: wait; }
.banner { padding: 10px 24px; font-size: 13px; background: #e8f4ec; color: var(--green); border-bottom: 1px solid var(--border); white-space: pre-wrap; }
.banner.warn { background: #fdf3e0; color: var(--amber); }
.banner.err { background: #fbe6e6; color: var(--red); }
.hidden { display: none !important; }
.hint { margin: 6px 24px 0; font-size: 12px; color: #777; }
.hint code { background: #f2f2f5; padding: 1px 5px; border-radius: 4px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.filters { display: flex; flex-wrap: wrap; gap: 16px; margin: 16px 24px 0; padding: 14px 16px; }
.filters label, .scatter-controls label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
select, input { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: #fff; }
button, input, select, textarea { font-family: inherit; }
.tabs { display: flex; gap: 4px; padding: 0 24px; margin-top: 14px; flex-wrap: wrap; }
.tab { border: 1px solid var(--border); border-bottom: none; background: #ece9f2; padding: 9px 16px; border-radius: 8px 8px 0 0; cursor: pointer; font-size: 13px; }
.tab.active { background: var(--card); font-weight: 600; color: var(--stc-purple); }
main { margin: 0 24px 32px; }
.view { background: var(--card); border: 1px solid var(--border); border-radius: 0 10px 10px 10px; padding: 20px; min-height: 300px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: right; }
th:first-child, td:first-child { text-align: left; }
thead th { background: #f3f0f8; color: var(--stc-purple); font-weight: 600; position: sticky; top: 0; }
.flag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; color: #fff; }
.flag.green { background: var(--green); } .flag.amber { background: var(--amber); } .flag.red { background: var(--red); }
.missing { color: var(--muted); font-style: italic; }
.n-note { font-size: 11px; color: var(--muted); }
.basis-tag { font-size: 10px; font-variant: small-caps; letter-spacing: .04em; color: var(--muted); background: #f3f0f8; border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; margin-left: 4px; white-space: nowrap; }
.chart-wrap { position: relative; height: 380px; margin-bottom: 20px; }
.chart-wrap.tall { height: 520px; }
.scatter-controls { display: flex; gap: 16px; padding: 12px 16px; margin-bottom: 14px; }
.popover { position: fixed; z-index: 50; background: #fff; border: 1px solid var(--stc-purple); border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.2); padding: 14px 16px; max-width: 360px; font-size: 12px; }
.popover h4 { margin: 0 0 6px; color: var(--stc-purple); }
.popover dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; }
.popover dt { color: var(--muted); } .popover dd { margin: 0; word-break: break-all; }
tr.line-row { cursor: pointer; }
tr.line-row:hover { background: #f6f2fb; }
form.manual { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; padding: 16px; }
form.manual .full { grid-column: 1 / -1; }
form.manual label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
form.manual h3 { grid-column: 1 / -1; margin: 10px 0 0; color: var(--stc-purple); font-size: 14px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.manual-actions { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; }
form.manual .fact-row { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
form.manual .fact-row label.wide { grid-column: span 2; }
form.manual .fact-row .manual-actions { grid-column: 1 / -1; }
.note { font-size: 12px; color: var(--muted); padding: 8px 16px; }
/* KPI engine */
#kpis-body .btn { border-color: var(--border); color: var(--stc-purple); padding: 4px 10px; font-size: 12px; }
#kpis-body .btn.primary { background: var(--stc-magenta); border-color: var(--stc-magenta); color: #fff; }
#kpis-body code { background: #f3f0f8; padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.kpi-actions { white-space: nowrap; }
.mono-line { font-family: 'STC Forward', "Segoe UI", system-ui, sans-serif; font-size: 11px; line-height: 1.7; background: #f8f6fc; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; word-break: break-word; }
form.manual.kpi-add { margin-top: 18px; border-top: 2px solid var(--stc-purple); }
form.manual.kpi-add input, form.manual.kpi-add select { font-size: 13px; }

/* ---- auth / login ---- */
.login-screen { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #3a1f5e 0%, var(--stc-purple) 55%, #6b3fa0 100%); }
.login-card { background: #fff; border-radius: 14px; box-shadow: 0 18px 60px rgba(0,0,0,.35); padding: 34px 36px; width: 340px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-card .logo { align-self: center; }
.login-card h2 { margin: 0; color: var(--stc-purple); font-size: 20px; }
.login-sub { margin: 0 0 6px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.login-card input { padding: 10px 12px; font-size: 14px; }
.login-btn { padding: 10px; font-size: 14px; color: #fff; }
.login-error { min-height: 16px; margin: 0; font-size: 12px; color: var(--red); }
.user-chip { font-size: 12px; background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.3); border-radius: 14px; padding: 5px 12px; align-self: center; white-space: nowrap; }
.user-chip .role-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; background: var(--stc-magenta); border-radius: 8px; padding: 1px 7px; margin-left: 6px; }
.user-chip .role-badge.viewer { background: #7a6f96; }
.confidential-tag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #fff; background: var(--red); border-radius: 8px; padding: 2px 9px; margin-left: 10px; vertical-align: middle; }
.view-only-banner { margin: 8px 24px 0; padding: 8px 14px; font-size: 12px; color: var(--stc-purple); background: #efeaf7; border: 1px solid var(--border); border-radius: 8px; }

/* === TAB: COST (owned by cost-structure redesign) === */
#view-cost { font-family: 'STC Forward','Segoe UI',system-ui,sans-serif; }
#view-cost .cost-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
#view-cost .cost-head-text { display: flex; flex-direction: column; gap: 2px; }
#view-cost .cost-title { margin: 0; font-size: 17px; font-weight: 700; color: #4E008E; padding-bottom: 5px; border-bottom: 3px solid #4E008E; align-self: flex-start; }
#view-cost .cost-subtitle { margin: 0; font-size: 12px; font-weight: 600; color: #808080; }
#view-cost .cost-kpi-picker { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
#view-cost .cost-kpi-picker select { border-color: #4E008E; font-weight: 600; color: #4E008E; min-width: 220px; }
#view-cost .cost-note { margin: -8px 0 14px; }
#view-cost .cost-tbl thead th { background: #F3E5FF; color: #4E008E; border-bottom: 2px solid #4E008E; }
#view-cost .cost-tbl tbody tr:hover { background: #F8F4FC; }

/* === TAB: SCORECARD (owned by scorecard slider/bullet redesign) === */
#view-scorecard { font-family: 'STC Forward','Segoe UI',system-ui,sans-serif; }
#view-scorecard .sc-legend { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin: 10px 0 18px; font-size: 12.5px; color: #333; }
#view-scorecard .sc-legend span { display: inline-flex; align-items: center; gap: 6px; }
#view-scorecard .sc-sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
#view-scorecard .sc-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
#view-scorecard .sc-kpi-picker { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 0 0 6px 46px; }
#view-scorecard .sc-kpi-picker select { padding: 6px 10px; font-size: 13px; border: 1px solid var(--stc-purple); border-radius: 8px; background: #fff; color: var(--stc-purple); font-weight: 600; }
#view-scorecard .sc-sliders { display: flex; flex-direction: column; gap: 0; margin-bottom: 26px; }
#view-scorecard .sc-slider { padding: 26px 46px 34px; border-bottom: 1px solid #E5E5E5; }
#view-scorecard .sc-slider:nth-child(even) { background: #F8F9FA; }
#view-scorecard .sc-kpi-name { font-weight: 600; font-size: 12.5px; color: #666; margin-bottom: 6px; display: flex; align-items: baseline; gap: 8px; }
#view-scorecard .sc-kpi-name .sc-n { font-weight: 400; font-size: 10.5px; color: #999; margin-left: auto; }
#view-scorecard .sc-canvas { position: relative; }
#view-scorecard .sc-zones { display: flex; pointer-events: none; margin-bottom: 6px; }
#view-scorecard .sc-zones span { flex: 1; font-size: 12.5px; font-style: italic; color: #909090; }
#view-scorecard .sc-zones span:nth-child(1) { text-align: left; }
#view-scorecard .sc-zones span:nth-child(2) { text-align: center; }
#view-scorecard .sc-zones span:nth-child(3) { text-align: right; }
#view-scorecard .sc-row { position: relative; height: 26px; }
/* smooth entrance animations (replay on every KPI/filter change, like the column chart's) */
@keyframes scTrackGrow { from { transform: scaleX(0); opacity: .4; } to { transform: scaleX(1); opacity: 1; } }
@keyframes scMarkerPop { 0% { transform: translate(-50%,-50%) scale(0); } 70% { transform: translate(-50%,-50%) scale(1.25); } 100% { transform: translate(-50%,-50%) scale(1); } }
@keyframes scFadeDown { from { opacity: 0; transform: translateX(-50%) translateY(-8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes scFadeUp { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
#view-scorecard .sc-track { position: relative; height: 14px; border-radius: 999px; background: linear-gradient(90deg, #FF3B30 0%, #FF9500 28%, #FFCC00 50%, #9BE15D 72%, #34C759 100%); box-shadow: inset 0 1px 3px rgba(0,0,0,.18); margin: 6px 0; transform-origin: left center; animation: scTrackGrow .55s cubic-bezier(.22,.8,.35,1) both; }
#view-scorecard .sc-marker { position: absolute; top: 50%; transform: translate(-50%, -50%); width: 22px; height: 22px; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); z-index: 3; animation: scMarkerPop .5s cubic-bezier(.22,.8,.35,1) .35s both; transition: left .45s ease, background .45s ease; }
#view-scorecard .sc-connector { position: absolute; top: 50%; height: 0; border-top: 2px dashed rgba(78,0,142,.45); transform: translateY(-50%); z-index: 2; }
#view-scorecard .sc-callout-top, #view-scorecard .sc-callout-bottom { position: absolute; top: 0; transform: translateX(-50%); z-index: 4; transition: left .45s ease; }
#view-scorecard .sc-callout-top { animation: scFadeDown .4s ease .15s both; }
#view-scorecard .sc-callout-bottom { animation: scFadeUp .4s ease .25s both; }
#view-scorecard .sc-box { display: inline-block; white-space: nowrap; border-radius: 9px; padding: 3px 10px; font-size: 12.5px; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
#view-scorecard .sc-box-stc { background: #F3E5FF; color: #4E008E; font-weight: 800; }
#view-scorecard .sc-box-bench { background: #B3F0F4; color: #123; font-weight: 600; }
#view-scorecard .sc-box-local { background: #80E5FF; color: #123; font-weight: 600; }
#view-scorecard .sc-callout-bottom .sc-box-local::after { content: ''; position: absolute; left: 50%; top: -5px; transform: translateX(-50%); border: 5px solid transparent; border-bottom-color: #80E5FF; border-top: 0; }
#view-scorecard .sc-callout-top .sc-box-stc::after { content: ''; position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%); border: 5px solid transparent; border-top-color: #F3E5FF; border-bottom: 0; }

#view-scorecard .sc-callout-bottom .sc-box-bench::after { content: ''; position: absolute; left: 50%; top: -5px; transform: translateX(-50%); border: 5px solid transparent; border-bottom-color: #B3F0F4; border-top: 0; }
#view-scorecard .sc-callout-top .sc-box, #view-scorecard .sc-callout-bottom .sc-box { position: relative; }
#view-scorecard .sc-missing .sc-nodata { font-size: 12px; color: #999; font-style: italic; padding: 8px 0; }
#view-scorecard .sc-missing { padding: 10px 46px; }
/* === TAB: SCORECARD end === */
