@font-face { font-family: 'Overused Grotesk'; font-style: normal; font-weight: 300 900; font-display: swap;
  src: url('/static/fonts/OverusedGroteskRoman-VF.woff2') format('woff2'); }

/* ============================================================
   Catbox CMS: giao diện quản trị theo phong cách Catbox ERP.
   Đơn sắc, nền xám rất nhạt, thẻ trắng bo 8px, ô nhập nền xám không viền,
   nút đen, thanh bên có biểu tượng và thu gọn được.
   ============================================================ */
:root {
  --bg: #fafafa; --surface: #fff; --surface-2: #f8f8f8; --control: #f3f3f3; --control-hover: #ededed;
  --text: #171717; --text-2: #383838; --muted: #6b6b6b; --faint: #969696; --kicker: #525252;
  --border: #e2e2e2; --divider: #ededed; --hover: rgba(23,23,23,.045); --selected: #f3f3f3;
  --accent: #171717; --accent-hover: #383838; --on-accent: #fff;
  --danger: #cc2a84; --danger-soft: #fbeaf3; --info: #0a6f99; --info-soft: #e6f3f9; --warn: #8a6a00; --warn-soft: #fbf3d9; --ok: #2f6b3f; --ok-soft: #e8f3ea;
  --r-sm: 4px; --r-md: 8px; --r-lg: 12px;
  --shadow-xs: 0 .5px 0 #0000000d, 0 0 0 1px #0000000f, 0 2px 4px #0000000a;
  --shadow-md: 0 0 1px #00000030, 0 1px 2px #00000012, 0 6px 15px -5px #0000001c;
  --side-w: 220px; --side-w-s: 56px; --top-h: 48px;
  --font: 'Overused Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fs-2xs: 10px; --fs-xs: 12px; --fs-sm: 13px; --fs-base: 14px; --fs-md: 16px; --fs-lg: 22px; --fs-kpi: 30px;
  --control-h: 30px; --control-h-sm: 26px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.admin { margin: 0; font-family: var(--font); font-size: var(--fs-base); line-height: 1.5; font-weight: 400; letter-spacing: normal; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body.admin a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
body.admin h1, body.admin h2, body.admin h3 { margin: 0; line-height: 1.2; letter-spacing: 0; font-weight: 600; }
body.admin p { margin: 0 0 1em; }
body.admin ul, body.admin ol { margin: 0; padding: 0; list-style: none; }
body.admin img, body.admin svg { max-width: 100%; }
body.admin button { font: inherit; cursor: pointer; }
body.admin :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body.admin code { background: var(--control); padding: 1px 6px; border-radius: var(--r-sm); font-size: .875em; }

/* ---------- Nút ---------- */
body.admin .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--control-h); padding: 0 12px; border: 1px solid var(--accent); border-radius: var(--r-md); background: var(--accent); color: var(--on-accent); font-weight: 500; font-size: var(--fs-base); line-height: 1.2; text-decoration: none; line-height: 1.2; transition: background .15s, border-color .15s; }
body.admin .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
body.admin .btn.ghost { background: var(--control); color: var(--text-2); border-color: transparent; }
body.admin .btn.ghost:hover { background: var(--control-hover); border-color: transparent; color: var(--text); }
body.admin .btn.small { min-height: var(--control-h-sm); padding: 0 9px; font-size: var(--fs-sm); }
body.admin .btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
body.admin .btn.danger:hover { background: #a82068; border-color: #a82068; }
body.admin .btn svg { width: 16px; height: 16px; flex: none; }

/* ---------- Khung ---------- */
.a-shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .18s; }
body.side-collapsed .a-shell { grid-template-columns: var(--side-w-s) minmax(0, 1fr); }
.a-side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--divider); padding: 0 9px 4px 10px; overflow-y: auto; overflow-x: hidden; z-index: 30; }
.a-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; margin: 0 -9px 8px -10px; padding-left: 16px; height: var(--top-h); border-bottom: 1px solid var(--divider); text-decoration: none; }
.a-brand img { width: 28px; height: 28px; border-radius: 7px; flex: none; }
.a-brand span { display: grid; line-height: 1.2; white-space: nowrap; }
.a-brand strong { font-size: 15px; font-weight: 700; letter-spacing: .04em; line-height: 1; }
.a-brand small { display: none; }
.a-nav-label { margin: 6px 0 0; padding: 0 10px; height: 26px; line-height: 26px; font-size: var(--fs-xs); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); white-space: nowrap; }
.a-side nav ul { display: grid; gap: 1px; }
.a-side nav a { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; line-height: 1.2; border-radius: var(--r-md); color: var(--muted); text-decoration: none; font-weight: 400; font-size: var(--fs-base); white-space: nowrap; position: relative; }
.a-side nav a svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
.a-side nav a:hover { background: var(--control); color: var(--text); }
.a-side nav a[aria-current="page"] { background: var(--selected); color: var(--text); font-weight: 500; }
.a-side nav a[aria-current="page"] svg { color: var(--text); }
.a-count { margin-left: auto; background: var(--accent); color: #fff; font-size: var(--fs-2xs); font-weight: 600; min-width: 18px; height: 18px; line-height: 18px; text-align: center; padding: 0 6px; border-radius: 10px; }
.a-side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--divider); }
.a-side-foot a { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; line-height: 1.2; border-radius: var(--r-md); color: var(--muted); text-decoration: none; font-weight: 400; white-space: nowrap; }
.a-side-foot a:hover { background: var(--hover); color: var(--text); }
.a-side-foot svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
body.side-collapsed .a-side { padding-inline: 8px; }
body.side-collapsed .a-brand span, body.side-collapsed .a-nav-label, body.side-collapsed .a-side nav a span.t, body.side-collapsed .a-side-foot span.t { display: none; }
body.side-collapsed .a-count { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; line-height: 16px; font-size: .625rem; padding: 0 4px; margin: 0; }
body.side-collapsed .a-side nav a, body.side-collapsed .a-side-foot a { justify-content: center; }

.a-col { min-width: 0; display: flex; flex-direction: column; }
.a-top { position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 10px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--divider); }
.a-icon-btn { width: var(--control-h); height: var(--control-h); display: grid; place-items: center; border: 0; border-radius: var(--r-md); background: transparent; color: var(--muted); }
.a-icon-btn:hover { background: var(--hover); color: var(--text); }
.a-icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.a-crumb { color: var(--muted); font-size: var(--fs-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a-crumb b { color: var(--text); font-weight: 600; }
.a-top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.a-user { position: relative; }
.a-user summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 3px 8px 3px 4px; border-radius: 999px; cursor: pointer; border: 1px solid transparent; }
.a-user summary::-webkit-details-marker { display: none; }
.a-user summary:hover, .a-user[open] summary { background: var(--surface); border-color: var(--border); }
.a-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: .78rem; font-weight: 600; text-transform: uppercase; }
.a-user .nm { font-weight: 500; font-size: var(--fs-base); max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-md); padding: 6px; }
.a-menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--divider); margin-bottom: 4px; }
.a-menu .who strong { display: block; }
.a-menu .who small { color: var(--muted); font-size: var(--fs-sm); }
.a-menu a, .a-menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: var(--r-md); text-decoration: none; color: var(--text-2); font-weight: 500; }
.a-menu a:hover, .a-menu button:hover { background: var(--hover); color: var(--text); }
.a-main { padding: clamp(18px, 3vw, 32px); width: 100%; max-width: 1180px; }

/* ---------- Tiêu đề trang, thông báo ---------- */
.a-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin-bottom: 20px; }
.a-main h1 { font-size: var(--fs-lg); font-weight: 500; letter-spacing: 0; }
.a-main h2 { font-size: var(--fs-md); font-weight: 600; margin: 28px 0 10px; }
.a-back { font-weight: 500; color: var(--muted); text-decoration: none; }
.a-back:hover { color: var(--text); }
.a-flash { display: flex; align-items: center; gap: 10px; background: var(--ok-soft); color: var(--ok); border-radius: var(--r-md); padding: 10px 14px; margin: 0 0 18px; font-weight: 500; }
.a-muted { color: var(--muted); }
.a-empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--r-lg); padding: 36px; color: var(--muted); text-align: center; }
.a-err { color: var(--danger); font-weight: 500; margin: 6px 0 0; }
.a-help { color: var(--muted); font-size: var(--fs-sm); margin: 6px 0 0; line-height: 1.5; }
body.admin .a-danger { color: var(--danger); }

/* ---------- Thẻ, số liệu, việc cần làm ---------- */
.a-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 8px; }
.a-stats a { background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--divider); padding: 16px 18px; text-decoration: none; display: flex; flex-direction: column-reverse; gap: 10px; transition: border-color .15s; }
.a-stats a:hover { border-color: var(--border); }
.a-stats b { display: block; font-size: clamp(20px, 2vw, var(--fs-kpi)); font-weight: 600; letter-spacing: 0; line-height: 1.2; font-variant-numeric: tabular-nums; }
.a-stats span { color: var(--kicker); font-size: var(--fs-base); font-weight: 500; line-height: 1.4; }
.a-todo { display: grid; gap: 8px; }
.a-todo li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; background: var(--surface); border-radius: var(--r-md); border: 1px solid var(--divider); padding: 9px 14px; }

/* ---------- Thanh công cụ danh sách ---------- */
.a-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-bottom: 14px; }
.a-search { position: relative; flex: 1 1 240px; max-width: 360px; }
.a-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--faint); fill: none; stroke-width: 1.8; stroke-linecap: round; }
.a-search input { width: 100%; height: var(--control-h); font-size: var(--fs-base); padding: 0 12px 0 34px; border: 0; border-radius: var(--r-md); background: var(--control); font: inherit; color: var(--text); }
.a-search input:focus { outline: 2px solid var(--accent); background: var(--surface); }
.a-total { color: var(--muted); font-size: var(--fs-sm); margin-left: auto; }
.a-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.a-filters a { height: var(--control-h); display: inline-flex; align-items: center; padding: 0 12px; border-radius: var(--r-md); text-decoration: none; font-weight: 500; font-size: var(--fs-base); color: var(--muted); background: var(--surface); box-shadow: 0 0 0 1px var(--border); }
.a-filters a:hover { color: var(--text); background: var(--control); }
.a-filters a[aria-current="true"] { background: var(--control-hover); color: var(--text); box-shadow: 0 0 0 1px var(--border); }

/* ---------- Bảng ---------- */
.a-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border-radius: var(--r-md); border: 1px solid var(--divider); font-size: var(--fs-base); font-variant-numeric: tabular-nums; overflow: hidden; }
.a-table th { text-align: left; font-weight: 500; font-size: var(--fs-sm); letter-spacing: 0; color: var(--muted); padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--divider); white-space: nowrap; }
.a-table td { padding: 9px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.a-table tbody tr:last-child td { border-bottom: 0; }
.a-table tbody tr:hover td { background: var(--surface-2); }
.a-table tr.is-new td { background: #f6f6f7; }
.a-table tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.a-table td a { text-decoration: none; }
.a-table td a strong { font-weight: 600; }
.a-table td a:hover { text-decoration: underline; }
.a-right { text-align: right !important; }
.a-actions { white-space: nowrap; }
.a-actions a { margin-left: 12px; color: var(--muted); }
.a-actions a:hover { color: var(--text); }
.a-actions a.a-danger { color: var(--danger); }
.a-badge { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 500; background: var(--control); color: var(--text-2); white-space: nowrap; line-height: 1.5; padding: 2px 9px; }
.a-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.a-badge.ok { background: var(--ok-soft); color: var(--ok); }
.a-badge.off { background: var(--control); color: var(--muted); }
.a-badge.info { background: var(--info-soft); color: var(--info); }
.a-badge.warn { background: var(--warn-soft); color: var(--warn); }
.a-badge.bad { background: var(--danger-soft); color: var(--danger); }
.a-role { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; background: var(--control); color: var(--text-2); }
.a-role-superadmin { background: var(--accent); color: #fff; }
.a-role-admin { background: var(--info-soft); color: var(--info); }
.a-rolelist { display: grid; gap: 8px; max-width: 760px; }
.a-rolelist li { background: var(--surface); border-radius: var(--r-md); border: 1px solid var(--divider); padding: 10px 14px; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }

/* ---------- Biểu mẫu ---------- */
.a-form { background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--divider); padding: clamp(18px, 3vw, 28px); display: grid; gap: 20px; max-width: 760px; }
.a-group { border: 1px solid var(--divider); border-radius: var(--r-md); padding: 18px; margin: 0; display: grid; gap: 16px; min-width: 0; }
.a-group legend { font-weight: 600; padding: 0 8px; }
.a-field { min-width: 0; }
.a-label { display: block; font-weight: 500; font-size: var(--fs-base); color: var(--text-2); margin-bottom: 6px; }
.a-label em { font-weight: 400; color: var(--muted); font-style: normal; }
.a-field input[type=text], .a-field input[type=number], .a-field input[type=date], .a-field input[type=password], .a-field input[type=email], .a-field select, .a-field textarea {
  width: 100%; font: inherit; color: var(--text); border: 1px solid transparent; border-radius: var(--r-md); background: var(--control); font-size: var(--fs-base); line-height: 1.4; padding: 5px 10px; min-height: var(--control-h); transition: background .15s, border-color .15s;
}
.a-field input:hover, .a-field select:hover, .a-field textarea:hover { background: var(--control-hover); }
.a-field input:focus, .a-field select:focus, .a-field textarea:focus { outline: 0; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23,23,23,.08); }
.a-field textarea { resize: vertical; line-height: 1.55; }
.a-field input[type=file] { font: inherit; font-size: .875rem; color: var(--muted); }
.a-field input[type=file]::file-selector-button { margin-right: 12px; padding: 7px 12px; border: 0; border-radius: var(--r-md); background: var(--control); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; }
.a-field input[type=file]::file-selector-button:hover { background: var(--control-hover); }
.a-field.has-err input, .a-field.has-err select, .a-field.has-err textarea { border-color: var(--danger); background: var(--danger-soft); }
.a-field select:disabled, .a-field input:disabled { opacity: .6; }
.a-check { display: flex; gap: 10px; align-items: center; font-weight: 500; cursor: pointer; }
.a-check input { width: 17px; height: 17px; accent-color: var(--accent); }
.a-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 16px; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--divider); }
.a-img { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.a-img img { width: 140px; height: 100px; object-fit: cover; background: var(--control); border-radius: var(--r-md); box-shadow: 0 0 0 1px var(--border); }
.a-submit { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-top: 4px; }
.a-facts { background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--divider); padding: 6px 22px; margin: 0 0 20px; max-width: 760px; }
.a-facts div { display: grid; grid-template-columns: 11rem 1fr; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--divider); }
.a-facts div:last-child { border-bottom: 0; }
.a-facts dt { font-weight: 500; color: var(--muted); }
.a-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.a-pre { white-space: pre-wrap; }

/* ---------- Đăng nhập ---------- */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-md); padding: 24px; width: min(380px, 100%); display: grid; gap: 18px; }
.login-head { display: flex; align-items: center; gap: 12px; }
.login-head img { width: 44px; height: 44px; border-radius: 11px; }
.login-head h1 { font-size: 18px; font-weight: 700; letter-spacing: .04em; }
.login-head p { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.login-box form { display: grid; gap: 14px; }
.login-box .btn { width: 100%; min-height: 36px; }
.a-pw { position: relative; }
.a-pw input { padding-right: 40px !important; }
.a-pw button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: 0; background: none; color: var(--muted); border-radius: var(--r-md); display: grid; place-items: center; }
.a-pw button:hover { color: var(--text); background: var(--hover); }
.a-pw svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Điện thoại ---------- */
.a-scrim { display: none; }
@media (max-width: 860px) {
  .a-shell, body.side-collapsed .a-shell { grid-template-columns: minmax(0, 1fr); }
  .a-side { position: fixed; inset: 0 auto 0 0; width: min(264px, 84vw); transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow-md); }
  body.nav-open .a-side { transform: none; }
  body.nav-open .a-scrim { display: block; position: fixed; inset: 0; background: #1717175c; z-index: 25; }
  body.side-collapsed .a-brand span, body.side-collapsed .a-nav-label, body.side-collapsed .a-side nav a span.t, body.side-collapsed .a-side-foot span.t { display: revert; }
  body.side-collapsed .a-side nav a, body.side-collapsed .a-side-foot a { justify-content: flex-start; }
  .a-table { display: block; overflow-x: auto; }
  .a-user .nm { display: none; }
  .a-facts div { grid-template-columns: 1fr; gap: 2px; }
}
