/* HumanlyYou Broadcast — Command Center UI (Light) 
   Drop-in replacement for app.css (keeps existing class names).
*/
:root{
  /* Core palette (reference-like: light, blue accents) */
  --primary:#2563EB;
  --primary-2:#1D4ED8;
  --success:#16A34A;
  --warning:#F59E0B;
  --danger:#DC2626;

  --bg:#F5F7FC;
  --bg2:#EEF3FF;
  --card:#FFFFFF;
  --text:#0F172A;
  --muted:#64748B;
  --border:rgba(15,23,42,.10);

  --shadow: 0 10px 24px rgba(15,23,42,.08);
  --shadow2: 0 16px 40px rgba(15,23,42,.10);
  --radius: 18px;

  /* Back-compat tokens used by existing markup */
  --sage: var(--primary);
  --sage-dark: var(--primary-2);
  --sand: #EAF0FF;
  --offwhite: var(--bg);
  --earth: var(--warning);

  --ink: var(--text);
  --line: var(--border);

  /* Wider admin */
  --max: 1560px;
}

*{ 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(--text);
  background:
    radial-gradient(900px 700px at 12% 0%, rgba(37,99,235,.10), transparent 60%),
    radial-gradient(900px 700px at 92% 10%, rgba(99,102,241,.10), transparent 60%),
    var(--bg);
  line-height:1.55;
}

a{ color:inherit; text-decoration:none; }
.muted{ color:var(--muted); }
.tiny{ font-size:13px; color:var(--muted); }
.inline{ display:inline; }

.shell{ max-width:var(--max); width: min(98vw, var(--max)); margin:0 auto; padding: 18px 24px; }

/* Topbar */
.topbar{
  position:sticky; top:0; z-index:50;
  background:rgba(255,255,255,.75);
  backdrop-filter: blur(10px);
  border-bottom:1px solid var(--border);
}
.topbar__left{ display:flex; align-items:center; gap:12px; }
.topbar__right{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }

.brand{
  display:flex; align-items:center; gap:10px;
  font-weight:800; letter-spacing:.2px;
}
.brand__mark{
  width:34px; height:34px; border-radius:12px;
  background: linear-gradient(135deg, rgba(37,99,235,.95), rgba(99,102,241,.85));
  box-shadow: 0 10px 18px rgba(37,99,235,.18);
  position:relative; overflow:hidden;
}
.brand__mark:before{
  content:""; position:absolute; inset:8px 10px 9px 10px;
  border:2px solid rgba(255,255,255,.85);
  border-top-left-radius:18px; border-bottom-right-radius:18px;
  transform: rotate(10deg); opacity:.9;
}

.iconbtn{
  display:inline-flex; align-items:center; justify-content:center;
  width:44px; height:44px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.85);
  border-radius:12px;
  cursor:pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  box-shadow: 0 8px 18px rgba(15,23,42,.06);
}
.iconbtn:hover{ transform: translateY(-1px); box-shadow: var(--shadow); }

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

/* Buttons */
.btn{
  display:inline-flex; align-items:center; justify-content:center;
  padding:10px 14px;
  border-radius:999px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.85);
  transition: transform .15s ease, box-shadow .15s ease;
  box-shadow: 0 8px 18px rgba(15,23,42,.06);
  font-size:14px; font-weight:700;
  white-space:nowrap;
}
.btn:hover{ transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active{ transform: translateY(0); }

.btn--ghost{ background:rgba(255,255,255,.85); }

.btn.primary{
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 14px 26px rgba(37,99,235,.20);
}

.btn--sm{ padding: 8px 12px; font-size: 13px; }

/* Layout */
.layout{
  display:grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  min-height: calc(100vh - 78px);
  margin-top: 14px;
}

/* Sidebar */
.sidebar{
  border-radius: 22px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.72);
  box-shadow: var(--shadow2);
  padding: 14px;
  height: calc(100vh - 120px);
  position: sticky;
  top: 86px;
  overflow:auto;
}
.navtitle{
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.12em;
  color:var(--muted);
  margin: 10px 8px 8px;
}
.navitem{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 12px;
  border-radius:16px;
  margin-bottom:8px;
  border:1px solid transparent;
  color: var(--text);
}
.navitem:hover{
  background: rgba(37,99,235,.08);
  border-color: rgba(15,23,42,.08);
}
.navitem.active{
  background: rgba(37,99,235,.12);
  border-color: rgba(37,99,235,.25);
}
.navitem.disabled{ opacity:.55; cursor:not-allowed; }

.badge{
  font-size:12px;
  padding:2px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.85);
  color: var(--muted);
}
.sidebar__footer{
  margin-top: 14px;
  padding-top: 12px;
  border-top:1px dashed rgba(15,23,42,.12);
}

/* Content */
.content{
  border-radius: 22px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.78);
  box-shadow: var(--shadow2);
  padding: 18px;
  overflow:hidden;
  padding-bottom:160px;
}

h1{ font-size:30px; line-height:1.15; margin:0 0 10px; letter-spacing:-.2px; }
h2{ margin:0 0 10px; font-size:18px; }
p{ margin: 8px 0; }

.card{
  background: rgba(255,255,255,.92);
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding:18px;
  box-shadow: var(--shadow);
}
.card--center{ max-width: 480px; margin: 36px auto; }
.card__title{ margin:0 0 6px; font-size:12px; text-transform:uppercase; letter-spacing:.10em; color:var(--muted); font-weight:800; }
.card__big{ font-size:34px; font-weight:900; margin: 2px 0 0; color: var(--text); }

.grid{ display:grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid4{ display:grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1200px){ .grid4{ grid-template-columns: repeat(2, 1fr);} }
@media (max-width: 920px){ .grid4{ grid-template-columns: 1fr;} }

.split{
  display:grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 16px;
  align-items:start;
}

.tablecard{ padding:0; overflow:visible; }

/* Tables */
.table{ width:100%; border-collapse: collapse; }
.table th, .table td{
  padding:12px 14px;
  border-bottom:1px solid rgba(15,23,42,.06);
  text-align:left;
  font-size:14px;
}
.table th{ color: var(--muted); font-weight:800; letter-spacing:.06em; text-transform:uppercase; font-size:12px; }
.table tr:hover td{ background: rgba(37,99,235,.05); }

/* Forms */
.form{ display:flex; flex-direction:column; gap:12px; margin-top:10px; }
.label{ font-size:14px; color:var(--muted); }
.input{
  width:100%;
  padding:12px 12px;
  border-radius:14px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.92);
  font: inherit;
  outline:none;
}
.input:focus{
  border-color: rgba(37,99,235,.45);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}

/* Alerts */
.alert{
  font-size:13px;
  color:var(--muted);
  background: rgba(255,255,255,.85);
  border:1px solid var(--border);
  padding:12px;
  border-radius:16px;
}
.alert--error{
  border-color: rgba(220,38,38,.25);
  background: rgba(220,38,38,.08);
  color: var(--text);
}

/* Pills / status */
.pill{
  display:inline-flex; align-items:center; gap:8px;
  padding:6px 12px; border-radius:999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.88);
  color: rgba(15,23,42,.80);
  font-size:12px;
  font-weight:800;
}
.pill.live{ border-color: rgba(22,163,74,.22); background: rgba(22,163,74,.10); color: var(--success); }
.pill.warn{ border-color: rgba(245,158,11,.25); background: rgba(245,158,11,.12); color: #B45309; }
.pill.bad{ border-color: rgba(220,38,38,.22); background: rgba(220,38,38,.10); color: var(--danger); }

/* Progress bars (quota, rate limit, etc.) */
.progress{
  height:8px;
  border-radius:999px;
  background: rgba(15,23,42,.06);
  overflow:hidden;
}
.progress > span{
  display:block; height:100%;
  border-radius:999px;
  background: linear-gradient(90deg, var(--primary), rgba(99,102,241,.9));
}

/* KPI cards */
.kpi{ display:flex; flex-direction:column; gap:10px; }
.kpi__row{ display:flex; justify-content:space-between; align-items:center; gap:12px; }
.kpi__value{ font-size:34px; font-weight:900; letter-spacing:-.4px; }
.kpi__delta{ font-size:12px; font-weight:900; color: var(--success); }
.kpi__spark{ height:34px; border-radius:12px; background: rgba(37,99,235,.06); border:1px solid rgba(37,99,235,.10); }

/* Panel header */
.panelhdr{ display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:10px; }
.panelhdr h2{ margin:0; }
.chips{ display:flex; gap:8px; flex-wrap:wrap; }
.chip{
  display:inline-flex; align-items:center; gap:6px;
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:999px;
  background: rgba(255,255,255,.90);
  color: var(--text);
  font-weight:800;
  font-size:13px;
}
.chip.active{ background: rgba(37,99,235,.12); border-color: rgba(37,99,235,.25); color: rgba(29,78,216,1); }

/* Mobile */
@media (max-width: 980px){
  .shell{ padding: 12px 14px; }
  .layout{ grid-template-columns: 1fr; }
  .sidebar{
    position: fixed;
    left: 14px;
    top: 72px;
    bottom: 14px;
    width: min(340px, calc(100vw - 28px));
    transform: translateX(-120%);
    transition: transform .2s ease;
    z-index: 60;
    height: auto;
  }
  .sidebar.open{ transform: translateX(0); }
  .grid{ grid-template-columns: 1fr; }
  .split{ grid-template-columns: 1fr; }
  .kbd{ display:none; }
}

/* === Command Center Topbar + Sidebar (drop-in) === */
.topbar .shell{ display:flex; align-items:center; justify-content:space-between; gap:14px; }
.topbar__center{ flex: 1; display:flex; align-items:center; justify-content:center; gap:14px; min-width: 280px; }
.cc-head{ display:flex; align-items:center; gap:10px; white-space:nowrap; }
.cc-title{ font-weight:900; letter-spacing:-.2px; }
.cc-status{ display:inline-flex; align-items:center; gap:8px; font-size:12px; font-weight:900; padding:6px 10px; border-radius:999px; border:1px solid rgba(0,0,0,.08); background: rgba(255,255,255,.70); }
.cc-status--live{ border-color: rgba(31,122,68,.18); background: rgba(31,122,68,.10); color:#1f7a44; }
.cc-dot{ width:8px; height:8px; border-radius:999px; background:#22c55e; box-shadow:0 0 0 4px rgba(34,197,94,.18); }

.cc-meters{ display:flex; align-items:center; gap:12px; padding:10px 12px; border-radius: 999px; border:1px solid rgba(0,0,0,.08); background: rgba(255,255,255,.72); backdrop-filter: blur(10px); }
.cc-meter{ min-width: 210px; }
.cc-meter__top{ display:flex; align-items:baseline; justify-content:space-between; gap:10px; }
.cc-meter__label{ font-size:12px; color: rgba(0,0,0,.55); font-weight:800; }
.cc-meter__value{ font-size:12px; color: rgba(0,0,0,.70); font-weight:700; }
.cc-bar{ height:6px; border-radius:999px; background: rgba(0,0,0,.06); overflow:hidden; margin-top:8px; }
.cc-bar__fill{ height:100%; border-radius:999px; background: linear-gradient(135deg, rgba(59,130,246,.95), rgba(37,99,235,.95)); }

.cc-user{ position: relative; }
.cc-user__summary{ display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:999px; border:1px solid rgba(0,0,0,.08); background: rgba(255,255,255,.70); cursor:pointer; list-style:none; }
.cc-user__summary::-webkit-details-marker{ display:none; }
.cc-avatar{ width:32px; height:32px; display:inline-flex; align-items:center; justify-content:center; border-radius:999px; background: rgba(59,130,246,.14); border:1px solid rgba(59,130,246,.22); font-weight:900; color: rgba(37,99,235,.92); }
.cc-user__name{ font-weight:800; font-size:13px; color: rgba(0,0,0,.72); }
.cc-caret{ opacity:.7; }
.cc-user__menu{ position:absolute; right:0; top: calc(100% + 10px); width: 220px; border-radius: 16px; border:1px solid rgba(0,0,0,.10); background:#fff; box-shadow: 0 18px 45px rgba(0,0,0,.10); overflow:hidden; z-index: 9999; }
.cc-user__item{ display:block; padding:12px 12px; font-weight:800; font-size:13px; color: rgba(0,0,0,.75); }
.cc-user__item:hover{ background: rgba(59,130,246,.08); }
.cc-user__sep{ height:1px; background: rgba(0,0,0,.06); }
.cc-user__logout{ width:100%; text-align:left; border:0; background:transparent; cursor:pointer; }

.cc-sidebar .navitem{ display:flex; align-items:center; justify-content:space-between; }
.cc-nav__left{ display:inline-flex; align-items:center; gap:10px; }
.cc-ico{ width:22px; height:22px; display:inline-flex; align-items:center; justify-content:center; opacity:.9; }

/* Mobile: hide center meters and keep header compact */
@media (max-width: 980px){
  .topbar .shell{ gap:10px; }
  .topbar__center{ display:none; }
  .cc-user__name{ display:none; }
}

/* ===============================
   FULL WIDTH LAYOUT FIX
=================================*/
.layout--full {
  grid-template-columns: 1fr !important;
}

.layout--full .content {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 0 !important;
}

/* ===============================
   PREMIUM GLASS LOGIN
=================================*/
.loginwrap{
  min-height: calc(100vh - 70px);
  display:grid;
  place-items:center;
  padding: 30px 16px;
  position:relative;
}

.loginbg{
  position:absolute;
  inset: 0;
  background:
    radial-gradient(900px 520px at 15% 15%, rgba(59,130,246,.15), transparent 55%),
    radial-gradient(900px 520px at 85% 20%, rgba(110,143,122,.15), transparent 55%);
}

.logincard{
  width: min(460px, 100%);
  border-radius: 24px;
  border: 1px solid rgba(0,0,0,.08);
  background: rgba(255,255,255,.75);
  backdrop-filter: blur(14px);
  box-shadow: 0 25px 70px rgba(0,0,0,.12);
  padding: 28px;
}

.loginbrand{
  display:flex;
  gap: 12px;
  align-items:center;
  margin-bottom: 12px;
}

.loginmark{
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg,#2563eb,#3b82f6);
}

.loginTitle{
  font-size: 28px;
  margin: 6px 0;
}

.loginBtn{
  width:100%;
  margin-top: 12px;
}

.loginFoot{
  margin-top: 12px;
  text-align:center;
}

/* Make login inputs + labels look premium */
.logincard .form{ display:flex; flex-direction:column; gap:12px; margin-top:10px; }

.logincard .label{
  font-size:13px;
  color: rgba(0,0,0,.55);
  font-weight: 700;
}

.logincard .input{
  width:100%;
  padding:12px 12px;
  border-radius:14px;
  border:1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.85);
  font: inherit;
  outline:none;
}

.logincard .input:focus{
  border-color: rgba(37,99,235,.45);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}

.logincard .btn.primary{
  width:100%;
  padding:12px 14px;
  border-radius:999px;
  border:0;
  color:#fff;
  font-weight:900;
  background: linear-gradient(135deg,#2563eb,#3b82f6);
  box-shadow: 0 14px 30px rgba(37,99,235,.22);
  cursor:pointer;
}

.logincard .btn.primary:hover{ filter: brightness(0.98); }

/* ========= Engagement Chart ========= */
.chartbox{
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 16px;
  background: rgba(255,255,255,.6);
  padding: 12px;
}

.chartsvg{
  width: 100%;
  height: auto;
  display: block;
}

.chartgrid{
  stroke: rgba(15,23,42,.10);
  stroke-width: 1;
}

.chartaxis{
  fill: rgba(15,23,42,.55);
  font-size: 11px;
  font-weight: 700;
}

.line{
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .95;
}

.line.sent{ stroke: #2563eb; }
.line.open{ stroke: #10b981; }
.line.click{ stroke: #f59e0b; }
.line.bounce{ stroke: #ef4444; opacity: .9; }

.chartlegend{
  display:flex;
  flex-wrap:wrap;
  gap: 10px 14px;
  margin-top: 10px;
  font-size: 12px;
  color: rgba(15,23,42,.75);
  font-weight: 800;
}

.chartlegend .dot{
  display:inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 6px;
  transform: translateY(1px);
}
.chartlegend .dot.sent{ background:#2563eb; }
.chartlegend .dot.open{ background:#10b981; }
.chartlegend .dot.click{ background:#f59e0b; }
.chartlegend .dot.bounce{ background:#ef4444; }

/* ===============================
   DASHBOARD LAYOUT FIXES
   (prevents squished columns / clipped tables)
=================================*/
@media (max-width: 1200px){
  .split{ grid-template-columns: 1fr; }
}

.tablewrap{
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}
.tablewrap .table{ min-width: 760px; }

/* List Health responsive layout */
.listhealth{
  display:grid;
  grid-template-columns: 180px 1fr;
  gap: 14px;
  align-items: center;
}
@media (max-width: 520px){
  .listhealth{ grid-template-columns: 1fr; }
}

.donut{
  width:180px;
  height:180px;
  border-radius:999px;
  border:14px solid rgba(37,99,235,.12);
  display:flex;
  align-items:center;
  justify-content:center;
  margin: 0 auto;
}
.donut__inner{ text-align:center; }
/* === Dashboard layout (dash__*) === */
.dash{ display:flex; flex-direction:column; gap:16px; }

.dash__header{ display:flex; justify-content:space-between; align-items:flex-start; gap:14px; }
.dash__title{ margin:0; font-size:28px; letter-spacing:-.4px; }
.dash__headerActions{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }

.dash__statusGrid{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.dash__kpiGrid{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.dash__main{
  display:grid;
  grid-template-columns: 1.35fr .65fr;
  gap: 16px;
  align-items:start;
}

.dash__stack{ display:flex; flex-direction:column; gap:16px; }

/* Prevent “tall right column pushes everything down” by capping scroll areas */
.dash__scroll{
  max-height: 220px;
  overflow:auto;
  padding-right: 6px;
}
.dash__scroll::-webkit-scrollbar{ width:10px; }
.dash__scroll::-webkit-scrollbar-thumb{ background: rgba(15,23,42,.14); border-radius:999px; }
.dash__scroll::-webkit-scrollbar-track{ background: rgba(15,23,42,.04); border-radius:999px; }

/* Smaller scroll for compact side widgets */
.dash__scroll--sm{ max-height: 170px; }

@media (max-width: 1200px){
  .dash__statusGrid{ grid-template-columns: repeat(2, 1fr); }
  .dash__kpiGrid{ grid-template-columns: repeat(2, 1fr); }
  .dash__main{ grid-template-columns: 1fr; }
}

@media (max-width: 680px){
  .dash__statusGrid{ grid-template-columns: 1fr; }
  .dash__kpiGrid{ grid-template-columns: 1fr; }
  .dash__header{ flex-direction:column; align-items:stretch; }
}

/* ===============================
   DASHBOARD ORGANIZATION LAYER
================================= */
.dash { display: grid; gap: 16px; }

.dash__header{
  display:flex; align-items:flex-start; justify-content:space-between;
  gap:16px; margin-bottom:4px;
}
.dash__title{ margin:0; font-size:28px; line-height:1.1; }
.dash__headerActions{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }

/* Status row inside a single card */
.dash__statusGrid{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap:14px;
}

/* KPI grid: 4 columns desktop, 2 tablet, 1 mobile */
.dash__kpiGrid{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap:16px;
}

/* Main: Left content + Right stack */
.dash__main{
  display:grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap:16px;
  align-items:start;
}

.dash__stack{ display:grid; gap:16px; }

/* Scrollable widgets so they don't grow forever */
.dash__scroll{
  max-height: 280px;
  overflow:auto;
  padding-right: 6px;
}

/* Improve small screens */
@media (max-width: 1100px){
  .dash__statusGrid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash__kpiGrid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash__main{ grid-template-columns: 1fr; }
  .dash__scroll{ max-height: 240px; }
}

@media (max-width: 640px){
  .dash__statusGrid{ grid-template-columns: 1fr; }
  .dash__kpiGrid{ grid-template-columns: 1fr; }
  .dash__header{ flex-direction:column; }
}

/* --- Dashboard: true 2-column flow (prevents big blank gaps) --- */
.dash__grid{
  display:grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap:16px;
  align-items:start;
  margin-top:16px;
}

.dash__col{
  display:flex;
  flex-direction:column;
  gap:16px;
  min-width:0;
}

/* Scroll helpers */
.dash__scroll{ max-height: 320px; overflow:auto; }
.dash__scroll--sm{ max-height: 220px; overflow:auto; }

/* Responsive: single column on smaller screens */
@media (max-width: 1100px){
  .dash__grid{ grid-template-columns: 1fr; }
  
}

/* =========================================================
   Mobile polish (non-breaking): dashboard + admin UI
   - Fix transparency/contrast on mobile
   - Make grids stack cleanly
   - Prevent buttons from disappearing/overflowing
   - Keep desktop look unchanged
   ========================================================= */

/* If backdrop-filter is not supported, fall back to solid surfaces */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .topbar, .sidebar, .card { background: #fff !important; }
}

/* Dashboard layout helpers (used by admin/dashboard view) */
.dash{ max-width:1180px; margin:0 auto; }
.dash__header{ display:flex; align-items:flex-start; justify-content:space-between; gap:14px; margin-bottom:16px; }
.dash__headerActions{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end; }

.dash__statusGrid{ display:grid; grid-template-columns:repeat(4, minmax(0,1fr)); gap:14px; }
.dash__kpiGrid{ display:grid; grid-template-columns:repeat(4, minmax(0,1fr)); gap:14px; margin-top:16px; }

.dash__main{ display:grid; grid-template-columns:minmax(0,1fr) 380px; gap:14px; margin-top:16px; }
.dash__stack{ display:flex; flex-direction:column; gap:14px; min-width:0; }

.dash__scroll{ max-height:280px; overflow:auto; padding-right:6px; }

/* Charts should not overflow on small screens */
.chartbox{ overflow-x:auto; }
.chartsvg{ width:100%; height:auto; min-width:640px; display:block; }
.chartlegend{ display:flex; flex-wrap:wrap; gap:10px 14px; }

/* Tables: allow horizontal scroll without breaking layout */
.tablewrap{ overflow:auto; -webkit-overflow-scrolling:touch; }

/* ---------------------------------------------------------
   Responsive: tablet / mobile
   --------------------------------------------------------- */
@media (max-width: 980px){
  .dash__statusGrid{ grid-template-columns:repeat(2, minmax(0,1fr)); }
  .dash__kpiGrid{ grid-template-columns:repeat(2, minmax(0,1fr)); }
  .dash__main{ grid-template-columns:1fr; }
  .dash__scroll{ max-height:240px; }
}

@media (max-width: 640px){
  /* kill glassy transparency on small screens (readability) */
  .topbar, .sidebar, .card{
    background: #fff !important;
  }

  /* layout padding + sticky sidebar issues */
  .shell{ padding: 10px !important; }
  .layout{ gap: 10px !important; }
  .sidebar{
    position: static !important;
    top: auto !important;
    height: auto !important;
    margin-bottom: 10px;
  }

  /* header wraps nicely */
  .dash__header{ flex-direction:column; align-items:stretch; }
  .dash__headerActions{ justify-content:flex-start; }

  /* grids become single column */
  .dash__statusGrid{ grid-template-columns:1fr; }
  .dash__kpiGrid{ grid-template-columns:1fr; }

  /* buttons become easier to tap */
  .btn{ width:100%; justify-content:center; }
  .chips, .panelhdr .chips{ width:100%; }
  .chip{ display:inline-flex; }

  /* prevent long URLs/titles from pushing layout */
  .alert span, .alert strong, .panelhdr h2, .panelhdr h1{ min-width:0; }
  .alert{ word-break:break-word; }
}

/* =========================================
   Mobile Topbar & Command Center Fix
   ========================================= */

@media (max-width: 1024px){

  .topbar .shell{
    flex-direction:column;
    align-items:stretch;
    gap:10px;
  }

  .topbar__left,
  .topbar__right{
    display:flex;
    justify-content:space-between;
    align-items:center;
  }

  .topbar__center{
    width:100%;
  }

  .cc-head{
    display:flex;
    justify-content:space-between;
    align-items:center;
  }

  .cc-meters{
    display:flex;
    flex-direction:column;
    gap:10px;
  }

  .cc-meter{
    width:100%;
  }

  .cc-bar{
    width:100%;
  }
}


/* ===== SMALL PHONE OPTIMIZATION ===== */
@media (max-width: 640px){

  /* Hide heavy Command Center meters on small screens */
  .cc-meters{
    display:none;
  }

  .cc-head{
    justify-content:space-between;
  }

  .topbar__center{
    padding:8px 0;
  }

  .topbar__right{
    justify-content:flex-end;
  }

  .btn{
    width:auto;
  }
}