﻿/* Giao diện theo quy chuẩn của STARLIGHT-ERP: nền navy hoặc sáng, điểm nhấn đỏ.
   Bootstrap đọc màu từ biến --bs-*, nên đổi biến là đổi được toàn bộ trang. */

:root {
  --sl-accent: #d92c45;
  --sl-accent-hover: #e8475d;
  --sl-accent-deep: #b91c32;
  --sl-sidebar: 260px;
  --sl-bottom-nav: 64px;
}

:root[data-theme="dark"] {
  --sl-bg: #0c1422;
  --sl-surface: #141f30;
  --sl-raised: #172438;
  --sl-hover: #1b2a3e;
  --sl-line: #31425a;
  --sl-text: #edf2fa;
  --sl-muted: #a5b3c6;
  --sl-link: #f26b7a;
  --sl-danger: #f58a8a;
  --sl-shadow: 0 4px 20px rgba(0, 0, 0, .18);
  --bs-link-color-rgb: 242, 107, 122;
  --bs-link-hover-color-rgb: 255, 168, 181;
}

:root[data-theme="light"] {
  --sl-bg: #f4f6fa;
  --sl-surface: #ffffff;
  --sl-raised: #f8fafc;
  --sl-hover: #edf2f8;
  --sl-line: #d5deea;
  --sl-text: #1c2b40;
  --sl-muted: #53657b;
  --sl-link: #b51d36;
  --sl-danger: #b51d36;
  --sl-shadow: 0 4px 20px rgba(36, 61, 96, .06);
  --bs-link-color-rgb: 181, 29, 54;
  --bs-link-hover-color-rgb: 150, 22, 42;
}

:root[data-theme] {
  --bs-body-bg: var(--sl-bg);
  --bs-body-color: var(--sl-text);
  --bs-emphasis-color: var(--sl-text);
  --bs-secondary-color: var(--sl-muted);
  --bs-border-color: var(--sl-line);
  --bs-tertiary-bg: var(--sl-raised);
  --bs-form-invalid-color: var(--sl-danger);
  --bs-form-invalid-border-color: var(--sl-danger);
  --bs-body-font-family: "Segoe UI", Arial, sans-serif;
}

html { font-size: 15px; }
body { min-width: 320px; background: var(--sl-bg); color: var(--sl-text); }
a { text-underline-offset: 2px; }
.text-danger { color: var(--sl-danger) !important; }
.text-muted { color: var(--sl-muted) !important; }
:is(button, a, input, select, textarea, summary):focus-visible { outline: 2px solid var(--sl-accent); outline-offset: 2px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--sl-accent-deep); }
.form-check-input:checked { background-color: var(--sl-accent-deep); border-color: var(--sl-accent-deep); }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }

/* ----- Khung ứng dụng ----- */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-content { flex: 1; padding: 24px; }

.sidebar {
  width: var(--sl-sidebar);
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--sl-surface);
  box-shadow: 1px 0 0 var(--sl-line);
  z-index: 1045;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; height: 72px; padding: 0 20px; border-top: 2px solid var(--sl-accent); flex: none; }
.sidebar-close { margin-left: auto; }

.sidebar-cta { padding: 4px 16px 12px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 0 12px 12px; }
.nav-section { padding: 16px 10px 6px; font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--sl-muted); }
.nav-link-item {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 8px 12px; margin-bottom: 2px;
  border-radius: 10px; color: var(--sl-text); text-decoration: none;
}
.nav-link-item:hover { background: var(--sl-hover); color: var(--sl-text); }
.nav-link-item.active { background: rgba(217, 44, 69, .12); color: var(--sl-link); font-weight: 600; }
.nav-link-item.active::after { content: ""; width: 7px; height: 7px; margin-left: auto; border-radius: 50%; background: var(--sl-accent); box-shadow: 0 0 0 4px rgba(217, 44, 69, .14); }
/* Ô chọn có tìm kiếm (site.js: enhanceSelect) */
.tp-search { position: relative; }
.tp-search-native { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.tp-search-input { cursor: text; text-overflow: ellipsis; }
.tp-search-list {
  position: absolute; z-index: 1060; left: 0; right: 0; top: calc(100% + 2px);
  max-height: 280px; overflow-y: auto; margin: 0; padding: 4px; list-style: none;
  background: var(--bs-body-bg); color: var(--bs-body-color);
  border: 1px solid var(--bs-border-color); border-radius: 8px; box-shadow: 0 10px 28px rgba(0, 0, 0, .16);
}
.tp-search-list li { padding: 7px 10px; border-radius: 6px; cursor: pointer; line-height: 1.3; }
.tp-search-list li.active { background: var(--sl-hover); }
.tp-search-list li[aria-selected="true"] { font-weight: 600; }
.tp-search-list li.note { color: var(--sl-muted); cursor: default; font-size: .85em; }
.tp-search:has(.is-invalid) .tp-search-input { border-color: var(--bs-form-invalid-border-color); }

/* Nhóm menu thu gọn được (Quản trị > Danh mục) */
.nav-group > summary { list-style: none; cursor: pointer; user-select: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-chevron { width: 16px; height: 16px; margin-left: auto; opacity: .75; transition: transform .15s ease; }
.nav-group[open] > summary .nav-chevron { transform: rotate(90deg); }
.nav-sub { padding-left: 32px; }
.nav-sub .nav-link-item { min-height: 38px; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--sl-line); }
.sidebar-user { font-size: .85rem; color: var(--sl-muted); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar {
  position: sticky; top: 0; z-index: 1020;
  height: 72px; flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  border-top: 2px solid var(--sl-accent);
  background: var(--sl-surface);
  box-shadow: 0 1px 0 var(--sl-line);
}
.topbar-title { flex: 1; min-width: 0; margin: 0; font-size: 1.2rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 42px; height: 42px; flex: none;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--sl-muted);
}
.icon-btn:hover { background: var(--sl-hover); color: var(--sl-link); }
:root[data-theme="dark"] .only-light, :root[data-theme="light"] .only-dark { display: none; }

.nav-backdrop { position: fixed; inset: 0; z-index: 1040; background: rgba(15, 23, 42, .72); }
.nav-toggle, .sidebar-close, .nav-collapse { display: none; }

/* Máy tính: ẩn/hiện menu trái */
@media (min-width: 1024px) {
  .nav-collapse { display: inline-grid; }
  .sidebar { transition: margin-left .2s ease, visibility .2s; }
  :root[data-nav="hidden"] .sidebar { margin-left: calc(-1 * var(--sl-sidebar)); visibility: hidden; }
}

.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--sl-surface);
  box-shadow: 0 -1px 0 var(--sl-line);
}
.bottom-item {
  height: var(--sl-bottom-nav);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: transparent;
  color: var(--sl-muted); font-size: .72rem; text-decoration: none;
}
.bottom-item.active { color: var(--sl-link); font-weight: 600; }
.bottom-create .bottom-plus {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(145deg, var(--sl-accent-hover), var(--sl-accent-deep));
}

/* ----- Thành phần Bootstrap ----- */
.card {
  --bs-card-bg: var(--sl-surface);
  --bs-card-border-color: var(--sl-line);
  --bs-card-cap-bg: transparent;
  --bs-card-border-radius: 14px;
  --bs-card-inner-border-radius: 13px;
  --bs-card-color: var(--sl-text);
  box-shadow: var(--sl-shadow);
}
.card-header { font-weight: 600; }
.panel { background: var(--sl-surface); border: 1px solid var(--sl-line); border-radius: 14px; box-shadow: var(--sl-shadow); }

.btn { min-height: 42px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-sm { min-height: 36px; }
.btn-link { min-height: 0; }
.btn-primary {
  --bs-btn-color: #fff; --bs-btn-bg: var(--sl-accent-deep); --bs-btn-border-color: var(--sl-accent-deep);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--sl-accent); --bs-btn-hover-border-color: var(--sl-accent);
  --bs-btn-active-color: #fff; --bs-btn-active-bg: var(--sl-accent-deep); --bs-btn-active-border-color: var(--sl-accent-deep);
  --bs-btn-disabled-bg: var(--sl-accent-deep); --bs-btn-disabled-border-color: var(--sl-accent-deep);
  border-radius: 999px; padding-left: 1.25rem; padding-right: 1.25rem; font-weight: 600;
}
.btn-outline-primary {
  --bs-btn-color: var(--sl-link); --bs-btn-border-color: var(--sl-link);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--sl-accent-deep); --bs-btn-hover-border-color: var(--sl-accent-deep);
  --bs-btn-active-color: #fff; --bs-btn-active-bg: var(--sl-accent-deep); --bs-btn-active-border-color: var(--sl-accent-deep);
}
.btn-outline-secondary {
  --bs-btn-color: var(--sl-text); --bs-btn-border-color: var(--sl-line);
  --bs-btn-hover-color: var(--sl-text); --bs-btn-hover-bg: var(--sl-hover); --bs-btn-hover-border-color: var(--sl-muted);
  --bs-btn-active-color: var(--sl-text); --bs-btn-active-bg: var(--sl-hover); --bs-btn-active-border-color: var(--sl-muted);
  --bs-btn-disabled-color: var(--sl-muted); --bs-btn-disabled-border-color: var(--sl-line);
}

.form-label { margin-bottom: .3rem; font-size: .88rem; color: var(--sl-muted); }
.form-control, .form-select { min-height: 42px; background-color: var(--sl-raised); border-color: var(--sl-line); color: var(--sl-text); border-radius: 10px; }
.form-control-sm, .form-select-sm { min-height: 38px; border-radius: 8px; }
.form-control:hover, .form-select:hover { border-color: var(--sl-muted); }
.form-control:focus, .form-select:focus { background-color: var(--sl-raised); color: var(--sl-text); border-color: var(--sl-accent); box-shadow: 0 0 0 .2rem rgba(217, 44, 69, .22); }
.form-control::placeholder { color: var(--sl-muted); opacity: .8; }
.form-control-plaintext { color: var(--sl-text); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--sl-danger); }

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--sl-text);
  --bs-table-border-color: var(--sl-line);
  --bs-table-hover-bg: rgba(217, 44, 69, .05);
  --bs-table-hover-color: var(--sl-text);
  margin-bottom: 0;
}
.table > thead th {
  font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--sl-muted); background: var(--sl-raised); white-space: nowrap;
}
.table > tbody > tr:last-child > * { border-bottom: 0; }
.table td, .table th { padding: .6rem .75rem; }
.table-responsive.panel { overflow-x: auto; }

.badge.status { border: 1px solid; border-radius: 999px; padding: .32em .75em; font-weight: 600; }
.status-draft { color: var(--sl-muted); background: rgba(148, 163, 184, .14); border-color: rgba(148, 163, 184, .4); }
.status-created { color: #215fbd; background: rgba(59, 130, 246, .12); border-color: rgba(59, 130, 246, .45); }
.status-printed { color: #11764f; background: #dcf5e8; border-color: #7fcfa8; }
.status-unlocked { color: #865d08; background: rgba(245, 185, 66, .2); border-color: rgba(202, 138, 4, .55); }
.status-completed { color: #fff; background: #11764f; border-color: #11764f; }
.status-cancelled { color: var(--sl-danger); background: rgba(242, 106, 106, .12); border-color: rgba(242, 106, 106, .45); }
:root[data-theme="dark"] .status-created { color: #93c0ff; }
:root[data-theme="dark"] .status-printed { color: #86efc1; background: rgba(52, 211, 153, .18); border-color: rgba(52, 211, 153, .5); }
:root[data-theme="dark"] .status-unlocked { color: #f5cf7a; }
:root[data-theme="dark"] .status-completed { color: #06281b; background: #86efc1; border-color: #86efc1; }

/* Thẻ thu gọn được trên màn hình hẹp */
.card.is-collapsible > .card-header { cursor: pointer; display: flex; align-items: center; gap: 8px; }
.card.is-collapsible > .card-header::after { content: "▾"; margin-left: auto; color: var(--sl-muted); transition: transform .15s; }
.card.is-collapsed > .card-header { border-bottom: 0; }
.card.is-collapsed > .card-header::after { transform: rotate(-90deg); }
.card.is-collapsed > :not(.card-header) { display: none; }

/* ----- Form tạo đơn ----- */
.stepper { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; }
.step-btn {
  width: 100%; min-height: 48px; padding: 6px 10px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--sl-line); border-radius: 10px;
  background: var(--sl-surface); color: var(--sl-muted); font-weight: 600;
}
.step-btn:hover { background: var(--sl-hover); }
.step-btn.active { background: var(--sl-accent-deep); border-color: var(--sl-accent-deep); color: #fff; }
.step-no { width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; background: rgba(148, 163, 184, .2); }
.step-btn.active .step-no { background: rgba(255, 255, 255, .25); }

.item-row { border-color: var(--sl-line) !important; background: var(--sl-raised); border-radius: 12px !important; }
#packageRows input, #packageRows select { min-width: 5.5rem; }
#packageRows select { min-width: 8rem; }
.table-hover > tbody > tr > td:first-child { white-space: nowrap; }

.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.form-actions-right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.summary-card { top: 88px; }
.summary-card dt { font-weight: 500; color: var(--sl-muted); }
.summary-card dd { margin-bottom: .4rem; word-break: break-word; }
.summary-mini { font-weight: 400; font-size: .85rem; color: var(--sl-muted); margin-left: auto; white-space: nowrap; }
.summary-card.is-collapsible > .card-header::after { margin-left: 0; }
@media (min-width: 1200px) { .summary-mini { display: none; } }

.form-select.w-auto { max-width: 100%; }

/* ----- Trang tổng quan ----- */
:root[data-theme="light"] { --dash-bar: #2f6fd0; }
:root[data-theme="dark"] { --dash-bar: #4388e6; }
.dash-filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding: 12px 14px; margin-bottom: 10px; }
.dash-filter .form-label { font-size: .8rem; color: var(--sl-muted); margin-bottom: 2px; }
.dash-presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.dash-presets .btn-check:checked + .btn { background: var(--sl-accent-deep); border-color: var(--sl-accent-deep); color: #fff; }
.dash-custom { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.dash-custom[hidden] { display: none; }
.dash-selects { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; flex: 1 1 100%; }
.dash-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; margin-bottom: 10px; font-size: .85rem; color: var(--sl-muted); }
.dash-meta-right { display: inline-flex; align-items: baseline; gap: 12px; }
.dash-banner { padding: 8px 12px; font-size: .9rem; }
.dash-banner[hidden], .dash-error[hidden], #dashContent[hidden] { display: none; }
.is-loading { opacity: .55; transition: opacity .15s; }

.dash-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.dash-tile { display: flex; flex-direction: column; gap: 4px; min-height: 132px; padding: 14px; background: var(--sl-surface); border: 1px solid var(--sl-line); border-radius: 14px; box-shadow: var(--sl-shadow); }
.dash-skeleton { background: var(--sl-raised); box-shadow: none; }
.dash-tile-label { font-size: .88rem; font-weight: 600; }
.dash-unit { font-weight: 400; font-size: .82rem; color: var(--sl-muted); }
.dash-tile-value { font-size: 1.9rem; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.dash-tile-none { font-size: 1.15rem; font-weight: 700; color: var(--sl-muted); line-height: 1.5; }
.dash-tile-note { margin: auto 0 0; font-size: .8rem; color: var(--sl-muted); }
.dash-delta { font-size: .8rem; color: var(--sl-muted); }
.dash-money { display: flex; flex-direction: column; gap: 2px; }
.dash-money-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.dash-money-amount { font-size: 1.25rem; font-weight: 700; overflow-wrap: anywhere; }
.dash-money-cur { font-size: .8rem; color: var(--sl-muted); }

.dash-card { height: 100%; }
.dash-empty { display: flex; flex-direction: column; justify-content: center; gap: 4px; min-height: 140px; padding: 16px; text-align: center; color: var(--sl-muted); }
.dash-empty strong { color: var(--sl-text); }
.dash-empty-error { color: var(--sl-danger); }
.dash-chart { position: relative; border-radius: 8px; }
.dash-chart:focus-visible { outline: 2px solid var(--sl-accent); outline-offset: 2px; }
.dash-svg { display: block; max-width: 100%; }
.dash-grid { stroke: var(--sl-line); stroke-width: 1; opacity: .6; }
.dash-axis { fill: var(--sl-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.dash-peak { fill: var(--sl-text); font-size: 12px; font-weight: 600; }
.dash-bar { fill: var(--dash-bar); }
.dash-bar.active, .dash-bar-cost.active { opacity: .75; }
/* Chi phí: cam #d95926, đã kiểm tra tách màu với xanh doanh thu trên nền sáng và tối (kể cả mù màu). */
.dash-bar-cost { fill: #d95926; }
.dash-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 6px; font-size: .82rem; color: var(--sl-muted); }
.dash-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dash-key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.dash-key-revenue { background: var(--dash-bar); }
.dash-key-cost { background: #d95926; }
.dash-hit { fill: transparent; }
.dash-tip { position: absolute; display: flex; flex-direction: column; padding: 6px 10px; background: var(--sl-raised); border: 1px solid var(--sl-line); border-radius: 8px; box-shadow: var(--sl-shadow); font-size: .82rem; pointer-events: none; white-space: nowrap; z-index: 2; }
.dash-tip[hidden] { display: none; }
.dash-details { margin-top: 8px; font-size: .85rem; }
.dash-details summary { color: var(--sl-muted); cursor: pointer; }
.dash-table-scroll { max-height: 220px; overflow-y: auto; margin-top: 6px; }
.dash-table td, .dash-table th { font-variant-numeric: tabular-nums; }

.dash-rank { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.dash-rank-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.dash-rank-name { min-width: 0; overflow-wrap: anywhere; }
.dash-rank-value { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; }
.dash-rank-track { height: 8px; border-radius: 4px; background: var(--sl-raised); box-shadow: inset 0 0 0 1px var(--sl-line); overflow: hidden; }
.dash-rank-bar { height: 100%; border-radius: 0 4px 4px 0; background: var(--dash-bar); }
.dash-rank-detail { margin-top: 2px; font-size: .8rem; color: var(--sl-muted); overflow-wrap: anywhere; }
.dash-rank-others { margin: 12px 0 0; font-size: .82rem; color: var(--sl-muted); }

.dash-orders td { overflow-wrap: anywhere; }
.dash-list-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.dash-tabs { display: inline-flex; gap: 6px; }
.dash-tabs .btn.active { background: var(--sl-accent-deep); border-color: var(--sl-accent-deep); color: #fff; }
.dash-pager { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; font-size: .85rem; color: var(--sl-muted); }
.dash-pager span { margin-right: auto; }

@media (max-width: 1199.98px) { .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767.98px) { .dash-selects { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 439.98px) { .dash-kpis { grid-template-columns: minmax(0, 1fr); } .dash-tile { min-height: 0; } }

/* ----- Chọn dịch vụ ----- */
.svc-tabs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.svc-tab { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 60px; padding: 8px 14px; border: 1px solid var(--sl-line); border-radius: 12px; background: var(--sl-raised); color: var(--sl-text); text-align: left; }
.svc-tab:hover { background: var(--sl-hover); }
.svc-tab.active { border-color: var(--sl-accent); background: rgba(217, 44, 69, .12); }
.svc-tab-name { font-weight: 700; }
.svc-tab-count { font-size: .82rem; color: var(--sl-muted); }
.svc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.svc-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 1px solid var(--sl-line); border-radius: 12px; background: var(--sl-raised); color: var(--sl-text); text-align: left; }
.svc-card:hover { background: var(--sl-hover); }
.svc-card.selected { border-color: var(--sl-accent); box-shadow: 0 0 0 1px var(--sl-accent); background: rgba(217, 44, 69, .08); }
.svc-logo { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 10px; background: var(--sl-surface); border: 1px solid var(--sl-line); font-size: .68rem; font-weight: 800; letter-spacing: .02em; color: var(--sl-link); overflow: hidden; }
.svc-main { display: flex; flex-direction: column; min-width: 0; }
.svc-name { font-weight: 700; overflow-wrap: anywhere; }
.svc-sub { font-size: .85rem; color: var(--sl-muted); overflow-wrap: anywhere; }
.svc-meta { display: flex; flex-wrap: wrap; column-gap: 12px; font-size: .82rem; color: var(--sl-muted); }
.svc-price { font-weight: 700; white-space: nowrap; text-align: right; }
.svc-card { position: relative; }
.svc-card.svc-best { border-color: #1f9d55; }
.svc-card.svc-best::after { content: "Đề xuất"; position: absolute; top: -9px; right: 10px; padding: 0 8px; border-radius: 999px; background: #1f9d55; color: #fff; font-size: .72rem; font-weight: 700; line-height: 18px; }
.svc-card.svc-over { opacity: .6; }
.svc-card.svc-noprice .svc-price { font-weight: 600; color: var(--sl-muted); }
/* Logo thường thiết kế trên nền trắng nên giữ nền trắng cả ở giao diện tối. */
.svc-logo-img { width: 48px; height: 48px; flex: none; object-fit: contain; padding: 4px; border-radius: 10px; background: #fff; border: 1px solid var(--sl-line); }
td .svc-logo-img, .svc-logo-sm { width: 36px; height: 36px; flex: none; }
.svc-logo-sm { font-size: .6rem; }
.svc-filters { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.svc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.svc-chip { padding: 4px 12px; border: 1px solid var(--sl-line); border-radius: 999px; background: var(--sl-raised); color: var(--sl-text); font-size: .85rem; }
.svc-chip:hover { background: var(--sl-hover); }
.svc-chip.active { border-color: var(--sl-accent); background: rgba(217, 44, 69, .12); font-weight: 600; }
.svc-more:not(:empty) { margin-top: 6px; }
.svc-weight-table td, .svc-weight-table th { white-space: nowrap; }
.rate-table th, .rate-table td { vertical-align: middle; }
.rate-edit input[type=number] { min-width: 92px; }
.rate-edit thead input { min-width: 92px; font-weight: 600; }

/* ----- Khách hàng và người nhận ----- */
.form-drawer { margin-bottom: 16px; background: var(--sl-surface); border: 1px solid var(--sl-line); border-radius: 14px; box-shadow: var(--sl-shadow); scroll-margin-top: 88px; }
.form-drawer > summary { list-style: none; display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 10px 16px; font-weight: 600; color: var(--sl-link); cursor: pointer; border-radius: 14px; }
.form-drawer > summary::-webkit-details-marker { display: none; }
.form-drawer > summary:hover { background: var(--sl-hover); }
.form-drawer > summary::after { content: "▾"; margin-left: auto; color: var(--sl-muted); transform: rotate(-90deg); transition: transform .15s; }
.form-drawer[open] > summary { border-bottom: 1px solid var(--sl-line); border-radius: 14px 14px 0 0; }
.form-drawer[open] > summary::after { transform: none; }
.form-drawer-body { padding: 16px; }

.list-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.list-bar form { display: flex; gap: 8px; flex: 1 1 280px; }
.list-count { color: var(--sl-muted); font-size: .9rem; white-space: nowrap; }
.list-title { margin: 0; font-size: 1.05rem; font-weight: 700; }
.list-empty { padding: 32px 16px; text-align: center; color: var(--sl-muted); background: var(--sl-surface); border: 1px dashed var(--sl-line); border-radius: 14px; }

.col > .party-card { height: 100%; }
.party-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--sl-surface); border: 1px solid var(--sl-line); border-radius: 14px; box-shadow: var(--sl-shadow); }
.party-card.is-off { opacity: .68; }
.party-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.party-avatar { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 50%; font-weight: 700; color: var(--sl-link); background: rgba(217, 44, 69, .12); }
.party-title { flex: 1; min-width: 0; }
.party-name { font-size: 1.05rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.party-sub { color: var(--sl-muted); font-size: .88rem; overflow-wrap: anywhere; }
.party-lines { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: .94rem; }
.party-lines li { display: flex; align-items: flex-start; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.party-lines .icon { width: 16px; height: 16px; margin-top: 3px; color: var(--sl-muted); }
.party-lines a { color: inherit; }
.party-foot { display: flex; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--sl-line); }
.party-foot > :first-child { flex: 1; }
.party-foot form { display: flex; margin: 0; }
/* Dòng tài khoản đăng nhập của khách hàng, nằm sát phía trên chân thẻ. */
.party-account { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--sl-line); font-size: .92rem; overflow-wrap: anywhere; }
.party-account .icon { width: 16px; height: 16px; color: var(--sl-muted); flex: none; }
.party-account form { margin: 0; }
.party-account + .party-foot { margin-top: 10px; }

/* ----- Đăng nhập ----- */
.login-shell {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 20% 14%, rgba(217, 44, 69, .24), transparent 32rem), var(--sl-bg);
}
.login-card { width: 100%; max-width: 400px; padding: 28px; background: var(--sl-surface); border: 1px solid var(--sl-line); border-radius: 16px; box-shadow: var(--sl-shadow); }
.login-theme { position: absolute; top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }

/* ----- Từ 1024px trở xuống: menu thành ngăn kéo ----- */
@media (max-width: 1023.98px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-105%); transition: transform .2s ease; box-shadow: none; }
  body.nav-open .sidebar { transform: none; box-shadow: 14px 0 42px rgba(0, 0, 0, .3); }
  .nav-toggle { display: inline-grid; }
  .sidebar-close { display: inline-grid; }
  .topbar { height: 64px; padding: 0 16px; }
  .form-actions { position: sticky; bottom: 0; z-index: 10; margin: 8px -24px -24px; padding: 10px 24px; background: var(--sl-surface); box-shadow: 0 -1px 0 var(--sl-line); }
}

@media (max-width: 1199.98px) {
  .summary-card { position: static !important; }
}

/* ----- Điện thoại ----- */
@media (max-width: 767.98px) {
  html { scroll-padding: 72px 0 calc(var(--sl-bottom-nav) + env(safe-area-inset-bottom) + 16px); }
  .app-content { padding: 16px 16px calc(var(--sl-bottom-nav) + env(safe-area-inset-bottom) + 16px); }
  .nav-toggle { display: none; }
  .bottom-nav { display: grid; }
  body.keyboard-open .bottom-nav, body.hide-bottom-nav .bottom-nav { display: none; }
  body.keyboard-open .app-content, body.hide-bottom-nav .app-content { padding-bottom: 16px; }
  /* Tài khoản khách hàng không có thanh dưới, mở menu bằng nút trên đầu trang. */
  body.no-bottom-nav .nav-toggle { display: inline-grid; }

  /* Cỡ chữ 16px để iPhone không tự phóng to khi chạm vào ô nhập. */
  .form-control, .form-select, .form-control-sm, .form-select-sm { font-size: 16px; min-height: 44px; }
  .btn { min-height: 44px; }
  .btn-link { min-height: 0; }

  .step-btn { flex-direction: column; gap: 2px; padding: 6px 2px; min-height: 56px; font-size: .75rem; }
  .step-long { display: none; }

  .form-actions { margin: 8px -16px -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); flex-wrap: nowrap; }
  .form-actions-right { flex: 1; flex-wrap: nowrap; justify-content: flex-end; margin-left: 0; }
  .form-actions .btn { padding-left: .7rem; padding-right: .7rem; white-space: nowrap; }
  .form-actions .btn-primary, #nextStep { flex: 1; }
  .form-preview { display: none; }
  #orderForm:not([data-step="4"]) .create-btn { display: none; }
  #orderForm[data-step="4"] #nextStep { display: none; }

  /* Bảng dữ liệu thành danh sách thẻ */
  .table-responsive, .table-responsive.panel { overflow: visible; background: none; border: 0; box-shadow: none; border-radius: 0; }
  .table-responsive > .table > thead { display: none; }
  .table-responsive > .table, .table-responsive > .table > tbody { display: block; width: 100%; }
  .table-responsive > .table > tbody > tr {
    display: block; padding: 10px 14px; margin-bottom: 10px;
    background: var(--sl-surface); border: 1px solid var(--sl-line); border-radius: 12px;
  }
  .table-responsive > .table > tbody > tr > td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
    padding: 4px 0; border: 0; text-align: right; word-break: break-word;
  }
  .table-responsive > .table > tbody > tr > td::before { content: attr(data-label); flex: none; max-width: 45%; color: var(--sl-muted); font-size: .85rem; text-align: left; }
  .table-responsive > .table > tbody > tr > td.is-empty { display: none; }
  .table-responsive > .table > tbody > tr > td:first-child { font-weight: 600; font-size: 1.02rem; justify-content: flex-start; text-align: left; }
  .table-responsive > .table > tbody > tr > td:first-child::before { display: none; }
  .table-responsive > .table > tbody > tr > td[colspan] { justify-content: center; }
  .table-responsive > .table > tbody > tr > td:not([data-label])::before,
  .table-responsive > .table > tbody > tr > td[data-label=""]::before { display: none; }
  .table-responsive > .table > tbody > tr > td[data-label=""] { justify-content: flex-end; }

  /* Bảng nằm trong thẻ: không vẽ thêm khung lồng nhau */
  .card > .table-responsive > .table > tbody > tr { margin: 0; background: none; border: 0; border-top: 1px solid var(--sl-line); border-radius: 0; }
  .card > .card-header + .table-responsive > .table > tbody > tr:first-child { border-top: 0; }

  /* Dòng kiện: ô nhập xếp 2 cột, nhãn nằm trên */
  .table-responsive > .pkg-table > tbody > tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: var(--sl-raised); }
  .table-responsive > .pkg-table > tbody > tr > td,
  .table-responsive > .pkg-table > tbody > tr > td:first-child { display: block; padding: 0; text-align: left; font-size: inherit; font-weight: 400; }
  .table-responsive > .pkg-table > tbody > tr > td::before,
  .table-responsive > .pkg-table > tbody > tr > td:first-child::before { display: block; max-width: none; margin-bottom: 2px; }
  .table-responsive > .pkg-table > tbody > tr > td[data-label=""] { grid-column: 1 / -1; text-align: right; }
  #packageRows input, #packageRows select { min-width: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Tracking */
.track-result { padding: 18px; }
.track-result > summary, .track-form > summary { cursor: pointer; font-weight: 600; }
.track-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.track-number { font-size: 1.1rem; font-weight: 700; overflow-wrap: anywhere; }
.track-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.track-actions:empty { display: none; }
.track-form { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--sl-line); }
.track-retired { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--sl-line); }
.track-timeline { list-style: none; margin: 16px 0 0; padding: 0 0 0 18px; border-left: 2px solid var(--sl-line); }
.track-timeline > li { position: relative; padding-bottom: 14px; overflow-wrap: anywhere; }
.track-timeline > li:last-child { padding-bottom: 0; }
.track-timeline > li::before { content: ""; position: absolute; left: -24px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--sl-surface); border: 2px solid var(--sl-muted); }
.track-timeline > li:first-child::before { background: var(--sl-accent); border-color: var(--sl-accent); }
.track-login { margin-top: 16px; text-align: center; }.track-tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.track-tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--sl-surface); border: 1px solid var(--sl-line); border-radius: 12px; color: var(--sl-text); text-decoration: none; }
.track-tile:hover { background: var(--sl-hover); color: var(--sl-text); }
.track-tile.active { border-color: var(--sl-accent); box-shadow: inset 0 0 0 1px var(--sl-accent); }
.track-tile-value { font-size: 1.4rem; font-weight: 700; line-height: 1.2; }
.track-tile-label { font-size: .8rem; color: var(--sl-muted); }
.track-code { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--sl-line); }
.track-steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); list-style: none; margin: 12px 0 8px; padding: 0; }
.track-steps > li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.track-steps > li:not(:first-child)::before { content: ""; position: absolute; top: 6px; right: 50%; width: 100%; height: 2px; background: var(--sl-line); }
.track-steps > li.done:not(:first-child)::before, .track-steps > li.current:not(:first-child)::before { background: var(--dash-bar); }
.track-dot { position: relative; z-index: 1; width: 14px; height: 14px; border-radius: 50%; background: var(--sl-surface); border: 2px solid var(--sl-line); }
.track-steps > li.done .track-dot { background: var(--dash-bar); border-color: var(--dash-bar); }
.track-steps > li.current .track-dot { background: var(--dash-bar); border-color: var(--dash-bar); box-shadow: 0 0 0 3px var(--sl-surface), 0 0 0 5px var(--dash-bar); }
.track-steps.is-attention > li.current .track-dot { background: var(--sl-danger); border-color: var(--sl-danger); box-shadow: 0 0 0 3px var(--sl-surface), 0 0 0 5px var(--sl-danger); }
.track-step-label { font-size: .72rem; line-height: 1.2; color: var(--sl-muted); }
.track-steps > li.current .track-step-label { color: var(--sl-text); font-weight: 600; }
@media (max-width: 1024px) { .track-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Tab Thanh toán */
.bill-payments td { min-width: 120px; }
.bill-payments td:last-child { min-width: 0; }
.bill-suggest:empty { display: none; }
@media (max-width: 575.98px) {
  .bill-payments thead { display: none; }
  .bill-payments tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--sl-line); }
  .bill-payments td { display: block; border: 0; padding: 2px 8px; }
  .bill-payments td[data-label]::before { content: attr(data-label); display: block; font-size: .78rem; color: var(--sl-muted); }
}

/* Xem trước mẫu invoice: khổ A4 thu nhỏ theo khung. */
.tpl-preview { width: 100%; height: 1150px; border: 0; background: #fff; display: block; }

/* Đối tác: chọn dịch vụ theo từng hãng. */
.agent-services { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem 1rem; }
.agent-carrier { border: 1px solid var(--bs-border-color); border-radius: .5rem; padding: .5rem .75rem; }

/* Thống kê */
.report-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.report-tab { padding: 6px 14px; border: 1px solid var(--sl-line); border-radius: 999px; background: var(--sl-surface); color: inherit; text-decoration: none; font-weight: 600; }
.report-tab:hover { background: var(--sl-hover); }
.report-tab.active { background: var(--sl-link); border-color: var(--sl-link); color: #fff; }
.report-table th, .report-table td { white-space: nowrap; }
.report-table td:nth-child(3), .report-table td:nth-child(4) { white-space: normal; min-width: 120px; }
.report-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.report-table tfoot td { border-top: 2px solid var(--sl-line); }
.report-missing td { background: var(--bs-warning-bg-subtle); }
.report-kpis .dash-tile-value, .report-filter ~ .dash-kpis .dash-tile-value { font-size: 1.5rem; }
