/* Giao diện tối tím, thẻ kính mờ, thanh icon bên trái (theo 2 mẫu Pinterest người dùng chọn). */
:root {
  color-scheme: dark;
  --bg: #0b0918;
  --surface-1: #17142c;
  --card: rgba(30, 25, 58, 0.62);
  --card-solid: #1b1733;
  --card-border: rgba(160, 140, 255, 0.14);
  --card-hi: rgba(160, 140, 255, 0.28);
  --text-primary: #f1eefc;
  --text-secondary: #bdb6dc;
  --text-muted: #8a83ad;
  --grid: rgba(190, 180, 255, 0.10);
  --axis: rgba(190, 180, 255, 0.28);
  --accent: #7c5cff;
  --accent-2: #a78bfa;
  --accent-glow: rgba(124, 92, 255, 0.45);
  /* màu dữ liệu: đã kiểm bằng validate_palette trên nền #17142c */
  --pkg-premium: #3987e5; --pkg-performance: #d95926; --pkg-economy: #199e70;
  --car-sedan: #9085e9; --car-suv: #d55181;
  --opt-1: #c98500; --opt-2: #008300;
  --seq-1: #184f95; --seq-2: #256abf; --seq-3: #3987e5; --seq-4: #6da7ec; --seq-5: #9ec5f4;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b; --neutral: #6e6a88;
  --radius: 18px;
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 14px; color: var(--text-primary); background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 85% -10%, rgba(124, 92, 255, 0.28), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(57, 135, 229, 0.16), transparent 60%),
    linear-gradient(180deg, #0b0918 0%, #110d26 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.muted { color: var(--text-muted); }
.sec { color: var(--text-secondary); }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- khung ---------- */
/* Chốt chặn cuối: không phần tử nào được đẩy cả trang rộng hơn màn hình. */
html, body { overflow-x: clip; }
.shell { display: flex; min-height: 100vh; }
.rail {
  position: fixed; left: 16px; top: 16px; bottom: 16px; width: 68px; z-index: 900;
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 0;
  background: rgba(24, 20, 48, 0.72); border: 1px solid var(--card-border); border-radius: 24px;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.rail a {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: var(--text-muted);
  transition: background .15s, color .15s; position: relative;
}
.rail a:hover { background: rgba(124, 92, 255, 0.14); color: var(--text-primary); }
.rail a.on { background: linear-gradient(135deg, #7c5cff, #5b3fd6); color: #fff; box-shadow: 0 6px 22px var(--accent-glow); }
.rail a svg { width: 21px; height: 21px; }
.rail .tip { position: absolute; left: 58px; white-space: nowrap; background: var(--card-solid); border: 1px solid var(--card-border);
  padding: 5px 10px; border-radius: 8px; font-size: 12px; color: var(--text-primary); opacity: 0; pointer-events: none; transition: opacity .12s; }
.rail a:hover .tip { opacity: 1; }
.rail .spacer { flex: 1; }
.rail-more-btn, .rail-sheet { display: none; }
.main { flex: 1; margin-left: 100px; padding: 22px 28px 40px 16px; max-width: 1680px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar { justify-content: flex-end; }
.topbar[hidden] { display: none; }
/* Chuông + nút ngôn ngữ gắn vào hàng tiêu đề của từng trang. */
.page-head-ctl { display: flex; margin-left: auto; }
.page-head-ctl .topbar-ctl { align-items: center; gap: 14px; }
.topbar-ctl { align-items: flex-end; gap: 22px; }
.dash-head-ctl { display: flex; margin-left: auto; }
.dash-head-ctl .topbar-ctl { align-items: center; gap: 14px; }
.hello h1 { font-size: 30px; line-height: 1.15; font-weight: 500; }
.hello h1 b { font-weight: 600; background: linear-gradient(90deg, #a78bfa, #7c5cff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hello p { margin: 6px 0 0; color: var(--text-secondary); font-size: 13px; }
.clock { text-align: right; }
.clock .time { font-size: 40px; font-weight: 300; letter-spacing: 1px; line-height: 1; }
.clock .date { color: var(--text-secondary); font-size: 13px; margin-top: 6px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- thẻ ---------- */
.card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 18px 20px; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(5, 3, 20, 0.35); min-width: 0;
}
.card h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.card h3 .sub { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.grid { display: grid; gap: 16px; }
.g-kpi { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-map { grid-template-columns: minmax(0, 2.1fr) minmax(300px, 1fr); }
.g-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.mt { margin-top: 16px; }
@media (max-width: 1280px) { .g-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g-map, .g-main { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .g-2, .g-3 { grid-template-columns: 1fr; } }

/* Tiêu đề module có trang danh mục tương ứng: giữ kiểu chữ, dễ nhận ra khi tương tác. */
.dash-title-link { color: inherit; text-decoration: underline; text-decoration-color: var(--axis); text-underline-offset: 4px; }
.dash-title-link:hover { color: var(--accent-2); text-decoration-color: currentColor; }
.dash-title-link:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 4px; border-radius: 3px; }

/* KPI */
.kpi { position: relative; overflow: hidden; display: flex; flex-direction: column; }
/* Thanh tiến độ luôn sát đáy ô, để các ô cạnh nhau thẳng hàng dù nội dung dài ngắn khác nhau. */
.kpi > .bar-track { margin-top: auto; }
.kpi > .delta { margin-bottom: 10px; }
.kpi .kpi-note { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.kpi .label { color: var(--text-secondary); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.kpi .label .ic { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: rgba(124, 92, 255, 0.16); color: var(--accent-2); }
.kpi .label .ic svg { width: 16px; height: 16px; }
.kpi .value { font-size: 34px; font-weight: 600; margin: 10px 0 4px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 15px; color: var(--text-muted); font-weight: 400; margin-left: 4px; }
.kpi .delta { font-size: 12px; color: var(--text-secondary); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: rgba(255, 255, 255, 0.06); color: var(--text-secondary); }
.chip.up { color: #b7f5b7; background: rgba(12, 163, 12, 0.16); }
.chip.down { color: #ffc2b0; background: rgba(208, 59, 59, 0.18); }
.chip.warn { color: #ffe3a3; background: rgba(250, 178, 25, 0.14); }
.bar-track { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.07); overflow: hidden; margin-top: 10px; }
.bar-track > i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #5b3fd6, #a78bfa); }

/* ---------- điều khiển ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--card-border); background: rgba(255, 255, 255, 0.04); cursor: pointer; white-space: nowrap; font-weight: 500;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: rgba(124, 92, 255, 0.14); border-color: var(--card-hi); }
.btn.primary { background: linear-gradient(135deg, #7c5cff, #5b3fd6); border-color: transparent; color: #fff; box-shadow: 0 6px 18px var(--accent-glow); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: #ffb4a6; border-color: rgba(208, 59, 59, 0.4); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 10px; }
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--card-border); }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 9px; cursor: pointer; color: var(--text-secondary); font-size: 13px; }
.seg button.on { background: var(--accent); color: #fff; }
#lang-seg button { display: inline-flex; align-items: center; gap: 6px; }
#lang-seg .flag { height: 12px; width: auto; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15); flex: none; }
input:not([type]), input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=month], input[type=email], input[type=search], select, textarea {
  height: 38px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--card-border); background: rgba(10, 8, 26, 0.55);
  outline: none; width: 100%; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.22); }
select option { background: #1b1733; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
label.f { display: block; font-size: 13px; color: var(--text-secondary); }
label.f > input, label.f > select, label.f > textarea { display: block; margin-top: 6px; }
label.f .req { color: var(--serious); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------- bảng ---------- */
.tbl-wrap { overflow: auto; border-radius: 12px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 500; color: var(--text-muted); padding: 9px 10px; border-bottom: 1px solid var(--card-border); position: sticky; top: 0; background: var(--card-solid); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid rgba(160, 140, 255, 0.07); vertical-align: top; }
.tbl tr:hover td { background: rgba(124, 92, 255, 0.05); }
.tbl td.r, .tbl th.r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl input { height: 32px; padding: 0 8px; text-align: right; min-width: 64px; }
.tbl tr.click { cursor: pointer; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover, .tbl th.sortable:focus-visible { color: var(--text-primary); outline: none; }
.tbl th.sortable::after { content: '↕'; margin-left: 3px; font-size: 11px; opacity: .35; }
.tbl th.sortable[aria-sort=ascending]::after { content: '▲'; opacity: 1; color: var(--accent-2); }
.tbl th.sortable[aria-sort=descending]::after { content: '▼'; opacity: 1; color: var(--accent-2); }
.tbl th.sortable[aria-sort=ascending], .tbl th.sortable[aria-sort=descending] { color: var(--text-primary); }

/* ---------- danh sách nhỏ ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.li { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 13px; background: rgba(255, 255, 255, 0.035); border: 1px solid rgba(160, 140, 255, 0.07); }
.li .bar { width: 3px; align-self: stretch; border-radius: 3px; background: var(--accent); }
.li .t1 { font-weight: 500; }
.li .t2 { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.li .grow { flex: 1; min-width: 0; }
.li .grow .t1, .li .grow .t2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li.click { cursor: pointer; }
.li.click:hover { border-color: var(--card-hi); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 8px; font-size: 12px; border: 1px solid currentColor; white-space: nowrap; }
.badge .dot, .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.b-high { color: #ff9c8c; } .b-medium { color: #ffd27a; } .b-low { color: #9fd8b5; }
.b-open { color: #ffd27a; } .b-doing { color: #9ec5f4; } .b-done { color: #9fd8b5; }
.b-planned { color: #c4b5fd; } .b-cancelled { color: var(--text-muted); }

/* ---------- biểu đồ ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text-muted); font-size: 11px; font-family: var(--font); }
.chart .val { fill: var(--text-primary); font-weight: 600; }
.chart .lbl { fill: var(--text-secondary); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 2px; width: 14px; border-radius: 2px; }
.legend i.dash { height: 0; width: 14px; border-top: 2px dashed; border-radius: 0; background: none !important; }
.tooltip {
  position: fixed; z-index: 2000; pointer-events: none; background: rgba(20, 16, 40, 0.96); border: 1px solid var(--card-hi);
  border-radius: 10px; padding: 8px 11px; font-size: 12px; color: var(--text-primary); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  max-width: 280px; line-height: 1.5;
}
.tooltip b { font-weight: 600; }
.tooltip .tr { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.tooltip .tr span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.empty { display: grid; place-items: center; text-align: center; color: var(--text-muted); padding: 26px 10px; font-size: 13px; gap: 6px; }
.empty svg { width: 34px; height: 34px; opacity: .5; }
.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring-wrap .ring-meta { display: flex; flex-direction: column; gap: 10px; flex: 1; min-width: 0; }
.mini-stat .k { font-size: 12px; color: var(--text-muted); }
.mini-stat .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- bản đồ ---------- */
.map-card { padding: 0; overflow: hidden; position: relative; }
.map-card .map-head { position: absolute; top: 14px; left: 16px; right: 16px; z-index: 500; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none; }
.map-card .map-head > * { pointer-events: auto; }
.map-card .map-title { background: rgba(20, 16, 40, 0.78); border: 1px solid var(--card-border); border-radius: 14px; padding: 10px 14px; backdrop-filter: blur(12px); }
.map-card .map-title h3 { margin: 0; font-size: 15px; }
.map-card .map-title p { margin: 3px 0 0; font-size: 12px; color: var(--text-muted); }
.map-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; max-width: 55%; }
.map-mode-control, .map-month-control { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 11px; color: var(--text-secondary); }
.map-mode-control select { width: 100%; max-width: 220px; height: 34px; font-size: 12px; }
/* Bộ lọc trang Bản đồ có hàng/cột riêng, không ảnh hưởng khối bản đồ Dashboard. */
.map-card.map-page { padding: 0; }
.map-page .map-head { position: static; display: grid; grid-template-columns: minmax(0, 1fr); justify-content: stretch; align-items: stretch; padding: 14px 16px; }
.map-filter-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.map-filter-heading > div { min-width: 0; }
.map-filter-heading > button { flex-shrink: 0; }
.map-filters { display: grid; gap: 12px; min-width: 0; }
.map-filter-row { display: grid; gap: 12px; min-width: 0; align-items: end; }
.map-filter-primary, .map-filter-secondary.no-owners { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.map-filter-secondary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.map-filter-field, .map-filters .map-mode-control { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 12px; color: var(--text-secondary); }
.map-filters input, .map-filters select { width: 100%; min-width: 0; max-width: none; height: 40px; box-sizing: border-box; font-size: 14px; }
@media (max-width: 1100px) {
  .map-filter-primary, .map-filter-secondary, .map-filter-secondary.no-owners { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-filter-search { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .map-filter-primary, .map-filter-secondary, .map-filter-secondary.no-owners { grid-template-columns: minmax(0, 1fr); }
  .map-filter-search { grid-column: auto; }
  .map-filter-heading { align-items: flex-start; flex-wrap: wrap; }
}
.map-context { max-width: 260px; margin: 8px 0 0; line-height: 1.4; font-size: 10px; color: var(--text-muted); }
.map-metric { margin: 10px 0; padding: 8px; border-radius: 8px; background: var(--surface-1); }
.map { height: 560px; background: #0e0c1d; }
.map.full { height: calc(100vh - 150px); min-height: 520px; }
.map-legend { position: absolute; left: 16px; bottom: 16px; z-index: 500; background: rgba(20, 16, 40, 0.82); border: 1px solid var(--card-border); border-radius: 14px; padding: 10px 14px; font-size: 12px; backdrop-filter: blur(12px); }
.map-legend div { display: flex; align-items: center; gap: 8px; margin: 3px 0; color: var(--text-secondary); }
.map-legend { max-width: calc(100% - 60px); max-height: 45%; overflow: auto; }
.leaflet-container { font-family: var(--font); background: #0e0c1d; }
.leaflet-control-zoom a { background: rgba(20, 16, 40, 0.9) !important; color: var(--text-primary) !important; border-color: var(--card-border) !important; }
.leaflet-control-attribution { background: rgba(10, 8, 26, 0.7) !important; color: var(--text-muted) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--text-secondary) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: rgba(22, 18, 44, 0.97); color: var(--text-primary); border: 1px solid var(--card-hi); box-shadow: 0 12px 30px rgba(0, 0, 0, .5); }
.leaflet-popup-content-wrapper { border-radius: 16px; }
.leaflet-popup-content { margin: 14px 16px; min-width: 230px; font-size: 13px; line-height: 1.45; }
.leaflet-container a.leaflet-popup-close-button { color: var(--text-muted); }
.pin { position: relative; width: 18px; height: 18px; }
.pin i { position: absolute; inset: 3px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px rgba(11, 9, 24, .9), 0 0 14px 3px var(--c); }
.pin.pulse::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--c); animation: pulse 2s ease-out infinite; }
.pin.approx i { outline: 1px dashed rgba(255, 255, 255, .6); outline-offset: 2px; }
@keyframes pulse { from { transform: scale(.6); opacity: .9; } to { transform: scale(1.8); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pin.pulse::after { animation: none; } }
.cluster { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; color: #fff;
  background: radial-gradient(circle, rgba(124, 92, 255, .95) 0 45%, rgba(124, 92, 255, .25) 46% 100%); box-shadow: 0 0 22px rgba(124, 92, 255, .6); }
.map-label { color: rgba(220, 214, 255, .72); font-size: 11px; font-weight: 500; white-space: nowrap; text-shadow: 0 1px 3px #000; letter-spacing: .2px; }
.map-label.sea { color: rgba(160, 190, 255, .45); font-size: 13px; letter-spacing: 3px; font-style: italic; }
.map-label.island { color: rgba(255, 220, 160, .85); font-size: 11px; }
.pop h4 { margin: 0 0 2px; font-size: 14px; }
.pop .meta { color: var(--text-muted); font-size: 12px; margin-bottom: 10px; }
.pop .kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 12px; margin-bottom: 12px; }
.pop .kv span:nth-child(odd) { color: var(--text-secondary); }
.pop .kv span:nth-child(even) { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- trang con ---------- */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 600; }
.page-head.sub h2 { font-size: 18px; font-weight: 600; }
.dash-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; min-width: 0; max-width: 100%; }
.dash-heading h1 { min-width: 0; }
.dash-month-select { width: 140px; }
.dash-brand { flex: none; width: 140px; padding: 9px 10px; background: #fff; border-radius: 8px; }
.dash-brand img { display: block; width: 100%; height: auto; }
@media (max-width: 760px) {
  .dash-heading { gap: 10px; }
  .dash-heading h1 { font-size: 21px; }
  .dash-brand { width: 104px; padding: 7px 8px; }
}
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { border: 1px solid var(--card-border); background: rgba(255, 255, 255, 0.03); padding: 8px 14px; border-radius: 12px; cursor: pointer; color: var(--text-secondary); }
.tabs button.on { background: rgba(124, 92, 255, 0.2); color: var(--text-primary); border-color: var(--card-hi); }
.checklist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.035); border: 1px solid rgba(160, 140, 255, 0.08); }
.check.on { border-color: rgba(12, 163, 12, 0.45); background: rgba(12, 163, 12, 0.08); }
.check .grow { flex: 1; }
.check input[type=number] { width: 70px; height: 30px; }
@media (max-width: 700px) { .checklist { grid-template-columns: 1fr; } }
.timeline { display: flex; flex-direction: column; gap: 12px; }
.tl { border-left: 2px solid rgba(124, 92, 255, .35); padding: 2px 0 2px 14px; position: relative; }
.tl::before { content: ''; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.tl.planned::before { background: transparent; border: 2px solid var(--accent-2); }
.tl .when { font-size: 12px; color: var(--text-muted); }
.tl .what { margin-top: 4px; white-space: pre-wrap; line-height: 1.5; }
.tr-note { font-size: 11px; color: var(--text-muted); margin-top: 4px; display: flex; gap: 8px; align-items: center; }
.tr-note button { background: none; border: 0; color: var(--accent-2); cursor: pointer; padding: 0; font-size: 11px; }
.issue-box { border: 1px dashed var(--card-hi); border-radius: 14px; padding: 14px; position: relative; }
.issue-box .x { position: absolute; top: 8px; right: 8px; }

/* ---------- modal và thông báo ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 1500; background: rgba(5, 3, 15, .62); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 20px; }
.modal { width: min(760px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: #18142f; border: 1px solid var(--card-hi); border-radius: 22px; padding: 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.modal.wide { width: min(1000px, 100%); }
.modal h2 { font-size: 19px; margin-bottom: 16px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 3000; background: #221c45; border: 1px solid var(--card-hi); padding: 11px 18px; border-radius: 12px; box-shadow: 0 12px 30px rgba(0, 0, 0, .5); font-size: 13px; }
.toast.err { border-color: rgba(208, 59, 59, .7); }
.pw-box { font-family: ui-monospace, Menlo, monospace; font-size: 20px; padding: 12px 16px; border-radius: 12px; background: rgba(0, 0, 0, .35); border: 1px dashed var(--card-hi); user-select: all; text-align: center; letter-spacing: 1px; }
.perm-group { margin-top: 10px; }
.perm-group h4 { margin: 0 0 6px; font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .6px; }
.perm-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.perm-row.blocked { opacity: .45; }
.perm-row small { color: var(--text-muted); }

/* ---------- đăng nhập ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(400px, 100%); padding: 30px; }
.login .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login .brand .logo { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, #e5322d, #b31b1b); font-weight: 800; color: #fff; }
.login .brand h1 { font-size: 20px; }
.login .brand p { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }

/* ---------- điện thoại ---------- */
@media (max-width: 760px) {
  .rail { top: auto; bottom: calc(10px + env(safe-area-inset-bottom)); left: 10px; right: 10px; width: auto; height: 64px; flex-direction: row; justify-content: space-around; padding: 0 6px; }
  .rail .spacer, .rail .tip, .rail .rail-x { display: none; }
  .rail a, .rail-more-btn { width: 48px; height: 48px; flex: none; }
  .rail-more-btn { display: grid; place-items: center; border: 0; border-radius: 14px; background: none; color: var(--text-muted); cursor: pointer; }
  .rail-more-btn.on { color: #fff; background: linear-gradient(135deg, #7c5cff, #5b3fd6); }
  .rail-more-btn.open { color: var(--text-primary); background: rgba(124, 92, 255, 0.22); }
  .rail-more-btn svg { width: 22px; height: 22px; }
  .rail-sheet:not([hidden]) { display: grid; position: fixed; z-index: 950; left: 10px; right: 10px; bottom: calc(82px + env(safe-area-inset-bottom));
    grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 10px; border-radius: 20px;
    background: rgba(24, 20, 48, 0.96); border: 1px solid var(--card-hi); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55); }
  .rail-sheet a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: 14px; color: var(--text-secondary); font-size: 12px; text-align: center; }
  .rail-sheet a.on { background: rgba(124, 92, 255, 0.22); color: var(--text-primary); }
  .rail-sheet a svg { width: 22px; height: 22px; }
  .rail-sheet .avatar { width: 24px !important; height: 24px !important; font-size: 10px !important; }
  .main { margin-left: 0; padding: 14px 12px calc(96px + env(safe-area-inset-bottom)); min-width: 0; }
  .topbar { gap: 10px; margin-bottom: 14px; }
  .hello h1 { font-size: 21px; }
  .hello h1 br { display: none; }
  .hello p { font-size: 12px; }
  /* iPhone tự phóng to trang khi chạm vào ô chữ nhỏ hơn 16px, rồi không thu lại: trang trông rộng hơn màn hình. */
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px; }
  /* Bản đồ lớn: bộ lọc nằm trên bản đồ thay vì đè lên, để còn thấy và kéo được bản đồ. */
  .map-card .map-head { position: static; flex-direction: column; align-items: stretch; padding: 10px 10px 10px; }
  .map-card .map-hint { position: static !important; display: block; margin: 0 10px 10px; width: fit-content; }
  .map-card .map-title { padding: 8px 10px; }
  .map-card .map-title.row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .map-card .map-title.row > input, .map-card .map-title.row > select { width: 100% !important; }
  .map-card .map-title.row > input, .map-card .map-title.row > .seg { grid-column: 1 / -1; }
  .map-card .map-title.row > .seg button { flex: 1; }
  .map-controls, .map-filters { max-width: 100%; }
  .map-controls { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; }
  .map-controls .map-mode-control { width: 100%; }
  .map-controls > a { justify-self: end; }
  .map-mode-control select { max-width: 100%; font-size: 16px; }
  .map-filters input, .map-filters select { font-size: 16px; }
  .map-month-control input { width: 100%; min-width: 0; }
  .map-legend { left: 10px; bottom: 10px; padding: 8px 10px; font-size: 11px; }
  .clock { display: none; }
  .g-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .value { font-size: 26px; }
  .map { height: 420px; }
  .card { padding: 14px; }
  .modal { padding: 16px; border-radius: 18px; }
}

/* Nhân viên kinh doanh */
a.staff-link { color: inherit; text-decoration: underline; text-decoration-color: rgba(167, 139, 250, 0.5); text-underline-offset: 3px; }
a.staff-link:hover { color: var(--accent-2); }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.kpi-tile { padding: 14px 16px; border-radius: 14px; background: rgba(255, 255, 255, 0.035); border: 1px solid rgba(160, 140, 255, 0.1); }
.kpi-tile .label { color: var(--text-secondary); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.kpi-tile .value { font-size: 26px; font-weight: 600; margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
.kpi-tile .value small { font-size: 13px; color: var(--text-muted); font-weight: 400; margin-left: 4px; }
.kpi-tile .delta { font-size: 12px; color: var(--text-secondary); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kpi-tile.met { border-color: rgba(12, 163, 12, 0.35); }
.kpi-tile.met .bar-track > i { background: linear-gradient(90deg, #0a8a0a, #6fdc6f); }
.kpi-tile.miss { border-color: rgba(250, 178, 25, 0.25); }
.tbl.kpi-edit td { vertical-align: top; }
.tbl.kpi-edit input, .tbl.kpi-edit select { height: 32px; }
.tbl.kpi-edit input[type=text] { text-align: left; }
.tbl.kpi-edit td.r input { text-align: right; }
.tbl.kpi-edit .btn.sm { padding: 0 8px; }

/* Công nợ */
a.debt-leg { color: inherit; text-decoration: none; padding: 3px 6px; margin: -3px -6px; border-radius: 8px; }
a.debt-leg:hover { background: rgba(255, 255, 255, 0.06); }
a.h-link { color: inherit; text-decoration: none; }
a.h-link:hover { text-decoration: underline; }
.chip.crit { color: #ffd0d0; background: rgba(208, 59, 59, 0.32); }
.bk-current { color: var(--seq-3); } .bk-d1_30 { color: var(--warning); } .bk-d31_60 { color: var(--serious); } .bk-d60 { color: var(--critical); } .bk-clear { color: var(--good); }
.aging-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: rgba(255, 255, 255, 0.06); }
.aging-bar > i { display: block; height: 100%; }
.seg.wrap { flex-wrap: wrap; }
.alloc-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px 140px; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); font-size: 13px; }
.alloc-row input { height: 32px; }
tr.flag td:first-child { box-shadow: inset 3px 0 0 var(--critical); }

/* Ảnh đại diện: ảnh thật hoặc chữ cái đầu trên nền tím. */
.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; object-fit: cover;
  background: linear-gradient(135deg, #7c5cff, #5b3fd6); color: #fff; font-weight: 600; letter-spacing: .02em;
  border: 1px solid rgba(255, 255, 255, 0.14); }
.rail a .avatar { border-width: 2px; }
.rail a.on .avatar { border-color: #fff; }

/* Support activities: compact linked summaries and responsive editing controls. */
.main { min-width: 0; }
.activity-summary { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px 24px; max-height: 360px; overflow: auto; }
.activity-summary-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--card-border); }
.activity-summary-row .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.activity-summary-row .badge { flex-shrink: 0; }
.activity-actions { flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.activity-fallback { font-size: 11px; }
.activity-note { white-space: pre-wrap; font-size: 13px; margin-top: 6px; overflow-wrap: anywhere; }
.activity-manage-row { display: flex; align-items: center; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--card-border); flex-wrap: wrap; }
.bulk-scope { border: 1px solid var(--card-border); border-radius: 10px; padding: 10px 12px; }
.bulk-field { display: flex; gap: 10px; align-items: flex-end; }
.bulk-field > .f { flex: 1; min-width: 0; }
.bulk-field > .f input, .bulk-field > .f textarea, .bulk-field > .f select { width: 100%; }
.bulk-field textarea { min-height: 60px; }
.bulk-pick { white-space: nowrap; padding-bottom: 10px; }
.bulk-scope > label.row { flex-wrap: nowrap; align-items: center; }
.bulk-custom { max-height: 180px; overflow: auto; margin: 6px 0; padding-left: 18px; }
@media (max-width: 600px) { .bulk-field { flex-direction: column-reverse; align-items: stretch; } .bulk-pick { padding-bottom: 0; } }
.activity-manage-row .grow { flex: 1; min-width: 160px; overflow-wrap: anywhere; }
.activity-filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.activity-filters .f { flex: 1 1 155px; min-width: 0; }
.activity-results { display: grid; grid-template-columns: minmax(0,1fr); gap: 12px; }
.activity-result-row { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.activity-result-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.activity-result-head > a { min-width: 0; overflow-wrap: anywhere; }
.activity-result-head .badge { flex-shrink: 0; }
.activity-result-row .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.activity-result-row h3 { margin: 0 0 6px; }
.activity-result-row .activity-actions { margin-top: 2px; }
.activity-result-row .btn { max-width: 100%; white-space: normal; }
.activity-result-row [data-tooltip] { position: relative; }
.activity-result-row [data-tooltip]:is(:hover,:focus-visible)::after { content: attr(data-tooltip); position: absolute; bottom: calc(100% + 6px); right: 0; z-index: 2; width: max-content; max-width: 220px; padding: 6px 9px; border: 1px solid var(--card-border); border-radius: 6px; background: var(--bg); color: var(--text-primary); font-size: 12px; font-weight: 400; box-shadow: 0 4px 12px rgba(0,0,0,.25); pointer-events: none; }
@media (min-width: 1100px) { .activity-results { grid-template-columns: repeat(2,minmax(0,1fr)); } }
.activity-results > .empty { grid-column: 1 / -1; }
.check .grow { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 760px) {
 .activity-summary { grid-template-columns: minmax(0,1fr); }
 .activity-summary-row { gap: 6px; flex-wrap: wrap; }
 .activity-summary-row .grow { flex-basis: 100%; }
}

/* Trạng thái triển khai: thẻ đếm bấm được, bảng lọc, bước trạng thái ở trang showroom. */
.ro-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.ro-card { display: block; color: inherit; border-top: 3px solid var(--c); transition: border-color .15s, transform .15s; }
.ro-card:hover { border-color: var(--card-hi); border-top-color: var(--c); }
.ro-card.on { box-shadow: 0 0 0 2px var(--accent); }
.ro-card .ro-name { font-weight: 600; overflow-wrap: anywhere; }
.ro-card .value { font-size: 28px; font-weight: 700; margin: 8px 0 2px; }
.ro-card .value small { font-size: 13px; font-weight: 500; color: var(--text-muted); margin-left: 6px; }
.ro-card .ro-exact { font-size: 12px; }
.ro-badge { gap: 6px; }
.ro-badge span { color: var(--text-primary); }
.ro-cond { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ro-cond select, .ro-cond input { flex: 1 1 160px; min-width: 0; }
.ro-colors { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.ro-colors label { cursor: pointer; }
.ro-colors input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ro-colors i { display: block; width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; }
.ro-colors input:checked + i { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.ro-colors input:focus-visible + i { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.ro-preview { border: 1px solid var(--card-border); border-radius: 12px; padding: 12px; margin-top: 4px; }
.ro-preview h3 { margin-top: 0; }
.ro-steps { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.ro-step { border: 1px solid var(--card-border); border-left: 3px solid var(--card-border); border-radius: 12px; padding: 10px 12px; opacity: .7; }
.ro-step.on { border-left-color: var(--c); opacity: 1; }
.ro-step.cur { box-shadow: 0 0 0 1px var(--c); }
.ro-step a { color: inherit; }
.ro-conds { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; font-size: 13px; color: var(--text-muted); }
.ro-conds li { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: center; gap: 6px; }
.ro-conds li > span { overflow-wrap: anywhere; }
.ro-conds li.ok { color: var(--good); }
.ro-override-box { border: 1px solid rgba(250, 178, 25, 0.35); background: rgba(250, 178, 25, 0.06); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }
.ro-override-box.off { border-color: var(--card-border); background: transparent; }
.ro-reason { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.ro-auto { margin-top: 4px; font-size: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.ro-override svg { width: 12px; height: 12px; }

/* Công việc */
.mt-s { margin-top: 12px; }
.mt-s:first-child { margin-top: 0; }
.linkbtn { border: 0; background: none; color: inherit; cursor: pointer; padding: 2px; display: inline-flex; opacity: .75; }
.linkbtn:hover { opacity: 1; }
.tk-row .tk-meta { flex: none; }
.tk-row .badge { flex: none; }
.tk-prog { width: 90px; flex: none; display: flex; align-items: center; gap: 6px; }
.tk-prog .bar-track { flex: 1; margin: 0; }
.tk-prog small { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.tk-who span:last-child { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.tk-todo { color: var(--text-secondary); } .tk-doing { color: #9ec5f4; } .tk-review { color: #ffd27a; } .tk-done { color: #9fd8b5; } .tk-cancelled { color: var(--text-muted); }
.tk-ext-pending { color: #ffd27a; } .tk-ext-approved { color: #9fd8b5; } .tk-ext-rejected { color: #ff9c8c; }
.tk-board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; }
.tk-col { background: rgba(255, 255, 255, 0.025); border: 1px solid var(--card-border); border-radius: 16px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 200px; }
.tk-col.over { border-color: var(--card-hi); background: rgba(124, 92, 255, 0.08); }
.tk-col-h { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 6px; }
.tk-card { display: block; padding: 10px 12px; border-radius: 12px; background: var(--card-solid); border: 1px solid rgba(160, 140, 255, 0.1); border-left: 3px solid var(--accent); cursor: grab; }
.tk-card:hover { border-color: var(--card-hi); }
.tk-card .t1 { font-weight: 500; font-size: 14px; }
.tk-card .t2 { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.tk-card .tk-prog { width: 100%; margin-top: 8px; }
.tk-card .chip { font-size: 11px; }
.tk-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.tk-cal-h { font-size: 12px; color: var(--text-muted); text-align: center; padding: 4px 0; }
.tk-day { min-height: 96px; border-radius: 10px; background: rgba(255, 255, 255, 0.025); border: 1px solid rgba(160, 140, 255, 0.06); padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tk-day.empty-day { background: none; border-color: transparent; }
.tk-day.today { border-color: var(--card-hi); }
.tk-day .n { font-size: 12px; color: var(--text-secondary); }
.tk-pill { display: block; font-size: 11px; padding: 2px 6px; border-radius: 6px; background: rgba(124, 92, 255, 0.14); border-left: 3px solid var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-pill.late { background: rgba(208, 59, 59, 0.2); }
.tk-pill.closed { opacity: .5; text-decoration: line-through; }
.tk-desc { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.tk-strike { text-decoration: line-through; }
.tk-mention { color: var(--accent-2); }
.mention-pop { position: fixed; z-index: 1000; min-width: 240px; max-width: 320px; max-height: 280px; overflow-y: auto; padding: 4px;
  background: var(--card-solid); border: 1px solid var(--card-hi); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); }
.mention-it { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.mention-it.on { background: rgba(124, 92, 255, 0.22); }
.mention-it .grow { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.mention-it b { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention-it small { color: var(--text-muted); font-size: 11px; }
.tk-info > div { display: flex; justify-content: space-between; gap: 12px; align-items: center; font-size: 13px; }
.tk-info > div > :last-child { text-align: right; }
.tk-ext { padding: 10px 12px; border-radius: 12px; background: rgba(250, 178, 25, 0.08); border: 1px solid rgba(250, 178, 25, 0.25); margin-bottom: 10px; font-size: 13px; }
.tk-watch { display: flex; flex-wrap: wrap; gap: 6px 14px; max-height: 150px; overflow: auto; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--card-border); }
.tk-chk { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; cursor: pointer; }
.tk-chk input { width: auto; height: auto; }
.tk-notif.unread { border-color: var(--card-hi); background: rgba(124, 92, 255, 0.1); }
.bell { position: relative; width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--card-border); background: rgba(255, 255, 255, 0.05); color: var(--text-secondary); cursor: pointer; display: grid; place-items: center; }
.bell svg { width: 18px; height: 18px; }
.bell:hover { border-color: var(--card-hi); color: var(--text-primary); }
#bell-n { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--critical); color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; }
#bell-n[hidden] { display: none; }
.tk-dash { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 14px; padding-bottom: 14px; }
.tk-dash .ic-box { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: rgba(124, 92, 255, 0.16); color: var(--accent-2); }
.tk-dash .ic-box svg { width: 16px; height: 16px; }
.tk-dash-links { display: flex; gap: 10px; flex-wrap: wrap; }
.tk-dash-link { display: flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: 12px; border: 1px solid var(--card-border); background: rgba(255, 255, 255, 0.03); font-size: 13px; color: var(--text-secondary); }
.tk-dash-link:hover { border-color: var(--card-hi); }
.tk-dash-link b { font-size: 18px; color: var(--text-primary); }
.tk-dash-link b.tk-red { color: #ff9c8c; } .tk-dash-link b.tk-amber { color: #ffd27a; }
@media (max-width: 900px) {
  .tk-row { flex-wrap: wrap; }
  .tk-row .grow { flex-basis: calc(100% - 40px); }
  .tk-row .grow .t2 { white-space: normal; }
  .tk-prog { width: 70px; }
  .tk-board { grid-template-columns: repeat(4, 78vw); }
  .tk-day { min-height: 64px; }
  .tk-pill { font-size: 10px; padding: 1px 4px; }
}
.tk-card, .tk-pill { color: var(--text-primary); }
.tk-row { color: var(--text-primary); }

/* Gantt công việc */
.gt-bar-tools { gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.gt { --lw: 260px; position: relative; overflow: auto; max-height: 70vh; border: 1px solid var(--card-border); border-radius: 12px; }
.gt-head, .gt-row { display: flex; width: max-content; min-width: 100%; }
.gt-head { position: sticky; top: 0; z-index: 3; background: var(--card-solid); border-bottom: 1px solid var(--card-border); }
.gt-label { position: sticky; left: 0; z-index: 2; flex: none; width: var(--lw); display: flex; align-items: center; gap: 7px; padding: 0 10px; height: 34px; background: var(--card-solid); border: 0; border-right: 1px solid var(--card-border); color: inherit; font: inherit; font-size: 13px; text-align: left; min-width: 0; }
.gt-label span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gt-label small { flex: none; max-width: 90px; font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.gt-label:hover span { color: var(--accent-2); }
.gt-corner { height: 46px; color: var(--text-muted); font-size: 12px; }
.gt-scale { position: relative; flex: none; height: 46px; }
.gt-ms, .gt-ds { position: absolute; left: 0; right: 0; height: 22px; }
.gt-ms { top: 0; } .gt-ds { top: 22px; }
.gt-m, .gt-d { position: absolute; top: 0; height: 22px; font-size: 11px; color: var(--text-secondary); border-left: 1px solid rgba(160, 140, 255, 0.1); white-space: nowrap; overflow: hidden; }
.gt-m { padding: 4px 6px; font-weight: 600; }
.gt-d { text-align: center; line-height: 22px; font-variant-numeric: tabular-nums; }
.gt-d small { margin-right: 2px; color: var(--text-muted); }
.gt-d.wk { text-align: left; padding-left: 4px; }
.gt-d.now { color: #fff; background: rgba(124, 92, 255, 0.35); border-radius: 6px; }
.gt-body { position: relative; }
.gt-bg { position: absolute; top: 0; bottom: 0; left: var(--lw); pointer-events: none; background-image: repeating-linear-gradient(90deg, rgba(160, 140, 255, 0.06) 0 1px, transparent 1px var(--cw)); }
.gt-we { position: absolute; top: 0; bottom: 0; background: rgba(255, 255, 255, 0.045); }
.gt-caret { display: inline-flex; transform: rotate(180deg); transition: transform .15s; color: var(--text-muted); }
.gt-caret.open { transform: rotate(-90deg); }
.gt-now { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--accent); opacity: .8; }
.gt-row { border-bottom: 1px solid rgba(160, 140, 255, 0.05); }
.gt-row.closed .gt-label span { color: var(--text-muted); }
.gt-row.closed .gt-bar { opacity: .55; }
.gt-group .gt-label { cursor: pointer; background: #1d1a33; gap: 6px; }
.gt-group .gt-label b { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.gt-group .gt-label small { max-width: none; }
.gt-group .gt-track { background: rgba(255, 255, 255, 0.02); }
.gt-track { position: relative; flex: none; height: 34px; }
.gt-bar { position: absolute; top: 8px; height: 18px; border-radius: 5px; background: color-mix(in srgb, var(--c) 38%, transparent); border: 1px solid var(--c); overflow: hidden; cursor: pointer; display: flex; align-items: center; touch-action: pan-x pan-y; }
.gt-bar.movable { cursor: grab; }
.gt-bar.drag { cursor: grabbing; box-shadow: 0 0 0 2px var(--accent-2); z-index: 1; }
.gt-bar.est { border-style: dashed; background: color-mix(in srgb, var(--c) 22%, transparent); }
.gt-bar.cut-l { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-width: 0; }
.gt-bar.cut-r { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right-width: 0; }
.gt-bar span { position: relative; padding: 0 6px; font-size: 10px; font-weight: 600; color: #fff; white-space: nowrap; font-variant-numeric: tabular-nums; }
.gt-prog { position: absolute; left: 0; top: 0; bottom: 0; background: var(--c); opacity: .85; }
.gt-h { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; z-index: 1; }
.gt-h.l { left: 0; } .gt-h.r { right: 0; }
.gt-bar:hover .gt-h { background: rgba(255, 255, 255, 0.35); }
.gt-late { position: absolute; top: 15px; height: 4px; border-radius: 2px; background: var(--critical); opacity: .85; }
.gt-orig { position: absolute; top: 5px; height: 24px; width: 2px; background: #ffd27a; opacity: .7; }
.gt-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.gt-legend span { display: inline-flex; align-items: center; gap: 6px; }
.gt-key { display: inline-block; width: 16px; height: 8px; border-radius: 3px; }
.gt-key.late { height: 4px; background: var(--critical); }
.gt-key.orig { width: 2px; height: 12px; background: #ffd27a; }
.gt-key.est { border: 1px dashed var(--text-secondary); }
.gt-undated { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 760px) { .gt { --lw: 140px; max-height: none; } .gt-label small { display: none; } }
.gt-late-n { color: #ff9c8c; }

/* Nhật ký thao tác */
.au-tbl tbody tr[data-id] { cursor: pointer; }
.au-sum { max-width: 520px; font-size: 12px; color: var(--text-secondary); overflow-wrap: anywhere; }
.au-raw pre { margin: 0; white-space: pre-wrap; font-size: 11px; color: var(--text-secondary); max-height: 320px; overflow: auto; }
.au-tbl .badge { white-space: nowrap; }
.al-dash .tk-dash-link span { max-width: 230px; }
/* Việc phụ thuộc */
.tk-deps { display: flex; flex-wrap: wrap; gap: 6px; }
.tk-dep { display: inline-flex; align-items: center; gap: 6px; }
.tk-dep .linkbtn { display: inline-grid; place-items: center; }
.tk-wait { white-space: normal; }
.tk-dep-list { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.tk-dep-list a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-primary); }
.tk-dep-list .badge { font-size: 10px; padding: 1px 6px; }
.gt-deps { position: absolute; top: 0; z-index: 1; pointer-events: none; overflow: visible; }
.gt-deps path { fill: none; stroke: #a78bfa; stroke-width: 1.5; opacity: .85; }
.gt-deps path.bad { stroke: #ff6b5e; stroke-dasharray: 4 3; opacity: 1; }
.gt-bar.dep-bad { box-shadow: 0 0 0 2px #ff6b5e; }
.gt-key.dep { height: 2px; background: #a78bfa; }
.gt-key.dep.bad { background: repeating-linear-gradient(90deg, #ff6b5e 0 4px, transparent 4px 7px); }

/* Loại vấn đề: số lượng và tỷ trọng dùng chung một bộ dữ liệu. */
.dash-issues { grid-column: 1 / -1; }
.issue-charts { display: grid; grid-template-columns: minmax(0, 1fr) 150px minmax(0, .8fr); column-gap: 24px; align-items: center; min-width: 0; }
.issue-charts h4 { margin: 0 0 12px; font-size: 13px; color: var(--text-muted); }
.issue-count-title { grid-column: 1; grid-row: 1; }
.issue-share-title { grid-column: 2 / 4; grid-row: 1; }
.issue-charts #issues, .issue-charts #issue-legend { display: contents; }
.issue-charts #issue-share { grid-column: 2; grid-row: 2 / span var(--issue-count); justify-self: center; min-width: 0; }
.issue-bar-row, .issue-share-row { grid-row: calc(var(--issue-row) + 2); display: grid; align-items: center; gap: 12px; min-width: 0; min-height: 32px; padding: 6px 0; font-size: 12px; color: var(--text-secondary); text-decoration: none; border-radius: 6px; }
.issue-bar-row { grid-column: 1; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) 36px; }
.issue-share-row { grid-column: 3; grid-template-columns: minmax(0, 1fr) max-content; }
.issue-label, .issue-share-label { overflow-wrap: anywhere; }
.issue-share-label { display: flex; align-items: center; gap: 6px; min-width: 0; }
.issue-share-label .dot { flex: none; }
.issue-bar-row b, .issue-share-row b { text-align: right; white-space: nowrap; color: var(--text-primary); }
.issue-bar-track { display: block; height: 12px; background: rgba(255,255,255,.04); border-radius: 6px; overflow: hidden; }
.issue-bar-track > span { display: block; height: 100%; border-radius: inherit; }
a.issue-bar-row:hover, a.issue-share-row:hover { background: rgba(255,255,255,.06); }
a.issue-bar-row:focus-visible, a.issue-share-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.issue-charts #issues.issue-empty { display: block; grid-column: 1; grid-row: 2; }
@media (max-width: 767px) {
  .issue-charts { grid-template-columns: 150px minmax(0, 1fr); column-gap: 18px; }
  .issue-count-title, .issue-bar-row, .issue-charts #issues.issue-empty { grid-column: 1 / -1; }
  .issue-share-title { grid-column: 1 / -1; grid-row: calc(var(--issue-count) + 2); margin-top: 20px !important; }
  .issue-charts #issue-share { grid-column: 1; grid-row: calc(var(--issue-count) + 3) / span var(--issue-count); }
  .issue-share-row { grid-column: 2; grid-row: calc(var(--issue-count) + var(--issue-row) + 3); }
}
@media (max-width: 480px) {
  .issue-charts { grid-template-columns: minmax(0, 1fr); }
  .issue-charts #issue-share { grid-column: 1; grid-row: calc(var(--issue-count) + 3); margin-bottom: 12px; }
  .issue-share-row { grid-column: 1; grid-row: calc(var(--issue-count) + var(--issue-row) + 4); }
}

/* Ô Sự cố kỹ thuật trên Tổng quan: số và chip bấm được mở danh sách đã lọc. */
#ops .mini-stat > a { color: inherit; text-decoration: none; display: block; }
#ops .mini-stat > a:hover .k, #ops a.chip:hover { text-decoration: underline; }
#ops a.chip { color: inherit; text-decoration: none; }
#ops .ord-late { color: var(--critical); text-decoration: none; }

/* Khi xếp dọc, mỗi thẻ Tổng quan cao theo nội dung. */
.dash-map-row, .dash-team-row { align-items: start; }
.dash-map-summary { gap: 16px; }
.dash-upcoming-card { display: flex; flex-direction: column; }
.dash-upcoming-all { align-self: flex-start; margin-top: 10px; font-size: 12px; }
@media (min-width: 901px) {
  .dash-team-row { align-items: stretch; }
  .dash-upcoming-card #upcoming { flex: 1; }
  .dash-upcoming-card #upcoming > .li { flex: 1; }
}
@media (min-width: 1281px) {
  .dash-map-row { align-items: stretch; }
  .dash-map-row > .map-card { display: flex; flex-direction: column; }
  .dash-map-row #dash-map { flex: 1; height: auto; min-height: 560px; }
  .dash-map-summary { display: grid; grid-template-rows: minmax(min-content, 1fr) minmax(min-content, 1.1fr); }
  .dash-map-summary > .card { display: flex; flex-direction: column; }
  .dash-map-summary .ring-wrap { flex: 1; }
  .dash-map-summary #opt-chart { flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; }
}
.dash-team-caption { font-size: 12px; color: var(--text-muted); margin: -4px 0 10px; }
.dash-team-summary { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 12px; color: var(--text-secondary); margin-bottom: 14px; }
.dash-team-summary b { color: var(--text-primary); }
.dash-stale-link { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 10px; font-size: 12px; color: var(--text-muted); text-decoration: none; }
.dash-option-row { display: block; padding: 10px 0; color: inherit; text-decoration: none; }
.dash-option-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 12px; }
.dash-option-heading > span { color: var(--text-secondary); overflow-wrap: anywhere; }
.dash-option-heading b { white-space: nowrap; }
.dash-option-row .bar-track { margin: 8px 0; }
.dash-option-row .bar-track i { background: var(--option-color); }
.dash-option-detail { font-size: 11px; color: var(--text-muted); overflow-wrap: anywhere; }
.dash-option-row:hover .dash-option-heading, .dash-stale-link:hover { color: var(--accent-2); }
.dash-option-row:focus-visible, .dash-stale-link:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; border-radius: 6px; }

/* ---- Bộ lọc dùng chung (theo mẫu trang Bản đồ): nhãn phía trên, ô cao bằng nhau, chia đều chiều ngang ---- */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; margin-bottom: 16px; }
.filters.card { padding: 14px 16px; }
.filters .ff { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 12px; color: var(--text-secondary); }
/* Ô tích nằm cùng hàng với các ô khác: chừa chỗ nhãn để thẳng đáy. */
.filters .ff > span:empty { display: none; }
.filters .ff > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filters .ff input:not([type=checkbox]), .filters .ff select { width: 100%; min-width: 0; max-width: none; height: 40px; box-sizing: border-box; font-size: 14px; margin: 0; }
.filters .ff.ff-check { flex-direction: row; align-items: center; gap: 8px; height: 40px; align-self: end; font-size: 13px; color: var(--text-primary); }
.filters .ff.ff-check input { width: auto; height: auto; }
.filters .ff.ff-wide { grid-column: span 2; }
.filters .ff:has(input[type=search]) { grid-column: span 2; }
.filters .filters-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; min-height: 40px; }
.filters .filters-actions .btn { height: 40px; }
@media (max-width: 760px) { .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } .filters .ff.ff-wide, .filters .filters-actions { grid-column: 1 / -1; } }
@media (max-width: 760px) {
  .filters .ff:has(input[type=search]) { grid-column: 1 / -1; }
  .filters .ff input:not([type=checkbox]), .filters .ff select { font-size: 16px; }
}
@media (max-width: 330px) { .filters { grid-template-columns: minmax(0, 1fr); } }
.month-select { min-width: 0; }
.page-head h1 .page-count { font-weight: 400; font-size: 16px; }
.filters-summary { margin: -6px 0 12px; font-size: 13px; }

/* Sửa KPI trên màn hình nhỏ: giữ cùng biểu mẫu và sự kiện lưu, đổi mỗi dòng thành một khối nhập. */
@media (max-width: 760px) {
  .tbl.kpi-edit, .tbl.kpi-edit tbody { display: block; width: 100%; min-width: 0; }
  .tbl.kpi-edit thead { display: none; }
  .tbl.kpi-edit tbody { display: grid; gap: 14px; }
  .tbl.kpi-edit tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 12px; border: 1px solid var(--card-border); border-radius: 12px; }
  .tbl.kpi-edit td { display: block; min-width: 0; padding: 0; border: 0; text-align: left; position: relative; }
  .tbl.kpi-edit td[data-label]::before { content: attr(data-label); display: block; color: var(--text-muted); font-size: 12px; margin-bottom: 6px; }
  .tbl.kpi-edit .kpi-order, .tbl.kpi-edit .kpi-ident, .tbl.kpi-edit .kpi-actions, .tbl.kpi-edit .kpi-locked { grid-column: 1 / -1; }
  .tbl.kpi-edit .kpi-ident > .row { display: grid; gap: 8px; }
  .tbl.kpi-edit input, .tbl.kpi-edit select { width: 100% !important; min-width: 0; max-width: 100%; height: 40px; font-size: 16px; }
  .tbl.kpi-edit .kpi-ident input[name=unit] { width: 110px !important; height: 36px !important; font-size: 16px !important; margin-top: 4px; }
  .tbl.kpi-edit td.r input { text-align: left; padding-right: 24px; }
  .tbl.kpi-edit .kpi-percent { position: absolute; right: 8px; bottom: 10px; }
  .tbl.kpi-edit .kpi-actions { display: flex; justify-content: flex-end; gap: 8px; }
}
.empty-hint { font-size: 12px; }

/* ---- Hoạt động hỗ trợ: bảng ma trận showroom x hoạt động ---- */
.act-matrix-wrap { overflow: auto; max-height: calc(100vh - 260px); }
.act-matrix { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: fixed; font-size: 13px; }
.act-showroom-col { width: 220px; }
.act-progress-col { width: 92px; }
.act-matrix th, .act-matrix td { padding: 8px 10px; border-bottom: 1px solid var(--card-border); text-align: center; white-space: nowrap; }
.act-matrix thead { position: sticky; top: 0; z-index: 2; }
.act-matrix thead th, .act-matrix thead td { background: var(--card-solid); color: var(--text-secondary); }
.act-matrix thead th { font-weight: 600; font-size: 12px; vertical-align: middle; white-space: normal; overflow-wrap: anywhere; line-height: 1.4; }
.act-matrix .act-col-names th { height: 64px; padding: 12px 10px 6px; border-bottom: 0; }
.act-matrix thead th a { color: inherit; }
.act-matrix thead .act-col-counts td { padding: 0 10px 10px; font-weight: 400; font-size: 12px; color: var(--text-muted); }
.act-matrix .act-sr { position: sticky; left: 0; z-index: 1; background: var(--card-solid); text-align: left; min-width: 200px; max-width: 260px; white-space: normal; }
.act-matrix thead .act-sr { z-index: 3; }
.act-matrix .act-sr .muted { font-size: 11px; display: block; }
.act-matrix .act-sr .act-sr-manage { margin-left: 6px; padding: 2px 6px; height: auto; font-size: 11px; }
.act-matrix th.hl, .act-matrix td.hl { background: color-mix(in srgb, var(--accent) 16%, var(--card-solid)); }
.act-cell { cursor: default; }
.act-cell.can { cursor: pointer; }
.act-cell.can:hover { outline: 1px solid var(--card-border); outline-offset: -3px; border-radius: 6px; }
.act-cell .act-mark { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-weight: 700; font-size: 13px; }
.act-cell.done .act-mark { background: rgba(46, 160, 67, .18); color: var(--good); }
.act-cell.pending .act-mark { background: rgba(248, 81, 73, .14); color: var(--critical); }
.act-cell.na { color: var(--text-muted); }
.act-cell.dim { opacity: .3; }
.act-cell .act-qty { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.act-matrix .act-progress { font-variant-numeric: tabular-nums; font-weight: 600; }
.act-legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--text-secondary); margin: 0 0 10px; }
.act-legend .act-cell { display: inline-flex; align-items: center; gap: 6px; }
.act-legend .act-mark { width: 20px; height: 20px; font-size: 11px; }
@media (max-width: 760px) { .act-matrix-wrap { max-height: none; } .act-showroom-col { width: 150px; } .act-matrix .act-sr { min-width: 140px; max-width: 160px; } }
