/* ==========================================================================
   KhoAcc — giao diện quản trị kho tài khoản số
   Không dùng CDN: toàn bộ CSS nằm trong file này để chạy được offline.
   ========================================================================== */

:root {
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e6ebf3;
    --line-strong: #d7e0ec;
    --bg: #f4f6fb;
    --card: #ffffff;
    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --primary-soft: #e9f0fe;
    --ok: #16a34a;
    --ok-soft: #e8f8ee;
    --warn: #d97706;
    --warn-soft: #fef4e6;
    --danger: #dc2626;
    --danger-soft: #fdecec;
    --violet: #7c3aed;
    --violet-soft: #f1ebfe;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 10px 26px -18px rgba(15, 23, 42, .35);
    --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }

h1, h2, h3, p { margin: 0; }

[hidden] { display: none !important; }

.ico { flex: none; }

/* ---------- Bố cục ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 238px;
    flex: 0 0 238px;
    background: linear-gradient(180deg, #141d31 0%, #0b1220 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    padding: 14px 12px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 50;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    margin-bottom: 14px;
    color: #fff;
}

.brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 17px;
    color: #fff;
    box-shadow: 0 8px 18px -10px rgba(59, 130, 246, .9);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 14px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: 10.5px; color: #7b8aa3; }

.nav { display: flex; flex-direction: column; gap: 16px; flex: 1; overflow-y: auto; padding-right: 2px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: #5a6880;
    padding: 0 10px 6px;
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 9px;
    color: #a8b3c5;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }

.nav-link.active {
    background: linear-gradient(90deg, rgba(37, 99, 235, .95), rgba(59, 130, 246, .72));
    color: #fff;
    box-shadow: 0 8px 18px -12px rgba(37, 99, 235, 1);
}

.nav-badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, .12);
    color: #dbeafe;
    border-radius: 999px;
    padding: 1px 7px;
}

.nav-link.active .nav-badge { background: rgba(255, 255, 255, .24); color: #fff; }

.sidebar-foot {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, .07);
    display: flex;
    align-items: center;
    gap: 9px;
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #1e293b;
    color: #c7d2fe;
    border: 1px solid rgba(255, 255, 255, .12);
    display: grid;
    place-items: center;
    font-size: 12.5px;
    font-weight: 700;
    text-transform: uppercase;
    flex: none;
}

.avatar-sm { width: 22px; height: 22px; font-size: 11px; background: var(--primary-soft); color: var(--primary); border: 1px solid #d5e3fd; }

.sidebar-user { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sidebar-user strong { font-size: 12.5px; color: #e2e8f0; font-weight: 600; }
.sidebar-user small { font-size: 10.5px; color: #64748b; }

.logout { margin-left: auto; color: #64748b; display: grid; place-items: center; padding: 5px; border-radius: 7px; }
.logout:hover { color: #f87171; background: rgba(255, 255, 255, .06); }

.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.menu-toggle {
    display: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink-2);
    place-items: center;
    cursor: pointer;
}

.crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.crumb strong { color: var(--ink); font-weight: 600; }
.crumb .sep { color: #cbd5e1; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.env {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    color: #15803d;
    background: var(--ok-soft);
    border-radius: 999px;
    padding: 3px 9px;
    font-weight: 500;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--ink-2);
    font-weight: 550;
    padding: 4px 8px;
    border-radius: 999px;
}
.user-chip:hover { background: #f4f6fb; }

.content {
    padding: 20px 22px 48px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 1560px;
}

/* ---------- Tiêu đề trang ---------- */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-head h1 { font-size: 21px; font-weight: 680; letter-spacing: -.02em; }
.sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; max-width: 100%; }
.page-head > div:first-child { min-width: 0; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    color: var(--muted);
    margin-bottom: 4px;
}
.back-link:hover { color: var(--primary); }

.link { font-size: 12.5px; font-weight: 550; color: var(--primary); }
.link:hover { text-decoration: underline; }

/* ---------- Nút ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 34px;
    padding: 0 13px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: #fff;
    color: var(--ink-2);
    font-family: inherit;
    font-size: 13px;
    font-weight: 550;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, box-shadow .15s, color .15s;
}

.btn:hover { background: #f8fafc; border-color: #c9d5e4; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 8px 16px -10px rgba(37, 99, 235, .9);
}
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }

.btn-danger { color: #b91c1c; border-color: #f0c9c9; background: #fff7f7; }
.btn-danger:hover { background: #fdecec; border-color: #e9b3b3; }

.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eef2f8; border-color: transparent; }

.btn-sm { height: 30px; font-size: 12.5px; padding: 0 10px; }
.btn-block { width: 100%; height: 38px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.icon-btn {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    border: 1px solid transparent;
    background: transparent;
    color: #7b8798;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    padding: 0;
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: #eef2f8; color: var(--primary); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.inline-form { display: inline; }

/* ---------- Thẻ ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    min-height: 54px;
}

.card-title { font-size: 14px; font-weight: 650; letter-spacing: -.01em; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 16px; }

.card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    background: #fbfcfe;
    flex-wrap: wrap;
}

/* ---------- Lưới ---------- */
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 12px; align-items: start; }

/* ---------- Thống kê ---------- */
.stat { padding: 15px 16px; display: flex; gap: 12px; align-items: flex-start; }

.stat-ico {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    flex: none;
}

.ico-blue { background: var(--primary-soft); color: var(--primary); }
.ico-green { background: var(--ok-soft); color: var(--ok); }
.ico-slate { background: #eef2f7; color: #475569; }
.ico-violet { background: var(--violet-soft); color: var(--violet); }
.ico-amber { background: var(--warn-soft); color: var(--warn); }

.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.mini-stat { padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.mini-label { font-size: 12px; color: var(--muted); }
.mini-value { font-size: 20px; font-weight: 700; }
.mini-value.ok { color: var(--ok); }
.mini-value.warn { color: var(--warn); }
.mini-value.danger { color: var(--danger); }

/* ---------- Bảng ---------- */
.table-wrap { width: 100%; overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 12.8px; }

.table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    text-align: left;
    padding: 9px 12px;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
    font-size: 10.8px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #748199;
    font-weight: 650;
    white-space: nowrap;
}

.table tbody td {
    padding: 9px 12px;
    border-bottom: 1px solid #eef2f7;
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #f9fbff; }

.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .nowrap { white-space: nowrap; }

.check-col { width: 36px; padding-right: 0 !important; }
.act-col { width: 96px; text-align: right; }

.row-actions { display: inline-flex; gap: 2px; align-items: center; justify-content: flex-end; }

.cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.strong-text { font-weight: 600; color: var(--ink); }
.strong-link { font-weight: 600; color: var(--ink); }
.strong-link:hover { color: var(--primary); }
.text-muted { color: var(--muted); }
.small { font-size: 11.5px; }
.mono { font-family: var(--mono); font-size: 12.2px; letter-spacing: -.01em; }

.cred-line { display: flex; align-items: center; gap: 3px; }
.secret { font-family: var(--mono); font-size: 12.2px; letter-spacing: .04em; color: var(--ink-2); min-width: 76px; }

.empty { padding: 34px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.empty p { margin-bottom: 10px; }
.empty-ico { width: 46px; height: 46px; border-radius: 12px; background: #f1f5f9; color: #94a3b8; display: grid; place-items: center; margin: 0 auto 10px; }

/* ---------- Pill / tag ---------- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11.3px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}
.pill .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--ok-soft); color: #15803d; }
.pill-mut { background: #eef2f7; color: #475569; }
.pill-warn { background: var(--warn-soft); color: #b45309; }
.pill-danger { background: var(--danger-soft); color: #b91c1c; }
.pill-info { background: var(--primary-soft); color: #1d4ed8; }
.pill-plain { background: #f1f5f9; color: #55637a; font-weight: 500; }

.tag {
    display: inline-block;
    font-family: var(--mono);
    font-size: 11.3px;
    background: #f4f7fb;
    border: 1px solid var(--line);
    color: #475569;
    padding: 1px 6px;
    border-radius: 6px;
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.tag-xs { font-size: 10.5px; padding: 0 5px; max-width: 150px; }
.cell-product { max-width: 240px; line-height: 1.35; }

.table-note { padding: 9px 14px; border-top: 1px dashed var(--line); font-size: 11.8px; color: var(--muted); }
.foot-note { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.table-scroll { max-height: 540px; overflow: auto; }
.table-preview { table-layout: fixed; font-size: 11.6px; }
.table-preview th, .table-preview td { padding: 7px 8px; }
.table-preview th:nth-child(1), .table-preview td:nth-child(1) { width: 40px; }
.table-preview th:nth-child(2), .table-preview td:nth-child(2) { width: 124px; }
.table-preview th:nth-child(3), .table-preview td:nth-child(3) { width: 92px; }
.table-preview th:nth-child(4), .table-preview td:nth-child(4) { width: 74px; }
.table-preview th:nth-child(5), .table-preview td:nth-child(5) { width: 112px; }
.table-preview th:nth-child(6), .table-preview td:nth-child(6) { width: 88px; }
.table-preview th:nth-child(7), .table-preview td:nth-child(7) { width: 92px; }
.table-preview th:nth-child(8), .table-preview td:nth-child(8) { width: 84px; }
.table-preview th:nth-child(9), .table-preview td:nth-child(9) { width: 78px; }
.table-preview th:nth-child(10), .table-preview td:nth-child(10) { width: 104px; }
.table-preview th:nth-child(11), .table-preview td:nth-child(11) { width: 92px; }
.table-preview th:nth-child(12), .table-preview td:nth-child(12) { width: 108px; }
.table-preview th:nth-child(13), .table-preview td:nth-child(13) { width: 92px; }
.table-preview td { height: 38px; }
.table-preview .pv-cell {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}
.table-preview .row-dim td { background: #fcfdff; color: #94a3b8; }
.tag-flag { background: #eef4ff; border-color: #dbe7fd; color: #1d4ed8; }

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 12px;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 11px 10px;
    font-size: 12.8px;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    font-weight: 500;
}

.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--primary); border-color: var(--primary); font-weight: 600; }

.tab-count {
    font-size: 10.8px;
    background: #eef2f7;
    color: #64748b;
    border-radius: 999px;
    padding: 0 6px;
    font-weight: 600;
    line-height: 1.7;
}
.tab.active .tab-count { background: var(--primary-soft); color: var(--primary); }

.tabs-spacer { flex: 1; }
.tab-link { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); padding: 0 6px; white-space: nowrap; }
.tab-link:hover { color: var(--primary); }

/* ---------- Toolbar ---------- */
.toolbar {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
    align-items: center;
    background: #fff;
}

.toolbar-search {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    color: #94a3b8;
    flex: 1;
    min-width: 220px;
    max-width: 380px;
}

.toolbar-search:focus-within { border-color: #93b4f7; box-shadow: 0 0 0 3px rgba(37, 99, 235, .13); }
.toolbar-search input { border: none; outline: none; background: transparent; font: inherit; font-size: 13px; color: var(--ink); width: 100%; height: 100%; }
.toolbar-search input::placeholder { color: #9aa7b8; }

.select-sm { height: 34px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 8px; font: inherit; font-size: 12.5px; background: #fff; color: var(--ink-2); max-width: 190px; }

/* ---------- Phân trang ---------- */
.table-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-top: 1px solid var(--line);
    font-size: 12px;
    flex-wrap: wrap;
    background: #fbfcfe;
}

.pager { display: inline-flex; gap: 4px; align-items: center; }

.page-btn {
    min-width: 28px;
    height: 28px;
    padding: 0 7px;
    display: inline-grid;
    place-items: center;
    border-radius: 7px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 500;
}
.page-btn:hover { background: #f1f5f9; }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn.disabled { opacity: .45; pointer-events: none; }

/* ---------- Bulk bar ---------- */
.bulkbar {
    position: sticky;
    bottom: 14px;
    margin: 0 14px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 10px;
    padding: 9px 12px;
    box-shadow: 0 16px 34px -18px rgba(15, 23, 42, .9);
    flex-wrap: wrap;
    z-index: 5;
}

.bulkbar-text { font-size: 12.5px; }
.bulkbar-text b { color: #fff; }
.bulkbar-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.bulkbar .btn { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .16); color: #e2e8f0; }
.bulkbar .btn:hover { background: rgba(255, 255, 255, .18); }
.bulkbar .btn-danger { background: rgba(220, 38, 38, .18); border-color: rgba(248, 113, 113, .4); color: #fecaca; }
.bulkbar .btn-ghost { background: transparent; border-color: transparent; color: #94a3b8; }

/* ---------- Biểu mẫu ---------- */
.form-card { overflow: visible; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.form-section + .form-section { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line); }
.form-section-title {
    font-size: 10.8px;
    text-transform: uppercase;
    letter-spacing: .09em;
    font-weight: 650;
    color: var(--muted);
    margin-bottom: 11px;
}

.file-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 18px 14px;
    border: 1px dashed #c7d3e3;
    border-radius: 10px;
    background: #fbfcfe;
    color: var(--muted);
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
}
.file-drop:hover, .file-drop.dragover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.file-drop b { color: var(--ink); font-weight: 600; }
.file-drop small { font-size: 11.5px; }
.file-drop input { display: none; }
.file-drop.has-file { border-color: #86efac; background: var(--ok-soft); color: #15803d; }
.file-drop.has-file b { color: #166534; }

.format-list {
    margin: 0 0 10px;
    padding-left: 18px;
    font-size: 12.3px;
    color: var(--ink-2);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* ---------- Ánh xạ cột khi nhập file ---------- */
.map-panel-wrap { overflow: hidden; }
.map-panel summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    cursor: pointer;
    list-style: none;
}
.map-panel summary::-webkit-details-marker { display: none; }
.map-panel summary::before { content: "▸"; color: var(--muted); font-size: 11px; }
.map-panel[open] summary::before { content: "▾"; }
.map-title { font-size: 13.5px; font-weight: 650; }
.map-sub { font-size: 11.8px; color: var(--muted); }
.map-form { padding: 12px 16px 14px; border-top: 1px dashed var(--line); background: #fbfcfe; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 9px; }
.map-item {
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 8px 9px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.map-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--muted);
    font-weight: 650;
}
.map-item select {
    height: 30px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    font: inherit;
    font-size: 12px;
    padding: 0 4px;
    width: 100%;
    background: #fff;
    color: var(--ink);
}
.map-hint { font-size: 10.8px; color: var(--muted); line-height: 1.4; }
.map-actions { display: flex; justify-content: flex-end; margin-top: 10px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12.3px; font-weight: 600; color: #3c4a60; }
.field-hint { font-size: 11.5px; color: var(--muted); }

.field input,
.field select,
.field textarea,
.form-card input[type="text"],
.form-card input[type="password"],
.form-card input[type="number"],
.form-card input[type="email"] {
    height: 36px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 0 10px;
    font: inherit;
    font-size: 13px;
    background: #fff;
    color: var(--ink);
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
}

.field textarea { height: auto; padding: 8px 10px; min-height: 76px; resize: vertical; line-height: 1.55; }

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: #93b4f7;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.field input::placeholder, .field textarea::placeholder { color: #9aa7b8; }

.input-group {
    display: flex;
    align-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    padding-right: 4px;
}
.input-group:focus-within { border-color: #93b4f7; box-shadow: 0 0 0 3px rgba(37, 99, 235, .14); }
.input-group input { border: none !important; box-shadow: none !important; background: transparent; }

.hint-box {
    height: 36px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    background: #f8fafc;
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
    font-size: 12px;
    color: var(--muted);
}

.total-box {
    height: 36px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--primary-soft);
    border: 1px solid #cfe0fd;
    border-radius: 8px;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.mono-input { font-family: var(--mono) !important; font-size: 12.4px !important; }

.detail-list { margin: 0; display: flex; flex-direction: column; gap: 0; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 28px; }
.detail-grid > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed #eef2f7; }
.detail-list > div:last-child { border-bottom: none; }
.detail-list dt { font-size: 12.3px; color: var(--muted); flex: none; }
.detail-list dd { margin: 0; font-size: 12.8px; font-weight: 550; text-align: right; color: var(--ink); word-break: break-word; }

.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.info-item { background: #f8fafc; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.info-item span { font-size: 11.5px; color: var(--muted); }
.info-item strong { font-size: 13px; font-weight: 600; word-break: break-word; }

/* ---------- Alert / toast ---------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 10px 13px;
    border-radius: 10px;
    font-size: 12.8px;
    border: 1px solid;
    line-height: 1.5;
}
.alert > .ico { margin-top: 1px; }
.alert-success { background: var(--ok-soft); border-color: #bfe8cf; color: #15803d; }
.alert-danger { background: var(--danger-soft); border-color: #f3c6c6; color: #b91c1c; }
.alert-warn { background: var(--warn-soft); border-color: #f5dcb7; color: #b45309; }
.alert-info { background: var(--primary-soft); border-color: #cfe0fd; color: #1d4ed8; }
.alert-close { margin-left: auto; border: none; background: transparent; color: inherit; font-size: 18px; line-height: 1; cursor: pointer; opacity: .6; padding: 0 2px; }
.alert-close:hover { opacity: 1; }
.alert-link { margin-left: auto; font-weight: 600; color: inherit; text-decoration: underline; white-space: nowrap; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 9px;
    padding: 9px 13px;
    font-size: 12.8px;
    box-shadow: 0 16px 34px -18px rgba(15, 23, 42, .9);
    animation: toast-in .18s ease-out;
}
.toast.ok { border-left: 3px solid #34d399; }
.toast.err { border-left: 3px solid #f87171; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Biểu đồ ---------- */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 176px; padding: 6px 2px 0; }
.chart-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; min-width: 0; }
.chart-bar {
    width: 100%;
    max-width: 44px;
    border-radius: 6px 6px 3px 3px;
    background: linear-gradient(180deg, #93c5fd, #2563eb);
    transition: filter .15s;
}
.chart-bar:hover { filter: brightness(1.08); }
.chart-lab { font-size: 10.8px; color: var(--muted); }
.chart-val { font-size: 10.8px; color: var(--ink-2); font-weight: 600; min-height: 14px; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 6px; display: flex; flex-direction: column; gap: 14px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.timeline li { display: flex; gap: 12px; position: relative; }
.tl-dot { width: 7px; height: 7px; border-radius: 50%; background: #cbd5e1; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); margin-top: 5px; flex: none; margin-left: -1px; z-index: 1; }
.tl-title { font-size: 12.8px; font-weight: 600; }
.tl-desc { font-size: 12px; color: var(--ink-2); }
.tl-time { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ---------- Khối mã ---------- */
.code-block {
    margin: 0 0 12px;
    background: #0f172a;
    color: #cbd5e1;
    border-radius: 9px;
    padding: 12px 13px;
    font-family: var(--mono);
    font-size: 11.8px;
    line-height: 1.65;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.tips { margin: 0; padding-left: 18px; font-size: 12.2px; color: var(--ink-2); display: flex; flex-direction: column; gap: 5px; }
.tips b { color: var(--ink); }

/* ---------- Đăng nhập ---------- */
.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(900px 420px at 12% 0%, #e3edff 0%, rgba(227, 237, 255, 0) 60%),
        radial-gradient(800px 400px at 100% 100%, #ede9fe 0%, rgba(237, 233, 254, 0) 55%),
        #f4f6fb;
    padding: 28px 18px;
}

.auth-wrap {
    width: min(980px, 100%);
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 30px 70px -40px rgba(15, 23, 42, .5);
    overflow: hidden;
}

.auth-side {
    padding: 34px 32px;
    background: linear-gradient(160deg, #0f172a 0%, #152242 55%, #1e3a8a 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-brand { display: flex; align-items: center; gap: 10px; color: #fff; margin-bottom: 6px; }
.auth-brand strong { display: block; font-size: 14.5px; }
.auth-brand small { font-size: 11px; color: #93a4bd; }
.brand-logo-lg { width: 40px; height: 40px; font-size: 20px; border-radius: 12px; }

.auth-side h1 { font-size: 22px; line-height: 1.35; letter-spacing: -.02em; color: #fff; font-weight: 680; }
.auth-side p { font-size: 12.8px; line-height: 1.65; color: #a9b7cb; }

.auth-points { list-style: none; margin: auto 0 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.auth-points li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #cbd5e1; }
.auth-points .ico { color: #34d399; }

.auth-card { padding: 34px 32px; display: flex; flex-direction: column; gap: 16px; }
.auth-card-head h2 { font-size: 19px; font-weight: 680; letter-spacing: -.02em; }
.auth-card-head p { font-size: 12.8px; color: var(--muted); margin-top: 3px; }

.auth-card .field label { font-size: 12.3px; }
.auth-card .field input { height: 38px; border: 1px solid var(--line-strong); border-radius: 9px; padding: 0 11px; font: inherit; font-size: 13.5px; width: 100%; }
.auth-card .field input:focus { outline: none; border-color: #93b4f7; box-shadow: 0 0 0 3px rgba(37, 99, 235, .14); }
.auth-card .input-group { border-radius: 9px; }
.auth-card .input-group input { border: none; box-shadow: none; }

.auth-hint { font-size: 11.8px; color: var(--muted); background: #f8fafc; border: 1px dashed var(--line-strong); border-radius: 9px; padding: 9px 11px; text-align: center; }
.auth-hint code { font-family: var(--mono); background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 0 4px; color: var(--ink-2); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-main { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 980px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 0 0 60px rgba(15, 23, 42, .5);
    }
    .sidebar.open { transform: none; }
    .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 40; }
    .menu-toggle { display: grid; }
    .env { display: none; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-side { display: none; }
    .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .content { padding: 16px 14px 40px; }
    .form-grid { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: 1fr; }
    .page-head h1 { font-size: 19px; }
    .toolbar-search { max-width: none; }
    .table-foot { justify-content: center; }
    .info-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0 14px; }
    .tab-link { display: none; }

    /* Bảng kho trên điện thoại: chuyển thành danh sách gọn */
    .table-accounts { display: block; width: 100%; }
    .table-accounts thead { display: none; }
    .table-accounts tbody { display: block; }
    .table-accounts tbody tr {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 11px 14px;
        border-bottom: 1px solid #eef2f7;
        flex-wrap: wrap;
    }
    .table-accounts tbody tr:last-child { border-bottom: none; }
    .table-accounts td { display: none; border: none; padding: 0; }
    .table-accounts td[colspan] { display: block; width: 100%; }
    .table-accounts td:nth-child(3),
    .table-accounts td:nth-child(8) { display: block; }
    .table-accounts td:nth-child(3) { min-width: 0; overflow-wrap: anywhere; }
    .table-accounts td:nth-child(3) .cell-sub { display: none; }
    .table-accounts td:nth-child(8) { flex: none; text-align: right; }
    .table-accounts td:nth-child(8) .cell-sub { display: none; }
    .table { font-size: 12.4px; }
    .table thead th, .table tbody td { padding: 8px 9px; }
}

/* ---------- In hoá đơn ---------- */
@media print {
    .sidebar, .topbar, .page-actions, .no-print, .bulkbar, .tabs, .toolbar, .card-foot, .toasts { display: none !important; }
    body { background: #fff; }
    .content { padding: 0; gap: 10px; max-width: none; }
    .card { box-shadow: none; border-color: #d9e0ea; break-inside: avoid; }
    .grid-main { grid-template-columns: 1fr; }
    .back-link { display: none; }
    .page-head h1 { font-size: 18px; }
}
