/* R32-T20 redesign layer (req. #1, #2, #3, #4, #5, #9).
 * Pure CSS on top of the deployed build: no markup, logic or data changes.
 * Rollback = remove the <link> to this file from index.html.
 * Palette: Burgundy & White, black text, Cairo.
 */
:root{
  --r-burg:#68283D; --r-burg-d:#4E1D2D; --r-burg-l:#9E596C; --r-soft:#F8EEF2; --r-soft2:#FCF7F9;
  --r-text:#111111; --r-muted:#5F5257; --r-border:#EADFE3; --r-white:#FFFFFF;
  --r-radius:14px; --r-shadow:0 1px 2px rgba(17,17,17,.04),0 4px 14px rgba(104,40,61,.06);
}

/* ---------- Base: white page, black text, Cairo ---------- */
html body{background:var(--r-white)!important;color:var(--r-text)!important;
  font-family:Cairo,Tahoma,Arial,sans-serif!important;}
body .app{max-width:1440px;margin-inline:auto;padding:0 20px 40px;}
body .app h1,body .app h2,body .app h3,body .app h4{color:var(--r-text)!important;font-family:Cairo,sans-serif!important;}

/* ---------- Header: burgundy band ---------- */
body .app > header{background:linear-gradient(135deg,var(--r-burg) 0%,var(--r-burg-d) 100%);
  color:#fff!important;margin:0 -20px 18px;padding:16px 28px;border-radius:0 0 18px 18px;
  box-shadow:0 6px 18px rgba(78,29,45,.22);}
body .app > header *{color:#fff!important;}
body .app > header .subtitle{opacity:.85;font-size:13px;}

/* ---------- Asset selector: compact pill bar ---------- */
body .asset-selector{display:flex;flex-wrap:wrap;gap:8px;margin:0 0 10px;}
body .asset-btn{background:var(--r-white)!important;color:var(--r-text)!important;border:1px solid var(--r-border)!important;
  border-radius:999px!important;padding:8px 16px!important;min-height:40px;font-weight:600;box-shadow:none!important;
  transition:background .15s,border-color .15s,color .15s;}
body .asset-btn:hover{border-color:var(--r-burg-l)!important;background:var(--r-soft2)!important;}
body .asset-btn.active{background:var(--r-burg)!important;border-color:var(--r-burg)!important;color:#fff!important;}
body .asset-btn.active *{color:#fff!important;}

/* ---------- Timeframes: segmented control ---------- */
body .interval-row{display:flex;flex-wrap:wrap;gap:6px;align-items:center;background:var(--r-soft2);
  border:1px solid var(--r-border);border-radius:var(--r-radius);padding:6px;margin:8px 0 14px;}
body .interval-btn{background:transparent!important;border:0!important;border-radius:10px!important;
  color:var(--r-muted)!important;min-height:38px;padding:6px 14px!important;font-weight:600;box-shadow:none!important;}
body .interval-btn:hover{background:var(--r-white)!important;color:var(--r-text)!important;}
body .interval-btn.active{background:var(--r-burg)!important;color:#fff!important;}
body .screener-btn,body .watchlist-panel .chart-view-mode{background:var(--r-white)!important;color:var(--r-burg)!important;
  border:1px solid var(--r-burg)!important;border-radius:10px!important;min-height:38px;font-weight:600;}
body .interval-row .screener-btn{margin-inline-start:auto;}

/* ---------- Price strip & verified MT5 strip ---------- */
body .top-bar{background:var(--r-white)!important;border:1px solid var(--r-border)!important;border-radius:var(--r-radius)!important;
  box-shadow:var(--r-shadow)!important;}
body .top-bar-price{color:var(--r-burg)!important;font-weight:800;}
body .r32-verified-market-strip{background:var(--r-soft)!important;color:var(--r-text)!important;
  border:1px solid var(--r-border)!important;border-radius:12px!important;}
body .r32-verified-market-strip *{color:var(--r-text)!important;}

/* ---------- Cards: one consistent surface ---------- */
body .ai-card,body .panel-card,body .rc-card,body .session-intelligence-card,body .market-intelligence,
body .tab-content > div > section,body .chart-card{
  background:var(--r-white)!important;border:1px solid var(--r-border)!important;border-radius:var(--r-radius)!important;
  box-shadow:var(--r-shadow)!important;}
body .ai-stat,body .score-item{background:var(--r-soft2)!important;border:1px solid var(--r-border)!important;border-radius:12px!important;}
body .ai-stat .value,body .score-value{color:var(--r-text)!important;}
body .ai-stat .label,body .score-label{color:var(--r-muted)!important;}

/* ---------- Chart area: professional frame ---------- */
body .tv-lightweight-charts{border-radius:10px;}
body .layer-toggle,body .chart-view-mode,body .chart-tool-btn{border-radius:999px!important;min-height:34px;
  border:1px solid var(--r-border)!important;background:var(--r-white)!important;color:var(--r-muted)!important;font-weight:600;}
body .layer-toggle.active,body .chart-view-mode.active{background:var(--r-burg)!important;border-color:var(--r-burg)!important;color:#fff!important;}
body .chart-tool-btn:hover,body .layer-toggle:hover{border-color:var(--r-burg-l)!important;color:var(--r-text)!important;}

/* ---------- Tabs: underline style ---------- */
body .tabs-bar{border-bottom:1px solid var(--r-border)!important;gap:4px;}
body .tab-btn{color:var(--r-muted)!important;font-weight:700;min-height:44px;background:transparent!important;
  border:0!important;border-bottom:3px solid transparent!important;border-radius:0!important;}
body .tab-btn.active{color:var(--r-burg)!important;border-bottom-color:var(--r-burg)!important;}

/* ---------- Badges keep semantic colours, just tidier ---------- */
body .ai-mini-badge,body .rc-badge,body .rc-pill{border-radius:999px!important;}

/* ---------- MT5 status widget: never cover content ---------- */
body #ttp-mt5-widget{position:static!important;width:auto!important;max-width:520px;margin:18px auto 24px!important;
  right:auto!important;bottom:auto!important;}
body .chat-fab{box-shadow:0 6px 16px rgba(78,29,45,.3)!important;}

/* ---------- Footer ---------- */
body .app > footer{color:var(--r-muted)!important;border-top:1px solid var(--r-border);padding-top:14px;margin-top:20px;}

/* ---------- Mobile ---------- */
@media (max-width:768px){
  body .app{padding:0 12px 32px;}
  body .app > header{margin:0 -12px 12px;padding:10px 14px;border-radius:0 0 14px 14px;}
  body .app > header h1,body .app > header .logo{font-size:20px!important;line-height:1.3;}
  body .app > header .subtitle,body .app > header p{font-size:11.5px!important;line-height:1.5;}
  body .asset-btn{padding:6px 12px!important;font-size:13px!important;}
  body .interval-btn{padding:6px 12px!important;font-size:13px!important;}
  body .top-bar-price{font-size:22px!important;}
  /* single-row horizontal scrollers instead of tall wrapped grids */
  body .asset-selector,body .interval-row{flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none;}
  body .asset-selector::-webkit-scrollbar,body .interval-row::-webkit-scrollbar{display:none;}
  body .asset-btn,body .interval-btn{flex:0 0 auto;white-space:nowrap;}
  body .interval-row .screener-btn{margin-inline-start:0;flex:0 0 auto;white-space:nowrap;}
  /* touch targets >= 40px */
  body .app button{min-height:40px;}
  body .infotip-btn{min-width:28px;min-height:28px!important;}
  body #ttp-mt5-widget{margin:14px 0 20px!important;max-width:none;}
}

/* ================================================================
 * R32-T20b: Execution Plan + SCALP tabs
 * White surfaces, one burgundy accent, semantic SL/TP colours kept,
 * no oversized type, no empty boxes. CSS only.
 * ================================================================ */
body .tab-content{--t-pad:16px;}
/* neutral surfaces: drop the stacked pink tints and gradients */
body .tab-content :is(.execution-live-quote,.execution-summary-row,.execution-live-progress,.execution-live-management,
  .r32-reference-levels-heading,.execution-ai-plan,.r32-alex-insight,.scalp-live-quote,.scalp-terminal-meta,
  .scalp-terminal-hero,.scalp-live-dashboard,.scalp-status-cell,.scalp-liq-box,.scalp-liq-confirmations,
  .scalp-liq-target,.scalp-liq-ai,.rc-order-box,.rc-tip,.execution-order-hero){
  background:var(--r-white)!important;background-image:none!important;
  border:1px solid var(--r-border)!important;border-radius:12px!important;box-shadow:none!important;}
/* one accent for the blocks that explain what to do */
body .tab-content :is(.execution-ai-plan,.scalp-wait-reasons,.r32-alex-insight,.rc-tip,.scalp-liq-ai){
  border-inline-start:4px solid var(--r-burg)!important;}
body .tab-content .scalp-wait-reasons{background:var(--r-soft2)!important;border-radius:12px!important;}
body .tab-content .r32-alex-state{background:var(--r-soft)!important;color:var(--r-burg)!important;border-radius:10px!important;}

/* status hero: smaller, cleaner */
body .tab-content .r32-reference-hero-title{font-size:32px!important;line-height:1.25!important;color:var(--r-burg)!important;}
body .tab-content .r32-reference-hero-icon{font-size:56px!important;height:auto!important;opacity:.8;}
body .tab-content .r32-reference-condition{background:var(--r-soft2)!important;border:1px solid var(--r-border)!important;}

/* remove the big empty areas */
body .tab-content .execution-live-progress{min-height:0!important;height:auto!important;padding:var(--t-pad)!important;
  display:flex;flex-direction:column;justify-content:center;}
body .tab-content .scalp-terminal-meta{min-height:0!important;height:auto!important;align-content:flex-start!important;
  align-items:flex-start!important;padding:var(--t-pad)!important;}

/* badges / pills: white, bordered, readable */
body .tab-content :is(.rc-badge,.scalp-state-pill,.type){background:var(--r-white)!important;
  border:1px solid var(--r-border)!important;color:var(--r-text)!important;border-radius:999px!important;}
body .tab-content .rc-badge.grade{border-color:var(--r-burg-l)!important;color:var(--r-burg)!important;}

/* price levels: keep meaning (Entry neutral, SL red, TP green) but crisp */
body .tab-content .rc-level{border-radius:12px!important;box-shadow:none!important;}
body .tab-content .rc-level.entry{background:var(--r-white)!important;border:1px solid #D4D4D8!important;}
body .tab-content .rc-level.sl{background:#FFF5F5!important;border:1px solid #F5B5B5!important;}
body .tab-content .rc-level.tp{background:#F3FBF6!important;border:1px solid #A7DDBC!important;}

/* status cells: calmer numbers */
body .tab-content .scalp-status-cell{min-height:0!important;}
body .tab-content .scalp-status-cell :is(strong,b,.value,.scalp-status-value){font-size:19px!important;}

/* primary action */
body .tab-content .scalp-refresh-btn{background:var(--r-burg)!important;border-radius:10px!important;min-height:42px;}

@media (max-width:768px){
  body .tab-content .r32-reference-hero-title{font-size:24px!important;}
  body .tab-content .r32-reference-hero-icon{font-size:40px!important;}
}

/* ================================================================
 * R32-T21: professional trading-terminal layout (desktop >= 1200px)
 * Re-arranges existing blocks with CSS grid only; DOM untouched.
 * ================================================================ */
@media (min-width:1200px){
  /* sticky command bar: brand + assets + timeframes stay reachable */
  body .app > header{position:sticky;top:0;z-index:40;}
  body .app{display:grid;grid-template-columns:1fr auto;column-gap:12px;align-items:center;}
  body .app > *{grid-column:1 / -1;}
  body .app > .asset-selector{grid-column:1;margin:0;}
  body .app > .watchlist-panel{grid-column:2;margin:0;}
  body .app > .watchlist-panel .watchlist-grid{grid-column:1 / -1;}

  /* market strips side by side */
  body .analysis-result-wrap{display:grid;grid-template-columns:1fr 1fr;gap:12px;align-items:start;}
  body .analysis-result-wrap > *{grid-column:1 / -1;margin:0!important;}
  body .analysis-result-wrap > .session-intelligence-card{grid-column:1;}
  body .analysis-result-wrap > .market-intelligence{grid-column:2;}
  body .analysis-result-wrap > .analysis-context{font-size:15px;color:var(--r-muted)!important;}

  /* chart + decision: two columns, chart pinned while reading */
  body .main-grid{display:grid!important;grid-template-columns:minmax(0,1.65fr) minmax(380px,1fr)!important;
    gap:16px!important;align-items:start!important;}
  /* beat the legacy :has(.execution-terminal-active) single-column override */
  body .app .main-grid > .chart-col{grid-column:1!important;grid-row:1;width:auto!important;min-width:0!important;
    position:sticky;top:96px;}
  body .app .main-grid > .panel-col{grid-column:2!important;grid-row:1;width:auto!important;min-width:0!important;max-width:none!important;}
  body .main-grid .ai-stat-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
}
@media (min-width:1600px){
  body .app{max-width:1680px;}
}
