/* PMeet — ưu tiên điện thoại: vùng bấm ≥ 44px, chữ ô nhập 16px (iOS không tự phóng to), thanh tab dưới đáy, bảng → thẻ. */
:root { --pri: #1f4e79; --pri-2: #2c6aa3; --bg: #f4f6f9; --line: #dde3ea; --muted: #6b7785; --bad: #c0392b; --ok: #1e8449; --warn: #b9770e;
  --nav-h: 60px; --safe-b: env(safe-area-inset-bottom, 0px); }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: #1d2733; }
.boot { padding: 2rem; text-align: center; color: var(--muted); }

/* ---------- khung ---------- */
header.top { position: sticky; top: 0; z-index: 10; background: var(--pri); color: #fff; padding: .55rem 1rem; display: flex; align-items: center; gap: .5rem;
  padding-top: max(.55rem, env(safe-area-inset-top)); }
header.top b { font-size: 1.1rem; }
header.top .sp { flex: 1; }
header.top .env { font-size: .75rem; background: #f39c12; color: #000; padding: 0 .4rem; border-radius: 4px; }
header.top button { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.35); min-height: 38px; }
nav.tabs { display: flex; background: #fff; border-bottom: 1px solid var(--line); overflow-x: auto; position: sticky; top: 52px; z-index: 9; }
nav.tabs button.tab { padding: .7rem 1rem; color: var(--muted); background: none; border: 0; border-radius: 0; white-space: nowrap; border-bottom: 3px solid transparent; cursor: pointer; position: relative; min-height: 44px; }
nav.tabs button.tab.on { color: var(--pri); border-color: var(--pri); font-weight: 600; }
nav.tabs .ic { margin-right: .3rem; }
nav.tabs .lbs { display: none; }
nav.tabs .badge { background: var(--bad); color: #fff; border-radius: 9px; padding: 0 .4rem; font-size: .72rem; margin-left: .25rem; }
main { max-width: 1000px; margin: 0 auto; padding: 1rem; padding-bottom: 4rem; }

/* ---------- thành phần ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
.card h3 { margin: 0 0 .6rem; font-size: 1rem; }
button.card { display: block; width: 100%; text-align: left; font: inherit; color: inherit; margin: 0; }
.card.click { cursor: pointer; } .card.click:hover { border-color: var(--pri); }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { font-size: 1.8rem; font-weight: 700; }
.muted { color: var(--muted); font-size: .88rem; }
.bad { color: var(--bad); } .ok { color: var(--ok); } .warn { color: var(--warn); }
.tag { display: inline-block; margin-left: .35rem; font-size: .7rem; padding: 0 .35rem; border-radius: 4px; background: #e3eef9; color: var(--pri); vertical-align: middle; }
hr { border: 0; border-top: 1px dashed var(--line); margin: .9rem 0; }

button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: .5rem .9rem; cursor: pointer; min-height: 44px; color: inherit; }
button.pri { background: var(--pri); color: #fff; border-color: var(--pri); }
button.pri:active { background: var(--pri-2); }
button.big { font-size: 1.05rem; padding: .75rem 1.2rem; }
button.wide { width: 100%; }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }

.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row .sp { flex: 1; }
label { display: block; margin: .6rem 0 .25rem; font-size: .88rem; color: var(--muted); }
label.req::after { content: " *"; color: var(--bad); }
label.inl { display: inline-flex; align-items: center; gap: .4rem; margin: 0; color: inherit; font-size: inherit; min-height: 44px; }
input, select, textarea { font: inherit; font-size: 16px; width: 100%; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: 44px; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--pri); }
textarea { min-height: 140px; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled input, fieldset:disabled select, fieldset:disabled textarea, input:disabled { background: #f7f9fb; color: inherit; }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .82rem; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover { background: #f0f5fb; }
.tbl { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
.show-sm { display: none; }

.timer { font-size: 2.2rem; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--pri); }
.live { border-left: 5px solid var(--ok); }
.att { display: grid; grid-template-columns: 1fr 11rem 11rem; gap: .4rem; align-items: center; padding: .3rem 0; border-bottom: 1px dashed var(--line); }
.att input[type=datetime-local] { padding: .3rem; font-size: 15px; }
.att .who .muted, .att .who .ok { margin-left: .4rem; }
.rrow { display: flex; justify-content: space-between; gap: .5rem; padding: .45rem 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }

/* ---------- phiên check-in ---------- */
.codebox { text-align: center; background: #f0f5fb; border-radius: 12px; padding: .8rem; margin: .8rem 0; }
.codebox .code { font-size: 3rem; font-weight: 800; letter-spacing: .15em; font-variant-numeric: tabular-nums; color: var(--pri); line-height: 1.1; }
.checkin { display: flex; gap: .5rem; margin-top: .8rem; flex-wrap: wrap; }
.checkin .codeinput { flex: 1 1 10rem; font-size: 1.6rem; text-align: center; letter-spacing: .25em; font-variant-numeric: tabular-nums; }
.checkin .codeinput::placeholder { letter-spacing: normal; font-size: 1.1rem; }
.checkin button { flex: 1 1 10rem; }
details.roster { margin: .6rem 0; }
details.roster summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--pri); font-weight: 600; }
.btns { margin-top: .6rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; margin: 0; padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 999px; color: inherit; font-size: .92rem; min-height: 40px; cursor: pointer; background: #fff; }
.chip.on { border-color: var(--pri); background: #e3eef9; color: var(--pri); }
.chip input { width: 16px; height: 16px; }

.savebar { margin-top: 1rem; }
.toast { position: fixed; bottom: calc(1rem + var(--safe-b)); left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: .7rem 1rem; border-radius: 10px; z-index: 40; max-width: calc(100vw - 2rem); }
.toast.err { background: var(--bad); }
.offline { background: var(--warn); color: #fff; text-align: center; padding: .3rem; font-size: .85rem; }
.login { max-width: 380px; margin: 10vh auto; }
.done td { color: var(--muted); text-decoration: line-through; }
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(20, 30, 40, .55); display: flex; align-items: flex-start; justify-content: center; padding: 1rem; }
.overlay .login { margin-top: 12vh; width: 100%; }

/* ---------- điện thoại ---------- */
@media (max-width: 640px) {
  body { font-size: 15.5px; }
  main { padding: .75rem; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 1.5rem); }
  .hide-sm { display: none !important; }
  .show-sm { display: block; }
  .card { padding: .85rem; border-radius: 14px; }
  .grid3 { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .grid3 > .card { margin: 0; }
  .stat { font-size: 1.5rem; }
  .timer { font-size: 1.8rem; }
  .codebox .code { font-size: 2.6rem; }

  /* Thanh tab cố định dưới đáy, cuộn ngang nếu nhiều tab */
  nav.tabs { position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 20; border-top: 1px solid var(--line); border-bottom: 0;
    padding-bottom: var(--safe-b); box-shadow: 0 -2px 10px rgba(0,0,0,.06); }
  nav.tabs { scrollbar-width: none; } nav.tabs::-webkit-scrollbar { display: none; }
  nav.tabs button.tab { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: .35rem .15rem; height: var(--nav-h); border-bottom: 0; border-top: 3px solid transparent; font-size: .68rem; }
  nav.tabs .lbs { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  nav.tabs button.tab.on { border-top-color: var(--pri); }
  nav.tabs .ic { font-size: 1.25rem; margin: 0; line-height: 1.2; }
  nav.tabs .lb { display: none; }
  nav.tabs .lbs { display: block; }
  nav.tabs .badge { position: absolute; top: 4px; right: 8px; margin: 0; }

  /* Bảng → thẻ: mỗi dòng một thẻ, ô có data-label hiện nhãn bên trái */
  table.rt, table.rt tbody { display: block; background: none; }
  table.rt tr.hd { display: none; }
  table.rt tr { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .5rem .75rem; margin-bottom: .55rem; }
  table.rt tr.total { display: flex; justify-content: space-between; background: #eef3f8; }
  table.rt tr.total th { border: 0; padding: .2rem 0; color: #1d2733; }
  table.rt tr.total th:empty { display: none; }
  table.rt td { display: flex; justify-content: space-between; gap: .75rem; border: 0; padding: .2rem 0; text-align: right; }
  table.rt td.main { display: block; text-align: left; font-size: 1rem; padding-bottom: .3rem; }
  table.rt td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .85rem; text-align: left; }
  table.rt td:empty { display: none; }
  table.rt td.muted { display: block; text-align: left; }
  table.rt td select { width: 100%; }
  .tbl { overflow: visible; }
  .tbl table:not(.rt) { min-width: 480px; }
  .tbl:has(table:not(.rt)) { overflow-x: auto; }

  /* Form buổi làm việc */
  .att { grid-template-columns: 1fr 1fr; } .att .who { grid-column: 1 / -1; }
  .savebar { position: sticky; bottom: calc(var(--nav-h) + var(--safe-b)); background: #fff; margin: 1rem -.85rem -.85rem; padding: .6rem .85rem;
    border-top: 1px solid var(--line); border-radius: 0 0 14px 14px; z-index: 5; }
  .savebar button.pri { flex: 1; }
  header.top button { padding: .35rem .65rem; }
  .toast { bottom: calc(var(--nav-h) + var(--safe-b) + .75rem); }
}
