/* ==========================================================================
   Design system – admin dashboard (mobile-first, sáng / tối)
   ========================================================================== */
:root {
  /* Light tone: warm ivory / linen paper with near-black ink (never pure white) */
  --bg: #f1eee8;
  --surface: #fcfbf8;
  --surface-2: #f7f5f0;
  --surface-3: #ece8e0;
  --ink: #1b1a18;
  --text-2: #3b3833;
  --muted: #77726a;
  --line: #e5e0d6;
  --line-2: #d6d0c4;
  --primary: #1b1a18;
  --primary-600: #000000;
  --primary-soft: #e9e5dc;
  --on-primary: #fcfbf8;
  --accent: #b52229;
  /* Brand (Cửu Vân Long logo): lacquer red + ink + ivory */
  --brand: #b52229;
  --brand-soft: #f6e2e0;
  --brand-on-dark: #e5524f;
  --logo-on-light: block;
  --logo-on-dark: none;
  --ok: #157f3c;
  --ok-soft: #e1f2e3;
  --warn: #a35a06;
  --warn-soft: #f8ead0;
  --bad: #c42b2b;
  --bad-soft: #f9e1dd;
  --info: #2a62c9;
  --info-soft: #e2eaf7;
  --off: #77726a;
  --off-soft: #ece8e0;
  --c-TSCD: #2a78d6;
  --c-CCDC_LON: #eb6834;
  --c-CCDC_TB: #1baf7a;
  --c-CCDC_TH: #eda100;
  --c-NGOAI: #e87ba4;
  --sidebar: #161513;
  --sidebar-2: #22201d;
  --sidebar-ink: #d9d5cc;
  --sidebar-muted: #8c867b;
  --sidebar-active: #2c2a26;
  --sidebar-accent: #f1eee8;
  --backdrop: rgba(22, 21, 19, 0.55);
  --shadow-sm: 0 1px 2px rgba(27, 26, 24, 0.05);
  --shadow: 0 1px 3px rgba(27, 26, 24, 0.06), 0 1px 2px rgba(27, 26, 24, 0.04);
  --shadow-lg: 0 20px 40px -12px rgba(27, 26, 24, 0.3);
  color-scheme: light;
  /* Asset class colours = chart palette (validated for colour-vision deficiency) */
  --f-body: 'Be Vietnam Pro', Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --r-lg: 14px;
  --r: 10px;
  --r-sm: 8px;
  --topbar-h: 60px;
  --tabbar-h: 62px;
  --actionbar-h: 68px;
  --sidebar-w: 264px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  /* Area hidden by the browser's bottom toolbar (iOS 26 floating tab bar, Chrome Android); set by js/viewport.js */
  --vv-bottom: 0px;
  /* Bottom padding of fixed bars: the home-indicator inset, or a small gap when there is none */
  --bar-pad-b: max(var(--safe-b), 4px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    /* Dark tone: neutral black with warm off-white ink */
    --bg: #0e0e0d;
    --surface: #171716;
    --surface-2: #131312;
    --surface-3: #222220;
    --ink: #f1eee8;
    --text-2: #d2cec6;
    --muted: #9b968c;
    --line: #272624;
    --line-2: #363431;
    --primary: #f1eee8;
    --primary-600: #ffffff;
    --primary-soft: #2a2926;
    --on-primary: #161513;
    --accent: #e5524f;
    --brand: #e5524f;
    --brand-soft: #3b1716;
    --logo-on-light: none;
    --logo-on-dark: block;
    --ok: #4fc97a;
    --ok-soft: #15301f;
    --warn: #f0b13c;
    --warn-soft: #362a10;
    --bad: #f27a6e;
    --bad-soft: #3a1714;
    --info: #6aa2f0;
    --info-soft: #172640;
    --off: #9b968c;
    --off-soft: #222220;
    --c-TSCD: #3987e5;
    --c-CCDC_LON: #d95926;
    --c-CCDC_TB: #199e70;
    --c-CCDC_TH: #c98500;
    --c-NGOAI: #d55181;
    --sidebar: #0a0a09;
    --sidebar-2: #181816;
    --sidebar-ink: #d2cec6;
    --sidebar-muted: #7f7a71;
    --sidebar-active: #22221f;
    --sidebar-accent: #f1eee8;
    --backdrop: rgba(0, 0, 0, 0.65);
    --shadow-sm: none;
    --shadow: 0 0 0 1px rgba(255, 255, 255, 0.02);
    --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.75);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  /* Dark tone: neutral black with warm off-white ink */
  --bg: #0e0e0d;
  --surface: #171716;
  --surface-2: #131312;
  --surface-3: #222220;
  --ink: #f1eee8;
  --text-2: #d2cec6;
  --muted: #9b968c;
  --line: #272624;
  --line-2: #363431;
  --primary: #f1eee8;
  --primary-600: #ffffff;
  --primary-soft: #2a2926;
  --on-primary: #161513;
  --accent: #e5524f;
  --brand: #e5524f;
  --brand-soft: #3b1716;
  --logo-on-light: none;
  --logo-on-dark: block;
  --ok: #4fc97a;
  --ok-soft: #15301f;
  --warn: #f0b13c;
  --warn-soft: #362a10;
  --bad: #f27a6e;
  --bad-soft: #3a1714;
  --info: #6aa2f0;
  --info-soft: #172640;
  --off: #9b968c;
  --off-soft: #222220;
  --c-TSCD: #3987e5;
  --c-CCDC_LON: #d95926;
  --c-CCDC_TB: #199e70;
  --c-CCDC_TH: #c98500;
  --c-NGOAI: #d55181;
  --sidebar: #0a0a09;
  --sidebar-2: #181816;
  --sidebar-ink: #d2cec6;
  --sidebar-muted: #7f7a71;
  --sidebar-active: #22221f;
  --sidebar-accent: #f1eee8;
  --backdrop: rgba(0, 0, 0, 0.65);
  --shadow-sm: none;
  --shadow: 0 0 0 1px rgba(255, 255, 255, 0.02);
  --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.75);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  min-height: 100%;
}
body {
  font-family: var(--f-body);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--primary);
  text-decoration: none;
}
h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
}
p {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
.boot {
  display: grid;
  place-items: center;
  height: 100vh;
  height: 100dvh;
}
.boot-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary);
  animation: pulse 1s infinite alternate;
}
@keyframes pulse {
  to {
    opacity: 0.4;
    transform: scale(0.92);
  }
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}
.xs {
  font-size: 12px;
}
.mono {
  font-family: var(--f-mono);
  font-size: 0.9em;
  letter-spacing: -0.01em;
}
.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.right {
  text-align: right;
}
.center {
  text-align: center;
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.wrap {
  flex-wrap: wrap;
}
.grow {
  flex: 1;
  min-width: 0;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Multi-line truncation: unlike .ellipsis the text can wrap, so table columns can still shrink */
.clamp-1,
.clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: break-word;
}
.clamp-1 {
  -webkit-line-clamp: 1;
  line-clamp: 1;
}
.nowrap {
  white-space: nowrap;
}
.eyebrow {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hidden {
  display: none !important;
}
@media (max-width: 1023px) {
  .only-desktop {
    display: none !important;
  }
}
@media (min-width: 1024px) {
  .only-mobile {
    display: none !important;
  }
}

/* ========== App shell ========== */
.app {
  min-height: 100vh;
  min-height: 100dvh;
}
.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + var(--bar-pad-b) + var(--vv-bottom));
}
body.with-actionbar .app-main {
  padding-bottom: calc(var(--tabbar-h) + var(--actionbar-h) + var(--bar-pad-b) + var(--vv-bottom));
}
body.no-tabbar .app-main {
  padding-bottom: calc(var(--bar-pad-b) + var(--vv-bottom));
}
body.no-tabbar.with-actionbar .app-main {
  padding-bottom: calc(var(--actionbar-h) + var(--bar-pad-b) + var(--vv-bottom));
}
/* Virtual keyboard open (js/viewport.js): bottom bars would ride above the keyboard and cover the field */
html.kb-open .tabbar,
html.kb-open .actionbar {
  display: none !important;
}
html.kb-open .app-main,
html.kb-open body.with-actionbar .app-main,
html.kb-open body.no-tabbar .app-main {
  padding-bottom: 0;
}

/* Sidebar (desktop: fixed left column; mobile: drawer) */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  z-index: 70;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  overflow-y: auto;
  padding-top: var(--safe-t);
}
.sidebar.open {
  transform: none;
  box-shadow: var(--shadow-lg);
}
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: var(--backdrop);
  animation: fade 0.15s;
}
.sb-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px 18px 14px;
  text-decoration: none;
}
.sb-logo {
  display: block;
  height: 58px;
  width: auto;
  max-width: 100%;
}
.sb-app {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  padding-left: 2px;
}
/* Logo variants: original on light surfaces, ivory lettering on dark ones */
.brand-img {
  display: block;
  height: auto;
  max-width: 100%;
}
.brand-img.on-light {
  display: var(--logo-on-light);
}
.brand-img.on-dark {
  display: var(--logo-on-dark);
}
.sb-site {
  margin: 0 14px 6px;
  padding: 10px 12px;
  border-radius: var(--r);
  background: var(--sidebar-2);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.sb-site .icon {
  color: var(--sidebar-muted);
  width: 18px;
  height: 18px;
}
.sb-site b {
  color: #fff;
  font-weight: 600;
  display: block;
}
.sb-site small {
  color: var(--sidebar-muted);
  font-size: 11.5px;
}
.sb-nav {
  padding: 6px 12px 16px;
  flex: 1;
}
.sb-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--sidebar-ink);
  font-weight: 500;
  margin-bottom: 2px;
  position: relative;
}
.sb-nav a .icon {
  width: 19px;
  height: 19px;
  color: var(--sidebar-muted);
}
.sb-nav a:hover {
  background: var(--sidebar-2);
  color: #fff;
}
.sb-nav a.active {
  background: var(--sidebar-active);
  color: #fff;
}
.sb-nav a.active .icon {
  color: var(--brand-on-dark);
}
.sb-nav a.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand-on-dark);
}
.sb-nav .badge-n {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 99px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
/* Collapsible menu groups (menu → submenu) */
.sb-group {
  margin-bottom: 2px;
}
.sb-group-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--sidebar-ink);
  font: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.sb-group-head .icon {
  width: 19px;
  height: 19px;
  color: var(--sidebar-muted);
}
.sb-group-head:hover {
  background: var(--sidebar-2);
  color: #fff;
}
.sb-group.current > .sb-group-head {
  color: #fff;
}
.sb-group.current > .sb-group-head .icon {
  color: var(--brand-on-dark);
}
.sb-group-head .sb-caret {
  margin-left: auto;
  width: 15px;
  height: 15px;
  transition: transform 0.18s ease;
}
.sb-group.open > .sb-group-head .sb-caret {
  transform: rotate(90deg);
}
.sb-sub {
  margin: 2px 0 6px 19px;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.09);
}
.sb-nav .sb-sub a {
  padding: 7px 10px;
  font-size: 13.5px;
  font-weight: 450;
  color: var(--sidebar-muted);
}
.sb-nav .sb-sub a:hover {
  color: #fff;
}
.sb-nav .sb-sub a.active {
  color: #fff;
  font-weight: 600;
}
.sb-nav .sb-sub a.active::before {
  left: -13px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
}
/* Sidebar: find a screen by name */
.sb-find {
  position: relative;
  margin: 2px 14px 6px;
  display: flex;
  align-items: center;
}
.sb-find > .icon {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--sidebar-muted);
  pointer-events: none;
}
.sb-find input {
  width: 100%;
  height: 36px;
  padding: 0 32px 0 34px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--r-sm);
  background: var(--sidebar-2);
  color: #fff;
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.sb-find input::placeholder {
  color: var(--sidebar-muted);
}
.sb-find input:focus {
  border-color: var(--brand-on-dark);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-on-dark) 25%, transparent);
}
.sb-find-x {
  position: absolute;
  right: 4px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--sidebar-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.sb-find-x:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}
.sb-find-x .icon {
  width: 14px;
  height: 14px;
}
.sb-hit {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.sb-hit small {
  color: var(--sidebar-muted);
  font-size: 11.5px;
  font-weight: 400;
}
.sb-empty {
  padding: 10px;
  color: var(--sidebar-muted);
  font-size: 13px;
}
/* Area sub-heading inside a menu group (e.g. Tổ chức / Tài sản & CCDC / Kế toán) */
.sb-subsec {
  margin: 10px 0 3px;
  padding-left: 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  opacity: 0.85;
}
.sb-foot {
  padding: 12px 14px calc(14px + var(--safe-b));
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.sb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--r);
  color: var(--sidebar-ink);
}
.sb-user:hover {
  background: var(--sidebar-2);
}
.sb-user b {
  display: block;
  color: #fff;
  font-size: 13.5px;
}
.sb-user small {
  color: var(--sidebar-muted);
  font-size: 12px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) 12px 0;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tb-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--r);
  border: 0;
  background: transparent;
  color: var(--text-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}
.tb-btn:hover {
  background: var(--surface-3);
  color: var(--ink);
}
.tb-btn .dot {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 99px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid var(--surface);
}
.tb-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
/* Long screen names ("Phiếu & phê duyệt", "Danh mục tên chuẩn & CCDC") wrap to a second line instead of being cut */
.tb-title b {
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.22;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: break-word;
}
.tb-title small {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-crumbs {
  display: none;
}
.tb-search {
  display: none;
}
.tb-user {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 99px;
  position: relative;
}
.tb-user .who {
  display: none;
  text-align: left;
}
.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 80;
  animation: fade 0.12s;
}
.dropdown .dd-head {
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.dropdown .dd-head b {
  display: block;
}
.dropdown .dd-head small {
  color: var(--muted);
}
.dropdown a,
.dropdown button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--ink);
  border: 0;
  background: none;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
}
.dropdown a:hover,
.dropdown button:hover {
  background: var(--surface-3);
}
.dropdown .icon {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

/* Page header */
.page-header {
  padding: 16px 16px 4px;
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
}
.ph-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.ph-title {
  flex: 1;
  min-width: 0;
  display: none;
}
.ph-title h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.ph-title p {
  color: var(--muted);
  margin-top: 2px;
}
.ph-sub-m {
  color: var(--muted);
  font-size: 13px;
}
.ph-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.ph-actions:empty {
  display: none;
}
.ph-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ab-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.ab-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.ab-btn .icon {
  width: 18px;
  height: 18px;
}
.ab-btn .dot {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 10.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.toolbar {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.body {
  flex: 1;
  padding: 12px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
}
.body.narrow {
  max-width: 760px;
}

/* Bottom tab bar (mobile) */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--vv-bottom);
  z-index: 45;
  height: calc(var(--tabbar-h) + var(--bar-pad-b));
  padding-bottom: var(--bar-pad-b);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-top: 1px solid var(--line);
  display: flex;
}
.tabbar a,
.tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  position: relative;
  border: 0;
  background: none;
  cursor: pointer;
  min-width: 0;
}
.tabbar .icon {
  width: 22px;
  height: 22px;
}
.tabbar .active {
  color: var(--brand);
  font-weight: 600;
}
.tabbar .active .ic {
  background: var(--brand-soft);
}
.tabbar .ic {
  padding: 3px 14px;
  border-radius: 99px;
  display: grid;
  place-items: center;
  transition: background 0.15s;
}
.tabbar .badge-n {
  position: absolute;
  top: 4px;
  left: calc(50% + 6px);
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 99px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* Sticky action bar (mobile) / page-header actions (desktop) */
.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-h) + var(--bar-pad-b) + var(--vv-bottom));
  z-index: 44;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  min-height: var(--actionbar-h);
}
body.no-tabbar .actionbar {
  bottom: var(--vv-bottom);
  padding-bottom: max(var(--safe-b), 10px);
}
.actionbar .btn {
  flex: 1;
  height: 46px;
}
.page-actions-inner {
  display: flex;
  gap: 8px;
}

/* ========== Cards ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-h {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.card-h h3 {
  font-size: 15px;
  flex: 1;
  min-width: 0;
}
.card-h .sub {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 400;
  display: block;
  margin-top: 1px;
}
.card-b {
  padding: 16px;
}
.card-b.flush {
  padding: 0;
}
.card-f {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  align-items: center;
}
.sec-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px 0;
}
.sec-title h2 {
  font-size: 16px;
  flex: 1;
}

/* KPI */
.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.tile,
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  color: inherit;
  position: relative;
}
a.tile:hover,
a.kpi:hover {
  border-color: var(--line-2);
}
.tile .lbl,
.kpi .lbl {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.tile .val,
.kpi .val {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.tile .val.sm {
  font-size: 20px;
}
/* Money values never wrap the currency sign (non-breaking space), so their size follows the tile width */
.tile:has(> .val.money),
.kpi:has(> .val.money) {
  container-type: inline-size;
}
.tile .val.money,
.kpi .val.money {
  font-size: min(26px, 13cqi);
  white-space: nowrap;
}
.tile .val.sm.money {
  font-size: min(20px, 12cqi);
}
.tile .sub,
.kpi .sub {
  font-size: 12.5px;
  color: var(--muted);
}
.kpi .kpi-ic {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  margin-bottom: 6px;
}
.kpi .kpi-ic .icon {
  width: 20px;
  height: 20px;
}
.ic-primary {
  background: var(--brand-soft);
  color: var(--brand);
}
.ic-ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.ic-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.ic-bad {
  background: var(--bad-soft);
  color: var(--bad);
}
.ic-info {
  background: var(--info-soft);
  color: var(--info);
}
.kpi .trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 99px;
}
.tile.t-ok,
.tile.t-warn,
.tile.t-bad {
  border-left-width: 1px;
}

/* Dashboard grid */
.dash {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.chart-box {
  position: relative;
  height: 240px;
}
.chart-box.sm {
  height: 200px;
}
.donut-wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: center;
}
.donut-box {
  position: relative;
  height: 190px;
  min-width: 0;
}
/* Donut above its legend in a narrow card: minmax(0, …) so the chart canvas cannot widen the column */
.donut-wrap.stacked,
.legend.one-col {
  grid-template-columns: minmax(0, 1fr);
}
.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  text-align: center;
}
.donut-center b {
  font-size: 24px;
  display: block;
  line-height: 1.1;
}
.donut-center small {
  color: var(--muted);
  font-size: 12px;
}

/* ========== Lists (mobile) ========== */
.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.item {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: inherit;
  text-align: left;
  width: 100%;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  font: inherit;
  box-shadow: var(--shadow-sm);
}
.item:hover {
  border-color: var(--line-2);
}
.item:active {
  background: var(--surface-2);
}
.item .band {
  background: var(--line);
}
.item > .main {
  padding: 11px 12px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.item .trail {
  padding: 11px 12px 11px 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  text-align: right;
}
.item .code {
  font-family: var(--f-mono);
  font-size: 11.5px;
  color: var(--muted);
}
.item .name {
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
}
.item .sub {
  font-size: 13px;
  color: var(--muted);
}
.item .meta {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 6px;
  align-items: center;
}
.item.plain {
  grid-template-columns: 1fr auto;
}
.item.plain .band {
  display: none;
}
.chev {
  color: var(--muted);
  width: 18px;
  height: 18px;
}
.band-TSCD {
  background: var(--c-TSCD) !important;
}
.band-CCDC_LON {
  background: var(--c-CCDC_LON) !important;
}
.band-CCDC_TB {
  background: var(--c-CCDC_TB) !important;
}
.band-CCDC_TH {
  background: var(--c-CCDC_TH) !important;
}
.band-NGOAI {
  background: var(--c-NGOAI) !important;
}

/* Data tables (desktop) */
.tbl {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
table.t {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 14px;
}
.t th {
  position: sticky;
  top: 0;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.t td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.t tbody tr:last-child td {
  border-bottom: 0;
}
.t tbody tr {
  transition: background 0.1s;
}
.t tbody tr.clickable {
  cursor: pointer;
}
.t tbody tr:hover td {
  background: var(--surface-2);
}
.t td.num,
.t th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.t .cell-main {
  font-weight: 600;
  color: var(--ink);
}
.t .cell-sub {
  font-size: 12.5px;
  color: var(--muted);
}
.t .neg {
  color: var(--bad);
  font-weight: 600;
}
.t .pos {
  color: var(--warn);
  font-weight: 600;
}
.t tr.grp td {
  background: var(--surface-3);
  color: var(--text-2);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-block: 7px;
}
.tbl-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

/* Tags */
.st {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  border-radius: 99px;
  padding: 2px 9px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.5;
}
.st::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.st.ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.st.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.st.bad {
  background: var(--bad-soft);
  color: var(--bad);
}
.st.off {
  background: var(--off-soft);
  color: var(--off);
}
.st.info {
  background: var(--info-soft);
  color: var(--info);
}
.cls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}
.cls::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: var(--line-2);
}
.cls.c-TSCD::before {
  background: var(--c-TSCD);
}
.cls.c-CCDC_LON::before {
  background: var(--c-CCDC_LON);
}
.cls.c-CCDC_TB::before {
  background: var(--c-CCDC_TB);
}
.cls.c-CCDC_TH::before {
  background: var(--c-CCDC_TH);
}
.cls.c-NGOAI::before {
  background: var(--c-NGOAI);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  background: var(--surface-3);
  border-radius: 6px;
  padding: 1px 8px;
  color: var(--text-2);
  white-space: nowrap;
  line-height: 1.6;
}
/* Long labels (permission names) wrap inside their card instead of overflowing it */
.pill.wrap {
  white-space: normal;
  max-width: 100%;
  overflow-wrap: break-word;
}
.code-tag {
  font-family: var(--f-mono);
  font-size: 12px;
  background: var(--surface-3);
  color: var(--text-2);
  padding: 1px 7px;
  border-radius: 6px;
  white-space: nowrap;
}

/* Filter chips */
.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px;
  padding: 0 16px;
}
.chips::-webkit-scrollbar {
  display: none;
}
.chip {
  flex-shrink: 0;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 5px 11px;
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
  color: var(--text-2);
}
.chip:hover {
  border-color: var(--line-2);
}
.chip.on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}
.chip .n {
  opacity: 0.65;
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
  font-weight: 600;
}

/* Unit of measure picker (UnitSelect): combobox with a list under the input */
.unit-select {
  position: relative;
  min-width: 0;
}
.unit-select .input {
  padding-right: 30px;
  text-overflow: ellipsis;
}
.unit-select .input[aria-invalid='true'] {
  border-color: var(--warn);
}
.unit-caret {
  position: absolute;
  right: 9px;
  top: calc(var(--field-h) / 2 - 8px);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}
.unit-pop {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  max-width: min(320px, calc(100vw - 32px));
  max-height: 248px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.unit-select.inline .unit-pop {
  position: static;
  margin-top: 6px;
  max-width: none;
  max-height: 208px;
  box-shadow: none;
}
.unit-opt {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.unit-opt small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.unit-opt:hover,
.unit-opt.hi {
  background: var(--surface-2);
}
.unit-opt.on {
  font-weight: 600;
}
.unit-opt.on::after {
  content: '✓';
  margin-left: auto;
  color: var(--ink);
}
@media (pointer: coarse) {
  .unit-opt {
    min-height: 44px;
    font-size: 15px;
  }
}
.unit-none {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 10px;
  color: var(--warn);
  font-size: 12.5px;
}
.unit-none .btn {
  max-width: 100%;
  height: auto;
  min-height: 32px;
  white-space: normal;
  text-align: left;
}
.unit-opt + .unit-none {
  margin-top: 4px;
  border-top: 1px solid var(--line);
}

/* Search box */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r);
  padding: 0 12px;
  height: 42px;
  box-shadow: var(--shadow-sm);
}
.search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.search input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  min-width: 0;
  height: 100%;
  font-size: 15px;
}
.search .icon {
  color: var(--muted);
  width: 18px;
  height: 18px;
}
.search button {
  border: 0;
  background: none;
  padding: 4px;
  cursor: pointer;
  color: var(--muted);
  display: grid;
}
/* Search inside a dialog matches the form field height */
.sheet-b .search {
  height: var(--field-h);
  box-shadow: none;
}
.search kbd {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 5px;
}

/* Progress bar */
.bar {
  height: 8px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
}
.bar.ok i {
  background: var(--ok);
}
.bar.warn i {
  background: var(--warn);
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  box-shadow: var(--shadow-sm);
  transition:
    background 0.12s,
    border-color 0.12s,
    transform 0.08s ease-out;
}
.btn:hover {
  background: var(--surface-2);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn .icon {
  width: 18px;
  height: 18px;
}
.btn.main {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--shadow-sm);
}
.btn.main:hover {
  background: var(--primary-600);
  border-color: var(--primary-600);
}
.btn.danger {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 35%, var(--line));
}
.btn.danger.main {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}
.btn.ok.main {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
.btn.ghost:hover {
  background: var(--surface-3);
}
.btn.quiet {
  background: var(--surface);
}
.btn.sm {
  height: 32px;
  padding: 0 11px;
  font-size: 13px;
  border-radius: var(--r-sm);
}
.btn.block {
  width: 100%;
}
.btn.icon-only {
  width: 40px;
  padding: 0;
}
.btn.sm.icon-only {
  width: 32px;
}
.seg {
  display: flex;
  background: var(--surface-3);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 3px;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  min-height: calc(var(--field-h) - 6px);
  padding: 4px 8px;
  font-weight: 500;
  font-size: 13px;
  line-height: 1.25;
  cursor: pointer;
  border-radius: 6px;
  color: var(--muted);
}
.seg button.on {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow);
}
.seg button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

/* ========== Forms ==========
   Compact density: 40 px fields on phones (16 px text so iOS does not zoom on focus),
   38 px from 640 px. Touch screens keep 16 px text at every width. */
:root {
  --field-h: 40px;
  --field-fs: 16px;
  --field-px: 11px;
  --btn-h: 40px;
}
@media (min-width: 640px) {
  :root {
    --field-h: 38px;
    --field-fs: 14px;
  }
}
@media (min-width: 640px) and (pointer: coarse) {
  :root {
    --field-fs: 16px;
  }
}
.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
/* Field grid: 2 columns (1 below 380 px). Inside dialogs and `.cq` containers the column count follows
   the container width: `.c3` → 3 columns from 720 px, `.c4` → 3 / 4 columns from 720 / 920 px.
   Spans: `.span-2` (2 columns, full row in a 2-column grid), `.full` / `.span-all` (whole row),
   `.full-m` (whole row only in narrow containers, e.g. long selects on phones). */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form-grid > .full,
.form-grid > .span-all,
.form-grid > .span-2 {
  grid-column: 1 / -1;
}
.cq {
  container-type: inline-size;
}
@container (max-width: 519px) {
  .form-grid > .full-m {
    grid-column: 1 / -1;
  }
  .form-grid.stack-m {
    grid-template-columns: minmax(0, 1fr);
  }
}
@container (min-width: 720px) {
  .form-grid.c3,
  .form-grid.c4 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .form-grid.c3 > .span-2,
  .form-grid.c4 > .span-2 {
    grid-column: span 2;
  }
}
@container (min-width: 920px) {
  .form-grid.c4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
/* Notes and checkboxes placed in a grid line up with the inputs, not the labels */
.form-grid > .alert,
.form-grid > .check {
  align-self: end;
}
.form-grid > .alert {
  min-height: var(--field-h);
  padding-block: 8px;
  align-items: center;
}
/* Two controls for one field (e.g. filter box + select): side by side when there is room */
.field-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}
@container (min-width: 520px) {
  .field-pair {
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  }
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.field > label {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-2);
}
.field .req {
  color: var(--bad);
}
.field .hint,
.form > .hint,
.form-grid > .hint,
fieldset > .hint {
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}
.input,
select.input,
textarea.input {
  width: 100%;
  height: var(--field-h);
  padding: 0 var(--field-px);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  font-size: var(--field-fs);
  transition:
    border-color 0.12s,
    box-shadow 0.12s;
}
textarea.input {
  height: auto !important;
  min-height: 62px;
  padding: 8px var(--field-px);
  resize: vertical;
  line-height: 1.45;
}
.input::placeholder {
  color: var(--muted);
  opacity: 0.85;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.input:disabled {
  background: var(--surface-3);
  color: var(--muted);
}
.input.mono {
  font-family: var(--f-mono);
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  min-height: 28px;
  line-height: 1.4;
}
.check input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--primary);
  flex-shrink: 0;
}
@media (pointer: coarse) {
  .check {
    min-height: 36px;
  }
  .chip {
    min-height: 32px;
  }
}
fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
fieldset legend {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  width: 100%;
  border-bottom: 1px solid var(--line);
  padding: 0 0 6px;
  margin-bottom: 2px;
}
/* Optional / rarely used fields: <details class="form-more"><summary>Thông tin thêm <small>…</small></summary>
   <div class="form-more-b">…fields…</div></details> */
.form-more {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  min-width: 0;
}
.form-more > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  border-radius: var(--r);
  user-select: none;
}
.form-more > summary::-webkit-details-marker {
  display: none;
}
.form-more > summary > .icon {
  width: 17px;
  height: 17px;
  color: var(--muted);
}
.form-more > summary small {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.form-more > summary::after {
  content: '';
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  margin: -4px 4px 0 auto;
  border-right: 1.8px solid var(--muted);
  border-bottom: 1.8px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s;
}
.form-more[open] > summary::after {
  transform: rotate(225deg);
  margin-top: 4px;
}
.form-more > summary:hover {
  background: var(--surface-3);
}
.form-more > summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.form-more[open] > summary {
  border-bottom: 1px solid var(--line);
  border-radius: var(--r) var(--r) 0 0;
}
.form-more-b {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border-radius: 0 0 var(--r) var(--r);
}
/* Two-pane dialog form (picker on the left, details on the right) from 760 px of dialog width */
.split-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.split-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.pick-list {
  max-height: 260px;
  overflow: auto;
  gap: 6px;
  padding: 2px;
}
.pick-list > * {
  flex-shrink: 0;
}
.pick-list .item > .main,
.pick-list .item .trail {
  padding-block: 8px;
}
.pick-list .item.on {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background: var(--primary-soft);
}
.pick-list input[type='radio'] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}
@container (min-width: 760px) {
  .split-form {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 24px;
  }
  .split-form > .split-pane + .split-pane {
    position: sticky;
    top: 0;
  }
  .pick-list {
    max-height: calc(88vh - 250px);
    max-height: calc(88dvh - 250px);
  }
}
/* Invoice lines: stacked card on phones, one table-like row per line in wide dialogs */
.inv-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.inv-line {
  display: grid;
  /* Phone card: money fields get a wide row each so 9-digit amounts stay readable, every field is labelled */
  grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr) 32px;
  grid-template-areas:
    'no type type del'
    'name name name name'
    'qty unit unit unit'
    'price price price price'
    'amount amount amount amount';
  gap: 6px 8px;
  align-items: end;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}
.inv-line-h {
  display: none;
}
.il-f {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.il-l {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.il-del {
  margin-bottom: 4px;
}
.il-no {
  grid-area: no;
}
.il-type {
  grid-area: type;
}
.il-name {
  grid-area: name;
}
.il-qty {
  grid-area: qty;
}
.il-unit {
  grid-area: unit;
}
.il-price {
  grid-area: price;
}
.il-amount {
  grid-area: amount;
}
.il-del {
  grid-area: del;
}
@container (min-width: 760px) {
  .inv-lines {
    gap: 4px;
  }
  .inv-line {
    grid-template-columns: 60px 150px minmax(0, 1fr) 72px 96px 130px 140px 32px;
    grid-template-areas: 'no type name qty unit price amount del';
    align-items: center;
    padding: 0;
    border: 0;
    background: none;
  }
  /* The header row labels the columns */
  .il-l {
    display: none;
  }
  .il-del {
    margin-bottom: 0;
  }
  .inv-line-h {
    display: grid;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
  }
}
/* Permission groups in the role dialog */
.perm-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.perm-card .card-h {
  padding: 8px 14px;
  min-height: 0;
}
.perm-card .card-b {
  padding: 8px 14px 10px;
}
@container (min-width: 600px) {
  .perm-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@container (min-width: 920px) {
  .perm-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
/* Radio / checkbox options as compact tiles: <div class="choice-grid"><label class="check choice" :class="{ on }"> */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr));
  gap: 6px;
}
.choice-grid.wide {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
}
.check.choice {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  min-height: var(--field-h);
}
.check.choice:hover {
  border-color: var(--line-2);
}
.check.choice.on {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.check.choice:has(input:focus-visible) {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* ========== Sheets / dialogs ==========
   Phone: compact bottom sheet. From 640 px: centred dialog; width by size class
   (sm 440 · default 600 · lg 860 · full 1100 px with a fixed tall height). Header and footer stay put,
   only the body scrolls. */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--backdrop);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overscroll-behavior: contain;
  /* Phone bottom sheet sits above the browser toolbar */
  padding-bottom: var(--vv-bottom);
  animation: fade 0.18s ease-out;
}
.sheet {
  --sheet-px: 16px;
  position: relative;
  background: var(--surface);
  width: 100%;
  max-height: 94vh;
  max-height: calc(100dvh - var(--safe-t) - 8px - var(--vv-bottom));
  display: flex;
  flex-direction: column;
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow-lg);
  outline: none;
  animation: sheet-up 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.full {
  height: 94vh;
  height: calc(100dvh - var(--safe-t) - 8px - var(--vv-bottom));
}
.sheet-h {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 8px 8px var(--sheet-px);
  border-bottom: 1px solid var(--line);
  min-height: 52px;
  position: relative;
  flex-shrink: 0;
}
.sheet-h::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 2px;
  background: var(--line-2);
}
.sheet-h .sh-ic {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--primary-soft);
  color: var(--ink);
}
.sheet-h .sh-ic .icon {
  width: 17px;
  height: 17px;
}
.sheet-h .sh-t {
  flex: 1;
  min-width: 0;
}
.sheet-h h3 {
  font-size: 16px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.sheet-h .sh-sub {
  display: block;
  margin-top: 1px;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sheet-h > .btn.icon-only {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.sheet-b {
  padding: 14px var(--sheet-px) 16px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  overscroll-behavior: contain;
  container-type: inline-size;
  /* Fields scrolled into view keep a gap from the footer */
  scroll-padding-block: 12px 24px;
}
/* A notice at the top of a dialog (e.g. read-only role) keeps a gap before the form below it */
.sheet-b > .alert:not(:last-child) {
  margin-bottom: 12px;
}
.sheet-f {
  display: flex;
  gap: 8px;
  padding: 10px 12px max(var(--safe-b), 10px);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  flex-shrink: 0;
}
.sheet-f .btn {
  flex: 1;
  height: var(--btn-h);
}
/* Icon-only actions (delete) keep a square size; callers may still pass an inline flex basis */
.sheet-f .btn.icon-only {
  flex: 0 0 var(--btn-h) !important;
  width: var(--btn-h);
}
@media (min-width: 640px) {
  .sheet-backdrop {
    align-items: center;
    padding: 24px 24px calc(24px + var(--vv-bottom));
  }
  .sheet {
    --sheet-px: 20px;
    width: min(600px, 100%);
    max-height: 88vh;
    max-height: min(88dvh, calc(100dvh - var(--safe-t) - 48px - var(--vv-bottom)));
    border-radius: var(--r-lg);
    animation: sheet-pop 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .sheet.sm {
    width: min(440px, 100%);
  }
  .sheet.lg {
    width: min(860px, 100%);
  }
  .sheet.full {
    width: min(1100px, 100%);
    height: min(88vh, 980px);
    height: min(88dvh, 980px, calc(100dvh - var(--safe-t) - 48px - var(--vv-bottom)));
  }
  .sheet-h {
    padding: 12px 12px 12px var(--sheet-px);
    min-height: 58px;
  }
  .sheet-h::before {
    display: none;
  }
  .sheet-h h3 {
    font-size: 16.5px;
  }
  .sheet-b {
    padding: 16px var(--sheet-px) 20px;
  }
  .sheet-f {
    justify-content: flex-end;
    padding: 12px var(--sheet-px) max(var(--safe-b), 12px);
    border-radius: 0 0 var(--r-lg) var(--r-lg);
  }
  .sheet-f .btn {
    flex: 0 0 auto;
    min-width: 96px;
    height: 38px;
  }
  .sheet-f .btn.icon-only {
    flex: 0 0 38px !important;
    width: 38px;
    min-width: 0;
  }
  /* Destructive icon action sits apart on the left */
  .sheet-f > .btn.danger.icon-only:first-child {
    margin-right: auto;
  }
}
/* Keyboard open: the dialog fits the visible part of the screen so its footer stays above the keyboard */
html.kb-open .sheet-backdrop {
  top: var(--vv-top, 0px);
  bottom: auto;
  height: var(--vv-height, 100%);
  padding: 8px 8px 0;
}
html.kb-open .sheet {
  max-height: calc(var(--vv-height, 100dvh) - 8px);
}
html.kb-open .sheet.full {
  height: calc(var(--vv-height, 100dvh) - 8px);
}
html.kb-open .sheet-f {
  padding-bottom: 10px;
}
@media (max-width: 639px) {
  html.kb-open .sheet-backdrop {
    padding: 0;
  }
}
@media (min-width: 640px) {
  html.kb-open .sheet {
    border-radius: var(--r-lg);
  }
}
@keyframes sheet-up {
  from {
    transform: translateY(32px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
@keyframes sheet-pop {
  from {
    transform: translateY(8px) scale(0.975);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
@keyframes up {
  from {
    transform: translateY(40px);
    opacity: 0.4;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.menu-list {
  display: flex;
  flex-direction: column;
  margin: -6px calc(-1 * var(--sheet-px, 18px)) -8px;
}
.menu-list button,
.menu-list a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border: 0;
  background: none;
  text-align: left;
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  width: 100%;
}
.menu-list button:hover,
.menu-list a:hover {
  background: var(--surface-2);
}
.menu-list button:last-child,
.menu-list a:last-child {
  border-bottom: 0;
}
.menu-list .icon {
  color: var(--primary);
}
.menu-list .danger,
.menu-list .danger .icon {
  color: var(--bad);
}
.menu-list small {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
}

/* ========== Notifications ========== */
.toasts {
  position: fixed;
  left: 12px;
  right: 12px;
  top: calc(12px + var(--safe-t));
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  align-items: center;
}
.toast {
  pointer-events: auto;
  width: 100%;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--ink);
  color: var(--surface);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: fade 0.15s;
}
.toast.error {
  background: #a82424;
  color: #fff;
}
.toast.success .icon {
  color: #6fd394;
}
.alert {
  padding: 11px 14px;
  border-radius: var(--r);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert .icon {
  margin-top: 1px;
  width: 18px;
  height: 18px;
}
.alert.info {
  background: var(--info-soft);
  color: var(--info);
}
.alert.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.alert.bad {
  background: var(--bad-soft);
  color: var(--bad);
}
.alert.ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.empty > .icon {
  width: 40px;
  height: 40px;
  padding: 9px;
  border-radius: 12px;
  background: var(--surface-3);
  box-sizing: content-box;
}

/* ========== Detail views ========== */
.dl {
  display: grid;
  grid-template-columns: minmax(110px, 36%) 1fr;
  margin: 0;
}
.dl dt,
.dl dd {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  margin: 0;
}
.dl dt {
  color: var(--muted);
  font-size: 13.5px;
  padding-right: 12px;
}
.dl dd {
  font-weight: 500;
  word-break: break-word;
}
.dl > :nth-last-child(-n + 2) {
  border-bottom: 0;
}
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}
.timeline li {
  position: relative;
  padding: 0 0 16px 24px;
}
.timeline li::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--primary);
}
.timeline li::after {
  content: '';
  position: absolute;
  left: 8px;
  top: 20px;
  bottom: 2px;
  width: 2px;
  background: var(--line);
}
.timeline li:last-child {
  padding-bottom: 0;
}
.timeline li:last-child::after {
  display: none;
}
.timeline .t-note {
  color: var(--muted);
  font-size: 13.5px;
}

/* Asset label preview */
.tem {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.tem .band {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--c-TSCD);
}
.tem .qr {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  color: var(--muted);
  flex-shrink: 0;
}
.tem .txt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.tem .tp {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.tem .code {
  font-family: var(--f-mono);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.01em;
  word-break: break-all;
}
.tem .code span {
  color: var(--muted);
}
.tem .nm {
  font-size: 13.5px;
  color: var(--text-2);
}

/* Thanh ngang */
.hbars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: center;
  color: inherit;
}
.hbar .lbl {
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
}
.hbar .v {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 13.5px;
}
.hbar .bar {
  grid-column: 1 / -1;
}
.stackbar {
  display: flex;
  height: 10px;
  gap: 2px;
  overflow: hidden;
  border-radius: 99px;
}
.stackbar span {
  height: 100%;
  min-width: 3px;
}
.legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px 16px;
}
.legend .li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-2);
}
.legend .sw {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border-radius: 3px;
}
.legend .li b {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.legend .li .lbl {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.legend .li .pct {
  color: var(--muted);
  font-size: 12px;
  min-width: 38px;
  text-align: right;
}

/* Link groups */
.nav-group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.nav-group a,
.nav-group button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  color: var(--ink);
  border: 0;
  background: none;
  width: 100%;
  border-bottom: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
  font-size: 14.5px;
}
.nav-group a:hover,
.nav-group button:hover {
  background: var(--surface-2);
}
.nav-group > :last-child {
  border-bottom: 0;
}
.nav-group .nic {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  flex-shrink: 0;
}
.nav-group > a > .icon:first-child,
.nav-group > button > .icon:first-child {
  color: var(--primary);
}
.nav-group .t {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}
.nav-group .t small {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 400;
}
.nav-group .cnt {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
}
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-2);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.avatar.sm {
  width: 32px;
  height: 32px;
  font-size: 12px;
}
.loadmore {
  display: flex;
  justify-content: center;
  padding: 6px 0;
}
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

/* Permission matrix */
.matrix th,
.matrix td {
  padding: 8px 12px;
}
.matrix td.c {
  text-align: center;
}
.matrix th.rc {
  text-align: center;
  min-width: 110px;
  font-size: 12px;
}
.matrix th.rc small {
  display: block;
  font-weight: 400;
  color: var(--muted);
}
.matrix .dirty {
  background: var(--warn-soft) !important;
}
.matrix input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}
.matrix .first {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
  min-width: 200px;
}
.matrix tr.grp .first {
  background: var(--surface-3);
}
.matrix th.first {
  background: var(--surface-2);
  z-index: 2;
}

/* ========== Sign-in ========== */
.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--surface);
}
.login-hero {
  display: none;
}
.login-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(32px + var(--safe-t)) 22px 32px;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  gap: 22px;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.login-brand b {
  font-size: 17px;
  display: block;
}
.login-brand span {
  font-size: 13px;
  color: var(--muted);
}
.login-body h1 {
  font-size: 26px;
  letter-spacing: -0.02em;
}
.demo {
  font-size: 13px;
}
.demo table {
  width: 100%;
  border-collapse: collapse;
}
.demo td {
  padding: 7px 4px;
  border-bottom: 1px solid var(--line);
}
.demo tr:last-child td {
  border-bottom: 0;
}
.demo button {
  border: 0;
  background: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-family: var(--f-mono);
  font-size: 13px;
}

.forbidden {
  text-align: center;
  padding: 48px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.forbidden .big {
  font-size: 64px;
  font-weight: 800;
  color: var(--line-2);
  letter-spacing: -0.04em;
}

/* ========== Tablet ========== */
@media (min-width: 640px) {
  .tiles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .donut-wrap {
    grid-template-columns: 190px 1fr;
  }
  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .chips {
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
  }
}

/* ========== Desktop ========== */
@media (min-width: 1024px) {
  .app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }
  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    transform: none;
    box-shadow: none;
  }
  .drawer-backdrop,
  .tabbar,
  .tb-menu {
    display: none !important;
  }
  .app-main,
  body.with-actionbar .app-main {
    padding-bottom: 0;
  }
  .topbar {
    padding: 0 24px;
    gap: 10px;
    height: var(--topbar-h);
  }
  .tb-title {
    display: none;
  }
  /* The crumbs take the free width of the top bar; the search box narrows with the viewport so the trail fits.
     When space still runs out only the parent crumbs shrink (ellipsis); the current page name keeps its width
     (up to 65 % of the trail). */
  .tb-crumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 13.5px;
    flex: 1 1 auto;
    min-width: 0;
  }
  .tb-crumbs a {
    color: var(--muted);
  }
  .tb-crumbs > a,
  .tb-crumbs > span {
    white-space: nowrap;
    flex: 0 1 auto;
    min-width: 2.5em;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tb-crumbs a:hover {
    color: var(--ink);
  }
  .tb-crumbs b {
    color: var(--ink);
    font-weight: 600;
    flex: 0 0 auto;
    max-width: 65%;
  }
  .tb-crumbs .icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
  }
  .tb-search {
    display: flex;
    flex: 0 0 auto;
    width: clamp(180px, 100vw - 1150px, 340px);
  }
  .tb-search input {
    text-overflow: ellipsis;
  }
  .tb-search .search {
    width: 100%;
    height: 38px;
    background: var(--surface-2);
    box-shadow: none;
  }
  .tb-user {
    flex-shrink: 0;
    padding: 4px 10px 4px 4px;
    border-radius: 99px;
  }
  .tb-user:hover {
    background: var(--surface-3);
  }
  .tb-user .who {
    display: block;
    line-height: 1.25;
  }
  .tb-user .who b {
    font-size: 13.5px;
    display: block;
  }
  .tb-user .who small {
    font-size: 12px;
    color: var(--muted);
  }
  .page-header {
    padding: 24px 28px 4px;
  }
  .ph-title {
    display: block;
  }
  .ph-sub-m {
    display: none;
  }
  .body {
    padding: 16px 28px 32px;
    gap: 16px;
  }
  .actionbar {
    display: none;
  }
  .dash {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
  }
  .col-4 {
    grid-column: span 4;
  }
  .col-5 {
    grid-column: span 5;
  }
  .col-6 {
    grid-column: span 6;
  }
  .col-7 {
    grid-column: span 7;
  }
  .col-8 {
    grid-column: span 8;
  }
  .col-12 {
    grid-column: span 12;
  }
  .chart-box {
    height: 280px;
  }
  .login {
    grid-template-columns: 1.05fr 1fr;
  }
  .login-hero {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 44px 52px;
    color: #e9e5dc;
    position: relative;
    overflow: hidden;
    background:
      radial-gradient(1100px 600px at 0% 0%, rgba(241, 238, 232, 0.1) 0%, transparent 60%),
      radial-gradient(800px 500px at 100% 100%, rgba(181, 34, 41, 0.38) 0%, transparent 55%), #121110;
  }
  .login-hero h2 {
    font-size: 36px;
    line-height: 1.15;
    color: #fff;
    letter-spacing: -0.03em;
    margin: 18px 0 12px;
    max-width: 520px;
  }
  .login-hero p {
    color: #bdb7ab;
    max-width: 460px;
    font-size: 15px;
  }
  .hero-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    max-width: 560px;
  }
  .hero-card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--r-lg);
    padding: 14px;
    backdrop-filter: blur(6px);
  }
  .hero-card b {
    display: block;
    font-size: 22px;
    color: #fff;
  }
  .hero-card span {
    font-size: 12.5px;
    color: #a9a397;
  }
  .login-body {
    max-width: 420px;
  }
}
/* ========== Desktop layout refinements ========== */
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.detail-main,
.detail-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.hub-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}
.hub-card {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 11px 14px;
  color: inherit;
}
.hub-card:hover {
  border-color: var(--line-2);
  box-shadow:
    var(--shadow),
    0 4px 14px -6px rgba(15, 23, 42, 0.12);
}
.hub-card .nic {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.hub-card .t {
  flex: 1;
  min-width: 0;
}
.hub-card .nic .icon {
  width: 18px;
  height: 18px;
}
.hub-card .t b {
  display: block;
  font-size: 14px;
}
.hub-card .t small {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 1px;
  line-height: 1.35;
}
.hub-card .t small.hub-warn {
  color: var(--warn);
}
.md-area .sec-title h2 {
  white-space: nowrap;
}
@media (max-width: 639px) {
  .md-area .sec-title > span {
    display: none;
  }
}
@media (min-width: 1280px) {
  .md-area .hub-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
/* Proposed asset change on a request: label · before → after */
.change-list {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  max-height: 280px;
  overflow: auto;
}
.change-row {
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--line);
}
.change-row:last-child {
  border-bottom: 0;
}
.change-row .lbl {
  flex: 0 0 34%;
  min-width: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.change-row .vals {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}
.change-row .from {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--muted) 50%, transparent);
}
.change-row .icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
}
/* Asset waiting for an approved movement */
a.pending-req {
  color: inherit;
}
a.pending-req .chev {
  margin-left: auto;
  flex-shrink: 0;
}
.menu-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0 0 10px;
}
.menu-note .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}
/* Catalog hub: global search + area sections */
.md-search {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.search.lg {
  height: 44px;
}
.md-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.md-results {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
@media (min-width: 1024px) {
  .md-results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}
.hub-card .cnt {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.steps-ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.steps-ol li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 14px;
  color: var(--text-2);
}
.steps-ol .n {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.dropzone {
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-lg);
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  transition:
    border-color 0.12s,
    background 0.12s;
}
.dropzone:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.dropzone .icon {
  width: 28px;
  height: 28px;
  color: var(--primary);
}
.dropzone b {
  font-size: 14.5px;
}
.dropzone small {
  color: var(--muted);
}
.mini-bar {
  width: 120px;
}
@media (min-width: 640px) {
  .hub-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1024px) {
  .app-main .list {
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
  }
  .app-main .list > .item {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px solid var(--line);
  }
  .app-main .list > .item:last-child {
    border-bottom: 0;
  }
  .app-main .list > .item:hover {
    background: var(--surface-2);
  }
  .toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }
  .toolbar > .search {
    flex: 0 1 400px;
  }
  .toolbar > .chips {
    flex: 1 1 auto;
  }
  .toolbar > .input,
  .toolbar > select {
    width: auto;
    min-width: 200px;
  }
  .dl {
    grid-template-columns: 210px minmax(0, 1fr);
  }
  .detail-grid {
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 16px;
  }
  .detail-grid > .detail-side {
    order: 2;
    position: sticky;
    top: calc(var(--topbar-h) + 16px);
  }
  .detail-side .dl {
    grid-template-columns: 130px minmax(0, 1fr);
  }
  .detail-grid.wide-side {
    grid-template-columns: 400px minmax(0, 1fr);
  }
  .detail-grid.wide-side > .detail-side {
    order: 0;
  }
  .hub-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }
}
@media (max-width: 380px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .tile .val,
  .kpi .val {
    font-size: 22px;
  }
}
@media print {
  .sidebar,
  .topbar,
  .tabbar,
  .actionbar,
  .page-header,
  .no-print,
  .toasts {
    display: none !important;
  }
  /* Landscape sheets can be laid out at desktop width: the hidden sidebar must not keep its grid column */
  .app {
    display: block !important;
  }
  .app-main {
    padding: 0 !important;
    margin: 0 !important;
  }
  body,
  .body {
    background: #fff !important;
    padding: 0 !important;
  }
  .paper {
    box-shadow: none !important;
    border: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    break-after: page;
  }
  /* The on-screen fit-to-width scale never applies to the printed sheet */
  .paper-fit-in {
    zoom: 1 !important;
    width: auto !important;
  }
}
@page {
  size: A4 portrait;
  margin: 10mm;
}
@page paper-landscape {
  size: A4 landscape;
  margin: 8mm;
}

/* ===== Audit log: field-level changes ===== */
.chg {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  font-size: 13px;
}
.chg li {
  display: grid;
  grid-template-columns: minmax(84px, 120px) 1fr;
  gap: 10px;
  align-items: baseline;
}
.chg li:last-child:has(.link-btn) {
  grid-template-columns: 1fr;
}
.chg-f {
  color: var(--muted);
  font-size: 12.5px;
}
.chg-v {
  min-width: 0;
  overflow-wrap: anywhere;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 0;
}
.chg-from {
  color: var(--bad);
  background: var(--bad-soft);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--bad) 55%, transparent);
  padding: 0 5px;
  border-radius: 4px;
}
.chg-to {
  color: var(--ok);
  background: var(--ok-soft);
  font-weight: 600;
  padding: 0 5px;
  border-radius: 4px;
}
.chg-from.empty,
.chg-to.empty {
  color: var(--muted);
  background: var(--surface-3);
  font-style: italic;
  font-weight: 400;
  text-decoration: none;
}
.chg-create .chg-to {
  color: var(--ink);
  background: none;
  padding: 0;
  font-weight: 500;
}
.chg-delete .chg-from {
  color: var(--muted);
  background: none;
  padding: 0;
}
.chg-arrow {
  color: var(--muted);
  margin: 0 6px;
}
.chg-tag {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
}
.chg-tag.add {
  color: var(--ok);
  background: var(--ok-soft);
}
.chg-tag.del {
  color: var(--bad);
  background: var(--bad-soft);
}
.link-btn {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.audit-t td {
  vertical-align: top;
}
.audit-card > .main {
  gap: 6px;
}
.audit-card .chg {
  margin: 4px 0 2px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.audit-card .chg li {
  grid-template-columns: 1fr;
  gap: 1px;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.filter-row > select {
  flex: 1 1 180px;
  max-width: 240px;
}
.date-range {
  flex: 1 1 320px;
  max-width: 420px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
}
.date-range .input {
  min-width: 0;
}
@media (max-width: 719px) {
  .filter-row > select,
  .date-range {
    max-width: none;
  }
}

/* ===== Inventory evidence ===== */
.ev-card {
  display: grid;
  gap: 12px;
}
.h-card {
  margin: 0;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.h-card .icon {
  width: 18px;
  height: 18px;
  color: var(--muted);
}
.ev-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}
.ev-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-3);
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text-2);
  font: inherit;
}
.ev-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ev-tile:hover {
  border-color: var(--line-2);
}
.ev-tile:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.ev-add {
  border: 1.5px dashed var(--line-2);
  background: var(--surface-2);
  align-content: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
}
.ev-add .icon {
  width: 22px;
  height: 22px;
}
.ev-add.busy {
  opacity: 0.6;
  cursor: progress;
}
.ev-doc {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px;
  max-width: 100%;
  font-size: 12px;
}
.ev-doc .icon {
  width: 24px;
  height: 24px;
  color: var(--bad);
}
.ev-doc small {
  max-width: 76px;
  color: var(--muted);
}
.ev-doc.big {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
}
.ev-full {
  display: block;
  max-width: 100%;
  max-height: 62vh;
  max-height: 62dvh;
  margin: 0 auto;
  border-radius: var(--r);
  background: var(--surface-3);
}
.inv-item {
  align-items: flex-start;
  padding-right: 12px;
}
.ev-btn {
  align-self: center;
  min-width: 44px;
  height: 44px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.ev-btn .icon {
  width: 19px;
  height: 19px;
}
.ev-btn.has {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 35%, var(--line));
  background: var(--ok-soft);
}
.ev-btn.need {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
  background: var(--warn-soft);
}
.proof-tag {
  margin-top: 6px;
  align-self: flex-start;
}
.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.checklist li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-weight: 500;
}
.checklist li .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.checklist li.ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.checklist li.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

/* ===== Excel import dialog ===== */
.dropzone.over {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.imp-rows {
  display: grid;
  gap: 8px;
  max-height: 46vh;
  max-height: 46dvh;
  overflow: auto;
  padding-right: 2px;
}
.imp-row {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 12px;
  background: var(--surface);
  display: grid;
  gap: 6px;
}
.imp-row.imp-error {
  border-color: color-mix(in srgb, var(--bad) 35%, var(--line));
  background: color-mix(in srgb, var(--bad-soft) 45%, var(--surface));
}
.imp-h {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.imp-h b {
  min-width: 0;
}
.imp-err {
  color: var(--bad);
}
.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.spec-card {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  display: grid;
  gap: 8px;
  align-content: start;
  background: var(--surface-2);
}
.spec-card p {
  margin: 0;
}
.spec-card .pill {
  margin: 0 4px 4px 0;
}
.spec-card .pill.req {
  font-weight: 600;
  color: var(--ink);
}
.spec-card .btn {
  justify-self: start;
}
.spec-ic {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
}
.spec-ic .icon {
  width: 18px;
  height: 18px;
}
/* QR on the tag: always black on white so it scans in dark mode too */
.tem .qr svg {
  width: 100%;
  height: 100%;
  display: block;
}
.tem .qr:has(svg) {
  background: #fff;
  padding: 4px;
}
/* Tag scanner */
.scan-view {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4 / 3;
}
.scan-view video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.scan-frame {
  position: absolute;
  inset: 18% 22%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35);
}
/* Asset photos in lists and the form */
.thumb {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-3);
  border: 1px solid var(--line);
}
.thumb.lg {
  width: 52px;
  height: 52px;
  border-radius: 10px;
}
.thumb.ph {
  display: grid;
  place-items: center;
  color: var(--muted);
}
.thumb.ph .icon {
  width: 16px;
  height: 16px;
}
.input-row {
  display: flex;
  gap: 8px;
}
.input-row .input {
  flex: 1;
  min-width: 0;
}
.input-row > .btn {
  height: var(--field-h);
  flex-shrink: 0;
}
.sm-gap {
  margin-bottom: 6px;
}
/* ===== Paper forms (offline): always black on white, also in dark mode ===== */
.paper {
  background: #fff;
  color: #111;
  border-radius: var(--r);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 22px 24px;
  margin-top: 12px;
  overflow-x: auto;
  font-size: 12px;
  color-scheme: light;
}
.paper.landscape {
  page: paper-landscape;
}
.paper-fit {
  min-width: 0;
}
.paper-fit-in {
  margin-inline: auto;
}
.paper-fit-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}
.paper-fit-hint .icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.paper-h {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  border-bottom: 2px solid #111;
  padding-bottom: 10px;
  margin-bottom: 8px;
}
.paper-h > div span {
  display: block;
  color: #555;
  font-size: 11px;
  margin-top: 2px;
}
.paper-title {
  font-size: 16px;
  letter-spacing: 0.02em;
}
.paper-h dl {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr);
  gap: 4px 10px;
  margin: 0;
  min-width: 300px;
}
.paper-h dt {
  color: #555;
}
.paper-h dd {
  margin: 0;
  border-bottom: 1px dotted #888;
  min-height: 16px;
  font-weight: 600;
}
.paper-note {
  margin: 6px 0 10px;
  color: #333;
  font-size: 11px;
}
.paper-t {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  table-layout: fixed;
}
.paper-t th,
.paper-t td {
  border: 1px solid #333;
  padding: 4px 6px;
  height: 26px;
  vertical-align: middle;
  color: #111;
}
.paper-t th {
  background: #f1eee8;
  font-size: 11px;
  text-align: left;
  line-height: 1.25;
}
.paper-t th small {
  display: block;
  font-family: var(--f-mono);
  font-size: 9.5px;
  color: #666;
  font-weight: 500;
}
.paper-t .c {
  text-align: center;
}
.paper-t .mono {
  font-family: var(--f-mono);
  font-size: 11px;
}
.paper-zone td {
  background: #f7f5f0;
  font-weight: 700;
}
.paper-t tr {
  break-inside: avoid;
}
.paper-sign {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  text-align: center;
  margin-top: 16px;
  min-height: 90px;
  font-weight: 600;
  break-inside: avoid;
}
.paper-sign small {
  font-weight: 400;
  color: #666;
}
.paper-names {
  columns: 3 240px;
  column-gap: 22px;
}
.paper-group {
  break-inside: avoid;
  margin-bottom: 10px;
}
.paper-group ul {
  margin: 4px 0 0;
  padding-left: 16px;
}
.paper-group li {
  margin: 1px 0;
}

/* =====================================================================
   Motion & loading: progress bar, skeletons, soft enter transitions
   ===================================================================== */
/* Thin progress bar for API calls; the delay keeps fast requests from flickering */
.topline {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 0;
  right: 0;
  height: 2.5px;
  z-index: 300;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.topline.on {
  opacity: 1;
  transition-delay: 0.15s;
}
.topline::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 38%;
  border-radius: 2px;
  background: var(--accent);
  animation: topline 1.1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes topline {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(280%);
  }
}

/* Skeleton placeholders (same footprint as the real content → no layout jump) */
.sk {
  display: grid;
  gap: 14px;
}
.sk-detail {
  grid-template-columns: minmax(0, 1fr);
}
.sk-col,
.sk-list {
  display: grid;
  gap: 10px;
}
.sk-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 14px;
}
.sk-tiles.two {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
}
.sk-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.sk-line,
.sk-block {
  display: block;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 45%, var(--surface-3) 90%);
  background-size: 300% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
.sk-line {
  height: 12px;
}
.sk-line.short {
  margin-left: auto;
}
.sk-block {
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
}
@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -50% 0;
  }
}
@media (min-width: 1024px) {
  .sk-detail {
    grid-template-columns: minmax(0, 1fr) 380px;
  }
  .sk-list {
    gap: 0;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    overflow: hidden;
  }
  .sk-list .sk-row {
    border: 0;
    border-radius: 0;
    border-bottom: 1px solid var(--line);
  }
}

/* New screen content eases in instead of popping (runs once, when the element is created) */
.body > *,
.page-header {
  animation: rise 0.24s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.body > .list > .item,
.body > .tbl tbody tr {
  animation: fade 0.22s ease-out both;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* =====================================================================
   Touch devices (phones, iPad): instant taps, press feedback, no sticky hover
   ===================================================================== */
a,
button,
label,
summary,
select,
input,
.item,
.chip {
  touch-action: manipulation;
}
@media (hover: none) {
  .btn:active,
  .chip:active,
  .ev-tile:active,
  .ev-btn:active,
  .tabbar a:active,
  .tabbar button:active,
  .sb-nav a:active {
    transform: scale(0.97);
  }
  .item:active {
    background: var(--surface-2);
  }
  .app-main .list > .item:hover,
  .t tr.clickable:hover {
    background: inherit;
  }
}
.sheet-b,
.sidebar,
.imp-rows {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* =====================================================================
   Tablet / iPad portrait (640–1023 px): centred dialogs, two-column cards
   ===================================================================== */
@media (min-width: 640px) and (max-width: 1023px) {
  .body {
    padding: 18px 24px 28px;
  }
  .body > .list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: start;
  }
  .dash {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dash > .col-8,
  .dash > .col-12 {
    grid-column: 1 / -1;
  }
  .detail-grid {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 300px);
  }
  .detail-grid > .detail-side {
    order: 2;
  }
  .actionbar {
    justify-content: flex-end;
    padding-inline: 24px;
  }
  .actionbar .btn {
    flex: 0 1 260px;
  }
  .tabbar {
    padding-inline: max(10%, env(safe-area-inset-left, 0px));
  }
  .ev-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }
  .toolbar > .chips {
    flex-wrap: wrap;
  }
}

/* iPad landscape / small laptops (1024–1279 px): give the content more room */
@media (min-width: 1024px) and (max-width: 1279px) {
  :root {
    --sidebar-w: 244px;
  }
  .t .opt {
    display: none;
  }
  .body {
    padding-inline: 20px;
  }
  /* The user's name is already in the sidebar footer: the avatar alone frees room for the breadcrumbs */
  .tb-user {
    padding: 4px;
  }
  .tb-user .who {
    display: none;
  }
  .detail-grid {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
  .t th,
  .t td {
    padding-inline: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
/* Touch screens keep 16 px search text so iOS does not zoom on focus (form fields: --field-fs) */
@media (pointer: coarse) {
  .search input {
    font-size: 16px;
  }
}

/* Date field: dd/mm/yyyy text + native picker behind the calendar button */
.date-input {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
}
.date-input > .input {
  padding-right: 40px;
  font-variant-numeric: tabular-nums;
}
.date-input.invalid > .input {
  border-color: var(--bad);
  box-shadow: 0 0 0 3px var(--bad-soft);
}
.di-btn {
  position: absolute;
  top: 0;
  right: 0;
  width: 38px;
  height: var(--field-h);
  display: grid;
  place-items: center;
  color: var(--muted);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.di-btn .icon {
  width: 18px;
  height: 18px;
}
.di-btn:hover {
  color: var(--ink);
}
.di-btn.off {
  opacity: 0.5;
}
.di-btn input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  padding: 0;
}
.di-btn input::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.di-err {
  color: var(--bad);
  font-size: 12px;
  margin-top: 4px;
}
/* Money field: grouped digits + ₫ unit inside the field */
.money-input {
  position: relative;
  min-width: 0;
}
.money-input > .input {
  padding-right: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.mi-unit {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
/* Login: logo sizes */
.login-logo {
  width: 260px;
  max-width: 70%;
}
.login-body .login-logo {
  width: 220px;
}
/* Paper forms carry the logo in their header */
.paper-logo {
  height: 38px;
  width: auto;
  display: block;
  margin-bottom: 6px;
}

/* ===== Approval workflows ===== */
/* Timeline step states (request detail) */
.timeline li.done::before {
  border-color: var(--ok);
  background: var(--ok);
}
.timeline li.rejected::before {
  border-color: var(--bad);
  background: var(--bad);
}
.timeline li.current::before {
  border-color: var(--warn);
  box-shadow: 0 0 0 4px var(--warn-soft);
}
.timeline li.skip {
  opacity: 0.55;
}
.timeline li.skip::before {
  border-style: dashed;
  border-color: var(--line-2);
}
/* Request type picker */
.type-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}
.type-grid .hub-card {
  text-align: left;
  font: inherit;
  cursor: pointer;
  background: var(--surface);
}
@media (min-width: 640px) {
  .type-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
/* Approval route preview: step chips joined by arrows */
.route-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.route-line .rs {
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.route-line .rs.off {
  color: var(--muted);
  text-decoration: line-through;
}
.route-line .icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
}
/* Editable rows of the approval configuration (steps, fields) */
.builder-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}
.builder-row .no {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  font-weight: 700;
  font-size: 13px;
}
.builder-row .tools {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
/* Remove button on an attachment tile */
.ev-tile .ev-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--bad);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.ev-tile .ev-del .icon {
  width: 14px;
  height: 14px;
}
.amount-big {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
/* ===== CCDC norms & accounting import ===== */
.norm-input {
  width: 110px;
  height: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.row-dirty td,
.norm-card.row-dirty {
  background: var(--brand-soft);
}
.norm-card .trail {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
.norm-sites {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.acc-file {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  background: var(--surface-2);
}
.acc-sheets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.acc-sheet {
  font-size: 12.5px;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
}
/* ===== Value-based classification ===== */
.tier-list {
  display: grid;
  gap: 8px;
}
.tier {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px 14px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  flex-wrap: wrap;
}
.tier .band {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
}
.tier-input {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
}
.tier-input .money-input {
  flex: 1;
}
.chg-preview {
  display: grid;
  gap: 4px;
  max-height: 320px;
  overflow: auto;
}
.chg-preview > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
}

/* Feature switches (Quản trị hệ thống → Bật / tắt tính năng) */
.feature-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  cursor: pointer;
}
.feature-row .nic {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.feature-row.off b {
  color: var(--muted);
}
.switch {
  position: relative;
  flex-shrink: 0;
  width: 46px;
  height: 26px;
  margin-top: 4px;
}
.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.switch i {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: var(--line-2);
  transition: background 0.15s;
  pointer-events: none;
}
.switch i::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s;
}
.switch input:checked + i {
  background: var(--ok, #157f3c);
}
.switch input:checked + i::after {
  transform: translateX(20px);
}
.switch input:focus-visible + i {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Active / inactive field in forms (components.js → ActiveSwitch) */
.active-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.active-switch .switch {
  margin-top: 0;
}
.active-switch.is-on {
  border-color: color-mix(in srgb, var(--ok) 35%, var(--line));
  background: var(--ok-soft);
}
.active-switch.is-off {
  background: var(--off-soft);
}
.active-switch:has(input:disabled) {
  cursor: default;
  opacity: 0.75;
}
.active-switch:has(input:disabled) input {
  cursor: default;
}
.active-switch:has(input:focus-visible) {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.as-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}
.as-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}
.as-state .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--off);
}
.active-switch.is-on .as-state {
  color: var(--ok);
}
.active-switch.is-on .dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
}
.active-switch.is-off .as-state {
  color: var(--muted);
}
.as-hint {
  font-size: 0.8125rem;
  color: var(--muted);
}
@media (prefers-reduced-motion: reduce) {
  .active-switch,
  .switch i,
  .switch i::after {
    transition: none;
  }
}

/* =====================================================================
   List toolkit (js/list-kit.js): filter bar, filter panel, summary strips, data table, list cards
   ===================================================================== */
.lk-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.lk-row {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}
.lk-search {
  flex: 1 1 auto;
  min-width: 0;
}
/* Our own clear button replaces the browser's */
.lk-search input::-webkit-search-cancel-button,
.lk-fsearch input::-webkit-search-cancel-button {
  display: none;
}
.lk-fbtn {
  flex-shrink: 0;
  height: 42px;
  padding: 0 14px;
}
.lk-fbtn.on {
  border-color: var(--ink);
}
.lk-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 11.5px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  font-variant-numeric: tabular-nums;
}
.lk-sort {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}
.lk-sort .input {
  height: 42px;
  width: auto;
  max-width: 220px;
}
.lk-sort .btn.icon-only {
  height: 42px;
  width: 42px;
}
.chips.lk-views .chip .icon {
  width: 14px;
  height: 14px;
  margin-right: 4px;
  vertical-align: -2px;
}
.lk-chip-saved {
  border-style: dashed;
}
.lk-views .chip.zero:not(.on) {
  color: var(--muted);
  border-style: dashed;
}
/* Phones: the summary is one compact scrolling row of chips, so the first records stay above the fold */
@media (max-width: 639px) {
  :root .lk-summary {
    display: flex;
    gap: 6px;
    padding: 0;
    margin: 0;
    background: none;
    border: 0;
    box-shadow: none;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    padding-right: 24px;
  }
  :root .lk-summary::-webkit-scrollbar {
    display: none;
  }
  :root .lk-summary .lk-strip,
  :root .lk-summary .lk-strip-items {
    display: contents;
  }
  :root .lk-summary .lk-strip-t,
  :root .lk-summary .lk-bar-track,
  :root .lk-summary .lk-strip-sk {
    display: none;
  }
  :root .lk-summary .lk-si {
    padding: 4px 9px;
    font-size: 12.5px;
    gap: 5px;
    white-space: nowrap;
  }
  :root .lk-summary .lk-si-n {
    font-size: 13px;
  }
}
.lk-active {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  min-height: 26px;
  font-size: 13px;
}
.lk-count {
  color: var(--muted);
  margin-right: 4px;
}
.lk-count b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}
.lk-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  border: 1px solid var(--line-2);
  background: var(--surface);
  border-radius: 99px;
  padding: 3px 6px 3px 10px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
  min-width: 0;
}
.lk-tag:hover {
  border-color: var(--ink);
}
.lk-tag:focus-visible,
.lk-link:focus-visible,
.lk-si:focus-visible,
.dt-sort:focus-visible,
.dt-grp-b:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.lk-tag-k {
  color: var(--muted);
  white-space: nowrap;
}
.lk-tag-v {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lk-tag-n {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.lk-tag .icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
}
.lk-link {
  border: 0;
  background: none;
  padding: 3px 4px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.lk-link .icon {
  width: 14px;
  height: 14px;
}
.lk-link:hover {
  color: var(--ink);
}

/* Filter panel: bottom sheet (phone), dialog (tablet), right side panel (desktop) */
@media (min-width: 1024px) {
  .sheet-backdrop:has(> .sheet.side) {
    justify-content: flex-end;
    align-items: stretch;
    padding: 0;
    background: color-mix(in srgb, var(--backdrop) 35%, transparent);
  }
  .sheet.side {
    width: 400px;
    max-height: none;
    height: 100%;
    border-radius: 0;
    animation: lk-side 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .sheet.side .sheet-f {
    border-radius: 0;
  }
}
@keyframes lk-side {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
.lk-panel {
  display: flex;
  flex-direction: column;
}
.lk-sec {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lk-sec:first-child {
  padding-top: 0;
}
.lk-sec:last-child {
  border-bottom: 0;
}
.lk-sec h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.lk-sec-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sheet-b .lk-fsearch,
.lk-fsearch {
  height: 36px;
  box-shadow: none;
}
.lk-opts {
  display: flex;
  flex-direction: column;
  max-height: 264px;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 -6px;
}
.lk-opts.plain {
  max-height: none;
}
.lk-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 6px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 14px;
  min-height: 38px;
}
.lk-opt:hover {
  background: var(--surface-2);
}
.lk-opt input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.lk-opt.on .lk-ol {
  font-weight: 600;
}
.lk-opt.zero {
  color: var(--muted);
}
.lk-ol {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lk-n {
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  margin-left: 6px;
}
.lk-ogrp {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  padding: 8px 6px 2px;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}
.lk-none {
  padding: 6px;
  margin: 0;
}
.lk-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--line-2);
}
.lk-dot.sq {
  border-radius: 3px;
}
.lk-dot.ok {
  background: var(--ok);
}
.lk-dot.warn {
  background: var(--warn);
}
.lk-dot.bad {
  background: var(--bad);
}
.lk-dot.info {
  background: var(--info);
}
.lk-dot.off {
  background: var(--off);
}
.lk-seg-wrap {
  flex-wrap: wrap;
}
.lk-seg-wrap button {
  flex: 1 1 auto;
}
.lk-range {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}
.lk-sortrow {
  display: grid;
  gap: 8px;
}
.lk-saved-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.lk-saved {
  display: inline-flex;
  align-items: center;
  border: 1px dashed var(--line-2);
  border-radius: 99px;
  background: var(--surface);
}
.lk-saved.on {
  border-style: solid;
  border-color: var(--ink);
}
.lk-saved button {
  border: 0;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 4px 5px 10px;
}
.lk-saved button.lk-x {
  padding: 5px 8px 5px 2px;
  color: var(--muted);
}
.lk-saved .icon {
  width: 14px;
  height: 14px;
}
.lk-tags-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Summary strips (counts by status / class; click = filter) */
.lk-summary {
  padding: 12px 14px;
  display: grid;
  gap: 12px;
}
.lk-strip {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.lk-strip-t {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.lk-strip-items {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
}
.lk-strip-items::-webkit-scrollbar {
  display: none;
}
.lk-strip-sk {
  height: 34px;
  width: 60%;
  border-radius: var(--r-sm);
  background: var(--surface-3);
}
.lk-si {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition:
    border-color 0.12s,
    opacity 0.12s;
}
.lk-si:hover {
  border-color: var(--line-2);
}
.lk-si.on {
  border-color: var(--ink);
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.lk-si.dim {
  opacity: 0.6;
}
.lk-si-n {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-size: 14px;
}
.lk-si-p {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.lk-strip.v-tiles .lk-si.tone-warn .lk-si-n {
  color: var(--warn);
}
.lk-strip.v-tiles .lk-si.tone-bad .lk-si-n {
  color: var(--bad);
}
.lk-bar-track {
  display: flex;
  height: 8px;
  border-radius: 99px;
  overflow: hidden;
  background: var(--surface-3);
  gap: 2px;
}
.lk-bar-track span {
  display: block;
  min-width: 3px;
  transition:
    width 0.3s ease,
    opacity 0.12s;
}
.lk-bar-track span.dim {
  opacity: 0.3;
}
@media (min-width: 1024px) {
  .lk-summary {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
  }
  .lk-strip-items {
    flex-wrap: wrap;
    overflow: visible;
  }
}

/* Data table */
.tbl.dt {
  /* clip (not a scroll container) keeps the header sticky against the page scroll */
  overflow: clip;
}
.dt .t th {
  top: var(--topbar-h);
  z-index: 2;
  box-shadow: 0 1px 0 var(--line);
}
.dt-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.dt-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}
.dt-group .input {
  height: 32px;
  width: auto;
  font-size: 13px;
  padding-block: 0;
}
.dt-cols {
  position: relative;
}
.dt-density {
  padding: 2px;
}
.dt-density button {
  min-height: 26px;
  padding: 2px 10px;
  font-size: 12.5px;
}
.lk-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
}
.lk-pop .lk-opt {
  min-height: 34px;
  font-size: 13.5px;
}
.lk-pop .lk-link {
  align-self: flex-end;
  margin: 4px;
}
.dt-sort {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.dt-sort .icon {
  width: 14px;
  height: 14px;
  opacity: 0;
  transition: opacity 0.12s;
}
.dt-sort:hover .icon {
  opacity: 0.5;
}
.dt-sort.on {
  color: var(--ink);
}
.dt-sort.on .icon {
  opacity: 1;
}
.t th.num .dt-sort {
  flex-direction: row-reverse;
}
.dt .t tbody tr[data-row]:nth-child(even of [data-row]) td {
  background: color-mix(in srgb, var(--surface-2) 70%, var(--surface));
}
@media (hover: hover) {
  .dt .t tbody tr[data-row]:hover td {
    background: var(--surface-3);
  }
}
.dt .t tbody tr[data-row]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.dt .t tbody tr.sel td {
  background: var(--primary-soft);
}
.dt .t tbody tr:last-child td {
  border-bottom: 1px solid var(--line);
}
.dt .t tbody:last-of-type tr:last-child td {
  border-bottom: 0;
}
.dt.compact .t td {
  padding-block: 5px;
}
.dt.compact .thumb {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}
.dt.compact .dt-prime .cell-sub {
  display: none;
}
.dt-sel {
  width: 40px;
}
.dt-sel input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
}
.dt .t tr.dt-grp td {
  background: var(--surface-3);
  padding: 0;
}
.dt-grp-b {
  width: 100%;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  text-align: left;
}
.dt-grp-b .icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: transform 0.15s;
}
.dt-grp-b .icon.open {
  transform: rotate(90deg);
}
.dt-grp-n {
  margin-left: auto;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
/* The primary column takes the width the other (single-line) columns leave, so nothing is clipped */
.dt .t td.dt-primary {
  width: 100%;
  max-width: 0;
  min-width: 220px;
}
.dt .t td:not(.dt-primary) {
  white-space: nowrap;
}
.dt-prime {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.dt-prime-t {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.dt-prime .cell-main {
  color: var(--ink);
  display: block;
}
.dt-prime .cell-main:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.dt-prime .cell-sub .mono {
  font-size: 12px;
  color: var(--text-2);
}
.dt-loc {
  white-space: nowrap;
  font-size: 13.5px;
}
.dt-loc .st {
  margin-left: 6px;
}
.t td.nowrap {
  white-space: nowrap;
}

/* Phone / tablet cards */
.lk-card .lk-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.lk-card .lk-card-top .st {
  flex-shrink: 0;
}
.lk-card .name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lk-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--text-2);
  min-width: 0;
}
.lk-fact {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}
.lk-fact .icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
}
.lk-fact.warn,
.lk-fact.warn .icon {
  color: var(--warn);
}
.lk-ghead {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 2px 2px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-2);
  grid-column: 1 / -1;
}

/* Empty result: name the filters that exclude everything */
.lk-empty {
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  color: var(--text-2);
}
.lk-empty > .icon {
  width: 40px;
  height: 40px;
  padding: 9px;
  border-radius: 12px;
  background: var(--surface-3);
  color: var(--muted);
  box-sizing: content-box;
}
.lk-empty p {
  max-width: 560px;
  color: var(--muted);
  font-size: 13.5px;
}
.lk-empty-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 720px;
}

/* List toolkit: the filter bar takes the full toolbar width (search box never collapses) */
.toolbar > .lk-bar {
  flex: 1 1 100%;
}

/* List pager: "Hiển thị 51–100 / 166" · page size · numbered pages */
.lk-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  width: 100%;
  font-size: 13px;
  color: var(--text-2);
}
.lk-pager.only-mobile {
  padding: 12px 2px 4px;
}
.lk-pg-info b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.lk-pg-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}
.lk-pg-size .input {
  width: auto;
  height: 32px;
  padding: 0 28px 0 10px;
  font-size: 13px;
}
.lk-pg-nums {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}
.lk-pg-nums .btn {
  min-width: 34px;
  height: 32px;
  padding: 0 8px;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
.lk-pg-n.on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
  font-weight: 700;
}
.lk-pg-gap {
  min-width: 18px;
  text-align: center;
  color: var(--muted);
}
@media (max-width: 639px) {
  .lk-pg-nums {
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }
  .lk-pg-nums .btn {
    min-width: 38px;
    height: 38px;
  }
}

/* Asset form: the picked item of the master catalog (assets.js → AssetForm) */
.catalog-pick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.catalog-pick > span:not(.cls) {
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text-2, var(--muted));
  font-size: 12.5px;
}
.add-catalog {
  justify-self: start;
  align-self: flex-start;
  margin-top: 6px;
}

/* Work mode switch in the sidebar (main.js, core.js hasModes): Kiểm kê | Nhập dữ liệu */
.mode-switch {
  margin: 0 14px 8px;
  background: var(--sidebar-2);
}
.mode-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 6px;
  color: var(--sidebar-muted);
  min-height: 34px;
  font-size: 12.5px;
  white-space: nowrap;
}
.mode-switch button .icon {
  width: 15px;
  height: 15px;
}
.mode-switch button:hover {
  color: #fff;
}
.mode-switch button.on {
  background: var(--sidebar-active);
  color: #fff;
  box-shadow: none;
}
.mode-switch button.on .icon {
  color: var(--brand-on-dark);
}
