/* Hợp Lực — giao diện nhẹ, dịu mắt */
:root {
  --bg: #f3f5f6;
  --surface: #ffffff;
  --surface-2: #f7f9f9;
  --line: #e3e8ea;
  --line-2: #eef2f3;
  --ink: #1e2b33;
  --ink-2: #56646d;
  --muted: #8a959c;
  --primary: #2b7a78;
  --primary-600: #22625f;
  --primary-300: #9ccbc7;
  --primary-soft: #e4f1f0;
  --accent-soft: #fcf3e6;
  --accent-ink: #8a5a17;
  --danger: #c4553f;
  --danger-soft: #fbebe7;
  --ok: #3a9d6e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 43, 51, .04), 0 4px 16px rgba(30, 43, 51, .05);
  --safe-top: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px));
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
.ic { flex: none; display: block; }
:focus-visible { outline: 2px solid var(--primary-300); outline-offset: 2px; }

/* ---------- Bố cục ---------- */
.sidebar { display: none; }
.main { min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: rgba(243, 245, 246, .92);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar-brand { display: flex; }
.topbar-title { min-width: 0; }
.topbar h1 { margin: 0; font-size: 20px; font-weight: 750; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar p { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }

.view { padding: 4px 16px calc(var(--safe-bottom) + 104px); max-width: 1120px; margin: 0 auto; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.loading { padding: 60px 0; text-align: center; color: var(--muted); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(6, 1fr); align-items: end;
  padding: 6px 6px calc(var(--safe-bottom) + 6px);
  background: rgba(255, 255, 255, .96);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 3px; font-size: 11px; font-weight: 600; color: var(--muted); }
.tab.on { color: var(--primary); }
.tab-fab {
  justify-self: center; width: 54px; height: 54px; border-radius: 18px;
  display: grid; place-items: center;
  background: var(--primary); color: #fff;
  box-shadow: 0 6px 16px rgba(43, 122, 120, .35);
  transform: translateY(-12px);
}
.tab-fab:active { transform: translateY(-11px) scale(.97); }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
  .sidebar {
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line);
  }
  .tabbar, .topbar-brand { display: none; }
  .topbar { padding: 22px 32px 14px; }
  .topbar h1 { font-size: 22px; }
  .view { padding: 4px 32px 48px; }
}
@media (max-width: 899px) { .hide-mobile { display: none !important; } }
@media (max-width: 520px) { .hide-sm { display: none !important; } }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand-name { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.sidebar-new { margin-bottom: 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-weight: 600; color: var(--ink-2); text-align: left; }
.nav-item:hover { background: var(--surface-2); }
.tab[hidden], .nav-item[hidden], .tab-fab[hidden] { display: none !important; }
.nav-item.on { background: var(--primary-soft); color: var(--primary-600); }
.sidebar-foot { margin-top: auto; padding: 8px; font-size: 12px; color: var(--muted); }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 14px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--line);
  font-weight: 600; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: #cdd6da; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-soft { background: var(--primary-soft); border-color: var(--primary-300); color: var(--primary-600); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-soft { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-block { width: 100%; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--ink-2); flex: none; }
.icon-btn:hover { background: var(--surface-2); }

.status {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 12px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status.ok .dot { background: var(--ok); }
.status.err { color: var(--danger); background: var(--danger-soft); border-color: #f0cdc5; }
.status.err .dot { background: var(--danger); }
.status.warn { color: #8a5a00; background: #fff4dc; border-color: #f0dcae; }
.status.warn .dot { background: #d99a1c; }
.status.busy .dot { background: var(--primary, #2b7a78); animation: status-pulse 1s ease-in-out infinite; }
.status.has-review::after { content: ""; width: 8px; height: 8px; margin-left: 2px; border-radius: 50%; background: var(--danger); }
@keyframes status-pulse { 50% { opacity: .3; } }
.review-diff { width: 100%; margin: 6px 0; border-collapse: collapse; font-size: 13px; }
.review-diff th, .review-diff td { padding: 4px 6px; border-bottom: 1px solid var(--line, #e6e6e6); text-align: left; font-weight: 400; overflow-wrap: anywhere; vertical-align: top; }
.review-diff thead th { font-weight: 600; }
.review-diff tbody th { color: var(--muted, #667); }

/* ---------- Thẻ ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-head .link { font-size: 13px; font-weight: 600; color: var(--primary); }
.card.list { padding: 0; overflow: hidden; }
.card.list > .card-head { padding: 14px 16px 6px; margin: 0; }
.grid-2 { display: grid; gap: 14px; align-items: start; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar > .select, .toolbar > .search { flex: 1 1 170px; min-width: 0; }

.input, .select {
  width: 100%; height: 42px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.select {
  -webkit-appearance: none; appearance: none; padding-right: 34px;
  font-weight: 600; color: var(--ink-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a959c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input:focus, .select:focus { border-color: var(--primary-300); box-shadow: 0 0 0 3px var(--primary-soft); }
.input::placeholder { color: #a9b2b8; }
.search { position: relative; display: flex; align-items: center; }
.search .ic { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 38px; }

/* ---------- Tổng quan ---------- */
.hero {
  position: relative; overflow: hidden; padding: 20px;
  background: linear-gradient(135deg, #e5f2f0 0%, #f3f8f4 55%, #fbf3e6 100%);
  border-color: #d8e8e5;
}
.hero-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.hero-value { margin: 4px 0 14px; font-size: clamp(28px, 7.5vw, 40px); font-weight: 800; letter-spacing: -.02em; color: var(--primary-600); font-variant-numeric: tabular-nums; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; position: relative; }
.hero-deco { position: absolute; right: -18px; bottom: -22px; color: var(--primary); opacity: .07; pointer-events: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px; background: rgba(255, 255, 255, .8); border: 1px solid rgba(43, 122, 120, .12); font-size: 13px; font-weight: 600; color: var(--ink-2); }

.readout { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin: -4px 0 12px; }
.readout strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.readout span { font-size: 13px; color: var(--muted); }
.colchart { position: relative; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; height: 176px; }
.colchart::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; bottom: 24px; pointer-events: none;
  background:
    linear-gradient(var(--line-2), var(--line-2)) 0 0 / 100% 1px no-repeat,
    linear-gradient(var(--line-2), var(--line-2)) 0 50% / 100% 1px no-repeat,
    linear-gradient(var(--line), var(--line)) 0 100% / 100% 1px no-repeat;
}
.col { position: relative; z-index: 1; display: flex; flex-direction: column; min-width: 0; }
.col-track { flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.col-bar { width: min(34px, 62%); background: var(--primary-300); border-radius: 4px 4px 0 0; transition: height .3s ease, background .15s; }
.col:hover .col-bar { background: #7fb8b3; }
.col.on .col-bar { background: var(--primary); }
.col-label { height: 24px; line-height: 24px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.col.on .col-label { color: var(--ink); }

.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bars li { padding: 6px 8px; margin: 0 -8px; border-radius: 10px; }
.bars li.clickable { cursor: pointer; }
.bars li.clickable:hover { background: var(--surface-2); }
.bar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.bar-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-val { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar-track { height: 6px; margin: 6px 0 4px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.bar-track span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.bar-sub { font-size: 12px; color: var(--muted); }

/* ---------- Danh sách phiếu ---------- */
.entry { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; text-align: left; }
.entry + .entry { border-top: 1px solid var(--line-2); }
.entry:hover { background: var(--surface-2); }
.entry-ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.entry-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.entry-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-sub { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.entry-amt { flex: none; max-width: 46%; display: flex; flex-direction: column; gap: 2px; text-align: right; }
.entry-amt strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.entry-amt small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-ink); font-size: 11.5px; font-weight: 600; white-space: nowrap; }

.day-head { display: flex; justify-content: space-between; gap: 8px; padding: 2px 4px 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.day-head span:last-child { font-variant-numeric: tabular-nums; }
.summary-strip { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--primary-soft); color: var(--primary-600); font-weight: 600; }
.summary-strip strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.more { display: flex; justify-content: center; }
.filters .form-grid { margin-bottom: 4px; }
.filters-foot { display: flex; justify-content: flex-end; }

/* ---------- Tổng hợp ---------- */
.seg { display: flex; gap: 4px; padding: 4px; background: #e7eced; border-radius: 12px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1 0 auto; height: 36px; padding: 0 12px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(30, 43, 51, .1); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-width: 0; }
.stat span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.stat strong { display: block; margin-top: 2px; font-size: 17px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat.main strong { color: var(--primary-600); }
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat.main { grid-column: 1 / -1; }
}

.group-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line-2); font-size: 13px; font-weight: 700; color: var(--ink-2); }
.group-head > span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.group-head > span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sum-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; width: 100%; padding: 12px 16px; text-align: left; }
.sum-row + .sum-row { border-top: 1px solid var(--line-2); }
.sum-row.clickable { cursor: pointer; }
.sum-row.clickable:hover { background: var(--surface-2); }
.sum-title { font-weight: 650; overflow-wrap: anywhere; }
.sum-sub { font-size: 12.5px; color: var(--muted); }
.sum-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; text-align: right; }
.sum-right strong { font-variant-numeric: tabular-nums; }
.qty { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--primary-soft); color: var(--primary-600); font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.qty.plain { background: none; padding: 0; color: var(--muted); font-weight: 600; }
.sum-row .bar-track { grid-column: 1 / -1; height: 4px; margin: 6px 0 0; }

/* ---------- Giờ máy ---------- */
.shift-live { display: flex; flex-direction: column; gap: 12px; border-color: var(--primary-300); }
.shift-head { display: flex; align-items: flex-start; gap: 8px; }
.shift-name { flex: 1; min-width: 0; }
.shift-name strong { display: block; font-size: 16px; overflow-wrap: anywhere; }
.shift-name span { font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.shift-state { flex: none; padding: 3px 10px; border-radius: 99px; background: var(--primary-soft); color: var(--primary-600); font-size: 12px; font-weight: 700; white-space: nowrap; }
.timer { text-align: center; font-size: clamp(40px, 13vw, 54px); font-weight: 800; line-height: 1.1; letter-spacing: -.01em; color: var(--primary-600); font-variant-numeric: tabular-nums; }
.shift-facts { text-align: center; font-size: 13px; color: var(--ink-2); }
.shift-live.paused { border-color: #ebd2a6; }
.shift-live.paused .timer { color: var(--accent-ink); }
.shift-live.paused .shift-state { background: var(--accent-soft); color: var(--accent-ink); }
.shift-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.shift-actions .btn { height: 48px; }
.btn-start { height: 48px; }
.assign-row { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; }
.assign-row + .assign-row { border-top: 1px solid var(--line-2); }
.assign-info { min-width: 0; }
.assign-info strong { display: block; overflow-wrap: anywhere; }
.assign-info span { font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.price-hint { margin: 0; font-size: 12.5px; color: var(--ink-2); }
.tag-internal { background: var(--primary-soft); color: var(--primary-600); }
.kv { margin: 0; display: flex; flex-direction: column; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px solid var(--line-2); }
.kv > div:first-child { border-top: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* ---------- Lợi nhuận theo công trình ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.profit-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.profit-table th, .profit-table td { padding: 10px 12px; white-space: nowrap; border-bottom: 1px solid var(--line-2); background: var(--surface); text-align: right; }
.profit-table thead th { background: var(--surface-2); font-size: 12px; font-weight: 700; color: var(--ink-2); }
.profit-table th:first-child { position: sticky; left: 0; z-index: 1; max-width: 148px; overflow: hidden; text-overflow: ellipsis; text-align: left; font-weight: 650; border-right: 1px solid var(--line); }
.profit-table tbody tr { cursor: pointer; }
.profit-table tbody tr:hover > * { background: var(--surface-2); }
.profit-table tfoot th, .profit-table tfoot td { background: var(--primary-soft); font-weight: 700; border-bottom: 0; }
.profit-table .strong { font-weight: 700; }
.profit-table .row-loss th:first-child { color: var(--danger); }
.profit-table tr.row-loss > * { background: var(--danger-soft); }
.loss, .profit-table td.loss { color: var(--danger); font-weight: 700; }
.stat.stat-loss strong { color: var(--danger); }
.profit-table .group-th { text-align: center; border-left: 1px solid var(--line); }
.mp-period { flex: 1 1 170px; min-width: 0; width: auto; }
.seg-sub { background: var(--line-2); }
.kv-head { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.kv-head strong { color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.kv-head strong.loss { color: var(--danger); }
.kv-link { display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 4px 0; font-size: 13px; color: var(--primary-600); text-align: left; font-variant-numeric: tabular-nums; }
.kv-link span:last-child { white-space: nowrap; }

/* ---------- Đăng nhập, quản trị ---------- */
.auth { position: fixed; inset: 0; z-index: 40; overflow-y: auto; padding: calc(var(--safe-top) + 24px) 16px calc(var(--safe-bottom) + 24px); background: var(--bg); }
.auth-card { display: flex; flex-direction: column; gap: 14px; width: min(420px, 100%); margin: 0 auto; }
.auth-card h2 { margin: 0; font-size: 19px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card p { margin: 0; }
.auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-brand strong { display: block; font-size: 18px; }
.auth-brand small { color: var(--muted); }
.auth-note { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--primary-soft); color: var(--primary-600); font-size: 14px; font-weight: 600; }
.auth-link { align-self: flex-start; font-size: 14px; font-weight: 600; color: var(--primary); text-align: left; }
.auth-update { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line-2); font-size: 13px; color: var(--muted); }
.auth-update .link { font-weight: 600; color: var(--primary); }
.pin-input { letter-spacing: .3em; font-variant-numeric: tabular-nums; }
.pin-input::placeholder { letter-spacing: normal; }
.perm-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.perm-table th, .perm-table td { padding: 8px 6px; border-bottom: 1px solid var(--line-2); text-align: center; white-space: nowrap; }
.perm-table thead th { font-size: 12px; color: var(--ink-2); }
.perm-table tbody th { text-align: left; font-weight: 600; white-space: normal; min-width: 110px; }
.perm-table input { width: 20px; height: 20px; accent-color: var(--primary); }
.review-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }

/* ---------- VAT ---------- */
.vat-rates { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.vat-rates .input { flex: 1 1 80px; width: auto; min-width: 70px; height: 34px; }
.switch-row { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.switch-row input { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }
.vat-btn { font-weight: 700; color: var(--primary-600); }

/* ---------- Cập nhật ứng dụng ---------- */
.update-bar { display: flex; align-items: center; gap: 8px; max-width: 1120px; margin: 0 auto 10px; padding: 6px 6px 6px 14px; background: var(--primary-soft); border: 1px solid var(--primary-300); border-radius: 12px; width: calc(100% - 32px); }
.update-text { flex: 1; min-width: 0; font-size: 14px; font-weight: 650; color: var(--primary-600); }
.update-bar .link { flex: none; font-size: 13px; font-weight: 600; color: var(--primary-600); text-decoration: underline; }
.btn-sm { flex: none; height: 34px; padding: 0 12px; font-size: 13px; }
.update-notes, .update-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--ink-2); }
@media (min-width: 900px) { .update-bar { width: calc(100% - 64px); } }

/* ---------- Danh mục ---------- */
.add-row { display: flex; gap: 8px; margin-bottom: 8px; }
.add-row .input { flex: 1; min-width: 0; }
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.cat-list li:first-child { border-top: 0; }
.cat-info { flex: 1; min-width: 0; }
.cat-name { font-weight: 600; overflow-wrap: anywhere; }
.cat-sub { font-size: 12.5px; color: var(--muted); }
.cat-actions { display: flex; flex: none; }
.section-title { margin: 12px 4px -2px; font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.settings p { margin: 0 0 12px; color: var(--ink-2); }
.text-danger { color: var(--danger); font-weight: 600; }
.field-end { justify-content: flex-end; }
.about { margin: 6px 0; text-align: center; font-size: 12px; color: var(--muted); }

/* ---------- Biểu mẫu ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field > label b { color: var(--danger); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-section { display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--ink-2); }
.chip.on { background: var(--primary-soft); border-color: var(--primary-300); color: var(--primary-600); }
.amount-box { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); border: 1px dashed #ebd2a6; }
.amount-box span { font-size: 13px; font-weight: 600; color: var(--accent-ink); }
.amount-box strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.form-error { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 14px; font-weight: 600; }

/* ---------- Bảng trượt & hộp thoại ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop, .dlg-backdrop { position: absolute; inset: 0; background: rgba(22, 34, 40, .38); animation: fade .2s; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 94%;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .12);
  animation: up .25s cubic-bezier(.2, .8, .2, 1);
}
.sheet-panel > form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 12px 10px 18px; border-bottom: 1px solid var(--line-2); }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.sheet-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px calc(var(--safe-bottom) + 12px); border-top: 1px solid var(--line-2); }
.spacer { flex: 1; }
@media (min-width: 700px) {
  .sheet-panel { left: 50%; right: auto; top: 50%; bottom: auto; width: min(600px, calc(100% - 48px)); max-height: calc(100% - 48px); border-radius: 18px; transform: translate(-50%, -50%); animation: pop .2s ease; }
}

.dialog { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; }
.dlg { position: relative; width: min(420px, 100%); padding: 20px; background: var(--surface); border-radius: 16px; box-shadow: 0 20px 50px rgba(0, 0, 0, .18); animation: fade .15s; }
.dlg h3 { margin: 0 0 6px; font-size: 17px; }
.dlg p { margin: 0 0 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.dlg .input { margin-bottom: 14px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 96px); z-index: 70;
  transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 12px;
  background: #24343b; color: #fff; font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: fade .2s;
}
.toast.error { background: var(--danger); }
@media (min-width: 900px) { .toast { bottom: 32px; } }

.empty { padding: 36px 20px; text-align: center; }
.empty h2 { margin: 16px 0 6px; font-size: 20px; }
.empty p { max-width: 460px; margin: 0 auto 18px; color: var(--ink-2); }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.empty-logo { display: inline-flex; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.note { margin: 0; padding: 20px 16px; text-align: center; color: var(--muted); font-size: 14px; }

@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -47%); } }
@keyframes fade { from { opacity: 0; } }
