/* Giao diện hiển thị lịch công tác (TV + web). Mọi màu lấy từ biến trong brand.css / theme feed.
   CSS tương thích ~Chromium 63: không gap trên flex, không aspect-ratio, có phương án dự phòng cho max()/clamp(). */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); -webkit-text-size-adjust: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ======================= thành phần dùng chung ======================= */
.data-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: var(--fs-table, 1.15rem); line-height: 1.35; }
.data-table th, .data-table td { border: 1px solid var(--line); padding: .5rem .7rem; text-align: left; vertical-align: middle; word-wrap: break-word; overflow-wrap: break-word; word-break: break-word; }
.data-table thead th { background: var(--brand-secondary); color: var(--brand-white); font-weight: 800; text-align: center; padding: .55rem .7rem; border-color: var(--brand-secondary); }
.data-table tbody tr.alt td { background: var(--grey-100); }
.data-table td.c-date { font-weight: 700; text-align: center; background: var(--brand-white); }
.data-table td.c-date span { display: block; }
.data-table td.c-time { font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.data-table td.c-time .sub { font-weight: 500; }
.data-table td.c-content { font-weight: 600; }

.pill { display: inline-block; margin-top: .25rem; padding: .03rem .7rem; border-radius: 999px; font-size: .78em; font-weight: 900; letter-spacing: .04em; white-space: nowrap; }
.pill.p-today { background: var(--brand-white); color: var(--brand-secondary); }
.pill.p-tomorrow { border: 2px solid var(--brand-secondary); color: var(--brand-secondary); background: transparent; }
.pill.p-past { border: 1px solid var(--muted); color: var(--muted); font-weight: 700; }

tr.d-today td { background: var(--brand-primary-100) !important; }
tr.d-today td.c-date { background: var(--st-today) !important; color: var(--brand-white); font-weight: 800; box-shadow: inset .4rem 0 0 var(--brand-primary); }
tr.d-tomorrow td.c-date { background: var(--st-tomorrow) !important; color: var(--brand-secondary); }
tr.d-past td { opacity: .5; color: var(--muted); }
tr.is-past td:not(.c-date) { opacity: .5; }
tr.is-live td:not(.c-date) { background: var(--live-bg) !important; font-weight: 800; }
tr.is-live td.c-time { box-shadow: inset .5rem 0 0 var(--st-live); }

.badge { display: inline-block; margin-top: .25rem; padding: .08rem .6rem; border-radius: 999px; font-size: .78em; font-weight: 900; letter-spacing: .03em; white-space: nowrap; }
.data-table .badge { display: table; }
.badge.live { background: var(--st-live); color: var(--brand-white); animation: pulse 1.8s ease-out infinite; }
.badge.soon { background: var(--st-soon); color: var(--brand-white); }
.badge.done { background: transparent; color: var(--muted); border: 1px solid var(--muted); font-weight: 700; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--st-live); } 70%, 100% { box-shadow: 0 0 0 .45rem transparent; } }
.sub { display: block; font-weight: 500; font-size: .82em; color: var(--muted); margin-top: .15rem; }
.empty { display: -webkit-box; display: flex; align-items: center; justify-content: center; height: 100%; min-height: 8rem; padding: 1rem; text-align: center; font-size: 2rem; font-weight: 700; color: var(--muted); }
.measure { position: absolute; left: 0; top: 0; width: 100%; visibility: hidden; pointer-events: none; z-index: -1; }

/* dải ĐANG DIỄN RA / TIẾP THEO */
.strip { background: var(--brand-secondary); color: var(--brand-white); border-radius: .5rem; border-left: .5rem solid var(--brand-primary); padding: .45rem 1rem; display: flex; flex-wrap: wrap; align-items: center; font-size: 1.4rem; line-height: 1.3; }
.strip.idle { background: var(--brand-secondary-50); color: var(--brand-secondary); }
.strip .s-live { display: flex; align-items: center; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; margin-right: 1.6rem; font-weight: 700; }
.strip .s-live > * { margin-right: .8rem; }
.strip .s-tag { background: var(--st-live); color: var(--brand-white); padding: .05rem .75rem; border-radius: 999px; font-weight: 900; letter-spacing: .03em; white-space: nowrap; }
.strip .s-time { font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }
.strip .s-idx { opacity: .85; font-size: .8em; white-space: nowrap; }
.strip .s-next { font-size: .85em; font-weight: 600; max-width: 100%; }
.strip .s-next b { color: var(--brand-white); }
.strip.idle .s-next b { color: var(--brand-secondary); }
.strip .s-next .lbl { background: var(--brand-primary-100); color: var(--brand-secondary); border-radius: 999px; padding: 0 .55rem; font-weight: 800; margin-right: .4rem; font-size: .85em; }
.strip.idle .s-live { font-weight: 600; }

/* chú giải */
.legend { display: flex; flex-wrap: wrap; align-items: center; margin: 0; padding: 0; list-style: none; font-weight: 700; color: var(--muted); }
.legend li { display: flex; align-items: center; margin: 0 .9rem .3rem 0; white-space: nowrap; }
.legend i { display: inline-block; width: 1.5rem; height: .9rem; margin-right: .35rem; border-radius: .2rem; }
.legend .l-today i { background: var(--st-today); box-shadow: inset .3rem 0 0 var(--brand-primary); }
.legend .l-tomorrow i { background: var(--st-tomorrow); border: 2px solid var(--brand-secondary); }
.legend .l-live i { background: var(--st-live); }
.legend .l-soon i { background: var(--st-soon); border-radius: 999px; }
.legend .l-past i { background: var(--grey-300); opacity: .7; }

.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--ok); margin-right: .35rem; }
.dot.off { background: var(--off); }

/* Mẫu B: Hôm nay + Sắp tới */
.tu { display: flex; height: 100%; font-family: var(--font-serif); }
.tu-left { flex: 0 0 40%; background: var(--brand-secondary-50); border-radius: .6rem; padding: 1rem 1.3rem; overflow: hidden; margin-right: 1.6rem; }
.tu-right { flex: 1 1 0%; background: var(--brand-white); border: 1px solid var(--grey-300); border-top: .35rem solid var(--brand-primary); border-radius: 1.1rem; box-shadow: 0 .3rem 1rem var(--shadow); padding: .9rem 1.6rem; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.tu-right > * + * { margin-top: .5rem; }
.tu-right h3 { margin: 0; font-size: 2rem; color: var(--brand-secondary); text-decoration: underline; -webkit-text-underline-position: under; text-underline-offset: .25rem; flex: none; }
.tu-right .strip { font-family: var(--font-body); font-size: 1.15rem; flex: none; }
.tu .scroller { overflow: hidden; -webkit-box-flex: 1; flex: 1 1 auto; min-height: 0; }
.tu-left .scroller { height: 100%; }
.tu-left h4 { margin: .9rem 0 .4rem; font-size: 1.45rem; color: var(--brand-secondary); display: flex; align-items: center; flex-wrap: wrap; }
.tu-left h4:first-child { margin-top: 0; }
.tu-left h4 .pill { margin: 0 .6rem 0 0; font-family: var(--font-body); background: var(--brand-primary-100); color: var(--brand-secondary); border: 2px solid var(--brand-secondary); }
.tu p { margin: 0 0 .7rem; font-size: 1.35rem; line-height: 1.45; text-align: justify; }
.tu-left p { font-size: 1.2rem; }
.tu p b.tm { color: var(--st-live); margin-right: .35rem; }
.tu p.is-past { opacity: .5; }
.tu p.is-live { border-left: .4rem solid var(--st-live); padding-left: .7rem; background: var(--live-bg); font-weight: 700; }
.tu .badge { font-family: var(--font-body); margin: 0 0 0 .5rem; }
.tu .none { color: var(--muted); font-style: italic; }

/* thẻ theo ngày (điện thoại) */
.cards .card-day { margin: 0 0 1.25rem; }
.card-day-h { display: flex; flex-wrap: wrap; align-items: center; margin: 0 0 .5rem; padding: .55rem .8rem; border-radius: .5rem; font-size: 1.05rem; font-weight: 800; color: var(--brand-secondary); background: var(--brand-secondary-50); border-left: .35rem solid var(--brand-primary); }
.card-day-h .pill { margin: 0 0 0 .6rem; }
.card-day.d-today .card-day-h { background: var(--st-today); color: var(--brand-white); }
.card-day.d-tomorrow .card-day-h { background: var(--st-tomorrow); }
.card-day.d-past .card-day-h { opacity: .6; }
.card-day.d-today .pill.p-today { background: var(--brand-white); }
.card-list { list-style: none; margin: 0; padding: 0; }
.card { margin: 0 0 .6rem; padding: .7rem .85rem; background: var(--brand-white); border: 1px solid var(--grey-300); border-left: .35rem solid var(--brand-primary); border-radius: .5rem; }
.card.is-live { border-left-color: var(--st-live); background: var(--live-bg); }
.card.is-past, .card-day.d-past .card { opacity: .6; }
.card-top { display: flex; align-items: center; flex-wrap: wrap; }
.card-time { font-weight: 800; font-size: 1.05rem; color: var(--brand-secondary); font-variant-numeric: tabular-nums; margin-right: .6rem; }
.card-top .badge { margin-top: 0; }
.card-content { margin: .3rem 0 0; font-weight: 700; font-size: 1.05rem; line-height: 1.4; word-wrap: break-word; overflow-wrap: break-word; }
.card-meta { margin: .25rem 0 0; font-size: .95rem; color: var(--muted); line-height: 1.4; word-wrap: break-word; overflow-wrap: break-word; }
.card-meta .k { font-weight: 700; }

@media (prefers-reduced-motion: reduce) { .badge.live { animation: none; } }

/* ======================= TV ======================= */
html.tv { font-size: 1.0417vw; font-size: max(10px, calc(100vw / 96)); }
html.tv, html.tv body { height: 100%; }
.tv body, body.tv { overflow: hidden; cursor: none; }
.tv .full { position: fixed; left: 0; top: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2rem; background: var(--bg); }
.tv .full img.big-logo { width: 11rem; height: 11rem; object-fit: contain; }
.tv .full h1 { margin: 1rem 0 0; font-size: 2.2rem; font-weight: 900; color: var(--brand-secondary); text-transform: uppercase; }
.tv .full h2 { margin: .4rem 0 0; font-size: 1.7rem; font-weight: 800; color: var(--st-live); letter-spacing: .08em; text-transform: uppercase; }
.tv .pair-label { margin-top: 2rem; font-size: 1.6rem; font-weight: 700; color: var(--muted); }
.tv .pair-code { margin: .3rem 0 0; font-size: 11rem; line-height: 1.1; font-weight: 900; letter-spacing: .18em; padding-left: .18em; color: var(--brand-secondary); font-variant-numeric: tabular-nums; background: var(--brand-primary-50); border: .3rem solid var(--brand-primary); border-radius: 1.2rem; padding-top: .1em; padding-bottom: .1em; padding-right: .05em; }
.tv .pair-help { margin: 1.6rem 0 0; font-size: 1.9rem; font-weight: 700; color: var(--ink); max-width: 90%; }
.tv .pair-state { margin: 1rem 0 0; font-size: 1.1rem; color: var(--muted); min-height: 1.4rem; }
.tv .pause-msg { margin: 2rem 0 0; font-size: 4.2rem; font-weight: 900; color: var(--brand-secondary); }
.tv .pause-sub { margin: .8rem 0 0; font-size: 1.4rem; color: var(--muted); }

.tv .screen { height: 100vh; display: flex; flex-direction: column; padding: 1rem 2rem 0; }
.tv .screen > * + * { margin-top: .55rem; }
.tv .head { display: flex; align-items: center; justify-content: center; flex: none; }
.tv .logo { width: 5.2rem; height: 5.2rem; flex: none; margin-right: 1.4rem; }
.tv .logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tv .titles { text-align: center; }
.tv .titles h1 { margin: 0; font-size: 2.35rem; line-height: 1.1; font-weight: 900; letter-spacing: .01em; color: var(--brand-secondary); text-transform: uppercase; }
.tv .titles h2 { margin: .25rem 0 0; font-size: 1.85rem; line-height: 1.1; font-weight: 800; color: var(--st-live); letter-spacing: .08em; text-transform: uppercase; display: inline-block; padding-bottom: .2rem; border-bottom: 3px solid var(--st-live); }
.tv .clock { text-align: center; font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; flex: none; }
.tv .strip { flex: none; }
.tv .table-wrap { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.tv .under { display: flex; align-items: center; justify-content: space-between; flex: none; min-height: 1.5rem; font-size: .9rem; font-weight: 700; color: var(--muted); }
.tv .pager { display: flex; align-items: center; justify-content: flex-end; flex: 1 1 auto; min-width: 0; }
.tv .pager > * + * { margin-left: 1rem; }
.tv .pager .bar { flex: 0 1 14rem; width: 14rem; height: .28rem; background: var(--brand-secondary-50); border-radius: 3px; overflow: hidden; }
.tv .pager .bar i { display: block; height: 100%; width: 100%; background: var(--brand-primary); -webkit-transform-origin: left; transform-origin: left; -webkit-transform: scaleX(0); transform: scaleX(0); }
.tv .pager .bar i.run { -webkit-animation: fill var(--page-sec, 10s) linear forwards; animation: fill var(--page-sec, 10s) linear forwards; }
@-webkit-keyframes fill { to { -webkit-transform: scaleX(1); transform: scaleX(1); } }
@keyframes fill { to { -webkit-transform: scaleX(1); transform: scaleX(1); } }
.tv .ticker { margin-left: -2rem; margin-right: -2rem; background: var(--brand-secondary); color: var(--brand-white); border-top: .2rem solid var(--brand-primary); overflow: hidden; white-space: nowrap; height: 2.6rem; display: flex; align-items: center; flex: none; }
.tv .ticker-track { display: inline-block; padding-left: 100%; font-size: 1.3rem; font-weight: 700; -webkit-animation: marquee var(--ticker-sec, 40s) linear infinite; animation: marquee var(--ticker-sec, 40s) linear infinite; will-change: transform; }
@-webkit-keyframes marquee { to { -webkit-transform: translateX(-100%); transform: translateX(-100%); } }
@keyframes marquee { to { -webkit-transform: translateX(-100%); transform: translateX(-100%); } }
.tv .foot { display: flex; justify-content: flex-end; align-items: center; font-size: .8rem; color: var(--muted); padding: .1rem 0 .35rem; flex: none; }
.tv .foot > * + * { margin-left: 1.4rem; }
@media (prefers-reduced-motion: reduce) { .tv .ticker-track { animation-duration: 120s; } }

/* ======================= Web người dân ======================= */
html.web { font-size: 16px; }
.web a, .web button { font-family: inherit; }
.web :focus { outline: 3px solid var(--brand-secondary); outline-offset: 2px; }
.web :focus:not(:focus-visible) { outline: 0; }
.web :focus-visible { outline: 3px solid var(--brand-secondary); outline-offset: 2px; }
.skip { position: absolute; left: .5rem; top: -4rem; background: var(--brand-secondary); color: var(--brand-white); padding: .6rem 1rem; border-radius: .4rem; z-index: 10; }
.skip:focus { top: .5rem; }
.web-wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.web-head { display: flex; align-items: center; justify-content: center; padding: 1rem 0 .5rem; text-align: center; }
.web-head .logo { width: 4.5rem; height: 4.5rem; flex: none; margin-right: 1rem; }
.web-head .logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.web-head .org { margin: 0; font-size: 1.15rem; line-height: 1.2; font-weight: 900; color: var(--brand-secondary); text-transform: uppercase; }
.web-head .sub-title { margin: .2rem 0 0; display: block; font-size: 1.6rem; line-height: 1.15; font-weight: 800; color: var(--st-live); letter-spacing: .06em; text-transform: uppercase; }
.week-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; margin: .75rem 0; padding: .6rem .8rem; background: var(--brand-secondary-50); border-radius: .6rem; border-left: .35rem solid var(--brand-primary); }
.week-bar .range { font-weight: 800; font-size: 1.05rem; color: var(--brand-secondary); margin: .25rem .75rem .25rem 0; }
.week-bar .btns { display: flex; flex-wrap: wrap; }
.btn { appearance: none; -webkit-appearance: none; cursor: pointer; margin: .2rem 0 .2rem .5rem; padding: .55rem 1rem; min-height: 44px; font-size: 1rem; font-weight: 700; color: var(--brand-secondary); background: var(--brand-white); border: 2px solid var(--brand-secondary); border-radius: .5rem; }
.btn:hover { background: var(--brand-primary-50); }
.btn[aria-current="true"] { background: var(--brand-secondary); color: var(--brand-white); }
.btn[disabled] { cursor: not-allowed; opacity: .45; }
.web .strip { margin: 0 0 .75rem; font-size: 1.05rem; }
.web .strip .s-live > * { margin-right: .5rem; }
.web .strip .s-live { margin-right: 1rem; }
.web .data-table { --fs-table: 1rem; font-size: 1rem; }
.web .table-scroll { overflow: visible; }
.web .tu { height: auto; }
.web .tu .scroller { overflow: visible; }
.web .tu-left, .web .tu-right { overflow: visible; }
.web .tu-right h3 { font-size: 1.5rem; }
.web .tu p { font-size: 1.15rem; }
.web .tu-left p { font-size: 1.05rem; }
.web .tu-left h4 { font-size: 1.2rem; }
.web .status-msg { padding: 2rem 1rem; text-align: center; font-weight: 700; color: var(--muted); font-size: 1.1rem; }
.web .web-under { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; margin: 1rem 0 0; font-size: .9rem; color: var(--muted); }
.web .ticker-static { margin: 1rem 0 0; padding: .7rem 1rem; background: var(--brand-secondary); color: var(--brand-white); border-top: .2rem solid var(--brand-primary); border-radius: .4rem; font-weight: 700; }
.web .foot { padding: 1rem 0 1.5rem; font-size: .85rem; color: var(--muted); display: flex; flex-wrap: wrap; justify-content: space-between; }

@media (max-width: 900px) {
  .web .tu { flex-direction: column; }
  .web .tu-left { flex: none; margin: 1rem 0 0; order: 2; }
  .web .tu-right { order: 1; }
}
@media (max-width: 600px) {
  .web-wrap { padding: 0 16px; }
  .web-head { flex-direction: column; padding-top: .75rem; }
  .web-head .logo { margin: 0 0 .5rem 0; }
  .web-head .org { font-size: 1rem; }
  .web-head .sub-title { font-size: 1.4rem; }
  .week-bar { display: block; }
  .week-bar .range { display: block; margin: 0 0 .4rem; }
  .week-bar .btns { margin-left: -.5rem; }
  .week-bar .btn { flex: 1 1 0%; margin-left: .5rem; padding-left: .4rem; padding-right: .4rem; }
  .web .strip { font-size: .95rem; }
  .web .tu-right { padding: .8rem 1rem; }
  .web .tu-left { padding: .8rem 1rem; }
  .web .tu-right h3 { font-size: 1.25rem; }
  .web .tu p { font-size: 1.05rem; text-align: left; }
  .web .legend { font-size: .85rem; }
}
