/* Tông SUN của Sun PhuQuoc Airways. Hai lớp:
   - Lớp ấn tượng (đăng nhập, đầu trang chủ): luôn nền tối, có vòng HUD và chuyển động.
   - Lớp làm việc (mọi màn hình còn lại): ít màu, không chuyển động liên tục; cửa sổ, menu và thanh
     trạng thái mang nét HUD (góc vạch, chữ đơn cách, viền vàng mảnh). */
:root {
  color-scheme: dark;
  --sun: #f2b705;
  --sun-red: #d7262e;
  --bg: #171411;
  --surface: #221e1a;
  --surface-2: #2d2822;
  --line: #443c32;
  --text: #f4efe6;
  --muted: #b9ae9d;
  --accent: #f2b705;
  --on-accent: #1c1a17;
  --danger: #ff8a8d;
  --ok: #5fc97e;
  --warn: #f2b705;
  --banner-bg: #b01c22;
  --banner-text: #ffffff;
  --bar: #e4d3b0;
  --bar-ink: #1c1a17;
  --grid: rgba(244, 239, 230, .07);
  --zebra: rgba(244, 239, 230, .025);
  /* Chart series, in fixed order; checked for colour-blind separation on this surface. */
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --map-sea: #141a22;
  --map-land: #2a2620;
  --map-border: #4a4236;
  --map-arc: #8fb8ea;
}
:root[data-theme="light"] {
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --map-sea: #dfeaf5;
  --map-land: #f4efe4;
  --map-border: #c9bfac;
  --map-arc: #043c73;
  color-scheme: light;
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #f0ebe1;
  --line: #d9d2c4;
  --text: #24211c;
  --muted: #625b4f;
  --accent: #c81f27;
  --on-accent: #ffffff;
  --danger: #b3161e;
  --ok: #1f7a3d;
  --warn: #8a6500;
  --bar: #5b4636;
  --bar-ink: #ffffff;
  --grid: rgba(36, 33, 28, .08);
  --zebra: rgba(36, 33, 28, .025);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Segoe UI", Arial, sans-serif;
}
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
a { color: inherit; }
.trial-banner {
  background: var(--banner-bg);
  color: var(--banner-text);
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  padding: 3px 8px;
}

/* ---------- khung chung ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .1em;
  text-decoration: none;
  white-space: nowrap;
}
.brand img { height: 28px; width: 28px; }
.spacer { flex: 1; }
.account {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  text-decoration: none;
  min-width: 0;
}
.account-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  color: var(--accent);
}
.account-mark svg { width: 16px; height: 16px; }
.account:hover .account-name { text-decoration: underline; }
.shell { display: grid; grid-template-columns: 200px minmax(0, 1fr); align-items: start; }
.sidebar {
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  overflow-y: auto;
  padding: 10px 8px 16px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.nav-group { margin-bottom: 10px; }
.nav-group > span {
  display: block;
  padding: 6px 10px 3px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 14px;
  text-decoration: none;
  color: var(--text);
}
.nav-item svg { flex: none; width: 17px; height: 17px; color: var(--muted); }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--surface-2); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav-item.active svg { color: var(--accent); }
main { min-width: 0; max-width: 1560px; padding: 18px 20px 48px; }
.page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.page-head > .spacer { min-width: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}

/* ---------- nút, ô nhập, bảng ---------- */
button, .btn {
  font: inherit;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .gantt-bar:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input, select, textarea {
  font: inherit;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  max-width: 100%;
}
label { display: block; margin-bottom: 10px; }
label > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
label > input, label > select, label > textarea { width: 100%; }
label > input[type="checkbox"] { width: auto; }
.filters label { margin: 0; display: inline-flex; align-items: center; gap: 5px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  white-space: nowrap;
}
td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }
a.btn { display: inline-block; text-decoration: none; font-size: 14px; }
a.btn:hover { border-color: var(--muted); }
.matrix td { vertical-align: middle; }
.matrix input[type="checkbox"] { width: 18px; height: 18px; margin: 0; cursor: pointer; }
.matrix input[type="checkbox"]:disabled { cursor: default; }
.pill {
  display: inline-block;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 12.5px;
  white-space: nowrap;
}
.pill.ok { color: var(--ok); }
.pill.bad { color: var(--danger); }
.pill.warn { color: var(--warn); }
.pill.personal { margin-left: 6px; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.section-head h2 { margin: 0; }
.denied { color: var(--muted); font-style: italic; }
.error { color: var(--danger); margin: 8px 0; }
.success { color: var(--ok); margin: 8px 0; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  width: min(460px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.secret {
  display: block;
  font: 15px Consolas, monospace;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  margin: 8px 0;
  word-break: break-all;
  user-select: all;
}
.own-ticks { margin: 10px 0; }
.own-ticks p { margin: 2px 0; }
.scroll-box { max-height: 320px; overflow-y: auto; }
.segmented { display: inline-flex; }
.segmented button { border-radius: 0; }
.segmented button:first-child { border-radius: 6px 0 0 6px; }
.segmented button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.segmented button.selected { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }

/* ---------- vòng HUD: dùng ở đăng nhập và đầu trang chủ ---------- */
.hud { position: relative; width: 200px; aspect-ratio: 1; flex: none; }
.hud svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.hud-sun {
  position: absolute;
  top: 25%;
  left: 25%;
  width: 50%;
  height: 50%;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(242, 183, 5, .55));
  animation: hud-turn 60s linear infinite;
}
.hud .ring-a, .hud .ring-b, .hud .ring-c { transform-origin: 100px 100px; }
.hud .ring-a { animation: hud-turn 40s linear infinite; }
.hud .ring-b { animation: hud-turn 26s linear infinite reverse; }
.hud .ring-c { animation: hud-turn 8s linear infinite; }
@keyframes hud-turn { to { transform: rotate(360deg); } }
.brand-title {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: .14em;
  background: linear-gradient(90deg, #fff8e8, #f2b705 60%, #e8602a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-title span {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  letter-spacing: .55em;
  -webkit-text-fill-color: #f4c98a;
}

/* ---------- đăng nhập: luôn nền tối ở cả hai chế độ ---------- */
.login {
  --surface: rgba(26, 11, 7, .82);
  --surface-2: #2c1a12;
  --bg: rgba(12, 5, 3, .6);
  --line: rgba(242, 183, 5, .35);
  --text: #fff3e4;
  --muted: #e8c49a;
  --accent: #f2b705;
  --on-accent: #1c1a17;
  --danger: #ff9c9f;
  --ok: #7fdc9a;
  color-scheme: dark;
  position: relative;
  overflow: hidden;
  min-height: calc(100vh - 26px);
  display: grid;
  place-items: center;
  padding: 20px 16px;
  color: var(--text);
  background: radial-gradient(80% 60% at 50% 30%, #5a1f12 0%, #1e0c08 50%, #070302 100%);
}
.login::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .35;
  background-image: linear-gradient(rgba(242, 183, 5, .12) 1px, transparent 1px), linear-gradient(90deg, rgba(242, 183, 5, .12) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(circle at 50% 35%, #000 20%, transparent 75%);
  mask-image: radial-gradient(circle at 50% 35%, #000 20%, transparent 75%);
}
.login::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -30%;
  height: 30%;
  background: linear-gradient(transparent, rgba(242, 183, 5, .08), transparent);
  animation: login-scan 6s linear infinite;
}
@keyframes login-scan { to { top: 110%; } }
.login-box {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}
.login-box .hud { width: min(50vw, 190px); }
.login-word { width: min(240px, 66vw); height: auto; margin-top: 2px; }
.login-card {
  width: 100%;
  max-width: 420px;
  margin-top: 8px;
  padding: 18px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .03) inset, 0 20px 50px rgba(0, 0, 0, .45);
  text-align: left;
}
.login > .login-card { position: relative; z-index: 1; }
.login-card > img { display: block; width: 56px; height: 56px; margin: 0 auto 10px; }
.login-card h1 { text-align: center; letter-spacing: .08em; font-size: 17px; margin-bottom: 12px; }
.login-card input { height: 40px; }
.login-card input:focus-visible { outline-color: #f2b705; }
.login-go {
  width: 100%;
  height: 46px;
  margin-top: 4px;
  border-radius: 10px;
  border: 1px solid #f2b705;
  color: #fff;
  font-weight: 700;
  letter-spacing: .1em;
  background: linear-gradient(90deg, rgba(242, 183, 5, .4), rgba(215, 38, 46, .4));
  box-shadow: 0 0 20px rgba(242, 183, 5, .3);
}
.login-go:hover:not(:disabled), .login-go:focus-visible { background: linear-gradient(90deg, rgba(242, 183, 5, .6), rgba(215, 38, 46, .6)); border-color: #f2b705; }
.login-note { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.fly { display: grid; gap: 12px; padding: 4px 0 2px; }
.fly-sky {
  position: relative;
  height: 74px;
  overflow: hidden;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(242, 183, 5, .08), transparent);
}
.fly-plane {
  position: absolute;
  top: 12px;
  left: -160px;
  width: 150px;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .5));
  animation: fly-across var(--dur) cubic-bezier(.55, .05, .35, 1) forwards;
}
.fly-trail {
  position: absolute;
  top: 46px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 243, 228, .85));
  box-shadow: 0 0 8px rgba(242, 183, 5, .6);
  animation: fly-grow var(--dur) cubic-bezier(.55, .05, .35, 1) forwards;
}
@keyframes fly-across {
  0% { left: -160px; transform: translateY(10px) rotate(3deg); }
  100% { left: 100%; transform: translateY(-12px) rotate(-5deg); }
}
@keyframes fly-grow { to { width: 100%; } }
.fly-load { height: 6px; border-radius: 999px; overflow: hidden; background: rgba(242, 183, 5, .15); border: 1px solid rgba(242, 183, 5, .3); }
.fly-load i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #d7262e, #f2b705);
  animation: fly-grow var(--dur) linear forwards;
}
.fly-text { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.fly-text b { color: #f2b705; font-variant-numeric: tabular-nums; }

/* ---------- trang chủ ---------- */
.hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 16px 24px;
  margin-bottom: 14px;
  border-radius: 12px;
  border: 1px solid rgba(242, 183, 5, .28);
  color: #fff3e4;
  background: radial-gradient(70% 140% at 12% 40%, #5a1f12 0%, #2a110a 55%, #120705 100%);
}
.hero .hud { width: 118px; }
.hero .brand-title { font-size: 28px; }
.hero .brand-title span { font-size: 11px; letter-spacing: .5em; }
.hero-word { display: block; width: 170px; height: auto; margin-bottom: 8px; }
.hero-clocks { display: flex; gap: 28px; margin-left: auto; }
.hero-clocks b { display: block; font-size: 30px; line-height: 1.1; font-weight: 600; font-variant-numeric: tabular-nums; color: #fff8e8; }
.hero-clocks span { font-size: 12.5px; color: #e8c49a; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); gap: 14px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  min-height: 96px;
  text-decoration: none;
}
.tile svg { display: block; width: 22px; height: 22px; margin-bottom: 7px; color: var(--accent); }
a.tile:hover { border-color: var(--accent); background: var(--surface-2); }
.tile strong { display: block; margin-bottom: 2px; }
.tile.later { opacity: .68; }
.tile.later svg { color: var(--muted); }
.today h2 { margin-bottom: 8px; }
.today-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.today-stats div { padding: 7px 4px; text-align: center; border-radius: 6px; background: var(--surface-2); }
.today-stats b { display: block; font-size: 19px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.today-stats span { font-size: 11.5px; color: var(--muted); }
.next-flight {
  display: grid;
  grid-template-columns: 50px 72px 1fr auto;
  gap: 6px;
  padding: 6px 4px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.next-flight:hover { background: var(--surface-2); }
.next-flight b { font-weight: 600; }
.today-more { display: inline-block; margin-top: 8px; font-size: 13px; }

/* ---------- lịch bay ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { padding: 9px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.kpi b { display: block; font-size: 22px; line-height: 1.2; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12.5px; color: var(--muted); }
.kpi.warn b { color: var(--warn); }
.gantt { --row: 28px; padding: 0 0 4px; margin-bottom: 0; }
.gantt.compact { --row: 20px; }
.gantt-row { display: flex; align-items: stretch; min-width: 860px; border-bottom: 1px solid var(--line); }
.gantt-row:nth-child(even) .gantt-track { background-color: var(--zebra); }
.gantt-label {
  position: sticky;
  left: 0;
  z-index: 3;
  flex: 0 0 136px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px 0 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.gantt-label .muted { font-weight: 400; }
.gantt-track {
  position: relative;
  flex: 1;
  height: var(--row);
  background-image: linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 12.5% 100%;
}
.gantt-head .gantt-track { height: 24px; background-image: none; }
.gantt-hour { position: absolute; top: 0; height: 100%; padding: 3px 0 0 4px; font-size: 12px; color: var(--muted); border-left: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.gantt-now { position: absolute; top: 0; bottom: 0; z-index: 2; width: 2px; background: var(--accent); pointer-events: none; }
.gantt-bar {
  position: absolute;
  top: 3px;
  bottom: 3px;
  z-index: 1;
  min-width: 3px;
  overflow: hidden;
  padding: 0 3px;
  border-radius: 3px;
  background: var(--bar);
  color: var(--bar-ink);
  font-size: 11px;
  line-height: calc(var(--row) - 6px);
  white-space: nowrap;
  cursor: default;
}
.gantt.compact .gantt-bar { top: 2px; bottom: 2px; font-size: 10.5px; line-height: calc(var(--row) - 4px); }
.gantt-bar:hover, .gantt-bar:focus { background: var(--accent); color: var(--on-accent); }
.gantt-bar.other { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--muted); }
.gantt-bar.other:hover, .gantt-bar.other:focus { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.gantt-bar.from-before { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 2px dashed var(--surface); }
.gantt-bar.runs-on { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 2px dashed var(--surface); }
.gantt-info {
  position: sticky;
  bottom: 0;
  z-index: 5;
  min-height: 34px;
  margin-bottom: 14px;
  padding: 7px 14px;
  font-size: 13.5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  font-variant-numeric: tabular-nums;
}
.gantt-legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 0 0 8px; font-size: 12.5px; color: var(--muted); align-items: center; }
.gantt-legend i { display: inline-block; width: 22px; height: 11px; margin-right: 5px; border-radius: 2px; vertical-align: -1px; background: var(--bar); }
.gantt-legend i.other { background: transparent; box-shadow: inset 0 0 0 1px var(--muted); }
.gantt-legend i.now { width: 2px; background: var(--accent); border-radius: 0; }
.gantt-legend i.cut { background: var(--bar); border-right: 2px dashed var(--surface); border-radius: 2px 0 0 2px; }

.crew-photo { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; border: 2px solid var(--accent); }

/* ---------- route và roster ---------- */
.run-wrap { display: inline-flex; align-items: center; gap: 8px; }
.run-wrap .error { margin: 0; font-size: 13px; }
dialog:has(.route-detail) { width: min(780px, calc(100vw - 32px)); }
.duty-block { margin-top: 12px; }
.duty-block p { margin: 0 0 4px; }
.roster-wrap { padding: 0; max-height: calc(100vh - 220px); overflow: auto; }
.roster-matrix { width: auto; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.roster-matrix th, .roster-matrix td { padding: 0; border-bottom: 1px solid var(--line); }
.roster-matrix thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); text-align: center; color: var(--muted); padding: 4px 0; }
.roster-matrix .rm-who {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 190px;
  min-width: 190px;
  padding: 3px 8px;
  text-align: left;
  background: var(--surface);
  border-right: 1px solid var(--line);
  font-weight: 400;
}
.roster-matrix thead .rm-who { z-index: 4; background: var(--surface-2); }
.rm-who b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rm-who .muted { font-size: 11px; }
.rm-num { width: 48px; min-width: 48px; text-align: right; padding-right: 6px !important; font-variant-numeric: tabular-nums; border-right: 1px solid var(--line); }
.rm-day { width: 44px; min-width: 44px; font-weight: 500; }
.rm-day.weekend { color: var(--text); }
.rm-cell { position: relative; height: 34px; text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; border-right: 1px solid var(--grid); }
.roster-matrix tbody tr:hover .rm-who, .roster-matrix tbody tr:hover .rm-cell { background-color: var(--surface-2); }
.rm-cell.k-fly { font-weight: 600; cursor: pointer; }
.rm-cell.k-pos, .rm-cell.k-lay { color: var(--muted); cursor: pointer; }
.rm-cell.k-between { cursor: pointer; }
.rm-cell.quiet { color: var(--muted); }
.rm-cell.code { color: var(--warn); font-weight: 600; }
.rm-cell sub { font-size: 9px; color: var(--muted); font-weight: 400; margin-left: 1px; }
/* Sợi dây nối các ngày của cùng một route. */
.rm-cell.chL::before, .rm-cell.chR::after {
  content: "";
  position: absolute;
  bottom: 3px;
  height: 2px;
  background: var(--accent);
}
.rm-cell.chL::before { left: 0; width: 50%; }
.rm-cell.chR::after { right: 0; width: 50%; }
.rm-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.roster-notes { margin-top: 14px; }

/* ---------- khung tác vụ: cửa sổ, menu, tìm nhanh, thanh trạng thái ---------- */
:root { --mono: Consolas, "Cascadia Mono", ui-monospace, monospace; --status-h: 28px; }
.dk-win[hidden], .dk-status[hidden], .dk-toast[hidden] { display: none; }
.dk-on .sidebar { height: calc(100vh - 52px - var(--status-h)); }
.dk-on main { padding-bottom: calc(48px + var(--status-h)); }
.dk-on .gantt-info { bottom: var(--status-h); }
kbd {
  font: 11px var(--mono);
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.tb-find {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(340px, 32vw);
  margin-left: 14px;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
}
.tb-find span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.link-btn:hover { background: none; color: var(--accent); text-decoration: underline; }
.rm-name { display: block; }
.route-crew { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 8px; }

.dk-status {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--status-h);
  padding: 0 10px;
  font: 11.5px var(--mono);
  color: var(--muted);
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -1px 0 color-mix(in srgb, var(--accent) 22%, transparent);
}
.dk-status > button { padding: 0; border: 0; background: none; line-height: 1; cursor: pointer; }
.dk-who { color: var(--text); font-weight: 600; white-space: nowrap; }
.dk-info { display: flex; gap: 12px; white-space: nowrap; }
.dk-info span::before { content: "| "; opacity: .5; }
.dk-clock { white-space: nowrap; color: var(--accent); font-variant-numeric: tabular-nums; }
.dk-chips { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.dk-chip {
  flex: none;
  max-width: 180px;
  padding: 1px 9px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
}
.dk-chip.min { color: var(--muted); border-style: dashed; }
.dk-chip.active { border-color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }

.dk-win {
  position: fixed;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .4);
  animation: dk-rise .12s ease-out;
}
.dk-win:focus { outline: none; }
.dk-win.active { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); box-shadow: 0 14px 36px rgba(0, 0, 0, .5); }
/* Góc vạch kiểu HUD của cửa sổ đang làm việc. */
.dk-win.active::before, .dk-win.active::after {
  content: "";
  position: absolute;
  z-index: 2;
  width: 12px;
  height: 12px;
  pointer-events: none;
  border: 2px solid var(--accent);
}
.dk-win.active::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.dk-win.active::after { right: -1px; bottom: -1px; border-left: 0; border-top: 0; }
.dk-win.max { border-radius: 0; }
.dk-win-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 32px;
  padding: 0 4px 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  border-radius: 4px 4px 0 0;
  cursor: move;
  touch-action: none;
  user-select: none;
}
.dk-win.max .dk-win-bar { cursor: default; }
.dk-win-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; overflow: hidden; white-space: nowrap; }
.dk-win-title b { overflow: hidden; text-overflow: ellipsis; font-size: 13px; letter-spacing: .02em; }
.dk-win-sub { font: 11.5px var(--mono); color: var(--muted); }
.dk-win-tools { display: flex; gap: 2px; flex: none; }
.dk-win-tools button { width: 28px; height: 24px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 14px; line-height: 1; cursor: pointer; }
.dk-win-tools button:hover { background: var(--surface-2); color: var(--text); }
.dk-win-tools .dk-close:hover { background: var(--sun-red); color: #fff; }
.dk-win-body { flex: 1; min-height: 0; overflow: auto; padding: 14px; container-type: inline-size; }
.dk-win-body .page-head h1 { font-size: 17px; }
.dk-win-body .card { margin-bottom: 0; }
.dk-edge { position: absolute; z-index: 1; touch-action: none; }
.dk-edge.e { top: 32px; right: -3px; bottom: 8px; width: 7px; cursor: ew-resize; }
.dk-edge.s { left: 8px; right: 8px; bottom: -3px; height: 7px; cursor: ns-resize; }
.dk-edge.se { right: -3px; bottom: -3px; width: 14px; height: 14px; cursor: nwse-resize; }
.dk-win.max .dk-edge { display: none; }
@keyframes dk-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.dk-menu {
  position: fixed;
  z-index: 10000;
  min-width: 210px;
  max-width: 340px;
  padding: 4px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 4px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .45);
}
.dk-menu-title {
  padding: 4px 9px 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 11.5px var(--mono);
  color: var(--accent);
}
.dk-menu hr { margin: 4px 0; border: 0; border-top: 1px solid var(--line); }
.dk-menu [role="menuitem"] {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 22px;
  padding: 5px 9px;
  border-radius: 3px;
  cursor: default;
  outline: none;
}
.dk-menu [role="menuitem"].active { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.dk-menu [role="menuitem"][aria-disabled="true"] { opacity: .45; }
.dk-menu .danger { color: var(--danger); }

.dk-back {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 11vh 16px 16px;
  background: rgba(0, 0, 0, .45);
}
.dk-pal, .dk-help {
  display: flex;
  flex-direction: column;
  width: min(620px, 100%);
  max-height: 72vh;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 6px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
}
.dk-pal-input { flex: none; width: 100%; padding: 12px 14px; font-size: 15px; border: 0; border-bottom: 1px solid var(--line); border-radius: 6px 6px 0 0; background: none; color: var(--text); }
.dk-pal-input:focus { outline: none; border-bottom-color: var(--accent); }
.dk-pal-list { flex: 1; min-height: 80px; overflow-y: auto; padding: 4px; }
.dk-pal-group { padding: 8px 10px 3px; font: 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.dk-pal-item { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 6px 10px; font-size: 14px; border-radius: 3px; cursor: pointer; }
.dk-pal-item small { margin-left: 10px; font: 11.5px var(--mono); color: var(--muted); }
.dk-pal-item.on { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.dk-pal-item.off { opacity: .45; cursor: default; }
.dk-pal-empty { padding: 18px 10px; text-align: center; color: var(--muted); font-size: 13px; }
.dk-pal-foot { flex: none; display: flex; gap: 16px; padding: 6px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.dk-pal-foot kbd { margin-right: 2px; }
.dk-help { width: min(720px, 100%); }
.dk-help header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.dk-help-body { overflow-y: auto; padding: 4px 14px 14px; }
.dk-help h3 { margin: 12px 0 6px; font: 11.5px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.dk-help dl { display: grid; grid-template-columns: minmax(0, 170px) minmax(0, 1fr); gap: 5px 14px; margin: 0; font-size: 13.5px; }
.dk-help dd { margin: 0; }
.dk-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--status-h) + 12px);
  z-index: 6000;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: 4px;
  transform: translateX(-50%);
}
.dk-copy { position: fixed; top: -100px; opacity: 0; }
.gantt-bar.edited { box-shadow: inset 0 -3px 0 var(--sun-red); }
dialog:has(.ro-dialog) { width: min(860px, calc(100vw - 32px)); }
.ro-dialog h4 { margin: 12px 0 5px; font-size: 13px; }
.ro-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 5px; }
.ro-codes button { display: flex; gap: 8px; min-width: 0; padding: 4px 8px; text-align: left; }
.ro-codes button[hidden] { display: none; }
.ro-codes b { font-family: var(--mono); }
.ro-codes span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-cell.rm-mark { outline: 2px solid var(--accent); outline-offset: -2px; }
.roster-log { margin-top: 14px; }
.roster-log tr.undone td { color: var(--muted); text-decoration: line-through; }

/* ---------- Flight Info ---------- */
.fi-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.fi-bar .error { margin: 0; font-size: 13px; }
.fi-head {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 16px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}
.fi-head > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; min-width: 0; }
.fi-flt { font: 700 20px var(--mono); color: var(--accent); }
.fi-st { font: 700 16px var(--mono); }
.fi-links { display: inline-flex; gap: 8px; font-size: 12px; }
.fi-bad { color: var(--danger); }
.fi-body { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; }
.fi-tabs { display: flex; flex-direction: column; gap: 3px; }
.fi-tabs button { text-align: left; font-size: 13px; padding: 7px 10px; background: none; border: 1px solid transparent; color: var(--muted); cursor: pointer; }
.fi-tabs button:hover { background: var(--surface-2); color: var(--text); }
.fi-tabs button.on { background: var(--surface-2); color: var(--text); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }
.fi-main { min-width: 0; }
.fi-mode { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.fi-mode label { display: inline-flex; align-items: center; gap: 4px; margin: 0; white-space: nowrap; color: var(--text); }
.fi-mode label > input { width: auto; }
.fi-t label > input { width: auto; }
.fi-check { margin: 0; }
.fi-act { display: grid; grid-template-columns: minmax(230px, 280px) minmax(0, 1fr); gap: 18px; }
.fi-grid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 10px; align-items: center; align-content: start; }
.fi-l { font-size: 13px; color: var(--muted); }
.fi-t { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.fi-t input:not([type]), .fi-t input[maxlength] { width: 72px; font: 13px var(--mono); }
.fi-t button { padding: 2px 9px; }
.fi-check { display: inline-flex; align-items: center; gap: 4px; }
.fi-wrong { outline: 2px solid var(--danger); }
.fi-sum { display: grid; grid-template-columns: repeat(4, auto 1fr); gap: 4px 8px; margin: 0 0 8px; font-size: 13px; }
.fi-sum dt { color: var(--muted); }
.fi-sum dd { margin: 0; font: 700 13px var(--mono); }
.fi-main h4 { margin: 12px 0 4px; font-size: 13px; }
.fi-dl { margin-bottom: 4px; }
.fi-dl input { width: 100%; font-size: 13px; }
.fi-dl input.fi-short, input.fi-short { width: 62px; }
.fi-imp { margin: 10px 0; }
.fi-pill { display: block; margin: 3px 0; padding: 4px 10px; white-space: normal; border-radius: 4px; }
.pill.warn.fi-pill, .pill.bad.fi-pill, .pill.ok.fi-pill { font-size: 13px; }
.fi-js { display: block; margin-top: 12px; }
.fi-js input { display: block; width: 100%; margin-top: 4px; }
.fi-main textarea { display: block; width: 100%; margin-top: 4px; }
.fi-sch { margin-bottom: 10px; }
@container (max-width: 700px) {
  .fi-head { grid-template-columns: minmax(0, 1fr); }
  .fi-body, .fi-act { grid-template-columns: minmax(0, 1fr); }
  .fi-tabs { flex-direction: row; flex-wrap: wrap; }
}

/* ---------- Bảng hạn năng định: lớp FUI, luôn nền tối ---------- */
.dk-win.xp-win { --xp-line: rgba(242, 183, 5, .35); --xp-text: #fff3e4; --xp-soft: #e8c49a; color-scheme: dark; }
.xp-win .dk-win-body {
  color: var(--xp-text);
  background: radial-gradient(120% 80% at 50% 0%, #4a1c10 0%, #1e0c08 45%, #0a0504 100%);
}
.xp { position: relative; font-size: 13px; }
.xp::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(242, 183, 5, .03) 0 1px, transparent 1px 3px); }
.xp .mono { font-family: var(--mono); }
.xp-hd {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto 76px;
  gap: 16px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--xp-line);
  border-radius: 8px;
  background: rgba(10, 5, 4, .45);
}
.xp-ava {
  position: relative;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  overflow: hidden;
  font: 700 26px var(--mono);
  border: 2px solid var(--sun);
  border-radius: 50%;
  background: #2a120a;
  box-shadow: 0 0 16px rgba(242, 183, 5, .45);
}
.xp-ava img { width: 100%; height: 100%; object-fit: cover; }
.xp-scan { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(242, 183, 5, .4) 50%, transparent 60%); animation: xp-scan 3.2s linear infinite; }
@keyframes xp-scan { from { transform: translateY(-100%); } to { transform: translateY(100%); } }
.xp-who small, .xp-pw small { font: 10px var(--mono); letter-spacing: .14em; color: var(--sun); }
.xp-who h3 { margin: 2px 0; font-size: 21px; color: #fff; text-shadow: 0 0 10px rgba(242, 183, 5, .4); }
.xp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.xp-chips span { padding: 2px 8px; font-size: 11px; border: 1px solid; border-radius: 999px; background: rgba(0, 0, 0, .25); }
.xp-chips .bad { color: #ff8a8d; }
.xp-chips .bad2 { color: #ffb3a0; }
.xp-chips .warn { color: #ffd166; }
.xp-chips .soon { color: #e8c49a; }
.xp-pw { display: flex; align-items: center; gap: 8px; }
.xp-pw b { display: block; font: 700 27px var(--mono); color: #fff; }
.xp-ring { width: 84px; height: 84px; }
.xp-ring .r-track { fill: none; stroke: rgba(242, 183, 5, .15); stroke-width: 7; }
.xp-ring .r-value { fill: none; stroke: #5fc97e; stroke-width: 7; filter: drop-shadow(0 0 5px #5fc97e); }
.xp-ring .r-spin { fill: none; stroke: var(--sun); stroke-width: 1.5; opacity: .7; transform-origin: 50% 50%; animation: xp-spin 14s linear infinite; }
@keyframes xp-spin { to { transform: rotate(360deg); } }
.xp-logo { width: 76px; height: auto; filter: drop-shadow(0 0 8px rgba(242, 183, 5, .45)); }
.xp-next { margin: 10px 2px; padding: 8px 12px; border-left: 3px solid var(--sun); background: rgba(242, 183, 5, .08); }
.xp-head, .xp-r { display: grid; grid-template-columns: 78px minmax(150px, 1.4fr) 88px 78px 88px 92px minmax(170px, 1.3fr); gap: 8px; align-items: center; }
.xp-head { padding: 4px 10px; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--sun); border-bottom: 1px solid var(--xp-line); }
.xp-group h4 { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--xp-soft); }
.xp-group h4::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--xp-line), transparent); }
.xp-group h4 i { font-style: normal; color: #5fc97e; }
.xp-r { --c: #5fc97e; margin-bottom: 3px; padding: 6px 10px; border: 1px solid transparent; border-radius: 4px; background: rgba(255, 255, 255, .025); }
.xp-r:hover { border-color: var(--xp-line); background: rgba(242, 183, 5, .07); }
.xp-r em { display: none; font-style: normal; color: var(--xp-soft); }
.xp-code i { margin-left: 3px; font-size: 10px; font-style: normal; color: #ff9f43; }
.xp-r.st-warn { --c: #f2b705; }
.xp-r.st-warn .xp-exp { color: #ffd166; }
.xp-r.st-soon { --c: #e8c49a; }
.xp-r.st-exp { --c: #ff4d5e; background: rgba(255, 77, 94, .08); }
.xp-r.st-exp .xp-exp { color: #ff8a8d; }
.xp-r.st-exp.crit { border-color: rgba(255, 77, 94, .55); box-shadow: inset 3px 0 0 #ff4d5e; }
.xp-r.st-off { --c: #8c7f70; opacity: .5; }
.xp-meter { display: grid; grid-template-columns: minmax(40px, 1fr) auto; gap: 8px; align-items: center; }
.xp-meter b { font-size: 11px; font-weight: 600; white-space: nowrap; }
.xp-bar { position: relative; display: block; height: 9px; overflow: hidden; border-radius: 2px; background: rgba(242, 183, 5, .13); transform: skewX(-18deg); }
.xp-bar i { position: absolute; inset: 0 auto 0 0; width: var(--p); background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 55%, #fff)); box-shadow: 0 0 8px var(--c); }
.xp-bar::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 7px, rgba(10, 5, 4, .75) 7px 9px); }
.xp-now { color: #ff8a8d; animation: xp-blink 1.4s ease-in-out infinite; }
@keyframes xp-blink { 50% { opacity: .35; } }
.xp-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.xp-foot { margin: 10px 0 0; font-size: 11px; color: var(--xp-soft); }
@container (max-width: 860px) {
  .xp-hd { grid-template-columns: 72px minmax(0, 1fr); }
  .xp-ava { width: 72px; height: 72px; }
  .xp-logo { display: none; }
  .xp-pw { grid-column: 1 / -1; }
  .xp-head { display: none; }
  .xp-r { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .xp-desc, .xp-meter { grid-column: 1 / -1; }
  .xp-r em { display: inline; }
}

.gantt-bar.hit { outline: 2px solid var(--sun-red); outline-offset: 1px; z-index: 2; animation: dk-hit .6s ease-in-out 3; }
@keyframes dk-hit { 50% { outline-color: transparent; } }
@container (max-width: 620px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- điện thoại: menu ở đáy, vuốt ngang ---------- */
@media (max-width: 760px) {
  .tb-find { display: none; }
  .dk-on .sidebar { height: auto; }
  .dk-on main { padding-bottom: 84px; }
  .dk-on .gantt-info { bottom: 62px; }
  /* Trên điện thoại chỉ còn dải tên cửa sổ, nằm ngay trên menu đáy; cửa sổ chiếm hết màn hình. */
  .dk-status { display: none; bottom: 58px; z-index: 21; height: 32px; }
  .dk-has-windows .dk-status { display: flex; }
  .dk-status > :not(.dk-chips) { display: none; }
  .dk-win {
    left: 0 !important;
    right: 0;
    top: 52px !important;
    bottom: 90px;
    width: auto !important;
    height: auto !important;
    border-radius: 0;
    z-index: 19;
  }
  .dk-win-bar { cursor: default; height: 40px; }
  .dk-win-tools button { width: 38px; height: 36px; }
  .dk-edge { display: none; }
  .dk-menu [role="menuitem"] { padding: 10px 11px; }
  .dk-toast { bottom: 100px; }

  .topbar { padding: 0 12px; gap: 8px; }
  .brand { font-size: 12px; letter-spacing: .06em; }
  .account-name { display: none; }
  .shell { display: block; }
  .sidebar {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    height: auto;
    padding: 4px 4px max(4px, env(safe-area-inset-bottom));
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .nav-group { display: contents; }
  .nav-group > span { display: none; }
  .nav-item { flex: none; flex-direction: column; gap: 2px; min-width: 68px; padding: 5px 6px; font-size: 11px; white-space: nowrap; }
  .nav-item.active { box-shadow: inset 0 3px 0 var(--accent); }
  main { padding: 14px 16px 84px; }
  .hero { padding: 12px 14px; gap: 12px; flex-wrap: wrap; }
  .hero .hud { width: 76px; }
  .hero .brand-title { font-size: 20px; }
  .hero .brand-title span { font-size: 10px; letter-spacing: .4em; }
  .hero-word { width: 130px; margin-bottom: 5px; }
  .hero-clocks { margin-left: 0; width: 100%; justify-content: space-between; }
  .hero-clocks b { font-size: 24px; }
  .home-grid { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gantt-info { bottom: 62px; }
  .gantt-label { flex-basis: 104px; padding-left: 8px; }
  .brand-title { font-size: 28px; }
}
@media (max-height: 720px) {
  .login-box .hud { width: 120px; }
  .login-box .brand-title { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .hud-sun, .hud .ring-a, .hud .ring-b, .hud .ring-c, .login::after { animation: none; }
  .fly-plane, .fly-trail, .fly-load i { animation-duration: .3s; }
  .xp-scan, .xp-ring .r-spin, .xp-now, .gantt-bar.hit, .dk-win { animation: none; }
}

/* ---------- charts (public/charts.js) ---------- */
.ch { position: relative; }
.ch-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0 0 6px; }
.ch-key { display: inline-flex; align-items: center; gap: 6px; padding: 2px 6px; border: 0; background: none; color: var(--text); font-size: 12.5px; cursor: pointer; }
.ch-key i { width: 12px; height: 12px; border-radius: 3px; }
.ch-key i.dash { height: 3px; border-radius: 0; }
.ch-key[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; }
.ch-key[aria-pressed="false"] i { opacity: .25; }
.ch-plot { position: relative; width: 100%; overflow: hidden; }
.ch-plot svg { display: block; }
.ch-grid { stroke: var(--grid); stroke-width: 1; }
.ch-base { stroke: var(--line); stroke-width: 1; }
.ch-ax { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ch-hit { fill: transparent; }
.ch-hit.pick { cursor: pointer; }
.ch-hit:hover { fill: var(--zebra); }
.ch-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.ch-dot { stroke: var(--surface); stroke-width: 2; }
.ch-dot.soft { stroke-width: 1; opacity: .8; }
.ch-dot.soft:hover { opacity: 1; stroke: var(--text); }
.ch-mean { stroke: var(--text); stroke-width: 2; }
.ch-tip { position: absolute; z-index: 3; min-width: 140px; padding: 7px 9px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .3); pointer-events: none; font-size: 12.5px; }
.ch-tip-t { font-weight: 600; margin-bottom: 3px; }
.ch-tip-r { display: flex; align-items: center; gap: 6px; }
.ch-tip-r i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.ch-tip-r span { flex: 1; color: var(--muted); }
.ch-tip-r b { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Dashboard ---------- */
.db-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 12px; }
.db-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; }
.db-chip i { width: 10px; height: 10px; border-radius: 50%; }
.db-chip.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.db-card .db-head { margin-bottom: 8px; }
.db-card .db-head h2 { margin: 0; font-size: 15px; }
.db-card .db-head p { margin: 2px 0 0; }
.db-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 14px; margin-bottom: 14px; }
.db-grid > .card { margin-bottom: 0; min-width: 0; }
.db-section { font-size: 16px; margin: 18px 0 10px; }
.db-story { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.db-story li { display: flex; gap: 10px; align-items: baseline; line-height: 1.45; }
.db-mark { flex: none; width: 20px; height: 20px; display: inline-grid; place-items: center; border-radius: 50%; font-size: 12px; font-weight: 700; border: 1px solid currentColor; }
.db-ok .db-mark { color: var(--ok); }
.db-warn .db-mark { color: var(--warn); }
.db-bad .db-mark { color: var(--danger); }
.db-kpi small { display: block; font-size: 11.5px; margin-top: 2px; }
.db-kpi.ok b { color: var(--ok); }
.db-kpi.warn b { color: var(--warn); }
.db-table { margin-top: 10px; max-height: none; }
.db-table td.num, .db-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Mạng bay ---------- */
.mp-intro { margin: -6px 0 10px; }
.mp-tools { align-items: center; flex-wrap: wrap; }
.mp-stn-input { width: 150px; text-transform: uppercase; }
.mp-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 14px; margin-bottom: 14px; }
.mp-map { position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--map-sea); }
.mp-svg { display: block; width: 100%; height: min(62vh, 560px); cursor: grab; touch-action: none; user-select: none; }
.mp-svg.drag { cursor: grabbing; }
.mp-sea { fill: var(--map-sea); }
.mp-land { fill: var(--map-land); stroke: var(--map-border); }
.mp-arc-l { fill: none; stroke: var(--map-arc); stroke-linecap: round; opacity: .75; }
.mp-arc-hit { fill: none; stroke: transparent; cursor: pointer; }
.mp-arc:hover .mp-arc-l, .mp-arc.on .mp-arc-l, .mp-arc:focus .mp-arc-l { stroke: var(--accent); opacity: 1; stroke-dasharray: none; }
.mp-arc:focus { outline: none; }
.mp-plane { fill: var(--accent); pointer-events: none; }
.mp-stn circle { fill: var(--surface); stroke: var(--map-arc); stroke-width: .5; cursor: pointer; }
.mp-stn.base circle { fill: var(--accent); stroke: var(--text); }
.mp-stn.on circle { stroke: var(--accent); stroke-width: 1.4; }
.mp-stn text { fill: var(--text); font-weight: 600; paint-order: stroke; stroke: var(--map-sea); stroke-width: .6; pointer-events: none; }
.mp-stn:focus { outline: none; }
.mp-stn:focus circle { stroke: var(--accent); stroke-width: 1.4; }
.mp-ctl { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; }
.mp-ctl button { width: 30px; height: 30px; padding: 0; }
.mp-hint { position: absolute; left: 8px; bottom: 6px; color: var(--muted); background: color-mix(in srgb, var(--surface) 80%, transparent); padding: 2px 8px; border-radius: 4px; }
.mp-list { margin: 0; padding: 10px 0; max-height: min(62vh, 560px); overflow: auto; }
.mp-lh { font-weight: 600; padding: 0 12px 6px; }
.mp-list ol { list-style: none; margin: 0; padding: 0; }
.mp-list li { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding: 6px 12px; cursor: pointer; border-left: 3px solid transparent; font-size: 13px; }
.mp-list li .muted { grid-column: 2; text-align: right; font-size: 11.5px; }
.mp-list li:hover, .mp-list li:focus { background: var(--zebra); outline: none; }
.mp-list li.on { border-left-color: var(--accent); background: var(--zebra); }
.mp-sum { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.mp-blk td b { white-space: nowrap; }
.mp-blk h4, .mp-dir h4 { margin: 0 0 6px; font-size: 14px; }
.mp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.mp-head h3 { margin: 0; }
.mp-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.mp-row { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin: 6px 0; }
.mp-row > span:first-child { color: var(--muted); min-width: 70px; }
.mp-bars { display: flex; align-items: flex-end; gap: 3px; height: 92px; margin: 6px 0 2px; }
.mp-bars span { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.mp-bars i { display: block; width: 100%; max-width: 26px; background: var(--s1); border-radius: 3px 3px 0 0; min-height: 1px; }
.mp-bars b { font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mp-bars em { font-style: normal; font-size: 10.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Gantt drag ---------- */
.gantt-bar.can-drag { cursor: grab; touch-action: none; }
.gantt-bar.dragging { cursor: grabbing; opacity: .9; outline: 2px dashed var(--accent); outline-offset: 1px; z-index: 5; }
.gantt-row.drop { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.gantt-row.drop-bad { background: color-mix(in srgb, var(--danger) 16%, transparent); }
.gantt-ghost-tip { position: fixed; z-index: 50; padding: 5px 9px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--accent); font-size: 12.5px; pointer-events: none; font-variant-numeric: tabular-nums; }
.move-impacts { margin: 8px 0; padding-left: 18px; }
.move-impacts li.bad { color: var(--danger); }
.move-impacts li.warn { color: var(--warn); }

@media (max-width: 760px) {
  .db-grid, .mp-sum { grid-template-columns: minmax(0, 1fr); }
  .mp-wrap { grid-template-columns: minmax(0, 1fr); }
  .mp-svg { height: 52vh; }
  .mp-list { max-height: 260px; }
}
@media print {
  .sidebar, .topbar, .db-filters button.db-chip:last-child, .page-head button, .page-head select, .dk-bar, .dk-status { display: none !important; }
  main { padding: 0 !important; }
  .db-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) {
  .mp-plane { display: none; }
}

/* ---------- Phân công (crew record) ---------- */
.ca-card { grid-column: 1 / -1; }
.ca-card tr.ca-now td { background: color-mix(in srgb, var(--warn) 10%, transparent); }
dialog:has(.ca-dialog) { width: min(900px, calc(100vw - 32px)); }
.ca-dialog fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; min-width: 0; }
.ca-dialog legend { font-weight: 700; padding: 0 4px; }
.ca-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 12px; align-items: end; }
.ca-roles { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
label.ca-check { display: flex; align-items: center; gap: 6px; }
.ca-nr { border: 1px dashed var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; }
.ca-table td { padding: 3px 4px; vertical-align: middle; }
.ca-table input, .ca-table select { width: 100%; min-width: 110px; }
.ca-table td:last-child { width: 1%; }

/* Danh mục mã năng định (Năng định screen) */
.cma-cat { padding: 0; margin-bottom: 12px; }
.cma-cat > summary { display: flex; align-items: baseline; gap: 12px; padding: 12px 16px; cursor: pointer; list-style: none; }
.cma-cat > summary::-webkit-details-marker { display: none; }
.cma-cat > summary::before { content: '▸'; color: var(--muted); }
.cma-cat[open] > summary::before { content: '▾'; }
.cma-cat > summary h2 { margin: 0; font-size: 1rem; }
.cma-body { padding: 0 16px 14px; }
.cma-body label.check { display: flex; gap: 8px; align-items: center; margin: 6px 0 10px; }
.cma-table input[type="checkbox"] { width: 18px; height: 18px; margin: 0; cursor: pointer; }
.cma-table input[type="checkbox"]:disabled { cursor: default; opacity: .4; }
.cma-table tr.grp td { font-weight: 600; background: var(--panel-2, rgba(127,127,127,.08)); }
.cma-table tr.changed td:first-child { box-shadow: inset 3px 0 0 var(--accent, #F2B705); }
.cma-table td.num { text-align: right; }
.rm-cell.k-sby { cursor: pointer; color: var(--accent, #F2B705); font-weight: 600; font-size: .85em; }

/* Thiết lập */
.set-card { margin-bottom: 14px; }
.set-card h3 { margin: 14px 0 6px; font-size: .95rem; }
.set-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 14px; }
.set-form label, .set-fields label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; }
.set-form label.wide, fieldset.wide { grid-column: 1 / -1; }
.set-form label.changed input, .set-fields label.changed input, .set-table input.changed { border-color: var(--accent, #F2B705); }
.set-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.set-card fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px 12px; display: grid; gap: 8px; margin-top: 10px; }
.set-card fieldset legend { padding: 0 4px; font-weight: 600; font-size: .85rem; }
.set-card label.check { flex-direction: row; align-items: center; gap: 8px; }
.set-card .pair { display: flex; align-items: center; gap: 6px; }
.set-table input[type="number"] { width: 60px; }
.set-table input[type="checkbox"] { width: 18px; height: 18px; }
.set-card textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; }
@media (max-width: 600px) { .set-form { grid-template-columns: 1fr; } }

/* MFA */
.mfa-title { margin: 0 0 4px; }
.mfa-code { font-family: ui-monospace, Consolas, monospace; letter-spacing: .15em; font-size: 1.1rem; }
.mfa-qr { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin: 10px 0; }
.mfa-qr img { background: #fff; padding: 6px; border-radius: 6px; }
.mfa-secret { display: inline-block; margin-top: 4px; padding: 6px 8px; border: 1px dashed var(--line); border-radius: 6px; word-break: break-all; }
.mfa-codes { columns: 2; font-family: ui-monospace, Consolas, monospace; margin: 8px 0; }
.mfa-steps { padding-left: 18px; }
.mfa-forced { max-width: 560px; text-align: left; }
.login-card label.check { flex-direction: row; display: flex; gap: 8px; align-items: center; }
