/* ============================================
   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;
}

: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(150px, 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; }

/* ---------- 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; }
}
