*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--fs-md)/var(--lh-body) var(--font);
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, p, figure, dl, dd, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3 { line-height: var(--lh-tight); text-wrap: balance; font-weight: 600; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
a { color: var(--blue); text-underline-offset: 0.2em; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--amber-bright); outline-offset: 2px; border-radius: var(--r-sm); }
[hidden] { display: none !important; }

.banner {
  background: var(--amber-wash);
  color: var(--amber);
  font-size: var(--fs-xs);
  font-weight: 500;
  padding: var(--s-1) var(--gutter);
}

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-2) var(--s-6);
  padding: var(--s-3) var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: var(--fs-md); color: var(--ink); text-decoration: none; }
.top nav { display: flex; gap: var(--s-5); }
.top nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 500;
  padding-block: var(--s-1);
  border-bottom: 2px solid transparent;
}
.top nav a:hover { color: var(--ink); }
.top nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--amber-bright); }

/* Người đang đăng nhập, ở mép phải thanh trên; màn hẹp thì xuống dòng riêng */
.user {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-1) var(--s-4);
  font-size: var(--fs-sm);
}
.user-who { display: grid; text-align: right; line-height: var(--lh-tight); }
.user-name { font-weight: 600; overflow-wrap: anywhere; }
.user-role { color: var(--ink-soft); font-size: var(--fs-xs); }
.logout button {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  padding: var(--s-1) var(--s-3);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
}
.logout button:hover { border-color: var(--blue); color: var(--blue-deep); }
@media (max-width: 560px) {
  .top { position: static; }
  .user { margin-left: 0; width: 100%; justify-content: space-between; }
  .user-who { text-align: left; }
}

main { max-width: var(--page); margin-inline: auto; padding: var(--s-6) var(--gutter) var(--s-8); }
main:focus { outline: none; }
.view { display: grid; gap: var(--s-6); min-width: 0; }
.view > * { min-width: 0; }

/* Thành phần dùng chung cho mọi màn hình */
.muted { color: var(--ink-soft); }
.small { font-size: var(--fs-sm); }
.num { text-align: right; white-space: nowrap; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-5); }
/* position: phần tử ẩn-trực-quan (absolute) trong ô bảng phải cuộn cùng bảng, không thì nó nới rộng cả trang. */
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { padding: var(--s-2) var(--s-3); text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { color: var(--ink-soft); font-weight: 500; border-bottom-color: var(--line); white-space: nowrap; }
td.num, th.num { text-align: right; }

.state { color: var(--ink-soft); padding: var(--s-7) 0; }
.state-error { color: var(--bad); }

/* Ẩn khỏi mắt, vẫn đọc được bằng trình đọc màn hình */
.vh {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* Dữ liệu bị che theo quyền */
.mask-note {
  justify-self: start;
  padding: var(--s-1) var(--s-3);
  border-left: 3px solid var(--blue);
  background: var(--blue-wash);
  color: var(--blue-deep);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.masked { letter-spacing: .02em; }
.masked-hidden { color: var(--ink-soft); font-style: italic; font-weight: 400; letter-spacing: 0; }

.no-role { display: grid; gap: var(--s-3); justify-items: start; max-width: 640px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
