/* MobiFiber Sales – giao diện ưu tiên điện thoại */
:root {
  --brand: #0b5cad;
  --brand-600: #094d91;
  --brand-50: #eaf2fb;
  --bg: #f3f5f8;
  --card: #fff;
  --text: #1a2230;
  --muted: #637083;
  --line: #e2e7ee;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --info: #0284c7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --topbar-h: 56px;
  --bottomnav-h: 62px;
  --sidebar-w: 248px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
small, .muted { color: var(--muted); }
.ic { width: 20px; height: 20px; flex: none; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
[hidden] { display: none !important; }

/* ---------- Khung trang ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 12px 0;
  display: flex; align-items: center; gap: 8px;
  background: var(--brand); color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  background: #fff; color: var(--brand); font-weight: 800; font-size: .8rem; letter-spacing: .5px;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; color: #fff; }
.user-chip:hover { text-decoration: none; }
.user-chip-text { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip-text small { color: rgba(255,255,255,.8); font-size: .75rem; }
.avatar {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,.18); font-weight: 700;
}
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: transparent; color: inherit; cursor: pointer;
}
.icon-btn:hover { background: rgba(0,0,0,.06); }
.topbar .icon-btn:hover { background: rgba(255,255,255,.14); }

.sidebar {
  position: fixed; z-index: 50; top: 0; bottom: 0; left: 0;
  width: min(84vw, 300px);
  background: #fff; overflow-y: auto;
  transform: translateX(-100%); transition: transform .22s ease;
  padding-bottom: 24px;
}
.sidebar ul { list-style: none; margin: 0; padding: 8px; }
.sidebar a, .nav-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 12px; border-radius: 10px; color: var(--text); font: inherit;
  background: none; border: 0; cursor: pointer; text-align: left;
}
.sidebar a:hover, .nav-btn:hover { background: var(--bg); text-decoration: none; }
.sidebar a.active { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.nav-section { padding: 16px 12px 6px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top, 0px)) 12px 14px 20px; border-bottom: 1px solid var(--line); }
.sidebar-head small { display: block; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, .45); opacity: 0; pointer-events: none; transition: opacity .2s; }
body.drawer-open .sidebar { transform: none; }
body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }

.bottomnav {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  height: calc(var(--bottomnav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex; background: #fff; border-top: 1px solid var(--line);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: .7rem; text-align: center; padding: 4px 2px; min-width: 0;
}
.bottomnav a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.bottomnav a:hover { text-decoration: none; }
.bottomnav a.active { color: var(--brand); font-weight: 600; }
.bottomnav .bn-primary .ic { width: 36px; height: 36px; padding: 7px; border-radius: 50%; background: var(--brand); color: #fff; margin-top: -14px; box-shadow: 0 3px 8px rgba(11, 92, 173, .35); }

.main { padding: 16px 14px; max-width: 1280px; margin: 0 auto; }
body.has-nav .main { padding-bottom: calc(var(--bottomnav-h) + var(--safe-b) + 24px); }
body.no-nav .main { padding: 0; max-width: none; }

@media (min-width: 960px) {
  .only-mobile { display: none !important; }
  .sidebar {
    transform: none; top: var(--topbar-h); width: var(--sidebar-w);
    border-right: 1px solid var(--line); z-index: 20;
  }
  body.has-nav .main { margin-left: var(--sidebar-w); padding: 24px 28px 40px; }
  .drawer-backdrop { display: none; }
}
@media (max-width: 959.98px) {
  .only-desktop { display: none !important; }
}

/* ---------- Tiêu đề trang ---------- */
.page-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 12px; margin-bottom: 16px; }
.page-head h1 { flex: 1 1 auto; min-width: 0; }
.page-head .sub { display: block; font-size: .85rem; font-weight: 400; color: var(--muted); margin-top: 2px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: .9rem; margin-bottom: 8px; color: var(--muted); }

/* ---------- Thẻ / lưới ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 16px; }
.card-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 12px; }
.card-head h2 { flex: 1 1 auto; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-head { padding: 14px 16px 0; }
.grid { display: grid; gap: 16px; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

/* Ô số liệu */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .stats-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); border-left: 4px solid var(--c, var(--brand)); min-width: 0; }
.card .stat { box-shadow: none; background: var(--bg); }
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-note { font-size: .75rem; color: var(--muted); }
a.stat { color: inherit; display: block; }
a.stat:hover { text-decoration: none; box-shadow: 0 0 0 2px var(--c, var(--brand)); }

/* Ô lối tắt trang chủ */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 10px; padding: 16px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); min-height: 108px;
}
.tile:hover { text-decoration: none; box-shadow: 0 0 0 2px var(--brand); }
.tile .ic { width: 28px; height: 28px; color: var(--brand); }
.tile b { font-size: .95rem; }
.tile small { margin-top: auto; }
.tile-primary { background: var(--brand); color: #fff; }
.tile-primary .ic, .tile-primary small { color: #fff; }
.tile .count {
  position: absolute; top: 12px; right: 12px; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 13px;
  display: grid; place-items: center; background: var(--err); color: #fff; font-size: .8rem; font-weight: 700;
}

/* Lead cần chăm sóc */
.care { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.care a { display: block; padding: 12px; border-radius: 10px; background: var(--bg); color: var(--text); text-align: center; border-top: 4px solid var(--c); }
.care a:hover { text-decoration: none; box-shadow: 0 0 0 2px var(--c); }
.care b { display: block; font-size: 1.6rem; line-height: 1.2; color: var(--c); }
.care span { font-size: .8rem; color: var(--muted); }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: var(--bg); }
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-danger { color: var(--err); border-color: #f3c2c2; }
.btn-danger:hover { background: #fdecec; }
.btn-sm { min-height: 34px; padding: 4px 10px; font-size: .85rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--brand); font-weight: 500; }
.btn-link:hover { background: none; text-decoration: underline; }
.btn-group { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-form { display: inline; }

/* ---------- Form ---------- */
.form-section { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.form-section > h2 { display: flex; align-items: center; gap: 8px; font-size: .95rem; color: var(--brand); margin-bottom: 14px; }
.form-section > h2 .num { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--brand-50); font-size: .8rem; }
.form-section.sec-success { border-top: 4px solid var(--ok); }
.form-section.sec-success > h2 { color: var(--ok); }
.form-section.sec-failed { border-top: 4px solid var(--err); }
.form-section.sec-failed > h2 { color: var(--err); }
.fields { display: grid; gap: 14px; }
@media (min-width: 720px) {
  .fields { grid-template-columns: 1fr 1fr; }
  .fields .full { grid-column: 1 / -1; }
}
@media (min-width: 1200px) { .fields-3 { grid-template-columns: repeat(3, 1fr); } }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: .85rem; font-weight: 600; }
.req { color: var(--err); }
.hint { font-size: .78rem; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid #cfd6df; border-radius: 10px;
  font: inherit; font-size: 16px; /* tránh iOS tự zoom */ color: var(--text); background: #fff;
}
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11, 92, 173, .15); }
.input[readonly] { background: var(--bg); color: var(--muted); }
.field.has-error .input { border-color: var(--err); }
.field-error { font-size: .8rem; color: var(--err); }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.readonly-box { padding: 10px 12px; border-radius: 10px; background: var(--bg); font-weight: 600; min-height: 44px; }

/* Nút chọn tệp (thay giao diện mặc định của trình duyệt) */
.file-pick {
  position: relative; display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  min-height: 44px; padding: 8px 16px; border: 1px dashed #9fb3c8; border-radius: 10px;
  background: var(--brand-50); color: var(--brand); font-weight: 600; cursor: pointer;
}
.file-pick:hover { border-color: var(--brand); }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-pick:focus-within { box-shadow: 0 0 0 3px rgba(11, 92, 173, .2); }

/* Cảnh báo SĐT trùng */
.dup-box { margin-top: 6px; padding: 10px 12px; border-radius: 10px; background: #fff7e6; border: 1px solid #f6d58e; font-size: .85rem; }
.dup-box ul { margin: 6px 0 0; padding-left: 18px; }

/* Thanh lưu cố định trên điện thoại */
.form-actions {
  position: sticky; bottom: calc(var(--bottomnav-h) + var(--safe-b)); z-index: 10;
  display: flex; gap: 10px; padding: 12px 0; background: linear-gradient(to top, var(--bg) 75%, transparent);
}
.form-actions .btn { flex: 1; }
@media (min-width: 960px) {
  .form-actions { bottom: 0; justify-content: flex-end; }
  .form-actions .btn { flex: 0 0 auto; min-width: 140px; }
}
.form-errors { padding: 12px 14px; border-radius: 10px; background: #fdecec; color: var(--err); margin-bottom: 14px; font-size: .9rem; }

/* ---------- Bộ lọc ---------- */
.filters { margin-bottom: 14px; }
.search-row { display: flex; gap: 8px; }
.search-row .input { flex: 1; }
.filter-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
@media (min-width: 720px) { .filter-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .filter-panel { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.filter-panel .field > label { font-size: .75rem; font-weight: 600; color: var(--muted); }
.filter-panel .input { min-height: 40px; padding: 7px 10px; }
.filter-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--text); font-size: .85rem; }
.chip:hover { text-decoration: none; border-color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip b { font-variant-numeric: tabular-nums; }
.chip-overdue { --c: var(--err); }
.chip-today { --c: var(--warn); }
.chip-upcoming { --c: var(--info); }
.chip[class*="chip-"]:not(.active) b { color: var(--c); }

/* ---------- Bảng ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { background: #f8fafc; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr:hover { background: #fafcff; }
.table tfoot td { font-weight: 700; background: #f8fafc; }
.table .muted-row td { color: var(--muted); }
.table-compact { font-size: .85rem; }
.table-compact th, .table-compact td { padding: 9px 8px; }
.table-compact th:first-child, .table-compact td:first-child { padding-left: 14px; }
.table-compact td:last-child { padding-right: 14px; }
/* Bảng nhiều cột: cuộn ngang trên điện thoại thay vì ép cột */
.table-wide { min-width: 640px; }
.table-wide td:first-child { min-width: 150px; }
.bar { position: relative; height: 6px; border-radius: 3px; background: var(--line); min-width: 60px; margin-top: 6px; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--c, var(--brand)); }

/* Danh sách dạng thẻ trên điện thoại */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: block; padding: 14px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text);
}
.item:hover { text-decoration: none; box-shadow: 0 0 0 2px var(--brand-50), var(--shadow); }
.item-top { display: flex; align-items: flex-start; gap: 8px; }
.item-title { font-weight: 700; flex: 1; min-width: 0; }
.item-code { font-size: .78rem; color: var(--muted); font-weight: 600; }
.item-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: .83rem; color: var(--muted); }
.item-meta span { display: inline-flex; align-items: center; gap: 4px; }
.item-meta .ic { width: 14px; height: 14px; }
.item-note { margin-top: 6px; font-size: .85rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (min-width: 960px) { .list-cards-desktop-table .list { display: none; } }
@media (max-width: 959.98px) { .list-cards-desktop-table .table-desktop { display: none; } }

.badge {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; white-space: nowrap;
  font-size: .75rem; font-weight: 600; color: var(--c, var(--brand));
  background: color-mix(in srgb, var(--c, var(--brand)) 12%, white);
}
.due { display: inline-flex; padding: 1px 8px; border-radius: 6px; font-size: .72rem; font-weight: 700; }
.due-overdue { background: #fdecec; color: var(--err); }
.due-today { background: #fff4e0; color: var(--warn); }
.due-upcoming { background: #e6f4fb; color: var(--info); }
.due-later { background: var(--bg); color: var(--muted); }

.pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.pagination a, .pagination span { min-width: 38px; height: 38px; padding: 0 10px; display: grid; place-items: center; border-radius: 8px; background: #fff; border: 1px solid var(--line); color: var(--text); font-size: .9rem; }
.pagination a:hover { text-decoration: none; border-color: var(--brand); }
.pagination .current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.result-info { font-size: .85rem; color: var(--muted); margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.empty .ic { width: 40px; height: 40px; opacity: .5; margin-bottom: 6px; }

/* ---------- Chi tiết ---------- */
.dl { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 8px 12px; margin: 0; font-size: .92rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; word-break: break-word; }
@media (min-width: 720px) { .dl { grid-template-columns: 180px 1fr; } }
.meta-line { font-size: .8rem; color: var(--muted); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--brand); }
.timeline .when { font-size: .8rem; color: var(--muted); }
.changes { margin: 6px 0 0; padding: 0; list-style: none; font-size: .86rem; }
.changes li { padding: 4px 0; border: 0; margin: 0; }
.changes li::before { display: none; }
.changes .old { color: var(--err); text-decoration: line-through; }
.changes .new { color: var(--ok); font-weight: 600; }

/* Hội thoại phản ánh */
.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; padding: 10px 14px; border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.msg.mine { align-self: flex-end; background: var(--brand-50); }
.msg.admin { border-left: 4px solid var(--brand); }
.msg-head { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.msg-head b { color: var(--text); }
.msg-body { white-space: normal; word-break: break-word; }
.msg-event { align-self: center; font-size: .8rem; color: var(--muted); background: #e9edf2; padding: 4px 12px; border-radius: 999px; text-align: center; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.att { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--bg); border-radius: 8px; font-size: .82rem; max-width: 100%; }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-img { display: block; width: 96px; height: 96px; border-radius: 8px; object-fit: cover; background: var(--bg); }

/* ---------- Thông báo ---------- */
.toasts { position: fixed; z-index: 60; top: calc(var(--topbar-h) + 10px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); width: min(560px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 10px; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: .92rem; animation: toast-in .2s ease; }
.toast span { flex: 1; }
.toast-success { background: var(--ok); }
.toast-error { background: var(--err); }
.toast-warning { background: var(--warn); }
.toast-info { background: var(--info); }
.toast-x { background: none; border: 0; color: #fff; font-size: 1.3rem; line-height: 1; cursor: pointer; opacity: .85; }
.toast.hide { opacity: 0; transform: translateY(-6px); transition: all .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

.alert { padding: 12px 14px; border-radius: 10px; font-size: .9rem; margin-bottom: 14px; display: flex; gap: 10px; align-items: flex-start; }
.alert .ic { flex: none; margin-top: 1px; }
.alert-warning { background: #fff7e6; color: #8a5300; }
.alert-info { background: var(--brand-50); color: var(--brand-600); }
.alert-error { background: #fdecec; color: var(--err); }

/* Mất kết nối */
.offline-bar {
  display: none; position: sticky; top: 0; z-index: 35;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 12px 6px; text-align: center;
  background: #1f2937; color: #fff; font-size: .82rem; font-weight: 600;
}
body.is-offline .offline-bar { display: block; }
body.is-offline .topbar { top: 0; }
.pending-card { border-left: 4px solid var(--warn); }
.pending-item.has-error { box-shadow: 0 0 0 2px #f3c2c2, var(--shadow); }
.push-prompt .ic { color: var(--brand); }

/* Hộp thoại xác nhận */
dialog.confirm { border: 0; border-radius: 14px; padding: 20px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog.confirm::backdrop { background: rgba(15, 23, 42, .5); }
dialog.confirm p { margin: 0 0 18px; }
dialog.confirm .btn-group { justify-content: flex-end; }

/* ---------- Đăng nhập ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, #0b5cad 0%, #0a4a8a 55%, #07335f 100%); }
.login-card { width: min(400px, 100%); background: #fff; border-radius: 18px; padding: 28px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-card .brand-mark { width: 52px; height: 52px; font-size: 1.1rem; border-radius: 14px; background: var(--brand); color: #fff; margin: 0 auto 12px; }
.login-card h1 { text-align: center; font-size: 1.25rem; }
.login-card p.muted { text-align: center; margin: 4px 0 22px; font-size: .9rem; }
.login-card .fields { grid-template-columns: 1fr; }

/* ---------- Dashboard ---------- */
.period-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.period-bar .field { flex: 1 1 140px; }
.period-bar .input { min-height: 40px; padding: 7px 10px; }
.section-period { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); }
.section-period .input { min-height: 34px; padding: 4px 8px; width: auto; font-size: .85rem; }
.chart-box { position: relative; height: 260px; margin-top: 16px; }
.chart-box.tall { height: 320px; }
.section-loading { opacity: .5; pointer-events: none; }
.layout-list { list-style: none; padding: 0; margin: 0; }
.layout-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.layout-list li label { flex: 1; }

/* Danh mục */
.cat-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; }
.cat-tabs a { flex: none; }
.cat-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cat-row:last-child { border-bottom: 0; }
.cat-row form.cat-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1 1 320px; }
.cat-row form.cat-edit .input { flex: 1 1 180px; min-height: 38px; padding: 6px 10px; }
.cat-row.inactive .input { color: var(--muted); text-decoration: line-through; }
.cat-row .pos { width: 30px; color: var(--muted); font-size: .8rem; text-align: center; }
