/* XNK Manager - giao diện ứng dụng */
@font-face { font-family: "Be Vietnam Pro"; font-weight: 400; font-display: swap; src: url(/vendor/fonts/be-vietnam-pro-vietnamese-400-normal.woff2) format("woff2"); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 400; font-display: swap; src: url(/vendor/fonts/be-vietnam-pro-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 600; font-display: swap; src: url(/vendor/fonts/be-vietnam-pro-vietnamese-600-normal.woff2) format("woff2"); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 600; font-display: swap; src: url(/vendor/fonts/be-vietnam-pro-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #f3f5f9; --surface: #fff; --border: #dfe4ec; --border-strong: #c5cdd9;
  --text: #1b2533; --muted: #64708a; --primary: #1657c2; --primary-dark: #0f459c; --primary-soft: #e8f0fd;
  --success: #15803d; --success-soft: #e3f6e9; --warning: #b45309; --warning-soft: #fdf1dc;
  --danger: #c02626; --danger-soft: #fde8e8; --info: #0b6aa8; --info-soft: #e1f1fb; --neutral-soft: #eceff4;
  --sidebar: #10213d; --sidebar-text: #c7d2e5; --radius: 8px; --shadow: 0 1px 2px rgba(16, 33, 61, .06), 0 1px 6px rgba(16, 33, 61, .04);
}
* { box-sizing: border-box; }
html { font-size: 14px; }
body { margin: 0; font-family: "Be Vietnam Pro", "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; font-weight: 600; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h2 { font-size: 1.02rem; margin: 0 0 .75rem; font-weight: 600; display: flex; align-items: center; gap: .4rem; }
h3 { font-size: 1.05rem; margin: 0 0 .75rem; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.18em; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; }
.empty { color: var(--muted); padding: .75rem 0; margin: 0; }
.hint { color: var(--muted); font-size: .88rem; margin: .2rem 0 .6rem; display: block; }

/* Bố cục */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 236px; background: var(--sidebar); color: var(--sidebar-text); flex: none; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .65rem; padding: 1rem 1rem .9rem; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark { background: var(--primary); color: #fff; font-weight: 600; border-radius: 8px; padding: .4rem .5rem; font-size: .85rem; letter-spacing: .04em; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text small { color: var(--sidebar-text); font-size: .78rem; }
.nav { padding: 0 .6rem 1.5rem; }
.nav-section { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #8494b3; padding: .9rem .6rem .3rem; }
.nav-item { display: flex; align-items: center; gap: .6rem; padding: .48rem .6rem; border-radius: 6px; color: var(--sidebar-text); }
.nav-item:hover { background: rgba(255, 255, 255, .07); text-decoration: none; color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; background: var(--surface); border-bottom: 1px solid var(--border); padding: .55rem 1.25rem; position: sticky; top: 0; z-index: 20; }
.topbar-title { font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: .4rem; }
.topbar-actions form { margin: 0; }
.menu-btn { display: none; }
.icon-btn { position: relative; background: none; border: 0; padding: .4rem; border-radius: 6px; cursor: pointer; color: var(--muted); display: inline-flex; }
.icon-btn:hover { background: var(--neutral-soft); color: var(--text); }
.dot { position: absolute; top: -2px; right: -4px; background: var(--danger); color: #fff; border-radius: 10px; font-size: .68rem; padding: 0 .32rem; line-height: 1.35; }
.user-chip { display: flex; align-items: center; gap: .5rem; padding: .2rem .5rem; border-radius: 8px; color: var(--text); }
.user-chip:hover { background: var(--neutral-soft); text-decoration: none; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 600; }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta small { color: var(--muted); font-size: .78rem; }
.content { padding: 1.25rem; max-width: 1500px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-actions { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }
.page-actions form { margin: 0; }
.back { font-size: .88rem; color: var(--muted); display: inline-block; margin-bottom: .15rem; }

/* Thẻ, lưới */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin: 0 0 1rem; box-shadow: var(--shadow); min-width: 0; }
fieldset.card legend { font-weight: 600; padding: 0 .4rem; font-size: 1.02rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .8rem 1rem; }
.col-2 { grid-column: span 2; } .col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; } .col-8 { grid-column: span 8; } .col-9 { grid-column: span 9; } .col-12 { grid-column: span 12; }
.grid > .card { margin: 0; }
.detail { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(280px, 1fr); gap: 1rem; align-items: start; }
.detail-main, .detail-side { min-width: 0; }
.dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem 1.2rem; margin: 0; }
.dl > div { min-width: 0; }
.dl > .wide { grid-column: 1 / -1; }
.dl dt { color: var(--muted); font-size: .82rem; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: var(--radius); padding: .75rem .9rem; display: flex; flex-direction: column; color: var(--text); box-shadow: var(--shadow); }
.stat:hover { text-decoration: none; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.45rem; font-weight: 600; line-height: 1.3; }
.stat-hint { color: var(--muted); font-size: .8rem; }
.stat-info { border-left-color: var(--info); } .stat-success { border-left-color: var(--success); }
.stat-warning { border-left-color: var(--warning); } .stat-danger { border-left-color: var(--danger); }

/* Nút, form */
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .8rem; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap; line-height: 1.3; }
.btn:hover { background: var(--neutral-soft); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #116632; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #9d1c1c; }
.btn-warning { background: var(--warning-soft); border-color: #e5c07b; color: #7a3a05; }
.btn-ghost { border-color: transparent; background: none; color: var(--muted); }
.btn-ghost-danger { border-color: transparent; background: none; color: var(--danger); }
.btn-sm { padding: .25rem .55rem; font-size: .88rem; }
.btn-block { width: 100%; justify-content: center; padding: .6rem; }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .2rem; min-width: 0; }
.field > label { font-size: .86rem; color: #3b4760; font-weight: 600; }
.req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input:not([type]), select, textarea {
  width: 100%; padding: .45rem .6rem; border: 1px solid var(--border-strong); border-radius: 6px; font: inherit; color: var(--text); background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(22, 87, 194, .28); border-color: var(--primary); }
textarea { resize: vertical; }
input.num { text-align: right; }
.check { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; cursor: pointer; }
.check input { width: auto; }
.form-actions { display: flex; gap: .5rem; margin: 1rem 0; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .8rem; align-items: center; }
.filters input[type=search] { width: 230px; }
.filters select, .filters input[type=date] { width: auto; max-width: 230px; }
.inline { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); }

/* Bảng */
.table-wrap { overflow-x: auto; margin: 0 -.2rem; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: .5rem .6rem; border-bottom: 1px solid var(--border-strong); white-space: nowrap; background: #f8f9fc; }
.table td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tfoot td { border-bottom: 0; background: #f8f9fc; }
.table-hover tbody tr:hover { background: #f5f8fe; }
.table .num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .idx { width: 2.4rem; color: var(--muted); text-align: center; }
.row-link { font-weight: 600; }
.lines td { padding: .25rem .3rem; border-bottom: 0; }
.lines input, .lines select, .lines textarea { padding: .35rem .45rem; }
.pagination { display: flex; justify-content: space-between; align-items: center; padding-top: .8rem; gap: 1rem; }
.pages { display: flex; gap: .9rem; align-items: center; }

/* Nhãn trạng thái, thông báo */
.badge { display: inline-block; padding: .08rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: var(--neutral-soft); color: #414c63; vertical-align: middle; }
.badge-info { background: var(--info-soft); color: var(--info); } .badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); } .badge-danger { background: var(--danger-soft); color: var(--danger); }
.alert { padding: .7rem .95rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.alert ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.alert-success { background: var(--success-soft); border-color: #b5e2c3; color: #0f5c2c; }
.alert-error { background: var(--danger-soft); border-color: #f3b9b9; color: #8f1a1a; }
.alert-warning { background: var(--warning-soft); border-color: #f0d49b; color: #7a3a05; }
.alert-info { background: var(--info-soft); border-color: #b6dcf2; color: #084f7e; }

/* Chi tiết: in ấn, tệp, trao đổi, dòng thời gian */
.docbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; background: var(--primary-soft); border: 1px solid #cfdefa; border-radius: var(--radius); padding: .55rem .9rem; margin-bottom: 1rem; }
.docbar-title { font-weight: 600; color: var(--primary-dark); display: inline-flex; gap: .35rem; align-items: center; }
.docgroup { display: inline-flex; align-items: center; gap: .1rem; }
.files, .comments, .timeline, .notif-list { list-style: none; padding: 0; margin: 0 0 .8rem; }
.files li { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; padding: .35rem 0; border-bottom: 1px dashed var(--border); }
.files li a { font-weight: 600; overflow-wrap: anywhere; }
.files li form { margin: 0 0 0 auto; }
.upload { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.upload input[type=file] { max-width: 100%; font-size: .88rem; }
.comments li { padding: .5rem .65rem; border-radius: 8px; background: #f6f8fb; margin-bottom: .5rem; }
.comments li.from-customer { background: #fff8e8; }
.comment-head { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; font-size: .88rem; }
.comment-body { margin-top: .2rem; overflow-wrap: anywhere; }
.comment-actions { display: flex; justify-content: space-between; align-items: center; margin-top: .4rem; gap: .5rem; }
.timeline li { padding: 0 0 .7rem .9rem; border-left: 2px solid var(--border); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: .45rem; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.timeline.small { font-size: .88rem; }
.notif-list li a { display: flex; flex-direction: column; padding: .65rem .5rem; border-bottom: 1px solid var(--border); color: var(--text); }
.notif-list li.unread a { background: var(--primary-soft); }
.doc-preview { border: 1px solid var(--border); border-radius: 6px; padding: 1.5rem 2rem; background: #fff; font-family: "Times New Roman", Tinos, "Liberation Serif", serif; font-size: 13pt; line-height: 1.45; max-height: 640px; overflow: auto; }
.doc-preview table { border-collapse: collapse; width: 100%; }
.doc-preview td, .doc-preview th { border: 1px solid #333; padding: 3px 6px; }
.rich table { border-collapse: collapse; } .rich td, .rich th { border: 1px solid var(--border-strong); padding: 2px 6px; }
.pipeline { display: flex; flex-wrap: wrap; gap: 2px; margin: 0 0 1rem; }
.pipeline span { flex: 1 0 auto; text-align: center; padding: .4rem .55rem; background: var(--neutral-soft); color: var(--muted); font-size: .78rem; white-space: nowrap; border-radius: 4px; }
.pipeline .done { background: var(--success-soft); color: var(--success); }
.pipeline .current { background: var(--primary); color: #fff; font-weight: 600; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: .5rem; align-items: baseline; padding: .25rem 0; }
.checklist .ok { color: var(--success); } .checklist .warn { color: var(--warning); } .checklist .err { color: var(--danger); }
.chart-box { position: relative; height: 280px; }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border-bottom: 1px dashed var(--border); }
.kv:last-child { border-bottom: 0; }
.kv strong { font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border-strong); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .5rem .9rem; border-radius: 6px 6px 0 0; color: var(--muted); }
.tabs a.active { background: var(--surface); border: 1px solid var(--border-strong); border-bottom-color: var(--surface); margin-bottom: -1px; color: var(--text); font-weight: 600; }

/* Hộp thoại */
.dialog { border: 0; border-radius: 10px; padding: 1.25rem; width: min(520px, 92vw); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.dialog::backdrop { background: rgba(16, 33, 61, .45); }
.dialog .field { margin-bottom: .7rem; }

/* Đăng nhập, lỗi */
.auth-body { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(135deg, #10213d, #1657c2); padding: 1rem; }
.auth-card { background: #fff; border-radius: 12px; padding: 2rem; width: min(420px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.auth-card h1 { margin-bottom: .4rem; }
.auth-card .field { margin-bottom: .85rem; }
.auth-brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.2rem; }
.auth-brand small { display: block; color: var(--muted); }
.error-code { font-size: 3rem; font-weight: 600; color: var(--primary); line-height: 1; }

/* Cổng khách hàng */
.portal-top { background: var(--sidebar); color: #fff; }
.portal-top .inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; flex-wrap: wrap; }
.portal-nav { display: flex; gap: .2rem; flex: 1; flex-wrap: wrap; }
.portal-nav a { color: var(--sidebar-text); padding: .4rem .7rem; border-radius: 6px; }
.portal-nav a.active, .portal-nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; text-decoration: none; }
.portal-top .icon-btn { color: var(--sidebar-text); }
.portal-content { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem; }

@media (max-width: 1100px) { .detail { grid-template-columns: 1fr; } .dl { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -260px; z-index: 40; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .4); }
  .menu-btn { display: inline-flex; }
  .user-meta { display: none; }
  .grid > [class*=col-] { grid-column: 1 / -1; }
  .dl { grid-template-columns: 1fr; }
  .content { padding: .9rem; }
}
@media print { .sidebar, .topbar, .page-actions, .docbar, .detail-side, .filters, .no-print { display: none !important; } .content { padding: 0; } .card { box-shadow: none; } }
