
:root {
  --navy: #0d1b2a;
  --navy2: #1a2f47;
  --navy3: #243b53;
  --gold: #F5D794;
  --gold2: #e8c56d;
  --white: #f0f4f8;
  --muted: #8899aa;
  --green: #4ade80;
  --red: #f87171;
  --yellow: #fbbf24;
  --blue: #60a5fa;
  --orange: #fb923c;
  --purple: #a78bfa;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);

  /* Platform brand colors */
  --plat-fb:  #1877f2;
  --plat-yt:  #ff0000;
  --plat-tt:  #ff0050;
  --plat-ig:  #c13584;
  --plat-web: #00b96b;
  --plat-za:  #1ba3ff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--navy); color: var(--white); font-family: 'Segoe UI', system-ui, sans-serif; font-size: 21px; min-height: 100vh; }

/* ─── Login ─── */
#login-overlay { position: fixed; inset: 0; background: var(--navy); display: flex; align-items: center; justify-content: center; z-index: 9999; }
#login-box { background: var(--navy2); padding: 40px; border-radius: 16px; border: 1px solid var(--navy3); box-shadow: var(--shadow); text-align: center; width: 360px; }
#login-box h2 { color: var(--gold); font-size: 33px; margin-bottom: 8px; }
#login-box p { color: var(--muted); margin-bottom: 24px; font-size: 20px; }
#login-box input { width: 100%; padding: 12px 16px; border-radius: 8px; border: 1px solid var(--navy3); background: var(--navy); color: var(--white); font-size: 22px; margin-bottom: 12px; outline: none; transition: border-color .15s; }
#login-box input:focus { border-color: var(--gold); }
#login-btn { width: 100%; padding: 12px; background: var(--gold); color: var(--navy); font-weight: 700; font-size: 22px; border: none; border-radius: 8px; cursor: pointer; transition: background .15s, transform .1s, box-shadow .15s; }
#login-btn:hover { background: var(--gold2); transform: scale(1.02); box-shadow: 0 0 14px rgba(245,215,148,.3); }
#login-btn:active { transform: scale(0.98); box-shadow: inset 0 2px 6px rgba(0,0,0,.2); }
#login-err { color: var(--red); font-size: 20px; margin-top: 8px; }

/* ─── Layout ─── */
#app { display: none; flex-direction: column; min-height: 100vh; }
header { background: var(--navy2); border-bottom: 1px solid var(--navy3); padding: 0 16px; display: flex; align-items: center; gap: 10px; height: 44px; }
header .logo { color: var(--gold); font-weight: 800; font-size: 24px; letter-spacing: 1px; flex-shrink: 0; }
header .logo span { font-weight: 300; opacity: 0.7; }
#vps-status { display: flex; gap: 8px; align-items: center; margin-left: auto; font-size: 18px; }
.vps-chip { background: var(--navy3); border-radius: 20px; padding: 4px 10px; display: flex; align-items: center; gap: 5px; }
.vps-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.vps-chip .dot.warn { background: var(--yellow); }
.vps-chip .dot.err { background: var(--red); animation: pulse-err 1.5s infinite; }
#reload-btn { background: none; border: 1px solid var(--navy3); color: var(--muted); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 18px; transition: all .15s, transform .1s; }
#reload-btn:hover { border-color: var(--gold); color: var(--gold); transform: scale(1.02); }
#reload-btn:active { transform: scale(0.97); box-shadow: inset 0 1px 4px rgba(0,0,0,.25); }
#live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; margin-right: 3px; transition: background .3s; }
#live-dot.connected { background: var(--green); box-shadow: 0 0 6px var(--green); animation: pulse 2s infinite; }
#live-dot.err { background: var(--red); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
@keyframes pulse-err { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ─── Tabs ─── */
nav { background: var(--navy2); border-bottom: 2px solid var(--navy3); padding: 0 14px; display: flex; gap: 0; overflow-x: auto; }
nav::-webkit-scrollbar { height: 0; }
.tab {
  padding: 7px 12px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 20px;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
  transition: color .18s;
}
.tab:hover { color: var(--white); }
/* Active tab: slide-in bottom border animation */
.tab.active { color: var(--gold); }
.tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gold);
  border-radius: 2px 2px 0 0;
  animation: tabSlideIn .22s cubic-bezier(.4,0,.2,1) both;
}
@keyframes tabSlideIn {
  from { transform: scaleX(0); opacity: 0; }
  to   { transform: scaleX(1); opacity: 1; }
}

/* ─── Content ─── */
main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.page { display: none; padding: 12px; }
.page.active { display: block; }

/* ─── Cards / Stats ─── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin-bottom: 12px; }
.stat-card { background: var(--navy2); border: 1px solid var(--navy3); border-radius: var(--radius); padding: 10px 14px; cursor: default; transition: border-color .15s, transform .2s, box-shadow .2s; }
.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(245,215,148,.12); }
.stat-card .label { color: var(--muted); font-size: 16px; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }
.stat-card .value { font-size: 33px; font-weight: 700; color: var(--gold); line-height: 1; }
.stat-card .sub { font-size: 16px; color: var(--muted); margin-top: 3px; }
.stat-card.green .value { color: var(--green); }
.stat-card.red .value { color: var(--red); }
.stat-card.blue .value { color: var(--blue); }
.stat-card.yellow .value { color: var(--yellow); }
.stat-card.orange .value { color: var(--orange); }

.section-title { font-size: 18px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }

/* ─── Tables ─── */
.table-wrap { background: var(--navy2); border: 1px solid var(--navy3); border-radius: var(--radius); overflow: hidden; }
.table-toolbar { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--navy3); flex-wrap: wrap; }
.table-toolbar .t-title { font-weight: 700; font-size: 21px; flex: 1; min-width: 140px; }
.t-search { background: var(--navy); border: 1px solid var(--navy3); color: var(--white); border-radius: 6px; padding: 6px 12px; font-size: 20px; outline: none; width: 200px; transition: border-color .15s; }
.t-search:focus { border-color: var(--gold); }
.t-refresh { background: none; border: 1px solid var(--navy3); color: var(--muted); border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 18px; transition: all .15s, transform .1s; }
.t-refresh:hover { border-color: var(--gold2); color: var(--gold2); transform: scale(1.04); }
.t-refresh:active { transform: scale(0.96); box-shadow: inset 0 1px 4px rgba(0,0,0,.2); }

/* ─── Filter Bar ─── */
.filter-bar { display: flex; flex-wrap: wrap; gap: 4px; padding: 5px 10px; border-bottom: 1px solid var(--navy3); align-items: center; background: rgba(0,0,0,.15); }
.filter-label { color: var(--muted); font-size: 16px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; margin-right: 2px; }
.filter-sep { width: 1px; height: 18px; background: var(--navy3); margin: 0 6px; flex-shrink: 0; }
.fchip {
  padding: 3px 8px;
  border-radius: 14px;
  border: 1px solid var(--navy3);
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  background: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  transition: color .12s, border-color .12s, background .12s, transform .1s;
}
.fchip:hover { color: var(--white); border-color: #445; transform: scale(1.03); }
.fchip:active { transform: scale(0.96); }
/* Ripple on chip click */
.fchip .chip-ripple {
  position: absolute;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  margin-top: -16px;
  margin-left: -16px;
  background: rgba(245,215,148,.35);
  pointer-events: none;
  animation: chipRipple .38s linear forwards;
}
@keyframes chipRipple {
  0%   { transform: scale(0); opacity: .9; }
  100% { transform: scale(3.5); opacity: 0; }
}
.fchip.fc-all.active { background: var(--gold); color: var(--navy); border-color: var(--gold); font-weight: 700; }
.fchip.fc-blue.active { background: rgba(96,165,250,.2); color: var(--blue); border-color: var(--blue); }
.fchip.fc-yellow.active { background: rgba(251,191,36,.2); color: var(--yellow); border-color: var(--yellow); }
.fchip.fc-orange.active { background: rgba(251,146,60,.2); color: var(--orange); border-color: var(--orange); }
.fchip.fc-green.active { background: rgba(74,222,128,.2); color: var(--green); border-color: var(--green); }
.fchip.fc-red.active { background: rgba(248,113,113,.2); color: var(--red); border-color: var(--red); }
.fchip.fc-warn.active { background: rgba(251,191,36,.15); color: var(--yellow); border-color: var(--yellow); }
.fchip.fc-ct.active { background: rgba(245,215,148,.15); color: var(--gold); border-color: var(--gold); font-weight: 700; }
.fchip.fc-plat.active { font-weight: 700; }

.table-scroll { overflow-x: auto; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 20px; }
.date-group-row td { background: var(--navy3); color: var(--gold); font-size: 18px; font-weight: 700; padding: 5px 10px; border-bottom: 1px solid rgba(255,255,255,.06); position: sticky; top: 29px; z-index: 2; }
.date-group-row.past td { color: var(--muted); font-weight: 600; }
.date-group-row.is-today td { color: var(--green); }
.dg-today-tag { background: var(--green); color: var(--navy); border-radius: 10px; padding: 1px 8px; font-size: 15px; margin-left: 6px; }
.dg-count { float: right; color: var(--muted); font-weight: 400; }
th { position: sticky; top: 0; background: var(--navy3); color: var(--muted); font-size: 16px; text-transform: uppercase; letter-spacing: .5px; padding: 7px 10px; text-align: left; white-space: nowrap; font-weight: 600; z-index: 1; }
td { padding: 7px 10px; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,0.03); }
tr:last-child td { border-bottom: none; }

/* ─── Row status coloring ─── */
tr[data-s="nhap"] > td:first-child { border-left: 3px solid var(--blue); }
tr[data-s="duyet"] > td:first-child { border-left: 3px solid var(--yellow); }
tr[data-s="dang"] > td:first-child { border-left: 3px solid var(--orange); }
tr[data-s="ok"] > td:first-child { border-left: 3px solid var(--green); opacity: .75; }
tr[data-s="loi"] > td:first-child { border-left: 3px solid var(--red); }
tr[data-s="loi"] { background: rgba(248,113,113,.04); }
tr[data-s="ok"] { opacity: 0.7; }

/* ─── Status badges ─── */
.badge { display: inline-block; padding: 3px 9px; border-radius: 12px; font-size: 16px; font-weight: 600; }
.badge-blue   { background: rgba(96,165,250,.18);  color: #93c5fd; }
.badge-yellow { background: rgba(251,191,36,.18);  color: #fcd34d; }
.badge-green  { background: rgba(74,222,128,.18);  color: #86efac; }
.badge-red    { background: rgba(248,113,113,.18); color: #fca5a5; }
.badge-orange { background: rgba(251,146,60,.18);  color: #fdba74; }
.badge-gray   { background: rgba(148,163,184,.12); color: #94a3b8; }
.badge-purple { background: rgba(167,139,250,.18); color: #c4b5fd; }

/* ─── Platform pill badges ─── */
.plat-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}
.plat-badge.fb  { background: rgba(24,119,242,.18); color: var(--plat-fb);  border: 1px solid rgba(24,119,242,.3); }
.plat-badge.yt  { background: rgba(255,0,0,.15);    color: var(--plat-yt);  border: 1px solid rgba(255,0,0,.25); }
.plat-badge.tt  { background: rgba(255,0,80,.15);   color: var(--plat-tt);  border: 1px solid rgba(255,0,80,.25); }
.plat-badge.ig  { background: rgba(193,53,132,.15); color: var(--plat-ig);  border: 1px solid rgba(193,53,132,.25); }
.plat-badge.web { background: rgba(0,185,107,.15);  color: var(--plat-web); border: 1px solid rgba(0,185,107,.25); }
.plat-badge.za  { background: rgba(27,163,255,.15); color: var(--plat-za);  border: 1px solid rgba(27,163,255,.25); }

/* ─── Action buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 6px; border: 1px solid;
  cursor: pointer; font-size: 18px; font-weight: 500;
  white-space: nowrap;
  transition: all .15s, transform .1s, box-shadow .15s;
}
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn:not(:disabled):active { transform: scale(0.96); box-shadow: inset 0 1px 4px rgba(0,0,0,.25); }
.btn-primary { background: var(--gold); color: var(--navy); border-color: var(--gold); }
.btn-primary:hover:not(:disabled) { background: var(--gold2); border-color: var(--gold2); transform: scale(1.02); box-shadow: 0 0 14px rgba(245,215,148,.3); }
.btn-ghost  { background: none; color: var(--muted); border-color: var(--navy3); }
.btn-ghost:hover:not(:disabled)  { border-color: var(--white); color: var(--white); transform: scale(1.02); }
.btn-danger { background: none; color: var(--red); border-color: rgba(248,113,113,.3); }
.btn-danger:hover:not(:disabled) { background: rgba(248,113,113,.1); transform: scale(1.02); }
.btn-blue { background: rgba(96,165,250,.15); color: var(--blue); border-color: rgba(96,165,250,.3); }
.btn-blue:hover:not(:disabled) { background: rgba(96,165,250,.25); transform: scale(1.02); }
.btn-green { background: rgba(74,222,128,.15); color: var(--green); border-color: rgba(74,222,128,.3); }
.btn-green:hover:not(:disabled) { background: rgba(74,222,128,.25); transform: scale(1.02); }
.btn-orange { background: rgba(251,146,60,.15); color: var(--orange); border-color: rgba(251,146,60,.3); }
.btn-orange:hover:not(:disabled) { background: rgba(251,146,60,.25); transform: scale(1.02); }
.btn-sm { padding: 3px 8px; font-size: 16px; }

/* ─── Video Pipeline ─── */
.pipeline { display: flex; align-items: center; gap: 3px; }
.pip-btn { padding: 3px 9px; border-radius: 5px; border: 1px solid; cursor: pointer; font-size: 16px; font-weight: 600; transition: all .12s, transform .1s; white-space: nowrap; }
.pip-btn:not([disabled]):hover { transform: scale(1.04); }
.pip-btn:not([disabled]):active { transform: scale(0.95); box-shadow: inset 0 1px 3px rgba(0,0,0,.25); }
.pip-btn.done   { color: var(--green);  border-color: rgba(74,222,128,.3);  background: rgba(74,222,128,.08); cursor: default; }
.pip-btn.active { color: var(--gold);   border-color: var(--gold);          background: rgba(245,215,148,.12); }
.pip-btn.active:hover { background: rgba(245,215,148,.22); }
.pip-btn.locked { color: var(--muted); border-color: var(--navy3);          background: none; cursor: not-allowed; opacity: .45; }
.pip-btn.running { color: var(--orange); border-color: var(--orange); background: rgba(251,146,60,.1); animation: pulse 1.5s infinite; }
.pip-arrow { color: var(--navy3); font-size: 14px; margin: 0 1px; }

/* ─── Workflow cards ─── */
.wf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.wf-card { background: var(--navy2); border: 1px solid var(--navy3); border-radius: var(--radius); padding: 12px 14px; }
.wf-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.wf-icon { font-size: 30px; }
.wf-name { font-weight: 700; font-size: 21px; flex: 1; }
.wf-toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.wf-toggle input { opacity: 0; width: 0; height: 0; }
.wf-toggle-slider { position: absolute; inset: 0; background: var(--navy3); border-radius: 24px; cursor: pointer; transition: .2s; }
.wf-toggle-slider:before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px; background: var(--muted); border-radius: 50%; transition: .2s; }
.wf-toggle input:checked + .wf-toggle-slider { background: rgba(74,222,128,.3); }
.wf-toggle input:checked + .wf-toggle-slider:before { background: var(--green); transform: translateX(20px); }
.wf-desc { color: var(--muted); font-size: 18px; margin-bottom: 12px; }
.wf-execs { display: flex; flex-direction: column; gap: 5px; }
.wf-exec { display: flex; align-items: center; gap: 8px; font-size: 18px; padding: 6px 10px; background: var(--navy); border-radius: 6px; }
.wf-exec .exec-id { color: var(--muted); font-family: monospace; }
.wf-exec .exec-time { color: var(--muted); margin-left: auto; font-size: 16px; }

/* ─── Toast ─── */
#toast-container { position: fixed; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 99999; }
.toast { background: var(--navy2); border: 1px solid var(--navy3); border-radius: 8px; padding: 11px 14px; min-width: 240px; max-width: 360px; font-size: 20px; box-shadow: var(--shadow); display: flex; align-items: flex-start; gap: 8px; animation: slideIn .18s ease; }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }
.toast .t-icon { font-size: 22px; flex-shrink: 0; margin-top: 1px; }
.toast .t-msg  { flex: 1; line-height: 1.4; }
.toast .t-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 24px; line-height: 1; padding: 0; }
@keyframes slideIn { from { transform: translateX(16px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Dashboard ─── */
.progress-bar { height: 5px; background: var(--navy3); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; border-radius: 3px; transition: width .4s; }
.fill-green { background: var(--green); }
.fill-yellow { background: var(--yellow); }
.fill-blue  { background: var(--blue);  }
.fill-red   { background: var(--red); }
.fill-gold  { background: linear-gradient(90deg, var(--navy2) 0%, var(--gold) 100%); }
.fill-orange { background: var(--orange); }

/* ─── KPI gradient progress bars ─── */
.kpi-bar-wrap { background: var(--navy3); border-radius: 3px; height: 7px; margin-top: 5px; overflow: hidden; min-width: 80px; position: relative; }
.kpi-bar {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--navy3) 0%, var(--gold) 100%);
  position: relative;
  transition: width .5s cubic-bezier(.4,0,.2,1);
}
/* Percentage text floated to the right of the bar container */
.kpi-bar-row { display: flex; align-items: center; gap: 8px; }
.kpi-bar-row .kpi-bar-wrap { flex: 1; }
.kpi-bar-pct { font-size: 16px; color: var(--muted); font-weight: 600; white-space: nowrap; min-width: 32px; text-align: right; }

.dash-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
@media (max-width: 700px) { .dash-row { grid-template-columns: 1fr; } }
.dash-block { background: var(--navy2); border: 1px solid var(--navy3); border-radius: var(--radius); padding: 12px 14px; }
.dash-block h3 { font-size: 18px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.metric-row { display: flex; align-items: center; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
.metric-row:last-child { border-bottom: none; }
.metric-label { color: var(--muted); font-size: 20px; }
.metric-value { font-weight: 600; font-size: 20px; }

/* ─── Loading ─── */
.loading { text-align: center; padding: 20px; color: var(--muted); }
.spinner { display: inline-block; width: 22px; height: 22px; border: 2px solid var(--navy3); border-top-color: var(--gold); border-radius: 50%; animation: spin .6s linear infinite; margin-right: 8px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Skeleton loading ─── */
.skeleton-wrap { padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.skeleton-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.04); }
.skeleton {
  background: linear-gradient(90deg, var(--navy3) 25%, #2d4460 50%, var(--navy3) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
  flex-shrink: 0;
}
.skeleton.sk-badge   { width: 60px;  height: 20px; border-radius: 10px; }
.skeleton.sk-title   { width: 160px; height: 14px; }
.skeleton.sk-text    { flex: 1; height: 12px; }
.skeleton.sk-short   { width: 80px;  height: 12px; }
.skeleton.sk-circle  { width: 28px;  height: 28px; border-radius: 50%; }
.skeleton.sk-block   { width: 100%;  height: 18px; }
.skeleton.sk-card    { width: 100%;  height: 88px; border-radius: var(--radius); }
/* Stagger shimmer delay on siblings */
.skeleton-row:nth-child(2) .skeleton { animation-delay: .1s; }
.skeleton-row:nth-child(3) .skeleton { animation-delay: .2s; }
.skeleton-row:nth-child(4) .skeleton { animation-delay: .3s; }
.skeleton-row:nth-child(5) .skeleton { animation-delay: .4s; }
.skeleton-row:nth-child(6) .skeleton { animation-delay: .5s; }
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

/* ─── Empty state ─── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  gap: 12px;
  color: var(--muted);
  text-align: center;
  animation: fadeInUp .25s ease both;
}
.empty-state .es-icon {
  font-size: 63px;
  opacity: .55;
  filter: grayscale(.3);
  margin-bottom: 4px;
}
.empty-state .es-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--white);
  opacity: .75;
}
.empty-state .es-sub {
  font-size: 20px;
  color: var(--muted);
  max-width: 300px;
  line-height: 1.55;
}

.url-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.url-cell a { color: var(--blue); text-decoration: none; }
.url-cell a:hover { text-decoration: underline; }

/* ─── Program Cards (Chiến Dịch) ─── */
.prog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.prog-card { background: var(--navy2); border: 1px solid var(--navy3); border-radius: var(--radius); padding: 10px 14px; border-left: 4px solid var(--navy3); transition: transform .18s, box-shadow .18s; }
.prog-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.prog-card.active-prog   { border-left-color: var(--green); }
.prog-card.upcoming-prog { border-left-color: var(--blue); }
.prog-card.done-prog     { border-left-color: var(--muted); opacity: .65; }
.prog-card.cancelled-prog { border-left-color: var(--red); opacity: .5; }
.prog-code { font-size: 24px; font-weight: 800; color: var(--gold); margin-bottom: 2px; }
.prog-name { font-size: 20px; font-weight: 600; margin-bottom: 10px; line-height: 1.35; }
.prog-meta { font-size: 18px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.prog-meta span { display: flex; align-items: flex-start; gap: 6px; }
.prog-status { margin-top: 10px; }

/* ─── Channel Groups (Kênh) — old kenh-item kept for create-post modal ─── */
.kenh-group { margin-bottom: 14px; }
.kenh-group-title { font-size: 18px; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--navy3); display: flex; align-items: center; gap: 8px; }
/* Legacy list (used inside modals) */
.kenh-list-legacy { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.kenh-item { background: var(--navy2); border: 1px solid var(--navy3); border-radius: 7px; padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.kenh-item .ki-platform { font-size: 15px; font-weight: 700; padding: 2px 7px; border-radius: 10px; white-space: nowrap; flex-shrink: 0; }
.kenh-item .ki-name { font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kenh-item .ki-status { font-size: 15px; flex-shrink: 0; }

/* ─── Channel Card Layout (Kênh tab) ─── */
.kenh-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.kenh-card {
  background: var(--navy2);
  border: 1px solid var(--navy3);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .15s, transform .18s, box-shadow .18s;
  position: relative;
}
.kenh-card:hover {
  border-color: #33506b;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.kenh-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.kenh-card-platform {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.kenh-card-status {
  margin-left: auto;
  font-size: 21px;
  flex-shrink: 0;
}
.kenh-card-name {
  font-size: 20px;
  font-weight: 600;
  color: var(--white);
  line-height: 1.35;
  word-break: break-word;
}
.kenh-card-link {
  font-size: 16px;
  font-family: monospace;
  color: var(--gold);
  text-decoration: none;
  opacity: .8;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kenh-card-link:hover { opacity: 1; text-decoration: underline; }
.kenh-card-note {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.45;
}
/* Inactive card dimmed */
.kenh-card.inactive {
  opacity: .5;
}
.kenh-card.inactive:hover {
  opacity: .7;
}

/* ─── Recent Activity ─── */
.activity-list { display: flex; flex-direction: column; gap: 5px; }
.activity-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--navy); border-radius: 6px; font-size: 18px; }
.activity-item .ai-id { font-family: monospace; color: var(--gold); font-size: 15px; flex-shrink: 0; min-width: 56px; }
.activity-item .ai-kenh { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-item .ai-date { color: var(--muted); flex-shrink: 0; font-size: 16px; }

/* ─── Lịch Đăng Detail Modal ─── */
#ld-detail-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.72); z-index: 1000; display: none; align-items: flex-start; justify-content: center; padding: 20px; overflow-y: auto; }
#ld-detail-overlay.show { display: flex; }
#cp-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.72); z-index: 1001; display: none; align-items: flex-start; justify-content: center; padding: 20px; overflow-y: auto; }
#cp-overlay.show { display: flex; }
.cp-channel-row { display: flex; align-items: center; gap: 8px; font-size: 20px; }
.cp-channel-row input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--gold); }
.ld-detail-box { background: var(--navy2); border: 1px solid var(--navy3); border-radius: 14px; width: 100%; max-width: 760px; box-shadow: var(--shadow); margin: auto; }
.ld-detail-header { padding: 18px 22px 14px; border-bottom: 1px solid var(--navy3); display: flex; align-items: flex-start; gap: 10px; }
.ld-detail-header .dh-id { font-family: monospace; font-size: 18px; color: var(--gold); }
.ld-detail-header .dh-meta { flex: 1; }
.ld-detail-header .dh-close { background: none; border: 1px solid var(--navy3); color: var(--muted); border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 27px; line-height: 1; flex-shrink: 0; transition: all .15s; }
.ld-detail-header .dh-close:hover { color: var(--white); border-color: var(--white); }
.ld-detail-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.ld-field { display: flex; flex-direction: column; gap: 5px; }
.ld-field-label { font-size: 16px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; display: flex; align-items: center; gap: 6px; }
.ld-field-value { font-size: 20px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.ld-field-value.caption-box { background: var(--navy); border: 1px solid var(--navy3); border-radius: 8px; padding: 12px 14px; color: var(--white); position: relative; }
.caption-copy-btn { float: right; background: none; border: 1px solid var(--navy3); color: var(--muted); border-radius: 5px; padding: 2px 8px; cursor: pointer; font-size: 15px; margin: -2px 0 4px 8px; transition: all .12s; }
.caption-copy-btn:hover { border-color: var(--gold); color: var(--gold); }
.caption-copy-btn.copied { color: var(--green); border-color: var(--green); }
.ld-field-value.hashtag-box { color: var(--blue); font-size: 18px; }
.ld-media-preview { border: 1px solid var(--navy3); border-radius: 8px; overflow: hidden; margin-top: 4px; }
.ld-media-preview img { width: 100%; max-height: 260px; object-fit: cover; display: block; }
.ld-media-preview .media-link { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 18px; }
.ld-media-preview .media-link a { color: var(--blue); text-decoration: none; word-break: break-all; }
.ld-media-preview .media-link a:hover { text-decoration: underline; }
.ld-detail-footer { padding: 14px 22px; border-top: 1px solid var(--navy3); }
.ld-footer-btns { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.ld-preflight { background: var(--navy); border-radius: 9px; padding: 12px 14px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 7px; }
.pf-row { display: flex; align-items: center; gap: 8px; font-size: 20px; }
.pf-row .pf-label { color: var(--muted); width: 80px; flex-shrink: 0; font-size: 18px; }
.pf-ok   { color: var(--green); font-weight: 600; }
.pf-warn { color: var(--red);   font-weight: 600; }
.ld-warning { background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.3); border-radius: 7px; padding: 10px 12px; display: flex; align-items: flex-start; gap: 8px; color: #fca5a5; font-size: 18px; margin-bottom: 4px; }
.ld-warning strong { color: var(--red); }
.channel-select-wrap { display: flex; gap: 8px; align-items: center; }
.channel-select { background: var(--navy); border: 1px solid var(--navy3); color: var(--white); border-radius: 6px; padding: 6px 10px; font-size: 20px; flex: 1; outline: none; cursor: pointer; transition: border-color .15s; }
.channel-select:focus { border-color: var(--gold); }
.channel-changed { border-color: var(--yellow) !important; }

/* ─── Leads ─── */
.lead-item { background: var(--navy2); border: 1px solid var(--navy3); border-radius: 8px; padding: 12px 16px; margin-bottom: 7px; display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr 100px; gap: 10px; align-items: center; font-size: 20px; transition: border-color .12s, transform .15s; }
.lead-item:hover { border-color: #334; transform: translateX(2px); }
@media (max-width: 700px) { .lead-item { grid-template-columns: 1fr 1fr; } }
.lead-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-phone { color: var(--blue); font-family: monospace; font-size: 18px; }
.lead-prog { color: var(--gold); font-size: 18px; font-weight: 700; }
.lead-date { color: var(--muted); font-size: 16px; }

/* ─── Calendar View ─── */
.cal-view-toggle { display: flex; gap: 6px; align-items: center; padding: 5px 10px; border-bottom: 1px solid var(--navy3); background: rgba(0,0,0,.1); }
.cal-toggle-btn { background: none; border: 1px solid var(--navy3); color: var(--muted); border-radius: 6px; padding: 5px 14px; cursor: pointer; font-size: 18px; font-weight: 500; transition: all .15s; }
.cal-toggle-btn.active { background: var(--gold); color: var(--navy); border-color: var(--gold); font-weight: 700; }
.cal-count { margin-left: auto; font-size: 18px; color: var(--muted); }
.cal-wrap { padding: 16px; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-nav-btn { background: none; border: 1px solid var(--navy3); color: var(--muted); border-radius: 6px; padding: 5px 14px; cursor: pointer; font-size: 20px; transition: all .15s; }
.cal-nav-btn:hover { color: var(--white); border-color: var(--white); transform: scale(1.03); }
.cal-month-label { font-size: 24px; font-weight: 700; color: var(--gold); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow { text-align: center; font-size: 16px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 5px 0; }
.cal-day { min-height: 88px; background: var(--navy2); border: 1px solid var(--navy3); border-radius: 7px; padding: 6px; transition: border-color .12s; position: relative; overflow: hidden; }
.cal-day.other-month { opacity: .28; }
.cal-day.today { border-color: var(--gold) !important; box-shadow: inset 0 0 0 2px rgba(245,215,148,.4), 0 0 16px rgba(245,215,148,.08); animation: glow-gold 2.5s infinite; }
.cal-day.has-posts { cursor: pointer; }
.cal-day.has-posts:hover { border-color: var(--gold2); background: rgba(245,215,148,.04); }
.cal-day-num { font-size: 18px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.cal-day.today .cal-day-num { color: var(--gold); }
.cal-post-chips { display: flex; flex-direction: column; gap: 2px; }
.cal-chip { font-size: 15px; padding: 2px 6px; border-radius: 4px; font-weight: 600; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.5; }
.cal-chip:hover { opacity: .8; }
.cal-chip.st-nhap   { background: rgba(96,165,250,.2);  color: #93c5fd; }
.cal-chip.st-duyet  { background: rgba(251,191,36,.2);  color: #fcd34d; }
.cal-chip.st-dang   { background: rgba(251,146,60,.2);  color: #fdba74; }
.cal-chip.st-ok     { background: rgba(74,222,128,.18); color: #86efac; }
.cal-chip.st-loi    { background: rgba(248,113,113,.2); color: #fca5a5; }
.cal-chip.st-other  { background: rgba(148,163,184,.12);color: #94a3b8; }
.cal-more { font-size: 15px; color: var(--blue); margin-top: 2px; cursor: pointer; padding: 1px 4px; }
.cal-more:hover { color: var(--gold); }
/* Cal day ripple */
.cal-day.has-posts:active::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(245,215,148,.2);
  width: 60px; height: 60px;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%) scale(0);
  animation: ripple .4s linear;
  pointer-events: none;
}

/* Side panel */
.cal-side-panel { position: fixed; right: 0; top: 0; height: 100vh; width: 370px; background: var(--navy2); border-left: 2px solid var(--navy3); box-shadow: -6px 0 30px rgba(0,0,0,.6); z-index: 800; transform: translateX(100%); transition: transform .22s cubic-bezier(.25,.8,.25,1); overflow-y: auto; display: flex; flex-direction: column; }
.cal-side-panel.open { transform: translateX(0); }
.cal-sp-header { padding: 18px 20px 14px; border-bottom: 1px solid var(--navy3); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.cal-sp-date { font-size: 22px; font-weight: 700; color: var(--gold); }
.cal-sp-close { background: none; border: 1px solid var(--navy3); color: var(--muted); font-size: 27px; cursor: pointer; border-radius: 6px; padding: 2px 9px; transition: all .15s; }
.cal-sp-close:hover { color: var(--white); border-color: var(--white); }
.cal-sp-body { padding: 14px 20px; flex: 1; }
.cal-sp-post { background: var(--navy); border: 1px solid var(--navy3); border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; transition: border-color .12s; }
.cal-sp-post:hover { border-color: var(--gold2); }
.cal-sp-kenh { font-size: 16px; color: var(--muted); margin-bottom: 5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cal-sp-caption { font-size: 18px; color: var(--white); line-height: 1.55; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; margin-bottom: 8px; }
.cal-sp-actions { display: flex; gap: 6px; }

/* ─── Confirm Modal ─── */
#modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 999; display: none; align-items: center; justify-content: center; }
#modal-overlay.show { display: flex; }
.modal-box { background: var(--navy2); border: 1px solid var(--navy3); border-radius: 14px; padding: 26px; width: 380px; box-shadow: var(--shadow); animation: scaleIn .16s ease both; }
.modal-box h3 { font-size: 24px; margin-bottom: 8px; }
.modal-box p  { color: var(--muted); font-size: 20px; margin-bottom: 18px; line-height: 1.5; white-space: pre-line; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ─── Motion Animations ─── */
@keyframes fadeInUp   { from { opacity:0; transform:translateY(14px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeInDown { from { opacity:0; transform:translateY(-10px); } to { opacity:1; transform:translateY(0); } }
@keyframes scaleIn    { from { opacity:0; transform:scale(.94); } to { opacity:1; transform:scale(1); } }
@keyframes shimmer    { 0%{background-position:-400px 0} 100%{background-position:400px 0} }
@keyframes ripple     { 0%{transform:scale(0);opacity:.7} 100%{transform:scale(3);opacity:0} }
@keyframes glow-gold  { 0%,100%{box-shadow:inset 0 0 0 2px rgba(245,215,148,.4),0 0 8px rgba(245,215,148,.05)} 50%{box-shadow:inset 0 0 0 2px rgba(245,215,148,.6),0 0 20px rgba(245,215,148,.18)} }
@keyframes chipRipple { 0%{transform:scale(0);opacity:.9} 100%{transform:scale(3.5);opacity:0} }
@keyframes tabSlideIn { from{transform:scaleX(0);opacity:0} to{transform:scaleX(1);opacity:1} }

/* Tab content entrance */
.page.active { animation: fadeInUp .18s ease both; }
.stat-card { animation: scaleIn .18s ease both; }
.stat-card:nth-child(2){animation-delay:.04s}
.stat-card:nth-child(3){animation-delay:.08s}
.stat-card:nth-child(4){animation-delay:.12s}
.stat-card:nth-child(5){animation-delay:.16s}

/* Numbers count-up class */
.count-up { display: inline-block; }

/* Table row hover motion */
tr.data-row:hover td { background: rgba(245,215,148,.04); transition: background .12s; }
tr.data-row { transition: background .12s; }

/* ─── KPI table ─── */
.kpi-summary { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:12px; margin-bottom:20px; }
.kpi-sc { background:var(--navy2); border:1px solid var(--navy3); border-radius:8px; padding:14px 16px; transition: border-color .15s; }
.kpi-sc:hover { border-color: #33506b; }
.kpi-sc-label { font-size: 16px; color:var(--muted); margin-bottom:4px; }
.kpi-sc-val   { font-size: 33px; font-weight:700; color:var(--gold); }
.kpi-sc-sub   { font-size: 16px; color:var(--muted); margin-top:2px; }
.kpi-table { width:100%; border-collapse:collapse; font-size: 20px; }
.kpi-table th { background:var(--navy2); color:var(--muted); font-size: 16px; text-transform:uppercase; letter-spacing:.5px; padding:9px 10px; text-align:left; position:sticky; top:0; z-index:1; }
.kpi-table td { padding:10px; border-bottom:1px solid var(--navy3); vertical-align:middle; }
.kpi-table tr:hover td { background:rgba(255,255,255,.03); }
.kpi-ct { display:inline-block; padding:2px 8px; border-radius:10px; background:rgba(245,215,148,.13); color:var(--gold); font-size: 16px; font-weight:700; }
.kpi-st-done   { background:#22c55e22; color:#22c55e; padding:2px 8px; border-radius:10px; font-size: 16px; }
.kpi-st-open   { background:#3b82f622; color:#60a5fa; padding:2px 8px; border-radius:10px; font-size: 16px; }
.kpi-st-cancel { background:rgba(239,68,68,.13); color:#ef4444; padding:2px 8px; border-radius:10px; font-size: 16px; }

/* ─── Từ Khóa table ─── */
.tk-table { width:100%; border-collapse:collapse; font-size: 20px; }
.tk-table th { background:var(--navy2); color:var(--muted); font-size: 16px; text-transform:uppercase; padding:9px 10px; text-align:left; position:sticky; top:0; z-index:1; }
.tk-table td { padding:10px; border-bottom:1px solid var(--navy3); vertical-align:top; }
.tk-table tr:hover td { background:rgba(255,255,255,.03); }
.tk-kw   { font-weight:600; color:#fff; line-height:1.5; }
.tk-hash { display:inline-block; background:rgba(245,215,148,.13); color:var(--gold); border-radius:10px; padding:2px 8px; margin:2px; font-size: 16px; cursor:pointer; }
.tk-hash:hover { background:rgba(245,215,148,.25); }
.tk-copy { background:none; border:1px solid var(--navy3); border-radius:4px; color:var(--muted); cursor:pointer; padding:1px 6px; font-size: 15px; margin-left:4px; vertical-align:middle; transition: all .12s; }
.tk-copy:hover { border-color:var(--gold); color:var(--gold); }

/* ─── Log Đăng table ─── */
.log-table { width:100%; border-collapse:collapse; font-size: 20px; }
.log-table th { background:var(--navy2); color:var(--muted); font-size: 16px; text-transform:uppercase; padding:9px 10px; text-align:left; position:sticky; top:0; z-index:1; }
.log-table td { padding:9px 10px; border-bottom:1px solid var(--navy3); vertical-align:middle; }
.log-table tr:hover td { background:rgba(255,255,255,.03); }
.log-link { color:var(--gold); text-decoration:none; font-size: 18px; }
.log-link:hover { text-decoration:underline; }

/* ─── ki-page-link (channel ID link in Kênh tab) ─── */
.ki-page-link { color:var(--gold); text-decoration:none; font-size: 16px; font-family:monospace; }
.ki-page-link:hover { text-decoration:underline; color:#fff; }

/* ─── Responsive Mobile ─── */
@media (max-width: 768px) {
  body { font-size: 20px; }
  header { padding: 10px 14px; gap: 8px; flex-wrap: wrap; }
  header h1 { font-size: 21px; }
  .vps-chip { font-size: 15px; padding: 3px 8px; }

  /* Nav: top tabs stay — bottom bar only added if sidebar exists */
  nav { padding: 0 10px; gap: 0; }
  .tab { padding: 10px 12px; font-size: 18px; }

  .content { padding: 14px; }

  /* Dashboard: 2 cols on mobile */
  .card-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 14px 12px; }
  .stat-card .value { font-size: 33px; }

  /* Table horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 700px; }
  th, td { padding: 8px 10px; font-size: 18px; }

  /* Filter bar */
  .filter-bar { padding: 8px 10px; gap: 5px; }
  .fchip { font-size: 16px; padding: 3px 8px; }
  .filter-sep { display: none; }

  /* Modal */
  .modal-box { width: 92vw; max-width: none; padding: 18px; }

  /* Calendar */
  .cal-wrap { padding: 8px; }
  .cal-grid { gap: 2px; }
  .cal-day { min-height: 52px; padding: 3px; }
  .cal-day-num { font-size: 15px; }
  .cal-chip { font-size: 14px; padding: 1px 4px; }
  .cal-nav { padding: 8px 10px; }
  .cal-month-label { font-size: 21px; }

  /* Side panel: slide up from bottom */
  .cal-side-panel { width: 100vw; border-left: none; border-top: 2px solid var(--navy3); top: auto; bottom: 0; height: 65vh; transform: translateY(100%); transition: transform .25s cubic-bezier(.25,.8,.25,1); border-radius: 16px 16px 0 0; }
  .cal-side-panel.open { transform: translateY(0); }

  /* Search full width */
  .search-wrap { flex: 1 1 100%; }
  #ld-search, #vs-search { width: 100%; box-sizing: border-box; }

  /* Buttons smaller */
  .btn { padding: 4px 9px; font-size: 16px; }
  .btn-sm { padding: 3px 7px; font-size: 15px; }

  /* VPS */
  .n8n-grid, .wf-list { gap: 8px; }

  /* Pipeline */
  .pipeline { flex-wrap: wrap; gap: 4px; }

  /* Leads */
  .leads-wrap { overflow-x: auto; }

  /* Kenh card grid: 1-2 col on mobile */
  .kenh-card-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
}

/* ─── Mobile bottom nav bar (sidebar collapse) ─── */
@media (max-width: 768px) {
  /* The top nav wraps nicely on its own — add bottom-bar only if body has .has-sidebar class.
     Since ken-panel does not use a sidebar, we implement a fixed bottom quick-access strip
     for the most-used tabs, toggled by JS adding .mobile-bar-active to body. */
  #mobile-bottom-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--navy2);
    border-top: 1px solid var(--navy3);
    z-index: 700;
    flex-direction: row;
    align-items: stretch;
    height: 52px;
    box-shadow: 0 -4px 20px rgba(0,0,0,.4);
  }
  body.mobile-bar-active #mobile-bottom-bar { display: flex; }
  body.mobile-bar-active main { padding-bottom: 52px; }
  .mbb-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    font-size: 15px;
    color: var(--muted);
    transition: color .15s;
    padding: 4px 2px;
  }
  .mbb-item .mbb-icon { font-size: 27px; line-height: 1; }
  .mbb-item:hover { color: var(--white); }
  .mbb-item.active { color: var(--gold); }
  .mbb-item.active .mbb-icon { filter: drop-shadow(0 0 4px rgba(245,215,148,.5)); }
}

@media (max-width: 480px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
  .stat-card .value { font-size: 30px; }
  nav { padding: 0 6px; }
  .tab { padding: 9px 10px; font-size: 16px; }
  .content { padding: 10px; }
  header h1 { font-size: 20px; }
  .kenh-card-grid { grid-template-columns: 1fr; }
}



/* === FULL-HEIGHT TABLE LAYOUT — page IDs = tab-{data-tab} === */
#tab-lich-dang.active,
#tab-video-short.active,
#tab-log-dang.active,
#tab-tu-khoa.active,
#tab-leads.active,
#tab-kpi.active {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
#tab-lich-dang.active .table-wrap,
#tab-video-short.active .table-wrap,
#tab-log-dang.active .table-wrap,
#tab-tu-khoa.active .table-wrap,
#tab-leads.active .table-wrap,
#tab-kpi.active .table-wrap {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
#tab-lich-dang.active .table-scroll,
#tab-video-short.active .table-scroll,
#tab-log-dang.active .table-scroll,
#tab-tu-khoa.active .table-scroll,
#tab-leads.active .table-scroll {
  flex: 1 !important;
  overflow: auto;
  max-height: none !important;
  min-height: 0;
}
