/* Bug 3Q Đại Chiến - "Thẻ phân loại": mặt bàn xám lạnh, thẻ bìa trắng, dải trạng thái ở mép thẻ.
   File này: màu, chữ, bố cục, ô nhập, nút, thanh điều hướng. Thẻ + dải trạng thái: portal-tag-cards.css. */
:root {
  /* mặt bàn + thẻ */
  --desk: #dfe2e4;
  --desk-2: #d2d6d9;
  --tag: #fbfbf9;
  --tag-2: #f0f1ef;
  --ink: #16181b;
  --ink-2: #474d55;
  --ink-3: #636a73;
  --rule: #c5cad0;
  --rule-2: #e2e4e6;
  --field: #ffffff;
  --field-line: #aeb4bb;
  --focus: #2f6bd8;
  /* dải trạng thái theo thứ tự vòng đời bug */
  --s-new: #2f6bd8;
  --s-info: #e39b00;
  --s-open: #0b7773;
  --s-progress: #6b4dc0;
  --s-fixed: #e5bf00;
  --s-reopen: #cf2a3e;
  --s-closed: #23803a;
  --s-muted: #6c737a;
  /* chữ trắng đậm cỡ nhỏ trên các màu trên đạt >= 4.5:1; vàng / hổ phách dùng chữ mực */
  /* chữ màu trên nền thẻ (đủ tương phản) */
  --danger: #b81f33;
  --danger-soft: #fbe7ea;
  --warn: #7d5200;
  --warn-soft: #fdf1d4;
  --ok: #1f7433;
  --ok-soft: #e3f3e6;
  --info: #1f4fa8;
  --info-soft: #e5edfb;
  /* kích thước */
  --radius: 10px;
  --radius-ctl: 8px;
  --tap: 48px;
  --shadow: 0 1px 0 rgba(22, 24, 27, 0.05), 0 8px 18px -12px rgba(28, 38, 52, 0.45);
  --shadow-lift: 0 1px 0 rgba(22, 24, 27, 0.05), 0 16px 30px -14px rgba(28, 38, 52, 0.5);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --z-nav: 20;
  --z-overlay: 50;
  color-scheme: light;
  accent-color: var(--ink);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: #9aa1a8 var(--desk); scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 500 16px/1.55 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  caret-color: var(--ink);
}
::selection { background: #f5dd6b; color: var(--ink); }
h1, h2, h3 { text-wrap: balance; letter-spacing: -0.015em; }
h1 { font-size: 1.6rem; line-height: 1.2; font-weight: 700; margin: 0 0 0.35rem; }
h2 { font-size: 1.15rem; line-height: 1.3; font-weight: 700; }
p { margin: 0.25rem 0 0.75rem; text-wrap: pretty; }
a { color: var(--ink); text-decoration-thickness: 1.5px; text-underline-offset: 3px; text-decoration-color: var(--s-new); }
a:hover { text-decoration-color: var(--ink); }
b, strong { font-weight: 700; }
kbd { font: inherit; font-size: 0.85em; border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--field); }

/* ---------- kẹp bìa (thanh trên) ---------- */
.topbar { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: var(--z-nav); }
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 8px 14px; /* luôn rộng: tên web + 6 mục điều hướng nằm 1 dòng trên máy tính */
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
body.wide .page { max-width: 1200px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1rem; white-space: nowrap; letter-spacing: -0.01em; }
.brand-mark { width: 22px; height: 22px; flex: none; }
/* chip build trên kẹp bìa: trung tính (vàng là màu trạng thái "Đã sửa", không dùng ở đây) */
.clip-build {
  font-size: 0.8rem; font-weight: 700; color: #fff; background: transparent; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
  border-radius: 3px; padding: 3px 8px;
  margin-right: auto; white-space: nowrap;
}
.nav { display: flex; flex-wrap: wrap; gap: 2px; }
.nav-link {
  color: #d9dde1; text-decoration: none; padding: 7px 12px; border-radius: 6px;
  min-height: 40px; display: inline-flex; align-items: center; gap: 7px; font-size: 0.92rem; font-weight: 500;
  transition: background-color 0.2s var(--ease-out), color 0.2s var(--ease-out);
}
.nav-link svg { width: 18px; height: 18px; flex: none; }
.nav-link .nav-short { display: none; }
.nav-link:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.nav-link.is-active { background: var(--tag); color: var(--ink); font-weight: 700; }
.nav-link:focus-visible { outline: 3px solid #8fb2f2; outline-offset: 1px; }

/* nút có display riêng: thuộc tính hidden phải thắng (vd. "Tải thêm bug cũ hơn" khi không còn gì để tải) */
.btn[hidden], .link-btn[hidden] { display: none !important; }
/* người đang đăng nhập + Đăng xuất (góc phải kẹp bìa) */
/* luôn nằm mép phải (Lead có 7 mục điều hướng: xuống dòng thì vẫn canh phải, không lệch trái dưới logo) */
.me-chip { display: inline-flex; align-items: center; gap: 10px; font-size: 0.85rem; color: #d9dde1; white-space: nowrap; margin-left: auto; }
.me-chip .me-name { color: #fff; font-weight: 700; }
.me-chip .link-btn { color: #d9dde1; min-height: 40px; }
.me-chip .link-btn:hover { color: #fff; }
/* Đã đăng nhập: danh tính lấy từ tài khoản, bỏ mọi ô "Tôi là" / "Đổi người" / "Người ghi" cũ */
.has-session #change-who, .has-session #who-change, .has-session #who-field, .has-session #setup,
.has-session label[for="note-who"], .has-session #note-who { display: none !important; }
/* Tài khoản Theo dõi tiến độ: chỉ xem, không thấy nút ghi của Lead */
.role-viewer .lead-write, .role-dev .lead-write { display: none !important; }

/* ---------- đăng nhập / tài khoản ---------- */
.google-btn { min-height: 48px; margin: 14px 0 10px; display: flex; }
.invite-box { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-ctl); background: #fff4cf; }
.invite-link { display: flex; gap: 8px; }
.invite-link input { flex: 1 1 auto; min-width: 0; }
.row-actions { white-space: nowrap; display: flex; gap: 8px; align-items: center; }

/* Điện thoại: tên web ở trên, chuyển trang bằng thanh dưới đáy (ngón cái với tới). */
@media (max-width: 639px) {
  .topbar { position: static; }
  .topbar-inner { padding: 10px 14px; min-height: 56px; }
  .clip-build { margin-right: 0; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-nav);
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0; /* số mục theo vai trò (3-7) */
    background: var(--ink); padding: 4px 2px calc(4px + env(safe-area-inset-bottom));
    box-shadow: 0 -10px 24px -16px rgba(0, 0, 0, 0.6);
  }
  .nav-link {
    flex-direction: column; justify-content: center; gap: 3px; min-height: 56px; padding: 4px 2px;
    font-size: 0.7rem; border-radius: 8px; text-align: center; line-height: 1.1;
  }
  .nav-link svg { width: 22px; height: 22px; }
  .nav-link .nav-full { display: none; }
  .nav-link .nav-short { display: inline; }
  .nav-link.is-active { background: var(--tag); }
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
}

/* ---------- bố cục ---------- */
.page { max-width: 800px; margin: 0 auto; padding: 16px 14px 56px; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.tiny { font-size: 0.75rem; word-break: break-all; }
.center { text-align: center; }
.req { color: var(--danger); font-weight: 700; }
.opt { color: var(--ink-3); font-weight: 500; font-size: 0.85rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.show-more { margin: 4px 0 20px; }

/* ---------- ô nhập ---------- */
.field { margin: 0 0 18px; border: 0; padding: 0; min-width: 0; }
.field > label, .field > legend, .field > .label { display: block; font-weight: 700; font-size: 0.95rem; margin-bottom: 6px; padding: 0; }
.help { font-size: 0.85rem; color: var(--ink-2); margin: 5px 0 0; }
input[type=text], input[type=search], input[type=password], select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* 16px: điện thoại không tự phóng to khi bấm vào */
  color: var(--ink); background: var(--field); border: 1px solid var(--field-line); border-radius: var(--radius-ctl);
  padding: 11px 12px; min-height: var(--tap);
  transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
textarea { resize: vertical; min-height: 92px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(47, 107, 216, 0.28); }
button:focus-visible, .btn:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.field.invalid input, .field.invalid textarea, .field.invalid .dropzone { border-color: var(--danger); background: var(--danger-soft); }
.field.invalid > label, .field.invalid > .label, .field.invalid > legend { color: var(--danger); }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); margin-bottom: 8px; }
.check input { width: 22px; height: 22px; }

/* ---------- nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px; border-radius: var(--radius-ctl); border: 1px solid transparent;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; text-align: center; line-height: 1.25;
  transition: background-color 0.2s var(--ease-out), border-color 0.2s var(--ease-out), transform 0.12s var(--ease-out);
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: #2c3137; }
.btn.secondary { background: var(--tag-2); color: var(--ink); border-color: var(--rule); }
.btn.secondary:hover { border-color: var(--ink-2); background: #e8e9e7; }
.btn.block { display: flex; width: 100%; margin-top: 8px; }
.btn.big { min-height: 56px; font-size: 1.05rem; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.link-btn {
  background: none; border: 0; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; padding: 8px;
  min-height: 44px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--s-new);
}

/* ---------- chọn 1 trong nhiều (Tôi là, thiết bị...) ---------- */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { flex: 1 1 0; min-width: 88px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label span, .seg-btn {
  display: flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 8px 12px;
  border: 1px solid var(--field-line); border-radius: var(--radius-ctl); background: var(--field);
  font: inherit; font-weight: 700; cursor: pointer; width: 100%; color: var(--ink);
  transition: background-color 0.2s var(--ease-out), border-color 0.2s var(--ease-out), color 0.2s var(--ease-out);
}
.seg label span:hover, .seg-btn:hover { border-color: var(--ink); }
.seg-btn { flex: 1 1 0; min-width: 88px; width: auto; }
.seg input:checked + span, .seg-btn[aria-pressed=true] { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 44px; padding: 8px 14px; border-radius: var(--radius-ctl); border: 1px solid var(--field-line); background: var(--field);
  font: inherit; font-size: 0.92rem; cursor: pointer; text-align: left; color: var(--ink);
}
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed=true] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- ảnh / video bằng chứng ---------- */
.dropzone { border: 2px dashed var(--rule); border-radius: var(--radius); padding: 14px; background: var(--tag-2); transition: border-color 0.2s, background-color 0.2s; }
.dropzone.is-drag { border-color: var(--ink); background: var(--info-soft); }
.dropzone .btn.block { margin-top: 0; }
.ev-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.has-files .ev-list { margin-top: 12px; }
.ev-item { position: relative; border-radius: var(--radius-ctl); overflow: hidden; border: 1px solid var(--rule); background: var(--desk); aspect-ratio: 1; }
.ev-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ev-video { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; font-weight: 700; color: var(--ink-2); text-align: center; }
.ev-remove {
  position: absolute; top: 4px; right: 4px; min-height: 32px; padding: 4px 10px; border-radius: 6px;
  border: 0; background: rgba(22, 24, 27, 0.82); color: #fff; font: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer;
}
.ev-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; background: rgba(0, 0, 0, 0.18); }
.ev-bar span { display: block; height: 100%; background: var(--ink); }
.ev-state { position: absolute; left: 0; right: 0; bottom: 0; font-size: 0.75rem; font-weight: 700; text-align: center; padding: 3px; }
.ev-state.ok { background: var(--ok-soft); color: var(--ok); }
.ev-state.err { background: var(--danger-soft); color: var(--danger); }

/* ---------- thông báo ---------- */
/* thông báo = mẩu thẻ nhỏ: nền trung tính, chữ mực, dải màu ở đáy nói loại thông báo */
.alert {
  position: relative; overflow: hidden; border-radius: var(--radius-ctl); padding: 11px 13px 15px; font-weight: 500;
  background: var(--tag); color: var(--ink); box-shadow: 0 0 0 1px var(--rule-2), 0 6px 14px -12px rgba(28, 38, 52, 0.5);
}
.alert::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--a, var(--s-new)); }
.alert.err { --a: var(--s-reopen); font-weight: 700; }
.alert.warn { --a: var(--s-info); }
.alert.info { --a: var(--s-new); }
.alert b { color: inherit; }

.whoami { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px 8px; }
.build-alert .actions { margin-top: 10px; }
/* dòng "Build Lead khai" (QA không nhập build, chỉ báo khi build trong game khác) */
.build-line-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; }
.build-line .link-btn { min-height: 40px; padding: 6px 0; }
.build-report { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--rule-2); }
.build-report .field { margin-bottom: 12px; }
.build-report .save-state { display: block; margin-top: 8px; }
/* Hôm nay: lời chào + "Đổi người" trên 1 dòng, để việc đầu tiên nằm ngay dưới thanh trên */
.hello-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.hello-row h1 { margin: 0; font-size: 1.35rem; }
.card:has(> .hello-row) { padding: 14px 16px; }
.card:has(> .hello-row) > .field[hidden] + #build-box:not(:empty) { margin-top: 6px; }
#build-box p:last-child { margin-bottom: 0; }
.success { text-align: center; padding: 32px 18px; }
.big-code { font-size: 3.4rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1; margin: 6px 0 14px; }

/* ---------- danh sách + bộ lọc ---------- */
.list-head { margin: 6px 2px 14px; }
.list-head.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: flex-end; padding-bottom: 4px; }
.filters .field { flex: 1 1 140px; margin-bottom: 12px; }
.filters .field.grow { flex: 2 1 220px; }
.filters .btn { margin-bottom: 12px; }
.bug-list { display: grid; gap: 14px; }
details summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; gap: 6px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--s-new); }
.kv { margin: 4px 0 8px; display: grid; grid-template-columns: 1fr; gap: 2px 14px; }
.kv dt { font-size: 0.78rem; color: var(--ink-2); font-weight: 700; margin-top: 8px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; }
.thumb {
  width: 76px; height: 76px; border-radius: 6px; overflow: hidden; border: 1px solid var(--rule); display: flex; align-items: center; justify-content: center;
  background: var(--desk); font-size: 0.8rem; font-weight: 700; text-decoration: none; color: var(--ink);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Lead: ô sửa bên cạnh phiếu */
.status-summary { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.lead-card { display: grid; grid-template-columns: 1fr; gap: 14px; }
.lead-edit { background: var(--tag-2); border: 1px solid var(--rule-2); border-radius: var(--radius-ctl); padding: 14px; }
.lead-edit .field { margin-bottom: 12px; }
.lead-edit label { font-size: 0.85rem; }
.edit-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.save-state { font-size: 0.875rem; font-weight: 700; }
.save-state.ok { color: var(--ok); }
.save-state.err { color: var(--danger); }
.save-state.warn { color: var(--warn); }
@media (min-width: 900px) {
  .lead-card { grid-template-columns: minmax(0, 1fr) 330px; }
  .kv { grid-template-columns: 150px minmax(0, 1fr); }
  .kv dt { margin-top: 0; }
}
