/* Giao diện đồng bộ với oranbox.com: nền kem, cam OranBox, font Be Vietnam Pro */
:root {
  --bg: #fcfbf8;
  --paper: #ffffff;
  --paper-2: #f9f8f4;
  --ink: #282823;
  --ink-2: #45443c;
  --muted: #6f6e66;          /* đậm hơn #85847d của OranBox một chút để đạt tương phản AA */
  --line: #eae8e1;
  --line-2: #f0ede7;
  --accent: #c65031;         /* cam thương hiệu (logo, chấm, nút chính) */
  --accent-hover: #b0452a;
  --accent-bright: #ee704b;
  --accent-soft: #fae7dc;    /* peach */
  --sage: #e8efdf;
  --lavender: #eeebf6;
  --butter: #f7efd6;
  --sand: #f4f1eb;
  --success: #4f6f45;
  --success-soft: #edf4e8;
  --danger: #b23a1e;
  --danger-soft: #fbe9e2;
  --warn: #85631a;
  --info: #5f4d85;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(45, 36, 28, .04);
  --shadow-pop: 0 25px 90px rgba(45, 36, 28, .2);
  --font: "Be Vietnam Pro", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
#app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { margin: 0; line-height: 1.2; color: var(--ink); }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -1.2px; }
h2 { font-size: 16px; font-weight: 650; letter-spacing: -.3px; }
h3 { font-size: 15px; font-weight: 650; letter-spacing: -.2px; }
.accent-text { color: var(--accent); }
a:focus-visible, .btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::placeholder { color: var(--muted); opacity: 1; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.nowrap { white-space: nowrap; }
.eyebrow { display: block; font-size: 10.5px; font-weight: 600; letter-spacing: 1.9px; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }

/* ---------- thương hiệu ---------- */
.brand { display: inline-flex; align-items: center; gap: 9px; font-size: 24px; font-weight: 800; letter-spacing: -1.4px; line-height: 1; color: var(--ink); white-space: nowrap; }
.brand:hover { color: var(--ink); }
.brand-icon { display: grid; place-items: center; width: 35px; height: 37px; border-radius: 10px; background: var(--accent); color: #fff; transform: rotate(-7deg); transition: transform .3s; flex: none; }
.brand-icon svg { width: 21px; height: 21px; }
.brand:hover .brand-icon { transform: rotate(5deg); }
.brand-dot { color: var(--accent); }

/* ---------- khung ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(252, 251, 248, .93); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 16px; height: 70px; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 7px 11px; border-radius: 9px; color: #6b6a63; white-space: nowrap; font-weight: 500; font-size: 13px; }
.nav a:hover { background: #eeeae1; color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
.nav a:focus-visible { outline-offset: -2px; }
.userbox { display: flex; align-items: center; gap: 9px; white-space: nowrap; min-width: 0; }
.userbox .name { font-weight: 600; font-size: 13px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.role-tag { font-size: 11px; padding: 3px 8px; border-radius: 7px; background: var(--sand); color: var(--ink-2); font-weight: 600; }
.main { max-width: 1200px; width: 100%; flex: 1 0 auto; margin: 0 auto; padding: 28px 20px 60px; overflow-x: clip; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head > div { min-width: 0; overflow-wrap: anywhere; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 12px; color: var(--muted); font-size: 13px; font-weight: 500; }
.back:hover { color: var(--ink); }
.site-footer { border-top: 1px solid var(--line); background: var(--paper-2); flex-shrink: 0; }
.site-footer-inner { max-width: 1200px; margin: 0 auto; padding: 18px 20px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent-hover); }

@media (max-width: 1199px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding-top: 10px; gap: 8px 12px; }
  .topbar-inner > .brand { flex: 1; }
  .nav { order: 3; flex-basis: 100%; padding-bottom: 10px; }
}
@media (max-width: 560px) {
  .userbox .name, .role-tag { display: none; }
  .brand { font-size: 21px; }
  .brand-icon { width: 30px; height: 32px; border-radius: 8px; }
  .brand-icon svg { width: 18px; height: 18px; }
  .modal-head h3 { font-size: 20px; }
  h1 { font-size: 23px; letter-spacing: -.9px; }
  .main { padding: 20px 16px 48px; }
  .topbar-inner { padding-left: 16px; padding-right: 16px; }
}

/* ---------- thành phần ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card > .table-wrap:first-child { border-top-left-radius: calc(var(--radius) - 1px); border-top-right-radius: calc(var(--radius) - 1px); }
.card > .table-wrap:last-child { border-bottom-left-radius: calc(var(--radius) - 1px); border-bottom-right-radius: calc(var(--radius) - 1px); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 15px 20px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.stack { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack > *, .grid-2 > *, .kpis > * { min-width: 0; }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.kpi { padding: 16px 18px; display: block; color: inherit; }
a.kpi:hover { border-color: #e0d7c9; color: inherit; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi .value { font-size: 22px; font-weight: 700; letter-spacing: -.8px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 420px) { .kpi .value { font-size: 18px; } .kpi { padding: 13px 14px; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 17px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .2s, box-shadow .2s, transform .2s; }
.btn:hover { background: #f6f5ef; border-color: #d6d2c7; color: var(--ink); transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn:disabled:hover { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 9px rgba(233, 129, 68, .13); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; box-shadow: 0 7px 16px rgba(233, 129, 68, .16); }
.btn.danger, .btn.neg { color: var(--danger); border-color: #efcfc4; }
.btn.danger:hover, .btn.neg:hover { background: var(--danger-soft); border-color: #e7b9a9; color: var(--danger); }
.btn.success { background: #34362e; border-color: #34362e; color: #fcf9ed; }
.btn.success:hover { background: #22241e; border-color: #22241e; color: #fcf9ed; }
.btn.sm { min-height: 34px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn.ghost, .btn.ghost.neg { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--sand); border-color: transparent; transform: none; }
.btn.ghost.neg:hover { background: var(--danger-soft); }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 16px; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--sand); color: var(--ink); }

/* nhãn trạng thái theo bảng màu pastel của OranBox (chữ đậm hơn để dễ đọc) */
.badge > i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.badge { gap: 6px; display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 6px; border: 1px solid transparent; font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.b-gray { background: var(--sand); color: #6b655a; border-color: #ebe6dc; }
.b-amber { background: var(--butter); color: var(--warn); border-color: #efe3bd; }
.b-blue { background: var(--lavender); color: var(--info); border-color: #e2dcef; }
.b-violet { background: var(--accent-soft); color: #9a3f24; border-color: #f3d6c6; }
.b-green { background: var(--success-soft); color: var(--success); border-color: #dbe8d3; }
.b-red { background: var(--danger-soft); color: var(--danger); border-color: #f3d3c7; }
.type-tag { font-size: 11px; font-weight: 700; letter-spacing: .8px; padding: 3px 8px; border-radius: 5px; white-space: nowrap; }
.t-advance { background: var(--sage); color: #4a5f3c; }
.t-reimburse { background: var(--butter); color: #7a5a12; }

/* ---------- bảng ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: .3px; background: #fbfaf7; white-space: nowrap; }
td.num, th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #fffdfa; }
tr.clickable:hover td a { color: var(--accent-hover); }
tfoot td { font-weight: 700; background: var(--paper-2); border-top: 1px solid var(--line); border-bottom: 0; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }

/* ---------- form ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 13px; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
/* Viền ô nhập đậm hơn OranBox (#eae8e1 chỉ đạt 1.3:1) để đạt chuẩn tương phản 3:1, nhìn rõ trên điện thoại */
input, select, textarea { font: inherit; color: inherit; width: 100%; min-width: 0; height: 42px; padding: 0 13px; border: 1px solid #928e83; border-radius: 9px; background: var(--paper); transition: border-color .15s; }
textarea { height: auto; min-height: 80px; padding: 10px 13px; resize: vertical; }
input[type=file] { height: auto; padding: 9px; background: var(--paper-2); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
input:hover, select:hover, textarea:hover { border-color: #7d796f; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid rgba(238, 112, 75, .22); outline-offset: 0; }
input:disabled, input[readonly] { color: #89877d; background: #f8f7f4; }
input.money { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row-2 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 9px; font-weight: 500; cursor: pointer; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 13px 20px; border-bottom: 1px solid var(--line-2); background: var(--paper-2); }
.card > .filters:first-child { border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0; }
.filters > * { width: auto; min-width: 130px; flex: 1 1 140px; height: 38px; }
.filters > .btn { flex: 0 0 auto; min-width: 0; height: 38px; }
.filters input[type=search] { flex: 2 1 200px; }

/* ---------- đăng nhập ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; }
.auth-card { width: 100%; max-width: 420px; padding: 33px; border-radius: 17px; background: #fffefa; border-color: #eae2d4; box-shadow: 0 8px 35px rgba(156, 126, 82, .05); }
.auth-card .brand { margin-bottom: 26px; }
.auth-card h1 { font-size: 26px; margin-bottom: 8px; }
.auth-card p { margin: 0 0 22px; color: var(--muted); }
@media (max-width: 420px) { .auth-card { padding: 26px 20px; } }

/* ---------- hộp thoại ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(48, 41, 31, .36); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); display: grid; place-items: center; padding: 18px; overflow-y: auto; }
.modal { width: 100%; max-width: 480px; background: #fffefa; border: 1px solid #e9e2d7; border-radius: 17px; box-shadow: var(--shadow-pop); margin: auto; }
.modal.wide { max-width: 640px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 22px 22px 6px; }
.modal-head h3 { font-size: 22px; letter-spacing: -.7px; }
.modal-body { padding: 18px 22px 4px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; flex-wrap: wrap; padding: 12px 22px 20px; }

#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 999; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast { padding: 13px 16px; border-radius: 11px; background: #33382e; color: #fcf9ed; border: 1px solid #555a49; box-shadow: 0 5px 30px rgba(42, 37, 30, .19); font-weight: 500; animation: pop .18s ease-out; }
.toast.error { background: #8f2f17; border-color: #a8442a; }
.toast.success { background: #33382e; }
.toast.success::before { content: "✓  "; color: #b9d3a8; font-weight: 700; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .toast, .brand-icon, .btn { animation: none; transition: none; } }

/* ---------- chi tiết phiếu ---------- */
.detail-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px 22px; }
.info-grid .k { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .8px; text-transform: uppercase; margin-bottom: 2px; }
.info-grid .v { font-weight: 600; word-break: break-word; }
.sum-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.sum-box { padding: 13px 15px; border-radius: 12px; background: var(--paper-2); border: 1px solid var(--line); }
.sum-box .k { font-size: 12px; color: var(--muted); font-weight: 500; }
.sum-box .v { font-size: 19px; font-weight: 700; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.callout { padding: 13px 16px; border-radius: 12px; border: 1px solid; font-weight: 500; overflow-wrap: anywhere; }
.callout.warn { background: var(--butter); border-color: #efe3bd; color: #5e4612; }
.callout.info { background: var(--lavender); border-color: #e2dcef; color: #45386a; }
.callout.danger { background: var(--danger-soft); border-color: #f3d3c7; color: #7e2810; }
.callout.success { background: var(--success-soft); border-color: #dbe8d3; color: #3c5634; }
.callout a { font-weight: 600; color: #a8432a; text-decoration: underline; }
.callout a:hover { color: #8f3920; }
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.atts { display: flex; gap: 6px; flex-wrap: wrap; }
.att-thumb { width: 46px; height: 46px; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; display: block; background: var(--paper-2); }
.att-file { display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 8px; border: 1px solid #f3d6c6; font-size: 11px; font-weight: 700; color: #9a3f24; background: var(--accent-soft); }
.att-edit { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.att-edit span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 15px 22px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent-soft); border: 2px solid var(--accent); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 19px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .t-act { font-weight: 600; }
.timeline .t-note { color: var(--muted); font-size: 13px; word-break: break-word; }
.timeline .t-meta { color: var(--muted); font-size: 12px; }

/* ---------- biểu đồ ---------- */
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; align-items: end; height: 200px; padding: 10px 4px 0; }
.chart .col { display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.chart .bars { display: flex; gap: 2px; align-items: flex-end; height: calc(100% - 20px); width: 100%; justify-content: center; }
.chart .bar { width: 42%; max-width: 18px; border-radius: 4px 4px 0 0; min-height: 1px; }
.chart .m { font-size: 11px; color: var(--muted); margin-top: 4px; }
.c-income { background: #6f9064; }
.c-expense { background: var(--accent-bright); }
.hbar > div:first-child { overflow-wrap: anywhere; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.hbar:last-child { border-bottom: 0; }
.hbar .track { grid-column: 1 / -1; height: 6px; background: var(--sand); border-radius: 3px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 3px; }
