/* ============================================================
   QLTS CNTT — Hệ màu theo nhận diện ANHAIAN (A member of HAI AN GROUP)
   Mã màu lấy trực tiếp từ file logo gốc: navy #030875 · cam #EC7626
   ============================================================ */
:root {
    /* Màu thương hiệu */
    --brand-navy: #030875;
    --brand-navy-600: #141a8f;
    --brand-navy-900: #01053f;
    --brand-orange: #EC7626;
    --brand-orange-600: #cf6318;
    --brand-orange-soft: #fdf0e6;

    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-2: #f6f8fc;
    --border: #e1e6ef;
    --border-strong: #ccd4e2;
    --text: #18203a;
    --text-soft: #56617a;
    --text-mute: #8893a8;

    --primary: var(--brand-navy);
    --primary-dark: var(--brand-navy-900);
    --primary-soft: #e9eafa;
    --accent: var(--brand-orange);
    --accent-soft: var(--brand-orange-soft);

    --sidebar: #050a55;
    --sidebar-2: #030875;
    --sidebar-soft: #a0a7da;
    --sidebar-active: var(--brand-orange);

    --ok: #15803d; --ok-bg: #e8f7ee;
    --warn: #b45309; --warn-bg: #fef3e2;
    --danger: #b91c1c; --danger-bg: #fdeaea;
    --info: #1d4ed8; --info-bg: #e8eefe;
    --mute-bg: #eef1f6; --mute-fg: #5b6678;
    --excel: #137547; --excel-dark: #0f5c38;

    /* Nền bảng */
    --th-bg: linear-gradient(180deg, #0c1495 0%, #030875 100%);
    --row-odd: #ffffff;
    --row-even: #f5f7fd;
    --row-hover: #fdf2e8;

    --radius: 10px;
    --shadow: 0 1px 2px rgba(18,22,60,.06), 0 1px 3px rgba(18,22,60,.09);
    --shadow-lg: 0 18px 44px rgba(16,18,64,.22);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 650; }

/* ---------- Khung ứng dụng ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 252px; flex-shrink: 0; color: var(--sidebar-soft);
    background: linear-gradient(170deg, var(--sidebar-2) 0%, var(--sidebar) 55%, #01053f 100%);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    transition: width .16s ease;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 3px; }

.sidebar-brand { padding: 16px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.09); }
.sidebar-brand .logo-full { width: 100%; max-width: 196px; display: block; }
.sidebar-brand .logo-mark { width: 34px; display: none; margin: 0 auto; }
.brand-app {
    margin-top: 10px; font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
    color: #c6cbe8; display: flex; align-items: center; gap: 7px;
}
.brand-app::before { content: ""; width: 16px; height: 2px; background: var(--brand-orange); border-radius: 2px; }

.nav-menu { padding: 8px 0 30px; }
.nav-group { margin-bottom: 2px; }
.nav-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #7a83b8; padding: 15px 20px 6px; }
.nav-item {
    display: flex; align-items: center; gap: 11px; padding: 9px 20px; color: var(--sidebar-soft);
    font-size: 13.5px; border-left: 3px solid transparent; transition: .12s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #eef0fb; }
.nav-item.active {
    background: linear-gradient(90deg, rgba(236,118,38,.22), rgba(236,118,38,.03));
    color: #fff; border-left-color: var(--sidebar-active); font-weight: 600;
}
.nav-ico { width: 20px; text-align: center; font-size: 15px; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 62px; background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 22px;
    position: sticky; top: 0; z-index: 30; box-shadow: 0 1px 0 rgba(18,22,60,.03);
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.nav-toggle { background: none; border: none; font-size: 18px; color: var(--text-soft); cursor: pointer; padding: 4px 8px; border-radius: 7px; }
.nav-toggle:hover { background: var(--surface-2); color: var(--primary); }
.topbar-company { font-weight: 650; color: var(--brand-navy); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-company small { display: block; font-weight: 400; font-size: 11.5px; color: var(--text-mute); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%; color: #fff; font-weight: 700;
    background: linear-gradient(135deg, var(--brand-orange), #cf6318); display: grid; place-items: center;
    box-shadow: 0 2px 6px rgba(236,118,38,.35);
}
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11.5px; color: var(--text-mute); }
.logout-form { margin: 0; }
.content { padding: 22px 24px 34px; flex: 1; }

/* ---------- Tiêu đề trang ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { font-size: 21px; color: var(--brand-navy); position: relative; padding-left: 13px; }
.page-head h1::before {
    content: ""; position: absolute; left: 0; top: 3px; bottom: 3px; width: 4px;
    background: var(--brand-orange); border-radius: 3px;
}
.page-head .sub { color: var(--text-soft); margin-top: 5px; margin-left: 13px; font-size: 13.5px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Nút ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 8px;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
    font-size: 13.5px; font-weight: 550; cursor: pointer; transition: .12s; font-family: inherit;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-mute); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--brand-navy-600); border-color: var(--brand-navy-600); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--brand-orange-600); border-color: var(--brand-orange-600); }
.btn-excel { background: var(--excel); border-color: var(--excel); color: #fff; }
.btn-excel:hover { background: var(--excel-dark); border-color: var(--excel-dark); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-danger { background: var(--danger-bg); border-color: #f0c4c4; color: var(--danger); }
.btn-danger:hover { background: #fadada; }
.btn-sm { padding: 5px 9px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Thẻ ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card-pad > h3 { color: var(--brand-navy); font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-pad > h3::before { content: ""; width: 3px; height: 15px; background: var(--brand-orange); border-radius: 2px; }

/* ---------- Ô thống kê ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand-navy); }
.stat.a-orange::after { background: var(--brand-orange); }
.stat.a-green::after { background: var(--ok); }
.stat.a-blue::after { background: var(--info); }
.stat-ico { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-size: 20px; margin-bottom: 10px; background: var(--primary-soft); }
.stat-val { font-size: 27px; font-weight: 750; color: var(--brand-navy); letter-spacing: -.5px; }
.stat-label { color: var(--text-soft); font-size: 13px; margin-top: 2px; }

/* ---------- Bảng dữ liệu ---------- */
.table-wrap {
    overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--surface); box-shadow: var(--shadow);
}
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid th {
    text-align: left; padding: 11px 14px; background: var(--th-bg); color: #fff; font-weight: 600;
    border-bottom: 2px solid var(--brand-orange); white-space: nowrap; font-size: 12px;
    text-transform: uppercase; letter-spacing: .035em; position: sticky; top: 0; z-index: 1;
}
table.grid th + th { border-left: 1px solid rgba(255,255,255,.12); }
table.grid td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.grid tbody tr { background: var(--row-odd); }
table.grid tbody tr:nth-child(even) { background: var(--row-even); }
table.grid tbody tr:hover { background: var(--row-hover); }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tr.row-total td {
    background: var(--primary-soft); font-weight: 700; color: var(--brand-navy); border-top: 2px solid var(--border-strong);
}

/* Cột số thứ tự */
th.th-stt { width: 58px; text-align: center; }
td.td-stt {
    width: 58px; text-align: center; color: var(--text-mute); font-variant-numeric: tabular-nums;
    font-weight: 600; background: rgba(3,8,117,.035);
}
table.grid tbody tr:hover td.td-stt { background: rgba(236,118,38,.16); color: var(--brand-orange-600); }

.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.cell-strong { font-weight: 600; color: var(--brand-navy); }
/* KHÔNG dùng display:flex trên <td>: ô sẽ thoát khỏi bố cục bảng và tràn ra ngoài viền. */
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn + .btn { margin-left: 6px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Nhãn trạng thái ---------- */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-mute { background: var(--mute-bg); color: var(--mute-fg); }
.badge-accent { background: var(--accent-soft); color: var(--brand-orange-600); }

/* ---------- Thanh công cụ / lọc ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.search { position: relative; }
.search input { padding-left: 32px; }
.search::before { content: "🔍"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: .6; }

/* ---------- Biểu mẫu ---------- */
input, select, textarea {
    width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 8px;
    font-size: 13.5px; font-family: inherit; background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-orange); box-shadow: 0 0 0 3px rgba(236,118,38,.18); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-soft); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- Hộp thoại ---------- */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(16,18,64,.5); display: grid; place-items: center; z-index: 100; padding: 20px; }
.dialog { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: 100%; max-width: 640px; max-height: 90vh; display: flex; flex-direction: column; }
.dialog-lg { max-width: 880px; }
.dialog-head { padding: 15px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--surface-2); border-radius: 12px 12px 0 0; }
.dialog-head h3 { font-size: 16px; color: var(--brand-navy); }
.dialog-body { padding: 20px; overflow-y: auto; }
.dialog-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.dialog-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-mute); }

/* ---------- Khác ---------- */
.notice { padding: 40px; text-align: center; color: var(--text-soft); }
.empty { padding: 48px 20px; text-align: center; color: var(--text-mute); }
.empty-ico { font-size: 40px; opacity: .4; margin-bottom: 8px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px; color: var(--text-soft); font-size: 13px; }
.pager-btns { display: flex; gap: 6px; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.subtle { color: var(--text-mute); font-size: 12.5px; }
.danger-text { color: var(--danger); }
.bar-track { height: 7px; border-radius: 4px; background: var(--mute-bg); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--brand-navy), var(--brand-orange)); }

/* ---------- Đăng nhập ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; background: var(--surface); }
.login-aside {
    position: relative; overflow: hidden; padding: 54px 56px 42px; color: #fff;
    background: linear-gradient(160deg, #141a8f 0%, #030875 48%, #01053f 100%);
    display: flex; flex-direction: column; justify-content: space-between;
}
.login-aside::before, .login-aside::after { content: ""; position: absolute; border-radius: 50%; }
.login-aside::before { width: 460px; height: 460px; right: -170px; top: -150px; background: radial-gradient(circle at 30% 30%, rgba(236,118,38,.34), transparent 62%); }
.login-aside::after { width: 340px; height: 340px; left: -120px; bottom: -130px; background: radial-gradient(circle at 60% 40%, rgba(236,118,38,.20), transparent 64%); }
.login-aside > * { position: relative; z-index: 1; }
.login-aside .logo-full { width: 290px; max-width: 78%; }
.login-aside h2 { font-size: 29px; line-height: 1.26; margin-top: 32px; font-weight: 700; }
.login-aside h2 em { font-style: normal; color: var(--brand-orange); }
.login-aside p.lead { color: #b9bfe4; margin-top: 12px; max-width: 420px; font-size: 14.5px; }
.login-points { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 11px; }
.login-points li { display: flex; align-items: center; gap: 11px; color: #d4d8f0; font-size: 14px; }
.login-points li span.dot {
    width: 25px; height: 25px; border-radius: 7px; display: grid; place-items: center; flex: none;
    background: rgba(236,118,38,.2); color: var(--brand-orange); font-size: 13px;
}
.login-foot { font-size: 12.5px; color: #8e96c6; }

.login-panel { display: grid; place-items: center; padding: 40px 24px; }
.login-card { width: 100%; max-width: 384px; }
.login-card .logo-full { width: 210px; display: none; margin: 0 auto 26px; }
.login-card h1 { font-size: 23px; color: var(--brand-navy); }
.login-card .hello { color: var(--text-soft); margin: 7px 0 26px; font-size: 13.5px; }
.login-error { background: var(--danger-bg); color: var(--danger); padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; border: 1px solid #f3cfcf; }
.login-card input { padding: 10px 12px; }
.remember { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-soft); margin-bottom: 18px; }
.remember input { width: auto; }
.login-card .btn-primary { padding: 11px 14px; font-size: 14.5px; }
.login-hint { text-align: center; font-size: 12px; color: var(--text-mute); margin-top: 16px; line-height: 1.6; }
.login-copy { text-align: center; font-size: 11.5px; color: var(--text-mute); margin-top: 26px; }

@media (max-width: 980px) {
    .login-wrap { grid-template-columns: 1fr; }
    .login-aside { display: none; }
    .login-card .logo-full { display: block; }
}

/* ---------- Thu gọn thanh điều hướng ---------- */
body.nav-collapsed .sidebar { width: 68px; }
body.nav-collapsed .nav-text,
body.nav-collapsed .nav-group-label,
body.nav-collapsed .brand-app,
body.nav-collapsed .sidebar-brand .logo-full { display: none; }
body.nav-collapsed .sidebar-brand .logo-mark { display: block; }
body.nav-collapsed .nav-item { justify-content: center; padding: 11px 0; }

@media (max-width: 900px) {
    .sidebar { width: 68px; }
    .nav-text, .nav-group-label, .brand-app, .sidebar-brand .logo-full { display: none; }
    .sidebar-brand .logo-mark { display: block; }
    .nav-item { justify-content: center; padding: 11px 0; }
    .user-meta, .topbar-company small { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .content { padding: 16px 14px 28px; }
}
