:root {
  --bg: #eef2f7; --surface: #ffffff; --border: #c9d6e3; --line: #dbe4ee;
  --text: #0f1f33; --muted: #52647a;
  --navy: #0c2340; --navy2: #15406f;
  --primary: #0b5cad; --primary-h: #094a8c;
  --accent: #e3262f;   /* đỏ theo logo Tiến Đạt */
  --ok: #15803d; --ok-bg: #dcfce7; --warn: #a16207; --warn-bg: #fef3c7; --err: #b91c1c; --err-bg: #fee2e2;
  --th: #15406f; --zebra: #f4f8fc; --hover: #e2eefb;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.layout { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }

/* thanh bên */
nav.side { background: linear-gradient(180deg, var(--navy) 0%, var(--navy2) 100%); color: #d6e2f0; padding: 16px 12px; display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 0; height: 100vh; overflow: auto; }
nav.side .brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 4px 8px 16px; border-bottom: 1px solid #ffffff22; margin-bottom: 8px; }
nav.side .brand img { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; }
nav.side .brand b { font-size: 15px; line-height: 1.25; display: block; }
nav.side .brand small { color: #9fb6d1; font-size: 13px; }
nav.side a { color: #d6e2f0; text-decoration: none; padding: 11px 14px; border-radius: 10px; font-size: 16px; border-left: 4px solid transparent; }
nav.side a:hover { background: #ffffff14; color: #fff; }
nav.side a.active { background: #ffffff1f; color: #fff; font-weight: 700; border-left-color: var(--accent); }
nav.side .grow { flex: 1; }
nav.side .me { font-size: 14px; padding: 8px 14px; color: #b9cbe0; border-top: 1px solid #ffffff22; margin-top: 8px; }
nav.side .hot { font-size: 13px; color: #9fb6d1; padding: 0 14px 6px; }
main { padding: 22px 28px; min-width: 0; }
h1 { font-size: 26px; margin: 0 0 16px; color: var(--navy); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.toolbar .field { margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: 0 1px 3px #0c234012; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { border-left: 5px solid var(--primary); }
.stat:nth-child(2) { border-left-color: #0891b2; } .stat:nth-child(3) { border-left-color: var(--accent); } .stat:nth-child(4) { border-left-color: var(--ok); }
.stat .n { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--navy); }
.stat .l { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }

/* nút */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 9px 16px; border-radius: 10px; cursor: pointer; font: inherit; font-size: 15.5px; text-decoration: none; white-space: nowrap; font-weight: 600; }
.btn:hover { background: #f1f5fa; border-color: #a9bdd2; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-h); }
.btn.danger { color: var(--err); border-color: #f3b4b4; }
.btn.danger:hover { background: var(--err-bg); }
.btn.sm { padding: 6px 11px; font-size: 14px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ô nhập */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 14px; color: var(--navy2); font-weight: 700; }
.field .hint { font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; font-size: 16px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--text); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 3px solid #0b5cad33; border-color: var(--primary); }
textarea { min-height: 130px; font-family: Consolas, monospace; }

/* bảng: kẻ khung rõ, tiêu đề đậm, dòng xen màu */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; max-height: calc(100vh - 230px); background: #fff; box-shadow: 0 1px 3px #0c234012; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); font-size: 15.5px; }
table.t th, table.t td { padding: 10px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.t th:last-child, table.t td:last-child { border-right: 0; }
table.t th { background: var(--th); color: #fff; font-size: 14.5px; font-weight: 700; position: sticky; top: 0; z-index: 1; border-color: #0f3560; white-space: nowrap; }
table.t tbody tr:nth-child(even) td { background: var(--zebra); }
table.t tbody tr:hover td { background: var(--hover); }
table.t td.r, table.t th.r { text-align: right; font-variant-numeric: tabular-nums; }
table.t td.c, table.t th.c { text-align: center; }
table.t tr.void td { color: #8b98a8; text-decoration: line-through; }
table.t tfoot td { font-weight: 800; background: #e6eef7; color: var(--navy); border-top: 2px solid var(--th); position: sticky; bottom: 0; }
table.t td.mono { white-space: nowrap; }
table.t td b { color: var(--navy); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: #e2e8f0; color: #334155; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.err { background: var(--err-bg); color: var(--err); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.blue { background: #dbeafe; color: #1e40af; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }

/* hộp thoại */
.overlay { position: fixed; inset: 0; background: rgba(12, 35, 64, .5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 16px; padding: 20px 22px; width: min(720px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 24px 60px rgba(0,0,0,.3); }
.modal h2 { margin: 0 0 14px; font-size: 21px; color: var(--navy); }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.toast { position: fixed; right: 18px; bottom: 18px; background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; z-index: 99; max-width: 460px; font-size: 15.5px; box-shadow: 0 8px 24px #0005; }
.toast.err { background: var(--err); }

/* phân quyền */
.perm-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 18px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #f8fbfe; }
.perm-grid .grp { grid-column: 1 / -1; font-weight: 800; color: var(--navy2); font-size: 14px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); padding-bottom: 3px; margin-top: 4px; }
.perm-grid label { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; cursor: pointer; }
.perm-grid input[type=checkbox] { width: 19px; height: 19px; margin-top: 2px; accent-color: var(--primary); }
.presets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chk { display: flex; gap: 8px; align-items: center; font-size: 15.5px; }
.chk input { width: 19px; height: 19px; accent-color: var(--primary); }

/* đăng nhập */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .brandside { background: linear-gradient(145deg, var(--navy) 0%, var(--navy2) 60%, #1b5c9c 100%); color: #fff; display: flex; flex-direction: column;
  justify-content: center; align-items: center; text-align: center; padding: 40px; gap: 14px; }
.login .brandside img { width: 150px; height: 150px; object-fit: contain; background: #fff; border-radius: 28px; padding: 12px; box-shadow: 0 12px 40px #0006; }
.login .brandside h2 { margin: 6px 0 0; font-size: 28px; line-height: 1.3; letter-spacing: .01em; }
.login .brandside .app { font-size: 19px; color: #cfe0f3; }
.login .brandside .hot { margin-top: 8px; font-size: 22px; font-weight: 800; color: #fff; background: var(--accent); padding: 8px 22px; border-radius: 999px; }
.login .formside { display: flex; align-items: center; justify-content: center; padding: 30px; }
.login .card { width: min(420px, 100%); padding: 28px; }
.login h1 { font-size: 26px; }
.login .btn { width: 100%; padding: 13px; font-size: 17px; }

.st-card { display: flex; flex-direction: column; gap: 7px; }
.st-card .w { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; font-family: Consolas, monospace; color: var(--navy); }
.mono { font-family: Consolas, monospace; font-size: 14px; word-break: break-all; }
.section-title { font-weight: 800; margin: 20px 0 10px; color: var(--navy); font-size: 17px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  nav.side { flex-direction: row; flex-wrap: wrap; height: auto; position: static; }
  nav.side .grow, nav.side .me, nav.side .hot { display: none; }
  nav.side .brand { width: 100%; }
  .grid2, .grid3, .perm-grid { grid-template-columns: 1fr; }
  main { padding: 14px; }
  .login { grid-template-columns: 1fr; }
  .login .brandside { padding: 28px 16px; }
  .login .brandside img { width: 96px; height: 96px; }
}
@media print {
  nav.side, .toolbar, .no-print { display: none !important; }
  .layout { display: block; }
  .table-wrap { max-height: none; border: 0; box-shadow: none; }
  table.t th { background: #ddd !important; color: #000 !important; }
}
