:root {
  --bg: #ffffff;
  --grid: rgba(10, 37, 64, .045);
  --paper: #ffffff;
  --paper-2: #fff8f1;
  --ink: #0a2540;
  --muted: #5b6b7f;
  --line: #e6ebf1;
  --accent: #e95e0e;
  --accent-2: #f5a323;
  --accent-soft: #fff1e6;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e1;
  --display: 'Chakra Petch', 'Be Vietnam Pro', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --shade: var(--ink);
  --off: #c5ced9;
  --off-line: #dbe2ea;
  --glass: rgba(255, 255, 255, .86);
  --overlay: rgba(10, 37, 64, .5);
  color-scheme: light;
}
/* Dark mode tự động theo hệ thống */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #06111f;
    --grid: rgba(255, 255, 255, .035);
    --paper: #0b1a2e;
    --paper-2: #10223a;
    --ink: #eaf1f8;
    --shade: #1d3552;
    --muted: #93a4b8;
    --line: #1a2d45;
    --accent: #fb7a24;
    --accent-2: #fbb03b;
    --accent-soft: #2a1608;
    --ok: #4ade80;
    --ok-soft: #10261a;
    --warn: #fbbf24;
    --warn-soft: #2a200b;
    --off: #46576b;
    --off-line: #263a52;
    --glass: rgba(11, 26, 46, .86);
    --overlay: rgba(0, 0, 0, .65);
    color-scheme: dark;
  }
  .btn:disabled { opacity: .45; }
  .logo img { border-color: var(--line); }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 44px 44px;
}
body.client { min-height: 100vh; overflow-x: hidden; }
/* Vệt chéo trang trí */
body.client::before, body.client::after {
  content: ""; position: fixed; z-index: -1; pointer-events: none;
  width: 2px; height: 140vh; top: -20vh; background: linear-gradient(transparent, rgba(233, 94, 14, .22), transparent);
}
body.client::before { left: 12%; transform: rotate(35deg); }
body.client::after { right: 14%; transform: rotate(35deg); }

a { color: var(--accent); }
h1, h2 { margin: 0 0 8px; line-height: 1.3; }
p { margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mono { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.ok { color: var(--ok); }

/* ---------- Khung trang người dùng ---------- */
.wrap { max-width: 520px; margin: 0 auto; padding: 32px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }
.wrap-sm { max-width: 420px; }
.wrap-wide { max-width: 600px; }

.panel {
  position: relative;
  background: var(--paper);
  border: 2px solid var(--ink);
  padding: 28px 28px 18px;
  box-shadow: 8px 8px 0 var(--accent), 8px 8px 0 2px var(--shade);
}
/* Khung viền trong */
.panel::before { content: ""; position: absolute; inset: 5px; border: 1px solid var(--line); pointer-events: none; }
/* 4 góc đỏ */
.panel::after {
  content: ""; position: absolute; inset: -2px; pointer-events: none;
  --c: var(--accent); --l: 16px; --w: 3px;
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--l) var(--w) no-repeat,
    linear-gradient(var(--c), var(--c)) top left / var(--w) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) top right / var(--l) var(--w) no-repeat,
    linear-gradient(var(--c), var(--c)) top right / var(--w) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / var(--l) var(--w) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom left / var(--w) var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / var(--l) var(--w) no-repeat,
    linear-gradient(var(--c), var(--c)) bottom right / var(--w) var(--l) no-repeat;
}
.panel > * { position: relative; z-index: 1; }

.panel-head { text-align: center; }
.tag {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 5px 12px; border: 1px solid var(--accent); color: var(--accent); background: var(--accent-soft);
  font-family: var(--mono); font-size: 10.5px; font-weight: 700; letter-spacing: .24em; text-transform: uppercase;
}
.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(233, 94, 14, .5); } 50% { box-shadow: 0 0 0 5px rgba(233, 94, 14, 0); } }

.logo { display: block; width: 64px; height: 64px; margin: 16px auto 10px; text-decoration: none; }
.is-hero .logo { width: 104px; height: 104px; margin: 20px auto 14px; }
.logo img { width: 100%; height: 100%; object-fit: cover; display: block; border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--shade); }
.emblem {
  width: 100%; height: 100%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 26px;
  border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--shade);
}
.is-hero .emblem { font-size: 42px; }

.site-title {
  font-family: var(--display); font-weight: 700; font-size: 20px; line-height: 1.1;
  letter-spacing: .05em; text-transform: uppercase;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.is-hero .site-title { font-size: 34px; }
.tag + .site-title { margin-top: 18px; }
.subtitle { margin: 8px 0 0; font-family: var(--mono); font-size: 13px; color: var(--muted); letter-spacing: .06em; }

.divider { position: relative; height: 1px; margin: 22px 0; background: linear-gradient(90deg, transparent, var(--line) 15%, var(--line) 85%, transparent); }
.divider span { position: absolute; left: 50%; top: -4px; width: 8px; height: 8px; background: var(--accent); transform: translateX(-50%) rotate(45deg); }


/* Ô thống kê */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.stat-box { background: var(--paper-2); border: 1.5px solid var(--ink); padding: 13px 6px 10px; text-align: center; }
.stat-box b { display: block; font-family: var(--display); font-size: 23px; line-height: 1.1; color: var(--accent); }
.stat-box span { display: block; margin-top: 3px; font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

.state { margin-bottom: 16px; }
.state .muted { margin: 10px 0 0; font-size: 12.5px; }
.block-title { font-family: var(--display); font-size: 20px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
h2.block-title { font-size: 15px; text-align: center; }

/* 3 bước */
.steps { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); border: 1.5px dashed var(--line); }
.steps li { padding: 10px 6px; text-align: center; font-size: 12.5px; font-weight: 600; }
.steps li + li { border-left: 1.5px dashed var(--line); }
.steps li span { display: block; font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: var(--accent); letter-spacing: .1em; margin-bottom: 2px; }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 16px; border: 2px solid var(--ink); border-radius: 0; background: var(--paper); color: var(--ink);
  font-family: var(--display); font-size: 13.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  cursor: pointer; text-decoration: none; transition: transform .1s, box-shadow .1s;
  box-shadow: 4px 4px 0 var(--shade);
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--shade); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--shade); }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; box-shadow: 4px 4px 0 var(--shade); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .18); }
.btn-ghost { background: var(--paper); }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 14px 18px; font-size: 15.5px; }
.btn-sm { padding: 5px 10px; font-size: 12px; box-shadow: 2px 2px 0 var(--shade); }
.btn-sm:hover { box-shadow: 3px 3px 0 var(--shade); }
.btn-stack { display: grid; gap: 10px; margin-top: 4px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 14px; }

/* ---------- Thông báo / trạng thái ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-bottom: 18px; border: 1.5px solid; border-left-width: 5px; font-weight: 600; font-size: 14px; }
.alert i { margin-top: 3px; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-err { background: var(--accent-soft); color: var(--accent); }
.alert a { color: inherit; }

.state-icon { width: 56px; height: 56px; margin: 0 auto 12px; display: grid; place-items: center; font-size: 22px; border: 2px solid currentColor; box-shadow: 4px 4px 0 currentColor; }
.state-ok { background: var(--ok-soft); color: var(--ok); }
.state-err { background: var(--accent-soft); color: var(--accent); }
.state-warn { background: var(--warn-soft); color: var(--warn); }

.keybox { display: flex; flex-wrap: nowrap; gap: 10px; align-items: center; padding: 8px 8px 8px 14px; margin: 20px 0 16px; border: 2px dashed var(--accent); background: var(--accent-soft); }
.keybox code { flex: 1; min-width: 0; font-family: var(--mono); font-size: 14px; font-weight: 700; text-align: left; white-space: nowrap; overflow-x: auto; scrollbar-width: none; }
.keybox code::-webkit-scrollbar { display: none; }
.keybox [data-copy] { flex: none; width: 40px; height: 40px; padding: 0; gap: 0; }
.keybox [data-copy] span { display: none; }

.progress { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.progress-step { display: flex; flex-direction: column; align-items: center; gap: 7px; font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: center; }
.progress-step span { width: 28px; height: 28px; display: grid; place-items: center; border: 2px solid var(--line); background: var(--paper-2); color: var(--muted); font-size: 13px; }
.progress-step.done span { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.progress-step.current { color: var(--ink); }
.progress-step.current span { border-color: var(--ink); background: var(--accent); color: #fff; box-shadow: 3px 3px 0 var(--shade); }

.cf-turnstile { width: 100%; margin: 0 0 16px; min-height: 65px; }
.expire { margin: 14px 0 0; }

/* ---------- Popup link đã sẵn sàng ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px 16px; background: var(--overlay); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal[hidden] { display: none; }
.modal-box {
  position: relative; width: 100%; max-width: 460px; max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--paper); border: 2px solid var(--ink); padding: 26px 24px 22px;
  box-shadow: 7px 7px 0 var(--accent), 7px 7px 0 2px var(--shade);
  animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-icon { width: 56px; height: 56px; margin: 0 auto 14px; display: grid; place-items: center; font-size: 24px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--shade); }
.modal-title { margin: 0 0 6px; text-align: center; font-family: var(--display); font-size: 21px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.modal-steps { list-style: none; padding: 0; margin: 16px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.modal-steps li { padding: 10px 6px; text-align: center; font-size: 12px; font-weight: 600; line-height: 1.35; border: 1.5px solid var(--line); background: var(--paper-2); }
.modal-steps li span { display: block; margin-bottom: 4px; font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--accent); }
.linkbox { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; margin-bottom: 14px; border: 1.5px solid var(--ink); background: var(--paper-2); }
.linkbox code { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13.5px; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkbox .btn { flex: none; }
.modal-close { margin-top: 12px; color: var(--muted); box-shadow: none; border-color: var(--line); }
.modal-close:hover { box-shadow: none; transform: none; color: var(--ink); border-color: var(--ink); }
body.modal-open { overflow: hidden; }

/* ---------- Form ---------- */
.form { display: grid; gap: 14px; }
.form-inline { margin-top: 16px; }
.field { display: grid; gap: 6px; }
.field span { font-family: var(--mono); font-size: 11.5px; font-weight: 700; letter-spacing: .05em; color: var(--muted); }
input, textarea, select {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--ink); border-radius: 0;
  background: var(--paper); color: var(--ink); font: inherit; font-size: 16px;
}
input.mono, textarea.mono { font-size: 16px; }
input[type=file] { padding: 8px; background: var(--paper-2); }
input:focus, textarea:focus, select:focus { outline: none; box-shadow: 3px 3px 0 var(--accent); }
textarea { resize: vertical; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.row-setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.row-setting h2 { margin: 0; }
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; flex: none; width: 50px; height: 28px; border: 2px solid var(--ink); background: var(--paper-2); box-shadow: 2px 2px 0 var(--shade); transition: background .15s; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: var(--ink); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(22px); background: #fff; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.filter input, .filter select { width: auto; min-width: 0; height: 42px; padding: 0 12px; }
.filter input { flex: 1 1 180px; }
.filter select { flex: 0 1 auto; }
.filter .btn { flex: none; width: 42px; height: 42px; padding: 0; box-shadow: 3px 3px 0 var(--shade); }
.filter .btn:hover { box-shadow: 4px 4px 0 var(--shade); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; padding: 0; accent-color: var(--accent); }
.filter .check { height: 42px; padding: 0 14px; border: 1.5px solid var(--ink); background: var(--paper-2); }
.filter .check:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.logo-preview { display: flex; align-items: center; gap: 14px; }
.logo-preview .logo { margin: 0; width: 64px; height: 64px; }
.logo-preview .emblem { font-size: 26px; box-shadow: 3px 3px 0 var(--shade); }
.logo-preview img { box-shadow: 3px 3px 0 var(--shade); }

/* ---------- Admin ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--paper); border-bottom: 2px solid var(--ink); }
.topbar-in { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-icon { width: 34px; height: 34px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: 2px solid var(--ink); }
.brand-img { width: 34px; height: 34px; object-fit: cover; border: 2px solid var(--ink); display: block; }
.brand-text { font-family: var(--display); font-weight: 700; font-size: 18px; letter-spacing: .08em; text-transform: uppercase; }
.topnav { display: flex; gap: 4px; overflow-x: auto; margin-left: auto; scrollbar-width: none; }
.topnav a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; color: var(--muted); text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 14px; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; border: 1.5px solid transparent; }
.topnav a.active { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
.admin-main { max-width: 1100px; margin: 0 auto; padding: 26px 16px 48px; }
.topbar-logout { display: none; }
.page-title { font-family: var(--display); font-size: 26px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head .page-title { margin-bottom: 0; }
.page-head form { margin: 0; }
.btn-icon-count { gap: 6px; padding: 7px 12px; font-family: var(--mono); }

.card { background: var(--paper); border: 2px solid var(--ink); padding: 22px; margin-bottom: 18px; box-shadow: 6px 6px 0 var(--line); }
.card h2 { font-family: var(--display); font-size: 17px; text-transform: uppercase; letter-spacing: .04em; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--paper); border: 2px solid var(--ink); padding: 16px; box-shadow: 4px 4px 0 var(--accent); }
.stat span { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat b { font-family: var(--display); font-size: 30px; color: var(--ink); }

.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); white-space: nowrap; border-bottom: 1.5px solid var(--ink); }
.tbl td { white-space: nowrap; }
.tbl td.mono { white-space: normal; min-width: 140px; }
.tbl td.ip { white-space: nowrap; min-width: 0; cursor: help; }
.tbl td.link-cell { white-space: nowrap; min-width: 0; }
.tbl td.link-cell a { color: var(--accent); text-decoration: none; font-weight: 700; }
.tbl td.link-cell a:hover { text-decoration: underline; }
.tbl form { margin: 0; }
.tbl .th-action, .tbl td:has(> form .btn-del) { text-align: center; }
.tbl form:has(.btn-del) { display: inline-block; }
.btn-del { color: var(--accent); border-color: var(--accent); background: var(--paper); box-shadow: 2px 2px 0 var(--accent); }
.btn-del:hover { background: var(--accent); color: #fff; box-shadow: 3px 3px 0 var(--shade); }

.badge { display: inline-block; padding: 2px 8px; font-family: var(--mono); font-size: 11px; font-weight: 700; border: 1px solid var(--line); background: var(--paper-2); color: var(--muted); }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: currentColor; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: currentColor; }
.badge-err { background: var(--accent-soft); color: var(--accent); border-color: currentColor; }

.pager { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; margin-top: 18px; font-family: var(--mono); font-weight: 700; }
.pager a, .pager span { display: grid; place-items: center; min-width: 38px; height: 38px; padding: 0 8px; border: 2px solid var(--ink); background: var(--paper); color: var(--ink); text-decoration: none; box-shadow: 3px 3px 0 var(--shade); transition: transform .1s, box-shadow .1s; }
.pager a:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--shade); }
.pager a:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shade); }
.pager .is-current { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.pager .is-disabled { color: var(--off); border-color: var(--off-line); box-shadow: 3px 3px 0 var(--off-line); }
.pager .gap { border: 0; background: none; box-shadow: none; min-width: 16px; padding: 0; color: var(--muted); }

@media (max-width: 560px) {
  [data-copy] span { display: none; }
  [data-copy] { gap: 0; }
  .keybox [data-copy], .linkbox [data-copy] { width: 40px; height: 40px; padding: 0; flex: none; }
  .wrap { padding-top: 18px; }
  .panel { padding: 20px 16px 14px; box-shadow: 5px 5px 0 var(--accent), 5px 5px 0 2px var(--shade); }
  .is-hero .logo { width: 84px; height: 84px; }
  .is-hero .site-title { font-size: 27px; }
  .stat-box b { font-size: 19px; }
  .stat-box span { font-size: 8.5px; letter-spacing: .06em; }
  .card { padding: 18px; }
  .table-wrap { margin: 0 -18px; padding: 0 18px; }
}

/* 2 khung key chưa cấp / đã cấp */
.key-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.key-lists .card-head { flex-direction: row; align-items: center; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.head-actions form { margin: 0; }
.key-list { background: var(--paper-2); line-height: 1.8; white-space: pre; overflow: auto; }

/* Bảng thống kê theo ngày */
.card-flush { padding: 0; }
.flush-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 2px solid var(--ink); }
.flush-head h2 { display: flex; align-items: center; gap: 12px; margin: 0; }
.head-icon { width: 38px; height: 38px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); border: 1.5px solid var(--accent); font-size: 15px; }
.month-nav { display: flex; align-items: center; gap: 12px; font-family: var(--display); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.month-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 2px solid var(--ink); color: var(--ink); background: var(--paper); box-shadow: 3px 3px 0 var(--shade); text-decoration: none; }
.month-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shade); }
.month-btn.disabled { color: var(--off); border-color: var(--off-line); box-shadow: 3px 3px 0 var(--off-line); }
.card-flush .table-wrap { margin: 0; padding: 0; }
.tbl-stats th, .tbl-stats td { padding: 13px 18px; text-align: right; }
.tbl-stats th:first-child, .tbl-stats td:first-child { text-align: left; }
.tbl-stats thead th { background: var(--paper-2); }
.tbl-stats td { font-family: var(--mono); font-size: 13.5px; }
.tbl-stats tr.is-today td { background: var(--accent-soft); font-weight: 700; }
.tbl-stats tr.is-today td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
.tbl-stats tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; background: var(--paper-2); font-family: var(--display); }
.tbl tr.empty-row td, .tbl-stats tr.empty-row td { padding: 0; border-bottom: 0; text-align: center; white-space: normal; background: transparent; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 38px 16px 34px; }
.empty-icon { width: 52px; height: 52px; margin-bottom: 8px; display: grid; place-items: center; font-size: 21px; color: var(--accent); background: var(--accent-soft); border: 2px dashed var(--accent); }
.empty b { font-family: var(--display); font-size: 16px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink); }
.empty span:not(.empty-icon) { font-size: 13px; color: var(--muted); }
.dur-grid { display: grid; grid-template-columns: repeat(4, 1fr); }
.dur { padding: 18px; border-right: 1px solid var(--line); }
.dur:last-child { border-right: 0; }
.dur span { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.dur b { display: block; margin-top: 4px; font-family: var(--display); font-size: 30px; line-height: 1.1; }
.dur b small { font-size: 15px; color: var(--muted); margin-left: 2px; }
.dur-set { background: var(--accent-soft); }
.dur-set b { color: var(--accent); }
.dur-set a { display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; font-size: 12px; font-weight: 700; text-decoration: none; }
.dur-hint { display: flex; align-items: center; gap: 8px; margin: 0; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.dur-hint.is-warn { color: var(--warn); background: var(--warn-soft); }
.txt-err { color: var(--accent); font-weight: 700; }

/* Admin mobile: tab bar dưới đáy kiểu iOS */
@media (max-width: 720px) {
  .topbar-in { padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
  .topbar-logout {
    display: grid; place-items: center; margin-left: auto; width: 38px; height: 38px;
    color: var(--ink); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--shade); text-decoration: none;
  }
  .topnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0;
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; overflow: visible;
    padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
    border-top: 2px solid var(--ink);
  }
  .topnav a {
    position: relative; flex-direction: column; justify-content: center; gap: 4px; padding: 6px 2px 4px;
    border: 0; font-size: 10px; letter-spacing: .04em; -webkit-tap-highlight-color: transparent;
  }
  .topnav a i { font-size: 20px; }
  .topnav a.active { background: transparent; }
  .topnav a.active::before { content: ""; position: absolute; top: -8px; left: 50%; width: 26px; height: 3px; background: var(--accent); transform: translateX(-50%); }
  .topnav a:active { transform: scale(.92); }
  .topnav .nav-logout { display: none; }
  .admin-main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .tbl-stats th, .tbl-stats td { padding: 11px 12px; }
  .card-head { flex-direction: column; align-items: stretch; }
  .filter { width: 100%; }
  .filter .check { order: 3; flex: 1 0 100%; justify-content: center; }
  .filter select { flex: 1 1 100%; }
  .flush-head { padding: 12px 14px; }
  .dur-grid { grid-template-columns: repeat(2, 1fr); }
  .dur { padding: 14px; border-bottom: 1px solid var(--line); }
  .dur:nth-child(2n) { border-right: 0; }
  .dur b { font-size: 24px; }
}

/* ---------- Danh sách nhiệm vụ ---------- */
.task-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.task-list li { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px; padding: 9px 12px; border: 1.5px solid var(--line); background: var(--paper-2); }
.tl-icon { width: 34px; height: 34px; display: grid; place-items: center; font-size: 15px; color: var(--accent); background: var(--accent-soft); border: 1.5px solid var(--accent); }
.tl-title { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.tl-meta { font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.task-steps li.is-done { border-color: var(--ok); background: var(--ok-soft); }
.task-steps li.is-done .tl-icon { color: var(--ok); background: var(--paper); border-color: var(--ok); }
.task-steps li.is-current { border: 2px solid var(--ink); background: var(--paper); box-shadow: 3px 3px 0 var(--accent); }
.task-steps li.is-current .tl-icon { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: var(--ink); }
.task-steps li.is-locked { opacity: .6; }
.task-steps li.is-locked .tl-icon { color: var(--muted); background: var(--paper); border-color: var(--line); }

.run-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.run-head b { font-family: var(--display); font-size: 20px; letter-spacing: .04em; color: var(--accent); }

/* ---------- Khung nhiệm vụ hiện tại ---------- */
.task-box { display: grid; gap: 14px; padding: 18px; margin-top: 6px; border: 2px solid var(--ink); background: var(--paper-2); }
.task-box form { display: grid; gap: 0; }
.task-title { margin: 0; display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 17px; text-transform: uppercase; letter-spacing: .03em; }
.task-title i { color: var(--accent); }
.hint { margin: 0; font-size: 13.5px; color: var(--muted); }
.hint b { color: var(--ink); }
.yt { position: relative; aspect-ratio: 16 / 9; max-width: 100%; background: #000; border: 2px solid var(--ink); }
.yt iframe, .yt > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.meter { height: 12px; border: 1.5px solid var(--ink); background: var(--paper); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s ease; }
.meter-text { margin: 0; font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: var(--muted); text-align: center; }
@media (prefers-reduced-motion: reduce) { .meter i { transition: none; } }

/* ---------- Admin: nhiệm vụ, chi tiết lượt ---------- */
.type-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; font-family: var(--mono); font-size: 11px; font-weight: 700; border: 1px solid var(--line); background: var(--paper-2); white-space: nowrap; }
.type-badge i { color: var(--accent); }
.tbl td.wrap-cell { white-space: normal; min-width: 180px; overflow-wrap: anywhere; }
.row-actions { display: inline-flex; gap: 6px; align-items: center; }
.row-actions form { display: inline-block; margin: 0; }
.tbl td:has(> .row-actions) { text-align: center; }
[data-show][hidden] { display: none !important; }
.copyline { display: flex; gap: 8px; align-items: center; }
.copyline input { flex: 1; min-width: 0; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0; border: 1.5px solid var(--ink); margin-bottom: 18px; background: var(--paper); }
.kv div { padding: 12px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-width: 0; }
.kv span { display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.kv b { display: block; margin-top: 2px; font-size: 14px; overflow-wrap: anywhere; }
.funnel-bar { position: relative; height: 8px; min-width: 120px; background: var(--paper-2); border: 1px solid var(--line); }
.funnel-bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
