/* Base */
:root{
  --bg:#efece6;
  --panel:#ffffff;
  --ink:#111827;
  --muted:#6b7280;
  --line:#e5e7eb;
  --shadow: 0 10px 30px rgba(15,23,42,.12);
  --top:#0b1220;
  --accent:#f97316;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color:var(--ink);
  background: radial-gradient(1200px 500px at 50% 0%, rgba(255,255,255,.25), transparent 60%), var(--bg);
}

.topbar{
  height:64px;
  background: linear-gradient(180deg, rgba(11,18,32,.98), rgba(11,18,32,.92));
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 18px;
  position:sticky;
  top:0;
  z-index:50;
}

.brand{display:flex; gap:10px; align-items:center}
.dot{width:10px;height:10px;border-radius:999px;background:var(--accent);display:inline-block}
.brand-title{font-weight:700; letter-spacing:.2px}
.brand-sub{font-size:12px; color:rgba(255,255,255,.75); margin-top:2px}

.btn{
  appearance:none;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  color:#fff;
  padding:8px 12px;
  border-radius:999px;
  cursor:pointer;
}
.btn:hover{background: rgba(255,255,255,.12)}

.shell{
  display:grid;
  grid-template-columns: 320px 1fr;
  gap:18px;
  padding:18px;
  max-width: 1500px;
  margin: 0 auto;
}

.sidebar{position:sticky; top:82px; align-self:start}
.card{
  background:var(--panel);
  border:1px solid rgba(229,231,235,.9);
  border-radius:16px;
  box-shadow: var(--shadow);
}
.side-card{padding:14px}
.side-head{display:flex; justify-content:space-between; align-items:center; padding:6px 6px 10px 6px}
.side-title{font-weight:800}
.pill{
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  background:#f3f4f6;
  border:1px solid #e5e7eb;
  color:#374151;
}
.tabs{display:flex; flex-direction:column; gap:10px; padding:6px}
.tab{
  display:flex;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid #e5e7eb;
  background:#fbfbfb;
  cursor:pointer;
}
.tab:hover{background:#f9fafb}
.tab.active{outline:2px solid rgba(249,115,22,.25); border-color: rgba(249,115,22,.45)}
.tab-title{font-weight:700; font-size:13px; line-height:1.2}
.tab-sub{font-size:12px; color:var(--muted); margin-top:2px}
.badge{
  font-size:12px;
  padding:4px 8px;
  border-radius:999px;
  background:#f3f4f6;
  border:1px solid #e5e7eb;
  color:#374151;
  white-space:nowrap;
  height: fit-content;
}
.side-note{
  margin:10px 6px 0 6px;
  padding:10px 12px;
  border-radius:14px;
  background:#f9fafb;
  border:1px dashed #e5e7eb;
  color:#4b5563;
  font-size:12px;
  line-height:1.4;
}
.side-footer{
  margin:12px 6px 2px 6px;
  padding-top:10px;
  border-top:1px solid var(--line);
}
.footer-title{font-size:12px; font-weight:700; color:#374151}
.footer-sub{font-size:12px; color:var(--muted); margin-top:4px}

.content{min-width:0}
.banner{
  background: rgba(239,68,68,.08);
  border:1px solid rgba(239,68,68,.25);
  color:#7f1d1d;
  padding:10px 12px;
  border-radius:14px;
  margin-bottom:12px;
}
.hidden{display:none}

.page{
  background: rgba(255,255,255,.55);
  border:1px solid rgba(229,231,235,.7);
  border-radius:18px;
  box-shadow: var(--shadow);
  padding:18px;
}
.page-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:12px;
  margin-bottom:16px;
}
.h1{font-size:28px;font-weight:900;margin:0}
.filters{display:flex; gap:10px; align-items:center; flex-wrap:wrap}
.select{
  border:1px solid #e5e7eb;
  background:#fff;
  border-radius:12px;
  padding:8px 10px;
  font-size:13px;
}

.grid-kpi{
  display:grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap:12px;
  margin-bottom:14px;
}

/* Overall KPI grid (8 cards = 2 rows of 4) */
.grid-4{
  display:grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap:12px;
  margin-bottom:14px;
}
.kpi{
  padding:14px;
  border-radius:16px;
  border:1px solid #e5e7eb;
  background:#ffffff;
  min-height:92px;
}
.kpi-label{font-size:12px; color:var(--muted); font-weight:700}
.kpi-value{font-size:26px; font-weight:900; margin-top:6px}
.kpi-sub{font-size:12px; color:var(--muted); margin-top:6px}

.grid-2{
  display:grid;
  grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr);
  gap:12px;
  align-items:start;
  margin-top:14px; /* ensures space from previous section */
}

.grid-2 > .card{min-width:0;}

.card-title{font-weight:900}
.card-sub{font-size:12px; color:var(--muted); margin-top:4px}
.card-body{padding:14px}
.card-head{padding:14px 14px 0 14px}
.chart-wrap{padding:12px 14px 14px 14px; height:320px}

/* Ensure charts use available space (prevents tiny squeezed plots) */
.chart-wrap canvas{
  width:100% !important;
  height:100% !important;
  display:block;
}

.hr{height:1px;background:var(--line);margin:12px 0}

.weekly-scroll{
  overflow-x:auto;
  padding-bottom:6px;
  overflow-y:hidden;
  max-width:100%;
  width:100%;
}

.weekly-scroll canvas{display:block}
.weekly-scroll canvas{min-width:900px; width:auto !important}

.insights{
  margin-top:14px;
}
.insights-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
  padding:14px;
}
.insight{
  border:1px solid #e5e7eb;
  border-radius:14px;
  background:#fff;
  padding:12px;
}
.insight-title{font-size:13px; font-weight:900; color:#111827}
.insight-value{font-size:22px; font-weight:900; margin-top:6px}
.insight-text{font-size:12px; color:var(--muted); margin-top:6px; line-height:1.35}

@media (max-width: 1100px){
  .shell{grid-template-columns:1fr}
  .sidebar{position:relative; top:auto}
  .grid-kpi{grid-template-columns: repeat(2, minmax(180px, 1fr))}
  .grid-4{grid-template-columns: repeat(2, minmax(180px, 1fr))}
  .grid-2{grid-template-columns:1fr}
  .weekly-scroll canvas{min-width:700px}
}


/* Weekly rhythm: keep it contained within the card and avoid forcing the grid to shrink siblings */
.chart-wrap.weekly-scroll{height:320px; min-width:0;}
.weekly-scroll{min-width:0;}
.weekly-scroll canvas{max-width:none;}


/* FINAL FIX: Align Weekly Rhythm height with Steward Output */
.card.steward-output,
.card.weekly-rhythm {
  height: 360px;
}

.card.weekly-rhythm .chart-wrap {
  height: 100%;
  padding-bottom: 0;
  margin-bottom: 0;
}

.card.weekly-rhythm canvas {
  height: 100% !important;
}
