/* ============================================
   Gạo Nâu brand identity — ported from GNPF (master, frontend/src/styles/
   tokens.css + brand-art.css, 29/09/2026). Same token names and values so the
   two apps stay visually in sync; fonts and brand art are vendored locally
   (fonts/, brand/) — this UI loads nothing from a CDN.
   ============================================ */

@font-face {
  font-family: "Be Vietnam Pro";
  src: url("fonts/be-vietnam-pro-400.woff2") format("woff2");
  font-weight: 400 500;
  font-display: swap;
}
@font-face {
  font-family: "Be Vietnam Pro";
  src: url("fonts/be-vietnam-pro-600.woff2") format("woff2");
  font-weight: 600 700;
  font-display: swap;
}
/* Le Jour Serif is capitals-only — headings. */
@font-face {
  font-family: "GN Art";
  src: url("fonts/le-jour-serif.woff2") format("woff2");
  font-display: swap;
}
/* Same file, digits and separators only: big numbers (clock, codes) get the
   serif, everything else falls back to Be Vietnam Pro. */
@font-face {
  font-family: "GN So";
  src: url("fonts/le-jour-serif.woff2") format("woff2");
  font-display: swap;
  unicode-range: U+0030-0039, U+002C, U+002E, U+002F, U+003A, U+0025;
}

/* Manrope — the brand's text face on printed labels (approved mock-up
   29/09/2026); the app itself stays on Be Vietnam Pro. */
@font-face { font-family: "Manrope"; src: url("fonts/manrope-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("fonts/manrope-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("fonts/manrope-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  /* Surfaces — cream tones */
  --color-bg: #f5f0e8;
  --color-surface: #ffffff;
  --color-surface-2: #faf7f2;
  --color-surface-3: #f0ebe3;

  /* Borders */
  --color-border: #e0d8cc;
  --color-border-light: #d5ccc0;
  --color-border-strong: #b5a894;

  /* Text */
  --color-text: #1a1a1a;
  --color-text-secondary: #666666;
  --color-text-muted: #686868;
  --color-text-dim: #8a8a8a;

  /* Brand — Brown Gold */
  --color-brand: #8b6914;
  --color-brand-light: #a07820;
  --color-brand-dark: #6b5010;

  /* Semantic — pastel for backgrounds/borders, -text for readable copy */
  --color-success-bg: rgba(107, 158, 122, 0.1);
  --color-success-text: #357049;
  --color-danger-bg: rgba(193, 124, 116, 0.1);
  --color-danger-text: #96463d;
  --color-warning: #c9a96e;
  --color-warning-bg: rgba(201, 169, 110, 0.1);
  --color-warning-text: #76601b;
  --color-info-bg: rgba(123, 167, 194, 0.1);
  --color-info-text: #376683;

  --color-raisin: #231f20;
  --color-cream: #ebe2c7;

  /* Typography */
  --font-body: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-art: "GN Art", Georgia, serif;
  --font-numeral: "GN So", var(--font-body);

  /* Spacing / sizing */
  --space-page-x: 16px;
  --space-page-y: 16px;
  --touch-min: 44px;
  --sidebar-w: 260px;
  --header-h: 56px;

  /* Radius */
  --radius-md: 8px;
  --radius-lg: 10px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);
  --shadow-brand: 0 2px 12px rgba(139, 105, 20, 0.12);

  /* Brand art */
  --gn-foil: linear-gradient(115deg, #8c6a2f 0%, #d9c28a 38%, #f3e6c0 50%, #c9a965 62%, #8c6a2f 100%);
  --gn-gold: #bfa06a;
  --gn-cream: #fffef5;
  /* Menu column: brand brown with the G-monogram tile fading in at the bottom. */
  --gn-sidebar-bg:
    linear-gradient(to bottom, var(--color-brand) 55%, transparent 100%),
    url("brand/hoa-van-lat-kem.svg") 0 0 / 120px auto repeat,
    var(--color-brand);
  /* Login brand panel: brand brown deepening to brand-dark bottom-right. */
  --gn-panel-bg: linear-gradient(122deg, #8b6914 0%, #8b6914 35%, #7a5b12 75%, #6b5010 100%);
}

@media (min-width: 768px) {
  :root {
    --space-page-x: 24px;
    --space-page-y: 24px;
  }
}

* { box-sizing: border-box; }

/* The theme is light-only: keep native form controls light on a dark-mode OS. */
html { color-scheme: light; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }

/* ---------- Brand art primitives (see GNPF BrandArt.tsx) ---------- */

/* A brand shape painted in currentColor through a mask of the original file. */
.gn-mark {
  display: block;
  pointer-events: none;
  background-color: currentColor;
  -webkit-mask: var(--gn-src) center / contain no-repeat;
  mask: var(--gn-src) center / contain no-repeat;
}

/* A repeating pattern filling its (positioned) parent, fading out via --gn-fade. */
.gn-tile {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-color: currentColor;
  -webkit-mask-image: var(--gn-src), var(--gn-fade, linear-gradient(to bottom left, #000, transparent 65%));
  -webkit-mask-size: var(--gn-size, 200px), 100% 100%;
  -webkit-mask-repeat: repeat, no-repeat;
  -webkit-mask-composite: source-in;
  mask-image: var(--gn-src), var(--gn-fade, linear-gradient(to bottom left, #000, transparent 65%));
  mask-size: var(--gn-size, 200px), 100% 100%;
  mask-repeat: repeat, no-repeat;
  mask-composite: intersect;
}

/* A thin repeating horizontal strip (rice grains / lattice). */
.gn-band {
  display: block;
  pointer-events: none;
  height: var(--gn-h, 10px);
  background-color: currentColor;
  -webkit-mask: var(--gn-src) 0 50% / auto 100% repeat-x;
  mask: var(--gn-src) 0 50% / auto 100% repeat-x;
}

/* ---------- Login screen (GNPF login.tsx + LoginBrandPanel.tsx) ---------- */

#login-view {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.login-brand {
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  padding: 36px 28px 32px;
  color: var(--gn-cream);
  background: var(--gn-panel-bg);
}
.login-brand > *:not(.gn-mark):not(.gn-tile) { position: relative; }

.login-brand .tall-lettering {
  position: absolute;
  right: -96px;
  top: 24px;
  width: 560px;
  height: 520px;
  color: rgba(255, 254, 245, 0.1);
  --gn-src: url("brand/art/chu-gao-nau-dung.png");
}
.login-brand .rice-scatter {
  color: rgba(255, 254, 245, 0.15);
  --gn-src: url("brand/art/hat-gao-rac.png");
  --gn-size: 260px;
  --gn-fade: linear-gradient(to bottom left, #000, transparent 60%);
}

.login-brand h1 { margin: 0; }
.login-brand .lockup { display: flex; align-items: center; gap: 16px; }
.login-brand .lockup .monogram { height: 56px; width: auto; }
.login-brand .lockup .wordmark { height: 34px; width: auto; }
.login-brand .eyebrow {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.login-clock { margin-top: 28px; }
.login-clock time {
  display: block;
  font-family: var(--font-numeral);
  font-size: 64px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
}
.login-clock .solar { margin: 8px 0 0; font-size: 15px; }
.login-clock .lunar { margin: 4px 0 0; font-size: 13px; }

.login-intro { margin: 24px 0 0; max-width: 520px; font-size: 15px; line-height: 1.625; }

.login-quote { margin: 24px 0 0; max-width: 520px; padding-left: 20px; }
.login-quote::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 2px;
  background: var(--gn-foil);
}
.login-quote blockquote { margin: 0; font-size: 17px; font-weight: 500; line-height: 1.375; }

.login-form-side {
  position: relative;
  overflow: hidden;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
}
.login-form-side .lattice-band {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  color: var(--gn-gold);
  opacity: 0.5;
  --gn-src: url("brand/art/dai-hoa-thi.png");
  --gn-h: 22px;
}
.login-form-side .corner-g {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 190px;
  height: 150px;
  color: var(--gn-gold);
  opacity: 0.7;
  --gn-src: url("brand/art/goc-g.svg");
  -webkit-mask-position: left bottom;
  mask-position: left bottom;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 384px;
  padding: 32px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.login-card h2 {
  margin: 0 0 4px;
  font-family: var(--font-art);
  font-size: 30px;
  font-weight: 400;
  line-height: 1.25;
}
.login-card .sub { margin: 0 0 8px; font-size: 14px; color: var(--color-text-muted); }
.login-card .btn { width: 100%; margin-top: 20px; }

@media (min-width: 1024px) {
  #login-view { flex-direction: row; height: 100vh; }
  .login-brand {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 52%;
    padding: 72px 80px;
  }
  .login-brand .tall-lettering { right: -40px; top: -40px; width: 640px; height: 780px; }
  .login-brand .lockup .monogram { height: 84px; }
  .login-brand .lockup .wordmark { height: 52px; }
  .login-brand .eyebrow { margin-top: 12px; font-size: 13px; }
  .login-clock { margin-top: 0; }
  .login-clock time { font-size: 104px; }
  .login-clock .solar { font-size: 17px; }
  .login-clock .lunar { font-size: 14px; }
  .login-intro { margin-top: 32px; font-size: 17px; }
  .login-quote { margin-top: 0; }
  .login-quote blockquote { font-size: 22px; }
  .login-form-side .corner-g { width: 260px; height: 210px; }
}

/* ---------- App shell: brown menu column + white top bar (GNPF AppShell) ---------- */

#app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  width: var(--sidebar-w);
  height: 100vh;
  overflow-y: auto;
  background: var(--gn-sidebar-bg);
  color: rgba(255, 255, 255, 0.75);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.28); border-radius: 999px; }

@media (min-width: 768px) {
  .sidebar { display: flex; }
}

/* Phone: the same column slides in as a drawer from the left. */
.sidebar.open {
  display: flex;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  width: 280px;
  box-shadow: var(--shadow-lg);
}
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgba(0, 0, 0, 0.45);
}

.sidebar-brand { display: flex; align-items: flex-end; gap: 8px; padding: 16px 16px 12px; }
.sidebar-brand img { height: 35px; width: auto; min-width: 0; }
.sidebar-brand span {
  flex-shrink: 0;
  margin-bottom: 3px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.95);
}
.sidebar .rice-band {
  flex-shrink: 0;
  margin: 0 20px;
  color: rgba(217, 194, 138, 0.7);
  --gn-src: url("brand/art/dai-hat-gao.png");
  --gn-h: 9px;
}
.sidebar-close {
  position: absolute;
  top: 8px;
  right: 4px;
  display: none;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.95);
  cursor: pointer;
}
.sidebar-close svg { width: 20px; height: 20px; }
.sidebar.open .sidebar-close { display: inline-flex; }
/* Leave room for the close button beside the wordmark in the drawer. */
.sidebar.open .sidebar-brand { padding-right: 52px; }

.profile-card {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  background: rgba(0, 0, 0, 0.15);
}
.profile-card .avatar {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gn-cream);
  color: var(--color-brand-dark);
  font-size: 15px;
  font-weight: 700;
}
.profile-card .who { flex: 1; min-width: 0; }
.profile-card .name,
.profile-card .role { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.profile-card .name { font-size: 12px; font-weight: 700; color: #fff; }
.profile-card .role { font-size: 10px; color: rgba(255, 255, 255, 0.95); }

nav#tabs { flex: 1; padding: 12px 8px; }
.nav-group + .nav-group { margin-top: 12px; }
.nav-group-label {
  padding: 4px 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.95);
}
.nav-group-items { margin-top: 4px; }
nav#tabs button[data-tab] {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 2px 0;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: rgba(255, 255, 255, 0.95);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
nav#tabs button[data-tab]:hover { background: rgba(0, 0, 0, 0.1); color: #fff; }
/* Active item: cream pill + gold foil bar on the left edge. */
nav#tabs button[data-tab].active {
  background: var(--gn-cream);
  color: var(--color-brand-dark);
  font-weight: 600;
}
nav#tabs button[data-tab].active::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: -8px;
  width: 3px;
  border-radius: 999px;
  background: var(--gn-foil);
}
nav#tabs svg { flex-shrink: 0; width: 16px; height: 16px; }

.sidebar-footer { padding: 12px 20px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.sidebar-footer #logout-btn {
  width: 100%;
  margin-bottom: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.12);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.sidebar-footer #logout-btn:hover { background: rgba(0, 0, 0, 0.2); }
.sidebar-footer .copyright { font-size: 10px; text-align: center; color: rgba(255, 255, 255, 0.95); }

.app-main { display: flex; flex: 1; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: var(--header-h);
  padding: 6px 8px 6px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.topbar h1 {
  overflow: hidden;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 4px; min-width: 0; }
#active-branch-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
#active-branch-wrap label { margin: 0; white-space: nowrap; }
#active-branch-select { width: auto; max-width: 240px; }
.menu-btn {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: var(--color-text);
  cursor: pointer;
}
.menu-btn:hover { background: var(--color-surface-2); }
.menu-btn svg { width: 20px; height: 20px; }

@media (min-width: 768px) {
  .topbar { padding: 8px 24px; }
  .topbar h1 { font-size: 20px; }
  .menu-btn { display: none; }
}
@media (max-width: 767px) {
  #active-branch-wrap label { display: none; }
  #active-branch-select { max-width: 160px; }
}

main#app { width: 100%; max-width: 960px; padding: var(--space-page-y) var(--space-page-x); }

.tab { display: none; }
.tab.active { display: block; }

/* ---------- Content ---------- */

.card {
  margin-bottom: 16px;
  padding: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.card h4 { margin: 12px 0 4px; font-size: 14px; font-weight: 600; }

hr { margin: 16px 0; border: none; border-top: 1px solid var(--color-border); }

label {
  display: block;
  margin: 12px 0 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
}

input, select, textarea, button { font-family: inherit; font-size: 14px; }

input[type="text"], input[type="password"], input[type="datetime-local"],
input[type="number"], input[type="date"], input[type="url"],
input[type="file"], select, textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--color-text-dim); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 1px var(--color-brand);
}
input[type="checkbox"] { accent-color: var(--color-brand); }

textarea { min-height: 72px; resize: vertical; }

button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  margin-top: 12px;
  padding: 7px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--color-brand);
  color: #fff;
  font-weight: 600;
  line-height: 1.375;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
button.btn:hover { background: var(--color-brand-light); box-shadow: var(--shadow-brand); }
button.btn:active { background: var(--color-brand-dark); }
button.btn.secondary {
  border-color: var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
}
button.btn.secondary:hover { border-color: var(--color-border-light); background: var(--color-surface-3); box-shadow: var(--shadow-sm); }
button.btn.danger { background: var(--color-danger-text); }
button.btn.small { min-height: 32px; margin: 0; padding: 5px 12px; font-size: 12px; }
button.btn:disabled { opacity: 0.5; pointer-events: none; }
button.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--color-brand); }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row > * { flex: 1; }

.error { margin-top: 8px; font-size: 13px; color: var(--color-danger-text); white-space: pre-wrap; }
.hint { margin-top: 4px; font-size: 12px; color: var(--color-text-muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--color-border); }
th { font-size: 12px; font-weight: 600; color: var(--color-text-secondary); background: var(--color-surface-2); }
td .btn { margin: 2px; white-space: nowrap; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.in_stock, .badge.verified { background: var(--color-success-bg); color: var(--color-success-text); }
.badge.pending_tag, .badge.pending, .badge.flagged { background: var(--color-warning-bg); color: var(--color-warning-text); }
.badge.checked_out, .badge.under_inspection { background: var(--color-info-bg); color: var(--color-info-text); }
.badge.maintenance, .badge.lost { background: var(--color-danger-bg); color: var(--color-danger-text); }
.badge.retired, .badge.scanned { background: var(--color-surface-3); color: var(--color-text-secondary); }
.badge.rejected { background: var(--color-danger-bg); color: var(--color-danger-text); text-decoration: line-through; }
.badge.flagged { margin-left: 6px; }
/* Due states for checked-out equipment (GET /api/loans). */
.badge.overdue { background: var(--color-danger-bg); color: var(--color-danger-text); }
.badge.due_soon { background: var(--color-warning-bg); color: var(--color-warning-text); }
.badge.on_time { background: var(--color-success-bg); color: var(--color-success-text); }
.badge.no_due { background: var(--color-surface-3); color: var(--color-text-secondary); }
/* Overview KPI tiles — each one opens its detailed list. */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.kpi-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 12px; border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  background: var(--color-surface-2); color: var(--color-text); text-align: left; cursor: pointer;
  font-family: inherit;
}
.kpi-card:hover { border-color: var(--color-border-strong); }
.kpi-card .kpi-value { font-size: 24px; font-weight: 700; color: var(--color-brand-dark); }
.kpi-card .kpi-label { font-size: 12px; color: var(--color-text-secondary); }
.kpi-card.alert { background: var(--color-danger-bg); border-color: var(--color-danger-text); }
.kpi-card.alert .kpi-value { color: var(--color-danger-text); }
/* One returned item's evidence form at the gate. */
.evidence-row { padding: 8px 0; border-bottom: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 6px; }
.evidence-row .name { font-size: 13px; font-weight: 600; }
/* ---------- Equipment list: a row expands into the full profile ---------- */
.asset-row { cursor: pointer; }
.asset-row:hover td, .asset-row.open td { background: var(--color-surface-2); }
.asset-row.open td { border-bottom-color: transparent; }
.asset-row:focus-visible { outline: 2px solid var(--color-brand); outline-offset: -2px; }
.asset-row .chev { display: inline-block; width: 14px; color: var(--color-brand); font-size: 18px; font-weight: 700; transition: transform 0.2s ease-out; }
.asset-row.open .chev { transform: rotate(90deg); }
.asset-thumb { display: block; width: 40px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--color-border); background: var(--color-surface-3); }
.asset-thumb.empty { display: grid; place-items: center; border-style: dashed; border-color: var(--color-border-strong); background: none; font-size: 9px; line-height: 1.2; text-align: center; color: var(--color-text-dim); }
.m-name { display: none; }
.asset-table .col-code strong { white-space: nowrap; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions .btn, .detail-actions .btn { min-height: 40px; padding: 8px 16px; font-size: 14px; }
td .row-actions .btn { margin: 0; }

.asset-detail > td { padding: 0 0 20px; background: var(--color-surface-2); }
.asset-detail-inner { padding: 16px 20px 4px; border-left: 3px solid var(--color-brand); }
.sec-title { margin: 22px 0 10px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-brand-dark); }
.asset-detail-inner > .sec-title:first-child { margin-top: 4px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 24px; }
.info .k { font-size: 12px; color: var(--color-text-muted); }
.info .v { margin-top: 2px; font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.info .v a, .link-btn { color: var(--color-brand); }
.link-btn { padding: 0; border: none; background: none; font: inherit; text-decoration: underline; cursor: pointer; text-align: left; }
.invoice-item { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.info .v > .btn { margin-top: 4px; }
.battery-bar { width: 160px; max-width: 100%; height: 8px; margin-top: 6px; overflow: hidden; border-radius: 999px; background: var(--color-surface-3); }
.battery-bar > span { display: block; height: 100%; background: var(--color-success-text); }
.battery-bar.low > span { background: var(--color-danger-text); }
.notes-box, .recent-list { border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); }
.notes-box { padding: 12px 14px; font-size: 14px; white-space: pre-wrap; }
.recent-list .scanned-item { padding: 10px 14px; }
.loan-box { margin-bottom: 12px; padding: 12px 14px; border: 1px solid rgba(123, 167, 194, 0.35); border-radius: var(--radius-lg); background: var(--color-info-bg); font-size: 14px; }
.profile-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 24px; }
.profile-form .wide { grid-column: 1 / -1; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--color-border); }
.detail-row-actions { display: none; flex-wrap: wrap; gap: 8px; }
.detail-row-actions [data-profile-id] { display: none; } /* the open profile is already open */

/* Photos: the frame hugs each picture (fitPhoto sets the exact size —
   long side 384px); this is only the placeholder while it loads. */
.gallery { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; margin: 6px 0; }
.gallery-item { position: relative; max-width: 100%; min-height: 48px; } /* room for the Gỡ button on very wide panoramas */
.gallery-item img { display: block; max-width: 100%; border-radius: var(--radius-lg); border: 1px solid var(--color-border); background: var(--color-surface-3); cursor: zoom-in; }
.gallery-item img:not(.sized) { width: 256px; height: 256px; }
.gallery-remove { position: absolute; top: 8px; right: 8px; min-height: 32px; padding: 4px 12px; border: 1px solid var(--color-border); border-radius: 999px; background: rgba(255, 255, 255, 0.92); font: inherit; font-size: 13px; cursor: pointer; }
.gallery-add { display: grid; place-content: center; width: 256px; height: 256px; border: 2px dashed var(--color-border-strong); border-radius: var(--radius-lg); background: var(--color-surface); color: var(--color-brand); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.gallery-add small { display: block; margin-top: 4px; font-size: 12px; font-weight: 400; color: var(--color-text-muted); }

@media (max-width: 767px) {
  .asset-table .col-name, .asset-table .col-actions { display: none; }
  .m-name { display: block; margin-top: 2px; font-weight: 400; }
  .asset-table th, .asset-table td { padding-left: 4px; padding-right: 4px; }
  .asset-row td:first-child, .asset-table th:first-child { padding-right: 0; }
  .asset-detail-inner { padding: 12px 10px 4px; }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-form { grid-template-columns: minmax(0, 1fr); }
  .detail-row-actions { display: flex; }
  .gallery-add { width: 100%; height: 96px; }
}
@media (prefers-reduced-motion: reduce) { .asset-row .chev { transition: none; } }

/* Overdue count next to a sidebar item. */
.nav-count {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--color-danger-text);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.review-actions { display: inline-flex; gap: 6px; margin-left: 8px; }

.resolution-menu {
  margin: 4px 0 12px;
  padding: 8px 10px;
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-md);
  background: var(--color-warning-bg);
}

pre.result {
  overflow-x: auto;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--color-raisin);
  color: var(--color-cream);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.scanned-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
}
.scanned-item .name { font-size: 13px; font-weight: 600; }
.scanned-item .epc { font-size: 12px; color: var(--color-text-muted); }

.code-display {
  margin: 8px 0;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  color: var(--color-brand-dark);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 4px;
  text-align: center;
}

/* ---------- Full-screen camera / QR overlay ---------- */

.qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 50; /* clear of the top bar (10) and the menu drawer (40) */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(35, 31, 32, 0.92);
}
.qr-overlay video { width: 100%; max-width: 480px; border-radius: var(--radius-md); }
.qr-overlay img { width: 90%; max-width: 480px; padding: 16px; border-radius: var(--radius-md); background: #fff; }

.qr-scan-feedback {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: 90%;
  overflow: hidden;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(53, 112, 73, 0.95); /* --color-success-text */
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.9);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.qr-scan-feedback.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.qr-scan-feedback.warn { background: rgba(118, 96, 27, 0.95); } /* --color-warning-text */

/* ---------- Single-screen pages (gate kiosk, public tag page) ---------- */

.brand-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 14px 20px 12px;
  background: var(--gn-panel-bg);
  color: var(--gn-cream);
}
.brand-header .brand-lockup { display: flex; align-items: flex-end; gap: 8px; margin: 0; }
.brand-header .brand-lockup img { height: 30px; width: auto; }
.brand-header .brand-lockup span {
  margin-bottom: 2px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 2px;
}
.brand-header .brand-side { font-size: 13px; font-weight: 500; color: rgba(255, 254, 245, 0.95); }
.rice-strip {
  margin: 10px 20px 0;
  color: var(--gn-gold);
  opacity: 0.6;
  --gn-src: url("brand/art/dai-hat-gao.png");
  --gn-h: 9px;
}

.single-page main,
.single-page #key-entry-view { max-width: 720px; margin: 0 auto; padding: var(--space-page-y) var(--space-page-x); }

/* tag.html — the public, unauthenticated QR-landing page */
.tag-page main { max-width: 420px; }
.tag-page .card { text-align: center; }
/* t.html — what a pre-printed label's QR opens (public side: owner + code only) */
.t-owner { margin: 8px 0 0; font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--color-text-muted); }
.t-brand { margin: 4px 0 8px; font-family: var(--font-art); font-size: 34px; font-weight: 400; color: var(--color-brand-dark); }
.t-code { margin: 8px 0; font-size: 22px; font-weight: 700; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }

/* ---------- Phones: comfortable touch targets, readable text ---------- */

@media (max-width: 767px) {
  /* iOS zooms in on focused fields under 16px. */
  input, select, textarea { font-size: 16px; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea { min-height: var(--touch-min); }
  button.btn { min-height: var(--touch-min); }
  input[type="checkbox"] { width: 18px; height: 18px; }
  /* Fields sharing a row wrap onto their own line instead of being squeezed
     to a sliver (e.g. type + date + actor in "Ghi bổ sung"). */
  .row > input, .row > select { flex: 1 1 160px; }
}

/* In-section view toggle (Phân quyền: Người có quyền / Nhật ký) */
.subtabs { gap: 8px; }
.subtabs .btn { flex: none; }
/* Beats button.btn.secondary:hover too, so the active tab never turns cream-on-white under the cursor. */
.subtabs button.btn.active,
.subtabs button.btn.active:hover { background: var(--color-brand); color: #fff; border-color: var(--color-brand); }

/* Phân quyền on phones: each grant becomes a stacked card (CEO 2b, 29/09/2026)
   so "Thu quyền" sits under the name instead of off-screen to the right. */
@media (max-width: 767px) {
  .grants-table, .grants-table tbody, .grants-table tr, .grants-table td { display: block; width: 100%; }
  .grants-table tr:first-child { display: none; }
  .grants-table tr { padding: 12px 0; border-bottom: 1px solid var(--color-border); }
  .grants-table td { border: none; padding: 2px 0; }
  .grants-table td:first-child { font-weight: 600; margin-bottom: 4px; }
  .grants-table td[data-label]::before { content: attr(data-label) ": "; color: var(--color-text-muted); font-weight: 400; }
  .grants-table td:last-child { padding-top: 8px; }
}

/* ---------- In tem: reserve, batches, print options (labels.js) ---------- */
.req { color: var(--color-danger-text); }
.lp-mono { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.intake-banner { margin: 12px 0 4px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--color-success-bg); color: var(--color-success-text); font-size: 13px; }
.intake-banner .hint { color: inherit; opacity: 0.85; }
.batch-item { cursor: pointer; }
.batch-item:hover, .batch-item:focus-visible { background: var(--color-surface-2); outline: none; }
.batch-main { flex: 1; min-width: 0; }
.progress { height: 6px; margin: 6px 0 2px; overflow: hidden; border-radius: 999px; background: var(--color-surface-3); }
.progress > span { display: block; height: 100%; background: var(--color-brand); }
button.btn.void-btn { border-color: var(--color-border); background: var(--color-surface); color: var(--color-danger-text); }
button.btn.void-btn:hover { background: var(--color-danger-bg); box-shadow: none; }
.seg { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; border: 1px solid var(--color-brand); border-radius: var(--radius-md); }
.seg-opt { position: relative; margin: 0; padding: 10px 8px; background: var(--color-surface); color: var(--color-brand); font-size: 13px; font-weight: 600; text-align: center; cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt small { display: block; font-size: 11px; font-weight: 400; }
.seg-opt.on { background: var(--color-brand); color: #fff; }
.seg-opt:focus-within { outline: 2px solid var(--color-brand-dark); outline-offset: -3px; }
.sheet-mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; max-width: 220px; margin-top: 10px; padding: 6px; border: 1px solid var(--color-border); border-radius: 6px; background: var(--color-surface); }
.sheet-mini div { height: 14px; border-radius: 2px; background: var(--color-surface-3); }
.sheet-mini div.p { background: var(--color-brand); opacity: 0.75; }
.lp-offset { margin-top: 10px; font-size: 13px; }
.lp-offset summary { cursor: pointer; color: var(--color-text-secondary); }

/* Print preview overlay */
.print-overlay { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: rgba(35, 31, 32, 0.92); }
.po-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; background: var(--color-surface); }
.po-bar .btn { flex: none; margin: 0; }
.po-hint { flex: 1 1 240px; font-size: 13px; color: var(--color-text-secondary); }
.po-scroll { flex: 1; overflow: auto; padding: 16px; }
body.print-open { overflow: hidden; }
#print-root.print-a4 .lp-sheet { margin: 0 auto 16px; background: #fff; box-shadow: var(--shadow-lg); }
#print-root.print-thermal { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#print-root.print-thermal .lp-page-thermal { background: #fff; }

/* ---------- Printed labels, real size (approved mock-up 29/09/2026) ---------- */
.lp-sheet { position: relative; width: 210mm; height: 296mm; overflow: hidden; } /* 1 mm short of A4: no spill-over blank page */
.lp-grid { display: grid; grid-template-columns: repeat(3, 70mm); grid-template-rows: repeat(8, 37mm); padding-top: 0.5mm; transform: translate(var(--off-x, 0mm), var(--off-y, 0mm)); }
.lp-cell { overflow: hidden; }
@media screen { .lp-cell { outline: 1px dashed #d8ccb0; outline-offset: -1px; } }
.lp-a4, .lp-thermal { font-family: "Manrope", var(--font-body); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.lp-qr { display: block; }
.lp-qr path { fill: currentColor; }
.lp-a4 { display: grid; grid-template-columns: 29mm 1fr; gap: 2.6mm; width: 70mm; height: 37mm; padding: 3.5mm; color: #231f20; }
.lp-a4 .lp-qr { width: 29mm; height: 29mm; }
.lp-a4 .lp-side { display: flex; flex-direction: column; justify-content: space-between; min-width: 0; padding-left: 2.4mm; border-left: 0.25mm solid #ba9e69; }
.lp-a4 .lp-logo { display: block; width: 24mm; margin-left: -1mm; }
.lp-a4 .lp-type { overflow: hidden; font-family: var(--font-art); font-style: italic; font-size: 2.9mm; line-height: 1; color: #8e6126; white-space: nowrap; text-overflow: ellipsis; }
.lp-a4 .lp-prefix { margin-top: 1.4mm; font-size: 2.6mm; font-weight: 700; line-height: 1; letter-spacing: 0.04em; }
.lp-a4 .lp-num { font-size: 7.4mm; font-weight: 700; line-height: 0.95; letter-spacing: 0.01em; font-variant-numeric: tabular-nums; }
.lp-a4 .lp-url { font-size: 1.7mm; line-height: 1; letter-spacing: 0.02em; color: #555e34; }
.lp-page-thermal { width: 40mm; height: 29.8mm; overflow: hidden; } /* a hair short of the roll's 30 mm: no blank label */
.lp-thermal { display: grid; grid-template-columns: 19mm 1fr; grid-template-rows: auto auto; column-gap: 1.8mm; row-gap: 1mm; width: 40mm; height: 29.8mm; padding: 1.6mm 2mm; color: #000; }
.lp-thermal .lp-qr { width: 19mm; height: 19mm; }
.lp-thermal .lp-side { display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.lp-thermal .lp-logo { display: block; width: 100%; filter: brightness(0); }
.lp-thermal .lp-type { overflow: hidden; font-family: var(--font-art); font-style: italic; font-size: 2.5mm; line-height: 1; white-space: nowrap; text-overflow: ellipsis; }
.lp-thermal .lp-num { font-size: 6.2mm; font-weight: 700; line-height: 0.9; font-variant-numeric: tabular-nums; }
.lp-thermal .lp-code { grid-column: 1 / -1; padding-top: 0.8mm; border-top: 0.3mm solid #000; font-size: 3.3mm; font-weight: 700; line-height: 1; letter-spacing: 0.05em; text-align: center; }

/* Printing: only the preview's sheets, at real size, one sheet/label per page. */
@media print {
  body.print-open > :not(#print-overlay) { display: none !important; }
  body.print-open { overflow: visible; background: #fff; }
  body.print-open #print-overlay { position: static; display: block; background: none; }
  body.print-open .po-bar { display: none; }
  body.print-open .po-scroll { overflow: visible; padding: 0; }
  body.print-open #print-root { zoom: 1 !important; }
  body.print-open #print-root.print-thermal { display: block; }
  #print-root.print-a4 .lp-sheet { margin: 0; box-shadow: none; break-after: page; }
  #print-root .lp-page-thermal { break-after: page; }
  #print-root .lp-sheet:last-child, #print-root .lp-page-thermal:last-child { break-after: auto; }
}

/* ---------- Nhập từ tem (form C) + the status line above the Thiết bị cards ---------- */
.intake-status { margin-bottom: 16px; padding: 10px 14px; border-radius: var(--radius-md); font-size: 14px; white-space: pre-wrap; }
.intake-status.ok { background: var(--color-success-bg); color: var(--color-success-text); }
.intake-status.info { background: var(--color-info-bg); color: var(--color-info-text); }
.intake-status.error { background: var(--color-danger-bg); color: var(--color-danger-text); }
#intake-card #in-copy-btn { margin: 8px 0 0; }
.intake-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
/* Code and category are fixed by the label — shown locked like the approved
   mock-up (grey, not tappable; the code at 13px so GN-TYPE-0001 fits a phone). */
.intake-grid input[readonly] { background: var(--color-surface-3); color: var(--color-text-secondary); box-shadow: none; pointer-events: none; }
.intake-grid #in-code { font-size: 13px; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; font-size: 13px; font-weight: 400; color: var(--color-text-secondary); }
.intake-photos { display: flex; flex-wrap: wrap; gap: 8px; }
.intake-photo { position: relative; width: 72px; height: 72px; }
.intake-photo img { width: 100%; height: 100%; object-fit: cover; border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.intake-photo-remove { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; padding: 0; border: 1px solid var(--color-border); border-radius: 50%; background: #fff; font: inherit; line-height: 1; cursor: pointer; }
.intake-photo-add { flex: 1 1 160px; min-height: 72px; border: 1.5px dashed var(--color-border-strong); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-text-secondary); font: inherit; font-size: 13px; cursor: pointer; }
.intake-photo-add:disabled { opacity: 0.5; cursor: default; }
.intake-actions { display: grid; gap: 8px; margin-top: 12px; }
.intake-actions .btn { margin: 0; }

/* ---------- In lại tem cho món đã có (8a) ---------- */
.pick-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 4px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--color-warning-bg); color: var(--color-warning-text); }
.pick-bar .btn { flex: none; }
.pick-bar .hint { flex-basis: 100%; margin: 0; color: inherit; }
.asset-table .col-pick { width: 32px; text-align: center; }
.asset-table .col-pick input { margin: 0; }
/* ---------- Home: day pass, my loans, my history ---------- */

.dp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.dp-head h3 { margin: 0; }
.count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; margin-left: 4px;
  border-radius: 999px; background: var(--color-surface-3); color: var(--color-text-secondary); font-size: 12px;
}
.day-pass-card { text-align: center; }
.day-pass-card .dp-head { text-align: left; }
.dp-qr {
  width: min(260px, 72vw); aspect-ratio: 1; margin: 8px auto 4px; padding: 10px;
  background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius-md);
}
.dp-qr img, .zoom-qr img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.dp-name { margin-top: 8px; font-size: 18px; font-weight: 700; }
.dp-sub { font-size: 13px; color: var(--color-text-muted); }
.dp-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 4px; }
.dp-actions .btn { min-height: var(--touch-min); }
.day-pass-card .hint { max-width: 420px; margin: 12px auto 0; }
.history-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--color-border); cursor: pointer; }
.history-row:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.history-row .badge { min-width: 56px; justify-content: center; }
.history-row .h-main { flex: 1; }
.history-row .name { font-size: 13px; font-weight: 600; }
.history-row .epc { font-size: 12px; color: var(--color-text-muted); }
.history-row .chev { font-size: 20px; color: var(--color-text-dim); }

/* Zoomed day pass — plain white so any scanner reads it. */
.zoom-overlay { position: fixed; inset: 0; z-index: 60; overflow: auto; background: #fff; }
.zoom-sheet {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px 16px; text-align: center;
}
.zoom-name { font-size: 22px; font-weight: 700; }
.zoom-sub { font-size: 14px; color: var(--color-text-muted); }
.zoom-qr { width: min(88vw, 70dvh, 520px); aspect-ratio: 1; padding: 8px; }
.zoom-valid { font-size: 15px; }
.zoom-sheet .btn { min-width: 160px; min-height: 48px; }

/* ---------- Gate as an unattended scanner (gate.html) ---------- */

.kiosk .kiosk-main { max-width: 820px; }
.kiosk-wait { padding: 40px 24px; text-align: center; }
.kiosk-icon { width: 96px; height: 96px; margin: 0 auto 12px; color: var(--color-brand); }
.kiosk-title {
  margin: 0; font-family: var(--font-art); font-size: clamp(26px, 5vw, 40px); font-weight: 400;
  letter-spacing: 1px; color: var(--color-brand-dark);
}
.kiosk-lead { margin: 10px 0 24px; font-size: 17px; color: var(--color-text-secondary); }
.kiosk-input { display: flex; flex-wrap: wrap; gap: 10px; max-width: 560px; margin: 0 auto; }
.kiosk-input input[type="text"] { flex: 1 1 260px; min-height: 52px; font-size: 16px; }
.kiosk-input .btn { margin: 0; min-height: 52px; }
.kiosk-error {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding: 16px 20px;
  border: 1px solid rgba(150, 70, 61, 0.25); border-radius: var(--radius-lg);
  background: var(--color-danger-bg); color: var(--color-danger-text); font-size: 17px;
}
.kiosk-ok {
  margin-top: 12px; padding: 16px 20px; border-radius: var(--radius-lg);
  background: var(--color-success-bg); color: var(--color-success-text); font-size: 18px; font-weight: 600;
}
.kiosk-person { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.kp-avatar {
  display: flex; flex: none; align-items: center; justify-content: center; overflow: hidden;
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--color-brand); color: #fff; font-size: 30px; font-weight: 700;
}
.kp-avatar img { width: 100%; height: 100%; object-fit: cover; }
.kp-who { flex: 1; min-width: 180px; }
.kp-name { font-size: 24px; font-weight: 700; }
.kp-sub { font-size: 14px; color: var(--color-text-muted); }
.kiosk-person .btn { margin: 0; min-height: 48px; }
.num { font-variant-numeric: tabular-nums; }
.mode-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 72px;
  border: 2px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface-2);
  color: var(--color-text); font-size: 20px; font-weight: 700; cursor: pointer; touch-action: manipulation;
}
.mode.on { border-color: var(--color-brand); background: var(--color-brand); color: #fff; }
.mode:focus-visible, .chip:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.due-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.chip {
  min-height: 48px; padding: 0 18px; border: 1.5px solid var(--color-border); border-radius: 999px;
  background: var(--color-surface); color: var(--color-text); font-size: 15px; font-weight: 600;
  cursor: pointer; touch-action: manipulation;
}
.chip.on { border-color: var(--color-brand); background: var(--color-warning-bg); color: var(--color-brand-dark); }
button.btn.kiosk-confirm { min-height: 64px; font-size: 20px; }
.idle-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; bottom: 12px; padding: 14px 18px; border-radius: var(--radius-lg);
  background: var(--color-raisin); color: var(--color-cream); font-size: 16px;
}
.idle-bar .btn { margin: 0; min-width: 96px; min-height: 48px; }
@media (max-width: 767px) {
  .kp-name { font-size: 20px; }
  .mode { min-height: 60px; font-size: 17px; }
}

/* --- Kiểm kê: camera scan counter, scanned chips, clean result (AU1, AU7) --- */
.audit-counter { font-size: 15px; margin: 8px 0 12px; padding: 10px 12px; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 8px; }
.audit-counter strong { font-size: 20px; color: var(--color-brand-dark); }
.audit-paste { margin: 10px 0; }
.audit-paste summary { cursor: pointer; font-size: 13px; color: var(--color-text-secondary); }
.audit-paste textarea { margin-top: 8px; }
.audit-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; max-height: 180px; overflow-y: auto; }
.audit-chip { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--color-success-bg); color: var(--color-success-text); border: 1px solid transparent; }
.audit-chip.unknown { background: var(--color-warning-bg); color: var(--color-warning-text); }
.ok-box { padding: 10px 12px; border-radius: 8px; background: var(--color-success-bg); color: var(--color-success-text); font-weight: 600; margin: 8px 0; }

/* --- Toast (short "done" notice) --- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--color-text); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 1000; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.error { background: var(--color-danger-text); border-radius: 12px; white-space: pre-line; }

/* --- Cần tôi xử lý: explanation + inline fix (F1, F2) --- */
.flag-card { border: 1px solid var(--color-border); border-radius: 10px; padding: 12px; margin: 10px 0; background: var(--color-surface); }
.flag-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.flag-head .name { font-weight: 600; }
.flag-head .epc { font-size: 12px; color: var(--color-text-muted); }
.flag-why { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: var(--color-warning-bg); color: var(--color-warning-text); font-size: 14px; }
.flag-fix .row { flex-wrap: wrap; }

/* --- Từ chối cần lý do (R1) --- */
.reject-form { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; width: 100%; }
.reject-form input { flex: 1 1 220px; }
.reject-form .error { flex-basis: 100%; }

/* --- Thiết bị: list first, one search box, filters, count (A1, A2, A12) --- */
.asset-search { display: flex; gap: 8px; }
.asset-search input { flex: 1; font-size: 16px; }
.asset-search .btn { flex: none; }
.asset-filters { flex-wrap: wrap; }
.asset-filters select { flex: 1 1 160px; }
.asset-count { font-size: 13px; font-weight: 600; color: var(--color-text-secondary); margin: 6px 0; }
.m-sub { display: none; }
.warn-text { color: var(--color-danger-text); font-weight: 600; }
@media (max-width: 767px) {
  .m-sub { display: block; font-size: 12px; font-weight: 400; color: var(--color-text-muted); margin-top: 2px; white-space: normal; }
}

/* --- Đổi tình trạng (A5) --- */
.lock-box { margin: 10px 0; padding: 10px 12px; border-radius: 8px; background: var(--color-warning-bg); color: var(--color-warning-text); font-size: 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.status-change { margin: 8px 0 4px; }
.status-form { margin-top: 8px; padding: 10px; border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-surface-2); }
.status-form .row { flex-wrap: wrap; }
.status-form select { flex: 0 1 200px; }
.status-form input { flex: 1 1 240px; }

/* --- Đang cho mượn: row opens its batch, quick extend (L1) --- */
.loan-row.clickable { cursor: pointer; }
.loan-row.clickable:hover { background: var(--color-surface-2); }
.loan-row:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.loan-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* --- Cổng: scanned rows, red rows, remove button, outcome list (C1–C5) --- */
.scanned-item.blocked { background: var(--color-danger-bg); border-radius: 8px; padding-left: 8px; padding-right: 8px; }
.block-why { font-size: 13px; color: var(--color-danger-text); font-weight: 600; margin-top: 2px; }
.unscan-btn { flex: none; width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--color-border-strong); background: var(--color-surface); font-size: 20px; line-height: 1; cursor: pointer; color: var(--color-text-secondary); }
.unscan-btn:hover { background: var(--color-surface-3); }
.scan-summary { margin: 8px 0; font-size: 14px; }
.error-text { color: var(--color-danger-text); }
.return-outcome { margin: 10px 0; padding-left: 20px; font-size: 15px; line-height: 1.5; }
.kiosk-confirm:disabled { opacity: .5; cursor: not-allowed; }
.error.ok-note { color: var(--color-success-text); }
/* Gate: report lost (C6) */
.held-row { padding: 10px 0; border-top: 1px solid var(--color-border); }
.held-row:first-child { border-top: 0; }
.held-row.is-lost { background: var(--color-danger-bg); border-radius: 8px; padding: 10px; }
.held-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.held-row input[data-lost-note] { margin-top: 8px; width: 100%; }
.lost-note { margin-top: 6px; font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
/* Batch list / detail (B1–B4) */
.batch-day { margin: 14px 0 4px; font-size: 13px; font-weight: 600; color: var(--color-text-muted, #6b6259); }
.batch-row.clickable { cursor: pointer; }
.due-change { font-size: 13px; padding: 6px 0; border-top: 1px solid var(--color-border); }
#batch-due-changes h4 { margin-top: 16px; }
.loan-group-head { margin: 14px 0 2px; font-weight: 600; font-size: 14px; }
.chip b { margin-left: 4px; }
/* Overview (O1–O7) */
.ov-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; margin-top: 10px;
  padding: 12px; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface-2);
  text-align: left; font-family: inherit; color: var(--color-text); cursor: pointer; }
.ov-line > span:first-child { display: flex; flex-direction: column; gap: 2px; }
.ov-line.line-yellow { background: var(--color-warning-bg); border-color: var(--color-warning); }
.ov-line.line-red { background: var(--color-danger-bg); border-color: var(--color-danger-text); }
.kpi-card.zero { background: var(--color-surface); }
.kpi-card.zero .kpi-value { color: var(--color-text-dim); }
.kpi-card.lv-red { background: var(--color-danger-bg); border-color: var(--color-danger-text); }
.kpi-card.lv-red .kpi-value { color: var(--color-danger-text); }
.kpi-card.lv-amber { background: var(--color-warning-bg); border-color: var(--color-warning); }
.kpi-card.lv-amber .kpi-value { color: var(--color-warning-text); }
.kpi-card.lv-brand { background: var(--color-surface-3); border-color: var(--color-brand); }
.stock-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; margin: 4px 0 6px; }
.st-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.backfill-box { margin-top: 10px; padding: 12px; border: 1px dashed var(--color-border-strong); border-radius: var(--radius-lg); }
.other-ways > summary { cursor: pointer; padding: 4px 0; }
.other-ways h4 { margin-top: 18px; }
.import-errors { margin: 6px 0 0; padding-left: 20px; font-size: 13px; color: var(--color-danger-text); }
/* Menu counts (K8), home alert (H5), mail body (N2), review trail (R2) */
.menu-btn.has-dot { position: relative; }
.menu-btn.has-dot::after { content: ''; position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--color-danger-text); }
.home-alert { display: block; width: 100%; text-align: left; font-family: inherit; cursor: pointer; background: var(--color-danger-bg); border-color: var(--color-danger-text); color: var(--color-text); }
.notif-row { cursor: pointer; }
.notif-body { padding: 4px 0 12px; }
.mail-text { white-space: pre-wrap; font-family: inherit; font-size: 13px; background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 8px; padding: 10px; margin: 0; }
.review-trail { flex-basis: 100%; font-size: 13px; padding: 6px 0 0; color: var(--color-text-secondary); }
.scanned-item:has(.review-trail) { flex-wrap: wrap; }
/* Branch cards (BR1–BR9) */
.branch-card { border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 12px; margin-top: 10px; background: var(--color-surface-2); }
.bc-head { margin-bottom: 6px; }
.bc-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; padding: 3px 0; }
.bc-line .k { min-width: 70px; color: var(--color-text-secondary); font-size: 13px; }
.bc-line select { width: auto; }
.bc-loc-form { margin: 6px 0; display: flex; flex-direction: column; gap: 6px; }
.key-qrs { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; }
.key-qrs figure { margin: 0; text-align: center; font-size: 12px; color: var(--color-text-secondary); }
.key-qrs img { width: 160px; height: 160px; display: block; }
.profile-card .avatar { overflow: hidden; }
.profile-card .avatar img { width: 100%; height: 100%; object-fit: cover; }
.inline-ask { margin-top: 8px; padding: 10px; border: 1px solid var(--color-border-strong); border-radius: 8px; background: var(--color-surface); display: flex; flex-direction: column; gap: 6px; text-align: left; }

/* C10: gate device settings, collapsed by default. */
.gate-settings > summary { cursor: pointer; font-size: 13px; color: var(--color-text-secondary); }
.gate-settings[open] > summary { margin-bottom: 8px; }

/* A12: phone rows carry one quick button; A13: a muted Chuyển explains itself. */
.m-quick { display: none; }
@media (max-width: 767px) {
  .m-quick { display: inline-flex; margin-top: 8px; min-height: 36px; }
  /* a long status ("Chờ gắn thẻ") used to push the table past the screen edge */
  .asset-table td .badge { white-space: normal; text-align: center; }
}
.btn.is-muted { opacity: 0.5; }
