/* Smart PFES demo prototype (KH-003). Design tokens follow the approved "Phương án tính toán" mockup:
   UI/UX Pro Max direction (government + data dashboard, minimal, accessible), PrimeVue Aura look,
   forest-green primary, Be Vietnam Pro, PrimeIcons, light theme only. */
:root {
  color-scheme: light;
  --primary: #15803d; --primary-600: #16a34a; --primary-700: #166534; --primary-50: #f0fdf4; --primary-100: #dcfce7;
  --bg: #f5f7f6; --surface: #ffffff; --surface-2: #f8faf9; --border: #e4e9e6; --border-strong: #cfd8d3;
  --text: #0f1f17; --text-2: #3d4f46; --muted: #66766e;
  --amber: #b45309; --amber-50: #fffbeb; --amber-100: #fef3c7;
  --red: #dc2626; --red-50: #fef2f2; --red-100: #fee2e2;
  --blue: #0369a1; --blue-50: #f0f9ff; --blue-100: #e0f2fe;
  --violet: #6d28d9; --violet-50: #f5f3ff; --violet-100: #ede9fe;
  --teal: #0f766e; --teal-50: #f0fdfa;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 32, 24, .06), 0 1px 3px rgba(16, 32, 24, .04);
  --shadow-lg: 0 10px 30px rgba(16, 32, 24, .12), 0 2px 6px rgba(16, 32, 24, .06);
  --ring: 0 0 0 3px rgba(21, 128, 61, .25);
  /* chart palette (categorical, colour-blind aware order) */
  --c1: #15803d; --c2: #0369a1; --c3: #b45309; --c4: #6d28d9; --c5: #0f766e; --c6: #be123c; --c7: #4d7c0f; --c8: #64748b;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 'Be Vietnam Pro', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
:focus-visible { outline: none; box-shadow: var(--ring); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { margin-left: auto; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.shell > div { min-width: 0; }
.sb { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; cursor: pointer; }
.logo { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #16a34a, #166534); display: grid; place-items: center; color: #fff; font-size: 17px; flex: none; }
.brand b { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand small { color: var(--muted); font-size: 12px; line-height: 1.3; display: block; }
.sb-scroll { overflow-y: auto; flex: 1; padding-bottom: 12px; }
.sb-prod { padding: 12px 18px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: #8a978f; }
.nav { padding: 0 10px; }
.nav .grp { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; margin: 1px 0; border-radius: 8px; border: 0; background: none; color: var(--text-2); font-weight: 600; cursor: pointer; text-align: left; white-space: nowrap; }
.nav .grp i.ic { width: 18px; text-align: center; color: var(--muted); font-size: 15px; }
.nav .grp .chev { margin-left: auto; font-size: 10px; color: var(--muted); transition: transform .2s; }
.nav .grp.open .chev { transform: rotate(90deg); }
.nav .grp:hover { background: var(--surface-2); }
.nav .grp.cur { color: var(--primary-700); }
.nav .grp.cur i.ic { color: var(--primary); }
.nav .items { display: none; padding: 2px 0 6px 28px; }
.nav .grp.open + .items { display: block; }
.nav .items a { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 7px; color: var(--text-2); text-decoration: none; font-size: 13.5px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav .items a:hover { background: var(--surface-2); }
.nav .items a.on { background: var(--primary-50); color: var(--primary-700); font-weight: 600; }
.nav .items a .pa { margin-left: auto; font-size: 10px; font-weight: 700; color: #8a978f; }
.nav .single { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 1px 0; border-radius: 8px; color: var(--text-2); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.nav .single i { width: 18px; text-align: center; color: var(--muted); font-size: 15px; }
.nav .single:hover { background: var(--surface-2); }
.nav .single.on { background: var(--primary-50); color: var(--primary-700); }
.nav .single.on i { color: var(--primary); }
.sb-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-100); color: var(--primary-700); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.sb-foot small { display: block; color: var(--muted); font-size: 12px; }

.topbar { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 28px; background: rgba(255,255,255,.88); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
.crumb { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; min-width: 0; }
.crumb i { font-size: 10px; }
.crumb b { color: var(--text); font-weight: 600; white-space: nowrap; }
.crumb a { color: var(--muted); text-decoration: none; cursor: pointer; white-space: nowrap; }
.crumb a:hover { color: var(--primary); }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.select { position: relative; display: inline-flex; align-items: center; }
.select i.lead { position: absolute; left: 10px; color: var(--muted); font-size: 13px; pointer-events: none; }
.select select { appearance: none; height: 36px; padding: 0 32px 0 32px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-weight: 500; cursor: pointer; }
.select.plain select { padding-left: 12px; }
.select::after { content: "\e902"; font-family: primeicons; position: absolute; right: 10px; font-size: 11px; color: var(--muted); pointer-events: none; }
.icon-btn { position: relative; width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid transparent; background: none; display: grid; place-items: center; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .badge { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }

.page { padding: 24px 28px 96px; max-width: 1520px; }
#view.enter { animation: fade .2s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- page header ---------- */
.ph { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.ph h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ph p { margin: 4px 0 0; color: var(--muted); max-width: 900px; }
.ph .acts { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; margin-bottom: 8px; border: 0; background: none; padding: 0; }
.back:hover { color: var(--primary); }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; text-decoration: none; color: var(--text); }
.btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn i { font-size: 13px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-700); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { border-color: transparent; background: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.segc { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #eef2f0; padding: 3px; border-radius: 9px; }
.segc button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.segc button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.inp { display: flex; align-items: center; height: 38px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: 0 10px; gap: 8px; }
.inp:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.inp input { border: 0; outline: 0; flex: 1; min-width: 0; background: none; }
.inp i { color: var(--muted); }
.inp span { color: var(--muted); font-size: 12px; }
.fld { display: grid; gap: 6px; }
.fld > label, .fld > .lb { font-size: 13px; font-weight: 600; }
.fld .help { font-size: 12px; color: var(--muted); line-height: 1.45; }
textarea.ta, input.tx, select.tx { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; background: var(--surface); }
input.tx, select.tx { height: 38px; padding: 0 10px; }
textarea.ta:focus, input.tx:focus, select.tx:focus { outline: 0; border-color: var(--primary); box-shadow: var(--ring); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .ch { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card .ch b, .card .ch .t { font-size: 14.5px; font-weight: 600; }
.card .ch .sub { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.card .ch .sp { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card .cb { padding: 14px 16px; }
.stack { display: grid; gap: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }

.chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip i { font-size: 11px; }
.chip.neutral, .chip.draft { background: #eef2f0; color: var(--text-2); }
.chip.ok, .chip.locked { background: var(--primary-100); color: var(--primary-700); }
.chip.warn { background: var(--amber-100); color: #92400e; }
.chip.bad { background: var(--red-100); color: #991b1b; }
.chip.info { background: var(--blue-100); color: #075985; }
.chip.violet { background: var(--violet-100); color: var(--violet); }
.chip.pa { background: #fff; border: 1px solid var(--border); color: var(--text-2); font-size: 11.5px; }
.chip.pa.pa1 { border-color: #bbf7d0; color: var(--primary-700); background: var(--primary-50); }
.chip.pa.pa2 { border-color: #bae6fd; color: #075985; background: var(--blue-50); }
.chip.pa.vc { border-color: #ddd6fe; color: var(--violet); background: var(--violet-50); }
.code { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: #f1f4f2; color: var(--text-2); margin: 1px 2px 1px 0; white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

.callout { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; line-height: 1.55; }
.callout > i { font-size: 16px; margin-top: 2px; }
.callout.info { background: var(--blue-50); color: #0c4a6e; border: 1px solid var(--blue-100); } .callout.info > i { color: var(--blue); }
.callout.ok { background: var(--primary-50); color: #14532d; border: 1px solid var(--primary-100); } .callout.ok > i { color: var(--primary); }
.callout.warn { background: var(--amber-50); color: #78350f; border: 1px solid var(--amber-100); } .callout.warn > i { color: var(--amber); }
.callout.bad { background: var(--red-50); color: #7f1d1d; border: 1px solid var(--red-100); } .callout.bad > i { color: var(--red); }
.callout .act { margin-left: auto; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpis.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis.k5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi { padding: 16px 18px; display: grid; gap: 6px; align-content: start; }
.kpi .top { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-size: 14px; flex: none; }
.ic.g { background: var(--primary-50); color: var(--primary); } .ic.b { background: var(--blue-50); color: var(--blue); }
.ic.a { background: var(--amber-50); color: var(--amber); } .ic.v { background: var(--violet-50); color: var(--violet); }
.ic.r { background: var(--red-50); color: var(--red); } .ic.t { background: var(--teal-50); color: var(--teal); }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .v small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.kpi .s { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* tabs */
.tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { position: relative; border: 0; background: none; padding: 14px 10px 12px; color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 7px; }
.tabs button .n { font-size: 11px; background: #eef2f0; color: var(--muted); padding: 1px 7px; border-radius: 999px; }
.tabs button.on { color: var(--text); }
.tabs button.on::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--primary); }

/* tables */
.tw { overflow: auto; max-height: 560px; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.t th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; padding: 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t td { padding: 9px 10px; border-bottom: 1px solid #eef2f0; vertical-align: middle; }
table.t tbody tr:hover td { background: #fafcfb; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.sel td { background: var(--primary-50); }
table.t tfoot td { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--border); }
.mini-bar { height: 6px; border-radius: 3px; background: #eef2f0; position: relative; min-width: 80px; overflow: hidden; }
.mini-bar span { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 3px; background: var(--primary-600); transition: width .9s cubic-bezier(.22, 1, .36, 1); }
.delta { font-weight: 600; font-size: 12.5px; }
.delta.up { color: var(--primary); } .delta.down { color: var(--red); } .delta.zero { color: var(--muted); font-weight: 500; }
.progress { height: 8px; border-radius: 4px; background: #eef2f0; overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 4px; background: var(--primary-600); transition: width 1s cubic-bezier(.22, 1, .36, 1); }

/* list items */
.list { display: grid; }
.li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid #eef2f0; }
.li:last-child { border-bottom: 0; }
.li .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.li .t { font-weight: 600; }
.li .d { color: var(--muted); font-size: 12.5px; }
.li .r { margin-left: auto; text-align: right; flex: none; }
.li.click { cursor: pointer; } .li.click:hover { background: var(--surface-2); }

/* charts */
.chart { width: 100%; display: block; }
.chart text { font-family: 'Be Vietnam Pro', system-ui, sans-serif; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* map */
.mapc { position: relative; overflow: hidden; }
.mapc .map { position: absolute; inset: 0; }
.map-legend { position: absolute; left: 12px; bottom: 12px; z-index: 5; background: rgba(255,255,255,.96); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 10px 12px; font-size: 12px; min-width: 180px; }
.map-legend b { display: block; margin-bottom: 6px; font-size: 12.5px; }
.map-legend div { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.map-legend i { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.map-tools { position: absolute; right: 12px; top: 12px; z-index: 5; display: flex; gap: 6px; }
.map-tools .segc { background: rgba(255,255,255,.95); box-shadow: var(--shadow); }
.map-drawer { position: absolute; right: 12px; top: 56px; z-index: 6; width: 320px; max-height: calc(100% - 70px); overflow: auto; background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); display: none; }
.map-drawer .dh { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; }
.map-drawer .dh b { font-size: 14px; }
.map-drawer .dh .icon-btn { margin-left: auto; width: 28px; height: 28px; }
.map-drawer .db { padding: 8px 14px 12px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 13px; border-bottom: 1px dashed #eef2f0; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { text-align: right; }
.map-badge { position: absolute; left: 50%; transform: translateX(-50%); top: 12px; z-index: 5; }

/* phone frame */
.phone-stage { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 28px; align-items: start; }
.phone { width: 360px; height: 740px; border-radius: 44px; background: #0f1f17; padding: 12px; box-shadow: var(--shadow-lg); position: relative; margin: 0 auto; }
.phone::before { content: ""; position: absolute; top: 18px; left: 50%; transform: translateX(-50%); width: 92px; height: 24px; border-radius: 12px; background: #000; z-index: 3; }
.phone .screen { width: 100%; height: 100%; border-radius: 34px; background: var(--bg); overflow: hidden; display: flex; flex-direction: column; position: relative; }
.phone .status { height: 44px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 26px; font-size: 12px; font-weight: 600; background: var(--surface); }
.phone .app-h { flex: none; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.phone .app-h b { font-size: 15px; }
.phone .app-b { flex: 1; overflow-y: auto; padding: 12px; display: grid; gap: 10px; align-content: start; }
.phone .app-nav { flex: none; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px 14px; }
.phone .app-nav button { border: 0; background: none; display: grid; justify-items: center; gap: 2px; font-size: 10.5px; color: var(--muted); cursor: pointer; padding: 4px 0; }
.phone .app-nav button i { font-size: 17px; }
.phone .app-nav button.on { color: var(--primary); font-weight: 600; }
.phone .card { border-radius: 14px; }
.phone .btn { height: 44px; }

/* modal, toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 31, 23, .4); backdrop-filter: blur(2px); display: none; align-items: center; justify-content: center; z-index: 70; padding: 16px; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); }
.modal.wide { width: min(860px, 100%); }
.modal .mh { display: flex; gap: 12px; align-items: flex-start; padding: 20px 22px 8px; }
.modal .mi { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 17px; flex: none; }
.modal h3 { margin: 2px 0 4px; font-size: 17px; }
.modal .mb { padding: 6px 22px 18px; color: var(--text-2); font-size: 13.5px; display: grid; gap: 12px; }
.modal .mf { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; background: var(--surface-2); border-top: 1px solid var(--border); }
.toast { position: fixed; top: 72px; right: 24px; z-index: 80; display: none; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--primary); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; max-width: 420px; }
.toast i { color: var(--primary); }

/* demo bar */
.proto { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 4px; background: #0f1f17; color: #fff; padding: 6px; border-radius: 999px; box-shadow: var(--shadow-lg); font-size: 12.5px; max-width: calc(100vw - 16px); }
.proto .lbl { padding: 0 10px 0 12px; opacity: .7; white-space: nowrap; }
.proto button { border: 0; background: none; color: rgba(255,255,255,.8); padding: 7px 12px; border-radius: 999px; cursor: pointer; font-weight: 600; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.proto button:hover { color: #fff; }
.proto button.on { background: #fff; color: #0f1f17; }
.proto .sep { width: 1px; height: 18px; background: rgba(255,255,255,.2); margin: 0 4px; }
.proto-menu { position: fixed; left: 50%; bottom: 66px; transform: translateX(-50%); z-index: 61; width: min(760px, 94vw); max-height: 70vh; overflow: auto; background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); padding: 14px; display: none; }
.proto-menu h4 { margin: 6px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.proto-menu .pm { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px; margin-bottom: 8px; }
.proto-menu a { display: flex; gap: 8px; align-items: center; padding: 7px 10px; border-radius: 8px; color: var(--text); text-decoration: none; cursor: pointer; font-size: 13px; }
.proto-menu a:hover { background: var(--surface-2); }
.proto-menu a .n { color: var(--muted); font-size: 11px; width: 20px; }

/* bare layouts: login, public */
.bare { min-height: 100vh; }

/* animations (demo) */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes glow { 0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .5); } 100% { box-shadow: 0 0 0 16px rgba(22, 163, 74, 0); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.anim { animation: rise .55s cubic-bezier(.22, 1, .36, 1) both; }
.glow { animation: glow 1.4s ease-out; }
body.no-anim .anim, body.no-anim .glow, body.no-anim #view.enter { animation: none; }
body.no-anim .mini-bar span, body.no-anim .progress span { transition: none; }

@media (max-width: 1200px) {
  .grid-main, .grid-side, .grid3 { grid-template-columns: minmax(0, 1fr); }
  .kpis, .kpis.k5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .phone-stage { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); } .sb { display: none; }
  .page { padding: 16px 16px 96px; } .topbar { padding: 0 16px; } .crumb { display: none; }
  .grid2, .kpis, .kpis.k3, .kpis.k5 { grid-template-columns: minmax(0, 1fr); }
  .proto .lbl { display: none; } .proto button { padding: 7px 8px; }
  .tb-right .select:nth-child(2) { display: none; }
}

/* ---------- collapsible menu (KH-004 §1) ---------- */
.shell { transition: grid-template-columns .2s ease; }
.shell.mini { grid-template-columns: 68px minmax(0, 1fr); }
.shell.mini .brand { justify-content: center; padding: 14px 0 10px; }
.shell.mini .brand > div:last-child, .shell.mini .lbl, .shell.mini .chev, .shell.mini .sb-foot > div:last-child { display: none; }
.shell.mini .sb-prod { font-size: 0; padding: 0; height: 1px; background: var(--border); margin: 10px 14px; }
.shell.mini .nav { padding: 0 8px; }
.shell.mini .nav .grp, .shell.mini .nav .single { justify-content: center; padding: 10px 0; gap: 0; }
.shell.mini .nav .grp i.ic, .shell.mini .nav .single i { font-size: 17px; }
.shell.mini .nav .items { display: none !important; }
.shell.mini .sb-foot { justify-content: center; padding: 12px 0; }
.flyout { position: fixed; z-index: 70; display: none; min-width: 230px; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; }
.flyout b { display: block; padding: 6px 10px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.flyout a { display: block; padding: 7px 10px; border-radius: 7px; color: var(--text-2); font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.flyout a:hover { background: var(--surface-2); }
.flyout a.on { background: var(--primary-50); color: var(--primary-700); font-weight: 600; }
#sb-toggle { flex: none; margin-left: -8px; }
@media (max-width: 860px) {
  .shell.m-open .sb { display: flex; position: fixed; left: 0; top: 0; width: 264px; z-index: 55; box-shadow: var(--shadow-lg); }
}

/* ---------- lot search in the top bar (map screens) ---------- */
.tb-search { position: relative; flex: 1; max-width: 480px; min-width: 200px; }
.tb-search > i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; }
.tb-search input { width: 100%; height: 36px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 12px 0 32px; background: var(--surface-2); font: inherit; color: var(--text); }
.tb-search input:focus { background: #fff; border-color: var(--primary); outline: none; box-shadow: var(--ring); }
.tb-sr { position: absolute; left: 0; right: 0; top: 42px; z-index: 40; display: none; max-height: 380px; overflow: auto; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 4px; }
.tb-sr a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13.5px; }
.tb-sr a.on, .tb-sr a:hover { background: var(--primary-50); }
.tb-sr a i { color: var(--primary); }
.tb-sr small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.topbar .crumb { flex: 0 1 auto; }

/* ---------- map-first workspace (KH-004 §2) ---------- */
.page.mapmode { padding: 0; max-width: none; height: calc(100vh - 60px); overflow: hidden; }
.mw { --lw: 300px; --dw: 420px; display: grid; height: 100%; background: var(--surface);
  grid-template-columns: 48px var(--lwc, var(--lw)) minmax(0, 1fr) var(--dwc, var(--dw)); grid-template-rows: minmax(0, 1fr) 32px;
  transition: grid-template-columns .2s ease; }
.mw.resizing { transition: none; user-select: none; }
.mw.no-left { --lwc: 0px; }
.mw.dock-min { --dwc: 44px; }
.mw-rail { display: flex; flex-direction: column; gap: 4px; padding: 8px 5px; background: var(--surface-2); border-right: 1px solid var(--border); overflow: hidden; }
.mw-rail button { position: relative; writing-mode: vertical-rl; transform: rotate(180deg); display: flex; align-items: center; gap: 8px; padding: 12px 0; border: 0; border-radius: 8px; background: none; color: var(--text-2); font-weight: 600; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.mw-rail button i { writing-mode: horizontal-tb; transform: rotate(180deg); font-size: 14px; color: var(--muted); }
.mw-rail button:hover { background: #eef2f0; }
.mw-rail button.on { background: var(--primary-50); color: var(--primary-700); }
.mw-rail button.on i { color: var(--primary); }
.mw-rail em { writing-mode: horizontal-tb; transform: rotate(180deg); font-style: normal; font-size: 10px; font-weight: 700; background: var(--red); color: #fff; border-radius: 8px; padding: 1px 5px; }
.mw-left { position: relative; min-width: 0; overflow: hidden; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--surface); }
.mw.no-left .mw-left { border-right: 0; }
.mw-lh { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 6px 0 14px; border-bottom: 1px solid var(--border); flex: none; }
.mw-lh b { font-size: 14px; white-space: nowrap; }
.mw-lh .icon-btn { margin-left: auto; width: 30px; height: 30px; }
.mw-lb { display: none; flex: 1; overflow-y: auto; padding: 12px 14px 20px; min-width: 260px; }
.mw-lb.on { display: block; }
.mw-sec { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.mw-pc > .mw-sec:first-child { margin-top: 2px; }
.mw-bases { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mw-bases button { padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: #fff; box-shadow: var(--shadow); cursor: pointer; text-align: left; }
.mw-bases img { display: block; width: 100%; height: 58px; object-fit: cover; background: #e5e7eb; }
.mw-bases span { display: block; padding: 5px 8px; font-size: 12.5px; font-weight: 600; }
.mw-bases button.on { border-color: var(--primary); }
.mw-theme { display: flex; align-items: center; gap: 10px; width: 100%; margin-bottom: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; background: #fff; cursor: pointer; text-align: left; font-weight: 600; font-size: 13px; transition: border-color .15s, background .15s; }
.mw-theme:hover { border-color: var(--border-strong); }
.mw-theme.on { border-color: var(--primary); background: var(--primary-50); color: var(--primary-700); }
.mw-theme .sw { width: 30px; height: 12px; border-radius: 4px; flex: none; }
.mw-theme small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.mw-lyr { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; cursor: pointer; }
.mw-lyr small { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; }
.mw-lyr input { accent-color: var(--primary); width: 16px; height: 16px; }
.mw-lyr .sw { width: 16px; height: 16px; border-radius: 4px; flex: none; margin-left: auto; }
.mw-range { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); padding: 8px 0; }
.mw-range input { flex: 1; accent-color: var(--primary); }
.mw-lb .map-legend { position: static; box-shadow: none; padding: 0; min-width: 0; background: none; font-size: 13px; }
.mw[data-tab="chu-giai"] .mw-map > .map-legend { display: none; }
.mw-grip { position: absolute; top: 0; bottom: 0; width: 7px; z-index: 8; cursor: col-resize; }
.mw-left .mw-grip { right: -3px; }
.mw-dock .mw-grip { left: -3px; }
.mw-grip:hover, .mw-grip.drag { background: rgba(21, 128, 61, .28); }
.mw.no-left .mw-left .mw-grip, .mw.dock-min .mw-dock .mw-grip { display: none; }
.mw-map { position: relative; min-width: 0; }
.mw-map .ol-zoom { top: 10px; left: 10px; }
.mw-tools { position: absolute; right: 10px; top: 10px; z-index: 6; display: flex; flex-direction: column; gap: 8px; }
.mw-tools .g { display: flex; flex-direction: column; overflow: hidden; background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg); }
.mw-tools button { width: 36px; height: 36px; border: 0; background: none; display: grid; place-items: center; color: var(--text-2); cursor: pointer; }
.mw-tools button + button { border-top: 1px solid var(--border); }
.mw-tools button:hover { background: var(--surface-2); }
.mw-tools button.on { background: var(--primary); color: #fff; }
.mw-meas { background: rgba(15, 31, 23, .88); color: #fff; padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.mw-map .map-legend { bottom: 14px; }
.mw-dock { position: relative; min-width: 0; display: flex; flex-direction: column; border-left: 1px solid var(--border); background: #fff; overflow: hidden; }
.mw-dmin { display: none; }
.mw.dock-min .mw-dock > :not(.mw-dmin) { display: none; }
.mw.dock-min .mw-dmin { display: flex; align-items: center; gap: 8px; writing-mode: vertical-rl; border: 0; background: none; padding: 14px 0; width: 100%; color: var(--text-2); font-weight: 600; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.mw.dock-min .mw-dmin:hover { background: var(--surface-2); color: var(--primary-700); }
.mw-dmin i { writing-mode: horizontal-tb; }
.mw-dh { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 8px 6px 8px 16px; border-bottom: 1px solid var(--border); flex: none; }
.mw-dh b.t { display: block; font-size: 15px; }
.mw-dh .sub { display: block; color: var(--muted); font-size: 12.5px; }
.mw-dh .icon-btn { margin-left: auto; width: 30px; height: 30px; flex: none; }
.mw-dtabs { flex: none; }
.mw-dtabs .tabs { padding: 0 8px; }
.mw-dtabs .tabs button { padding: 11px 8px 10px; font-size: 13px; }
.mw-db { flex: 1; overflow-y: auto; padding: 12px 16px 24px; }
.mw-empty { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 40px 16px; color: var(--muted); font-size: 13px; }
.mw-empty i { font-size: 26px; color: var(--border-strong); }
.mw-empty b { color: var(--text-2); font-size: 14px; }
.mw-money { display: flex; justify-content: space-between; align-items: baseline; margin: 12px 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.mw-money span { color: var(--muted); font-size: 13px; }
.mw-money b { font-size: 18px; font-variant-numeric: tabular-nums; }
.mw-money small { color: var(--muted); font-weight: 600; font-size: 12px; }
.mw-sum { margin-bottom: 12px; }
.mw-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.mw-tbl th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.mw-tbl td { padding: 6px 4px; border-bottom: 1px solid var(--border); }
.mw-tl .it { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 10px; padding-bottom: 14px; position: relative; font-size: 13px; }
.mw-tl .it::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 2px; background: var(--border); }
.mw-tl .it:last-child::before { display: none; }
.mw-tl .it > i { width: 12px; height: 12px; border-radius: 50%; margin-top: 3px; background: var(--primary-600); box-shadow: 0 0 0 3px var(--primary-100); }
.mw-tl b { display: block; }
.mw-tl span { color: var(--muted); }
.mw-status { grid-column: 1 / -1; display: flex; align-items: center; gap: 18px; padding: 0 14px; border-top: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; }
.mw-status b { color: var(--text-2); font-weight: 600; }
.mw-status i { font-size: 11px; }
.mw-status .ol-scale-line { position: static; background: none; padding: 0; border-radius: 0; }
.mw-status .ol-scale-line-inner { border-color: var(--text-2); color: var(--text-2); font-size: 10.5px; margin: 0; }
@media (max-width: 860px) {
  .mw { grid-template-columns: 40px var(--lwc, var(--lw)) minmax(0, 1fr) var(--dwc, var(--dw)); }
  .mw:not(.no-left) { --dwc: 0px; }
  .mw-status [data-st="xy"], .mw-status [data-st="zoom"] { display: none; }
  .tb-search { min-width: 0; }
}
.mw-sec .chip { text-transform: none; letter-spacing: 0; height: 20px; font-size: 11px; }
