/* ─────────────────────────────────────────────────────────────────────────
   Meta Neurons ATS — design system v2 (Dark AI-tech + gradient)
   Không tải tài nguyên ngoài: font hệ thống, hiệu ứng CSS thuần.
   ───────────────────────────────────────────────────────────────────────── */
:root {
  /* Bảng màu đồng bộ metaneurons.com: nền #06060d, primary #00DC82 (green),
     secondary #0066FF/#0099FF (blue), teal #00BBCC, purple #7C6AF7. */
  --bg: #06060d;
  --surface: #0b1310;
  --surface-2: #101c16;
  --surface-3: #17281f;
  --line: rgba(140, 220, 185, 0.13);
  --line-strong: rgba(140, 220, 185, 0.26);
  --text: #eef7f2;
  --muted: #97aaa2;
  --brand-a: #00DC82;   /* neon green  */
  --brand-b: #0066FF;   /* blue        */
  --grad: linear-gradient(135deg, #00DC82, #0066FF);
  --accent: #2fe39b;
  --teal: #00BBCC; --blue: #0099FF; --purple: #7C6AF7;
  --ok: #00DC82; --warn: #fbbf24; --err: #f87171;
  --pub: #00DC82; --cand: #a78bfa; --int: #00B4FF;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  --glow: 0 0 0 1px rgba(0, 220, 130, 0.35), 0 8px 40px rgba(0, 180, 160, 0.16);
  /* aliases giữ tương thích v1 */
  --panel: var(--surface); --panel2: var(--surface-2);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14.5px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
::selection { background: rgba(0, 220, 130, 0.35); }

/* gradient text */
.grad-text {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

/* ── header / nav ─────────────────────────────────────────── */
header.app {
  position: sticky; top: 0; z-index: 40;
  padding: 14px 28px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: rgba(5, 20, 16, 0.7);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
header.app h1 { font-size: 16.5px; font-weight: 700; }
header.app .sub { color: var(--muted); font-size: 12.5px; }
.logo-mark {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: var(--grad);
  box-shadow: 0 0 18px rgba(0, 220, 130, 0.5);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; color: #fff; font-weight: 800;
}
nav.top-links { display: flex; gap: 20px; margin-left: 22px; }
nav.top-links a { color: var(--muted); font-size: 13.5px; }
nav.top-links a:hover { color: var(--text); text-decoration: none; }

main.page { padding: 28px 24px 60px; max-width: 1200px; margin: 0 auto; }

/* ── cards ────────────────────────────────────────────────── */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0)) , var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 10px;
  transition: border-color .2s, transform .2s, box-shadow .25s;
}
.card.hover:hover, .card.job:hover {
  transform: translateY(-3px);
  border-color: rgba(0, 220, 130, 0.5);
  box-shadow: var(--glow);
}
.grid { display: grid; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); font-size: 12.5px; }
.right { margin-left: auto; }

/* ── buttons ──────────────────────────────────────────────── */
button, .btn {
  position: relative; overflow: hidden;
  background: linear-gradient(var(--surface-2), var(--surface-2)) padding-box,
              linear-gradient(120deg, rgba(140,220,185,.35), rgba(140,220,185,.12)) border-box;
  color: var(--text); border: 1px solid transparent;
  border-radius: 11px; padding: 9px 18px; cursor: pointer; font-size: 13.5px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, color .15s;
}
button:hover, .btn:hover {
  background: linear-gradient(var(--surface-3), var(--surface-3)) padding-box,
              var(--grad) border-box;
  text-decoration: none; transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
button:active { transform: translateY(0); }
button.primary, .btn.primary {
  background: var(--grad); border: none; color: #fff; font-weight: 650;
  box-shadow: 0 4px 22px rgba(0, 200, 130, 0.35), inset 0 1px 0 rgba(255,255,255,.25);
}
/* vệt sáng quét qua khi hover */
button.primary::after, .btn.primary::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.35) 50%, transparent 65%);
  transform: translateX(-110%); transition: transform .5s ease;
}
button.primary:hover::after, .btn.primary:hover::after { transform: translateX(110%); }
button.primary:hover, .btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 30px rgba(0, 190, 170, 0.45), inset 0 1px 0 rgba(255,255,255,.25);
}
button.danger { background: rgba(248,113,113,.06) padding-box, linear-gradient(120deg, rgba(248,113,113,.5), rgba(248,113,113,.2)) border-box; color: var(--err); }
button.danger:hover { background: rgba(248, 113, 113, 0.12) padding-box, var(--err) border-box; box-shadow: 0 6px 18px rgba(248,113,113,.15); }
button.ghost { background: transparent; border-color: transparent; box-shadow: none; }
button.ghost:hover { background: var(--surface-2); border-color: transparent; box-shadow: none; }
button:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

/* ── forms ────────────────────────────────────────────────── */
input, select, textarea {
  background: rgba(8, 16, 13, 0.75); color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 11px; padding: 10px 13px; font-size: 13.5px; font-family: inherit;
  width: 100%; transition: border-color .15s, box-shadow .15s, background .15s;
}
input:hover, select:hover, textarea:hover { border-color: rgba(140, 220, 185, 0.45); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-a); background-color: rgba(10, 22, 17, 0.9);
  box-shadow: 0 0 0 3px rgba(0, 220, 130, 0.15), 0 0 24px rgba(0, 220, 130, 0.09);
}
select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2394a1bf' stroke-width='1.8' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 13px center;
}
select:focus {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2300DC82' stroke-width='1.8' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 13px center;
}
::placeholder { color: rgba(151, 170, 162, 0.55); }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; }
input[type="file"] { padding: 8px; }
input[type="file"]::file-selector-button {
  background: var(--surface-3); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 5px 12px; margin-right: 10px; cursor: pointer; font-size: 12.5px;
}
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.field { margin-bottom: 13px; }
form .row > .field { flex: 1; margin-bottom: 0; }

/* ── table ────────────────────────────────────────────────── */
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
tr:hover td { background: rgba(0, 220, 130, 0.045); }

/* ── badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2.5px 11px; border-radius: 999px; font-size: 11.5px;
  border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap;
  background: rgba(255, 255, 255, 0.02);
}
.badge.ok, .badge.published, .badge.hired, .badge.confirmed, .badge.accepted, .badge.synced, .badge.delivered { color: var(--ok); border-color: rgba(0,220,130,.5); background: rgba(0,220,130,.08); }
.badge.warn, .badge.draft, .badge.pending, .badge.offer, .badge.offer_accepted, .badge.sent, .badge.unassigned { color: var(--warn); border-color: rgba(251,191,36,.45); background: rgba(251,191,36,.06); }
.badge.err, .badge.closed, .badge.rejected, .badge.failed, .badge.declined, .badge.expired, .badge.cancelled, .badge.dead { color: var(--err); border-color: rgba(248,113,113,.45); background: rgba(248,113,113,.06); }
.badge.info, .badge.applied, .badge.screening, .badge.interview, .badge.scheduled { color: var(--int); border-color: rgba(0,180,255,.45); background: rgba(0,180,255,.08); }
.badge.skill { color: #5ff0b6; border-color: rgba(0,220,130,.35); background: rgba(0,220,130,.07); }

/* ── toast ────────────────────────────────────────────────── */
.toast-wrap {
  position: fixed; z-index: 100;
  bottom: max(20px, env(safe-area-inset-bottom)); right: max(20px, env(safe-area-inset-right));
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--surface-2); border: 1px solid var(--line-strong); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 11px 15px; max-width: 380px; font-size: 13px;
  box-shadow: var(--shadow); animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }

/* ── modal ────────────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(3, 5, 10, 0.78);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px; z-index: 50; overflow: auto; animation: fade-in .18s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0)), var(--surface);
  border: 1px solid var(--line-strong); border-radius: 18px;
  padding: 24px; width: 100%; max-width: 560px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow); animation: modal-in .22s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.modal.wide { max-width: 880px; }
.modal h2 { font-size: 17px; }

/* ── internal shell ───────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 218px; flex: none; padding: 18px 12px;
  display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 0; height: 100vh;
  background: rgba(9, 13, 24, 0.85);
  border-right: 1px solid var(--line);
}
.sidebar .brand { font-size: 15px; font-weight: 700; padding: 4px 10px 16px; display: flex; align-items: center; gap: 9px; }
.sidebar a.nav {
  display: flex; align-items: center; gap: 9px; padding: 8.5px 11px; border-radius: 10px;
  color: var(--muted); font-size: 13.5px; border: 1px solid transparent;
}
.sidebar a.nav:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar a.nav.active {
  background: linear-gradient(100deg, rgba(0,220,130,.14), rgba(0,102,255,.12));
  border-color: rgba(0, 220, 130, 0.35);
  color: var(--text); font-weight: 600;
}
.content { flex: 1; padding: 24px 28px; min-width: 0; }
.content > h2 { font-size: 18px; margin-bottom: 16px; }

/* ── pipeline board ───────────────────────────────────────── */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.col {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  width: 248px; flex: none; padding: 11px; display: flex; flex-direction: column; gap: 8px;
  min-height: 130px;
}
.col h3 { font-size: 12.5px; display: flex; justify-content: space-between; padding: 2px 4px 6px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.col h3 .count { color: var(--text); background: var(--surface-3); border-radius: 999px; padding: 0 8px; font-size: 11px; }
.col.dragover { border-color: var(--brand-a); box-shadow: var(--glow); }
.col-cards { display: flex; flex-direction: column; gap: 8px; }
.col-more { width: 100%; justify-content: center; font-size: 12.5px; padding: 7px 10px; margin-top: 2px; }
.card-app {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px;
  padding: 11px; cursor: grab; font-size: 13px; display: flex; flex-direction: column; gap: 4px;
  transition: border-color .15s, transform .15s;
}
.card-app:hover { border-color: rgba(0, 220, 130, 0.5); transform: translateY(-1px); }
.card-app:active { cursor: grabbing; }
.card-app .name { font-weight: 600; }

/* ── tabs / stats / misc ──────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: none; background: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 9px 14px; color: var(--muted); }
.tabs button.active { color: var(--text); border-bottom-color: var(--brand-a); }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .v { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.stat .k { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 13px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.pager .pager-ctrl { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager button { padding: 5px 10px; font-size: 12.5px; min-width: 34px; justify-content: center; }
.pager button.active { color: var(--text); background: var(--surface-2); border-color: var(--brand-a); font-weight: 600; }
.pager button.pager-gap { color: var(--muted); min-width: 28px; padding: 5px 6px; }

/* ── email chips input ────────────────────────────────────── */
.chips-input {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 42px; padding: 6px 8px; cursor: text;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
}
.chips-input:focus-within { border-color: var(--brand-a); box-shadow: 0 0 0 3px rgba(0,220,130,.12); }
.chips-input .chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 6px 3px 10px; font-size: 12.5px; line-height: 1.5;
  color: var(--text); background: rgba(0,220,130,.08);
  border: 1px solid rgba(0,220,130,.5); border-radius: 999px; max-width: 100%;
}
.chips-input .chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips-input .chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; padding: 0; min-width: 0; font-size: 14px; line-height: 1;
  color: var(--muted); background: transparent; border: none; border-radius: 50%; box-shadow: none;
}
.chips-input .chip-x:hover { color: var(--err); background: rgba(248,113,113,.12); transform: none; }
.chips-input .chips-entry {
  flex: 1; min-width: 140px; margin: 0; padding: 4px 2px;
  background: transparent; border: none; box-shadow: none; border-radius: 0;
}
.chips-input .chips-entry:focus { border: none; box-shadow: none; outline: none; }
.chips-input .chips-entry.invalid { color: var(--err); }
/* Ô "+ thêm…" là <select>: ép nền tối + chữ sáng cho cả control lẫn dropdown,
   nếu không option bị chữ trắng trên nền trắng (mặc định trình duyệt). */
.chips-input select.chips-add { color: var(--text); background: var(--surface-2); cursor: pointer; }
.chips-input select.chips-add option { color: var(--text); background: var(--surface-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.pub { background: var(--pub); } .dot.cand { background: var(--cand); } .dot.int { background: var(--int); }
pre.json {
  background: #070b14; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font: 12px/1.5 ui-monospace, Menlo, monospace;
  overflow: auto; max-height: 300px; white-space: pre-wrap; margin: 0;
}
code { background: var(--surface-3); border-radius: 6px; padding: 1px 6px; font-size: 12px; }

/* ── hero decorations (careers / login) ───────────────────── */
.fx-wrap { position: relative; overflow: hidden; }
.fx-grid::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(110, 220, 175, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110, 220, 175, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 45%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 45%, transparent 100%);
}
.orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; pointer-events: none; }
.orb.a { width: 420px; height: 420px; background: rgba(0, 220, 130, 0.26); top: -140px; left: 6%; animation: drift 16s ease-in-out infinite alternate; }
.orb.b { width: 360px; height: 360px; background: rgba(0, 130, 255, 0.24); top: -60px; right: 4%; animation: drift 20s ease-in-out infinite alternate-reverse; }
@keyframes drift { from { transform: translate(0, 0); } to { transform: translate(50px, 36px); } }
@media (prefers-reduced-motion: reduce) { .orb { animation: none; } }

.notif-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--err); }

/* ── motion utilities ─────────────────────────────────────── */
/* chữ gradient lấp lánh chậm */
.shimmer {
  background: linear-gradient(100deg, #00DC82, #00BBCC, #00B4FF, #00DC82);
  background-size: 260% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: shimmer 7s linear infinite;
}
@keyframes shimmer { to { background-position: -260% 0; } }

/* hiện dần khi cuộn tới (kèm IntersectionObserver) */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity .6s ease, transform .6s cubic-bezier(.16,1,.3,1); }
.reveal.in { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: .08s; } .reveal.d2 { transition-delay: .16s; }
.reveal.d3 { transition-delay: .24s; } .reveal.d4 { transition-delay: .32s; }

/* card viền gradient khi hover (đẹp hơn đổi màu viền đơn) */
.card.job, .card.hover {
  border: 1px solid transparent;
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0)) padding-box,
              linear-gradient(var(--surface), var(--surface)) padding-box,
              linear-gradient(120deg, rgba(140,220,185,.22), rgba(140,220,185,.08)) border-box;
}
.card.job:hover, .card.hover:hover {
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0)) padding-box,
              linear-gradient(var(--surface), var(--surface)) padding-box,
              var(--grad) border-box;
  transform: translateY(-4px);
  box-shadow: 0 18px 44px rgba(0,0,0,.5), 0 0 30px rgba(0, 200, 140, 0.13);
}
@media (prefers-reduced-motion: reduce) {
  .shimmer { animation: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ── responsive / mobile (iOS + Android) ──────────────────────
   Chưa có breakpoint nào cho màn nhỏ: dưới đây gom hết các sửa đổi
   cho điện thoại. Áp cho MỌI trang dùng ui.css (nội bộ, careers, ứng viên). */

/* iOS: không "phình" chữ khi xoay ngang. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

@media (max-width: 820px) {
  /* iOS zoom-on-focus khi input < 16px → ép 16px lúc focus trên mobile. */
  input, select, textarea { font-size: 16px; }

  /* Shell nội bộ: sidebar dọc → thanh điều hướng ngang cuộn được trên đầu.
     Thanh dính đỉnh phải né Dynamic Island của iPhone 16 (safe-area-inset-top). */
  .shell { flex-direction: column; min-height: 100vh; min-height: 100dvh; }
  .sidebar {
    width: 100%; height: auto;
    position: sticky; top: 0; z-index: 45;
    flex-direction: row; align-items: center; gap: 4px;
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    border-right: none; border-bottom: 1px solid var(--line);
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar .brand { padding: 0 6px; margin: 0; font-size: 14px; white-space: nowrap; flex: none; }
  .sidebar a.nav { padding: 7px 11px; font-size: 13px; white-space: nowrap; flex: none; }
  /* Khối tên + đăng xuất: gọn lại, đẩy về cuối; ẩn badge vai trò cho đỡ chật. */
  .sidebar > .muted {
    display: flex; align-items: center; gap: 8px;
    /* !important để thắng inline style margin-top:auto của khối này. */
    margin: 0 0 0 auto !important; padding: 0 4px; flex: none; white-space: nowrap;
  }
  .sidebar > .muted br, .sidebar > .muted .badge { display: none; }
  .sidebar > .muted > div { margin-top: 0 !important; }

  /* Giảm padding khung nội dung để tận dụng bề ngang; chừa safe-area 2 bên +
     đáy (home indicator) để nội dung cuối không bị che. */
  .content {
    padding: 16px max(14px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-right));
  }
  main.page {
    padding: 20px max(14px, env(safe-area-inset-right)) max(48px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }
  /* header đăng nhập cũng dính đỉnh → né Dynamic Island. */
  header.app {
    padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  }

  /* Bảng: cho cuộn ngang trong khung thay vì bóp cột chật cứng. */
  .content table, .card table {
    display: block; overflow-x: auto; -webkit-overflow-scrolling: touch;
  }

  /* Modal: vừa khít màn hình nhỏ. */
  .modal, .modal.wide { max-width: 100%; }
  .modal-bg { padding: 4vh 10px; }

  /* Toast không rộng quá viewport; chừa safe-area (home indicator + viền bo). */
  .toast-wrap {
    left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }
  .toast { max-width: none; }

  /* Grid auto-fit inline (báo cáo) → 1 cột trên mobile. */
  .grid[style*="minmax"] { grid-template-columns: 1fr !important; }
}

/* ── mobile UX: nút bấm, tìm kiếm, trường nhập (≤640px, tối ưu iPhone 16 Pro 402px) ── */
@media (max-width: 640px) {
  /* Nút bấm to hơn cho dễ chạm (≈44px HIG). Chỉ tăng padding ở nút thường —
     chip-x/pager/tabs có rule riêng đặc thù hơn nên không bị ảnh hưởng. */
  button, .btn { padding: 12px 18px; }

  /* Tiêu đề + hành động: xếp dọc để tên không chen với nút. */
  .row.spread { flex-direction: column; align-items: stretch; gap: 10px; }
  .row.spread > h2 { margin-bottom: 0; }
  /* Cụm nút ở đầu trang trải đều, dễ chạm. */
  .row.spread > .row, .row.spread > span.row { width: 100%; }
  .row.spread > .row > button, .row.spread > span.row > button { flex: 1; }

  /* Thanh tìm kiếm/lọc: lưới 2 cột gọn, mỗi ô full-width, nút + ghi chú trải hết. */
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; }
  .filters > input, .filters > select, .filters > label,
  .filters > button, .filters > .muted, .filters > span {
    max-width: none !important; width: 100%; margin: 0;
  }
  .filters > label { display: flex; align-items: center; gap: 6px; }
  .filters > label input { width: 100%; }
  .filters > label br { display: none; }
  .filters > button, .filters > .muted { grid-column: 1 / -1; }

  /* Trường nhập trong form modal: 2 ô cạnh nhau → xuống dòng full-width. */
  form .row > .field { flex: 1 1 100%; }

  /* Modal footer: nút hành động dễ chạm, trải rộng. */
  .modal .row[style*="flex-end"] { flex-direction: column-reverse; align-items: stretch; }
  .modal .row[style*="flex-end"] > button { width: 100%; }
}

@media (max-width: 480px) {
  body { font-size: 14px; }
  .content { padding: 14px 11px; }
  main.page { padding: 16px 12px 40px; }
  header.app { padding: 10px 13px; }
  header.app h1 { font-size: 15px; }
  .stat .v { font-size: 24px; }
  /* Cột pipeline hẹp lại để lộ rõ có thể vuốt ngang. */
  .board .col { width: 82vw; max-width: 300px; }
  .modal { padding: 18px; border-radius: 14px; }
}

/* Màn siêu hẹp: thanh lọc về 1 cột (iPhone 16 Pro 402px vẫn giữ 2 cột). */
@media (max-width: 380px) {
  .filters { grid-template-columns: 1fr; }
}

/* ── filter chip rows ────────────────────────────────────────────────── */
.frow { display: flex; align-items: center; gap: 8px; min-width: 0; }
.frow-label { font-size: 12px; color: var(--muted); white-space: nowrap; width: 84px; flex-shrink: 0; }
.frow-scroll { display: flex; align-items: center; gap: 4px; min-width: 0; flex: 1; }
.fchips { display: flex; gap: 4px; overflow-x: auto; scroll-behavior: smooth; scrollbar-width: none; flex: 1; padding-bottom: 2px; }
.fchips::-webkit-scrollbar { display: none; }
.fchip {
  font-size: 12px; padding: 3px 11px; border-radius: 999px;
  background: transparent; cursor: pointer; white-space: nowrap;
  color: var(--muted); transition: all .15s; flex-shrink: 0;
  border: 1px solid rgba(140,220,185,.25);
}
.fchip:hover { border-color: var(--int); color: var(--int); transform: none; box-shadow: none; }
.fchip.active { background: rgba(0,180,255,.15); border-color: var(--int); color: var(--int); font-weight: 600; }
.fscroll-btn {
  background: transparent; border: 1px solid rgba(140,220,185,.2);
  border-radius: 50%; width: 22px; height: 22px; min-width: 22px;
  padding: 0; cursor: pointer; flex-shrink: 0; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); transition: all .15s;
}
.fscroll-btn:hover { border-color: var(--int); color: var(--int); transform: none; box-shadow: none; }
