/* ============================================================
   HAL GROUP — Tài chính công trình
   "Architectural ledger": deep black / graphite / off-white
   ============================================================ */

:root {
  --ink-950: #0b0c0e;
  --ink-900: #111318;
  --ink-850: #15181d;
  --ink-800: #1b1e24;
  --ink-700: #262a31;
  --ink-600: #333944;
  --paper: #edeae2;
  --paper-dim: #c7c4bc;
  --paper-mute: #8b919c;
  --paper-faint: #80868f;
  --brand: #f2a33c;
  --brand-strong: #ffb85c;
  --ok: #57b98a;
  --bad: #e06a50;
  --warn: #e4c55f;
  --info: #6e9fc8;
}

* { -webkit-tap-highlight-color: transparent; }

/* clip (không phải hidden) để chặn tràn ngang do phần tử fixed inset-0 rộng hơn clientWidth khi có scrollbar, mà vẫn giữ sticky topbar */
html { scroll-behavior: smooth; overflow-x: clip; }

body {
  background-color: var(--ink-950);
  color: var(--paper);
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  min-height: 100vh;
}

/* Blueprint grid + vignette nền */
#bg-grid {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(ellipse 80% 55% at 50% -10%, rgba(242, 163, 60, 0.07), transparent 60%),
    linear-gradient(rgba(139, 145, 156, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139, 145, 156, 0.045) 1px, transparent 1px);
  background-size: 100% 100%, 44px 44px, 44px 44px;
  mask-image: radial-gradient(ellipse 90% 90% at 50% 0%, #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 90% 90% at 50% 0%, #000 30%, transparent 100%);
}

::selection { background: rgba(242, 163, 60, 0.35); color: var(--paper); }

/* Scrollbar 4px tự ẩn (khối tokens.css), tô bằng palette dự án */
* { --scrollbar-thumb: transparent; }
*:hover { --scrollbar-thumb: color-mix(in srgb, var(--paper) 16%, transparent); }
.is-scrolling { --scrollbar-thumb: color-mix(in srgb, var(--paper) 28%, transparent); }
*::-webkit-scrollbar { width: 4px; height: 4px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 9999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--brand); }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: transparent transparent; }
  *:hover { scrollbar-color: color-mix(in srgb, var(--paper) 18%, transparent) transparent; }
  .is-scrolling { scrollbar-color: color-mix(in srgb, var(--paper) 28%, transparent) transparent; }
}

.font-display { font-family: "Archivo", "Be Vietnam Pro", sans-serif; }
.num { font-family: "Archivo", "Be Vietnam Pro", sans-serif; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.mono { font-family: "IBM Plex Mono", monospace; }

/* ---------- Component ---------- */
.card {
  background: linear-gradient(180deg, var(--ink-850), var(--ink-900));
  border: 1px solid var(--ink-700);
  border-radius: 12px;
}
.card-hover { transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease; }
.card-hover:hover { border-color: rgba(242, 163, 60, .45); transform: translateY(-2px); box-shadow: 0 10px 30px -18px rgba(0,0,0,.9); }

.label { display:block; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--paper-mute); margin-bottom: 6px; }

.input {
  width: 100%; background: var(--ink-950); color: var(--paper);
  border: 1px solid var(--ink-700); border-radius: 8px;
  padding: 9px 12px; font-size: 14px; line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--paper-faint); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(242,163,60,.15); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b919c' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
input[type="date"].input, input[type="month"].input { color-scheme: dark; }
textarea.input { resize: vertical; min-height: 64px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 8px; font-size: 13.5px; font-weight: 600;
  padding: 9px 16px; border: 1px solid transparent;
  cursor: pointer; transition: all .15s ease; white-space: nowrap;
  user-select: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn-primary { background: var(--brand); color: #14100a; }
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); box-shadow: 0 4px 18px -6px rgba(242,163,60,.55); }
.btn-ghost { background: transparent; color: var(--paper-dim); border-color: var(--ink-700); }
.btn-ghost:hover:not(:disabled) { border-color: var(--paper-faint); color: var(--paper); background: rgba(255,255,255,.03); }
.btn-danger { background: rgba(224,106,80,.12); color: var(--bad); border-color: rgba(224,106,80,.35); }
.btn-danger:hover:not(:disabled) { background: rgba(224,106,80,.22); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn .lucide { width: 15px; height: 15px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 7px; color: var(--paper-mute);
  border: 1px solid transparent; cursor: pointer; transition: all .14s ease; flex: none;
}
.icon-btn:hover { color: var(--paper); background: var(--ink-800); border-color: var(--ink-700); }
.icon-btn.danger:hover { color: var(--bad); background: rgba(224,106,80,.1); border-color: rgba(224,106,80,.3); }
.icon-btn .lucide { width: 15px; height: 15px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  padding: 3px 9px; border-radius: 999px; border: 1px solid;
  white-space: nowrap;
}
.chip .lucide { width: 11px; height: 11px; }
.chip-amber { color: var(--brand); border-color: rgba(242,163,60,.4); background: rgba(242,163,60,.08); }
.chip-green { color: var(--ok); border-color: rgba(87,185,138,.4); background: rgba(87,185,138,.08); }
.chip-red { color: var(--bad); border-color: rgba(224,106,80,.4); background: rgba(224,106,80,.08); }
.chip-blue { color: var(--info); border-color: rgba(110,159,200,.4); background: rgba(110,159,200,.08); }
.chip-grey { color: var(--paper-mute); border-color: var(--ink-600); background: rgba(139,145,156,.07); }

.seg { display: inline-flex; background: var(--ink-950); border: 1px solid var(--ink-700); border-radius: 8px; padding: 3px; gap: 3px; }
.seg button {
  padding: 6px 14px; border-radius: 6px; font-size: 13px; font-weight: 600;
  color: var(--paper-mute); cursor: pointer; transition: all .14s ease; border: none; background: transparent;
}
.seg button.on { background: var(--brand); color: #14100a; }
.seg button.on.seg-income { background: var(--ok); color: #0a1410; }
.seg button:not(.on):hover { color: var(--paper); }

/* Table */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--paper-faint); padding: 10px 12px; border-bottom: 1px solid var(--ink-700);
  white-space: nowrap;
}
.tbl td { padding: 11px 12px; border-bottom: 1px solid rgba(38,42,49,.55); vertical-align: middle; }
.tbl tbody tr { transition: background .12s ease; }
.tbl tbody tr:hover { background: rgba(242,163,60,.035); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .r { text-align: right; }

/* Progress bar dự toán */
.bar { height: 6px; border-radius: 999px; background: var(--ink-800); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; transition: width .5s cubic-bezier(.22,1,.36,1); }

/* Nav */
.navlink {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
  color: var(--paper-mute); cursor: pointer; transition: all .15s ease; border: 1px solid transparent;
  white-space: nowrap;
}
.navlink:hover { color: var(--paper); }
.navlink.on { color: var(--brand); background: rgba(242,163,60,.09); border-color: rgba(242,163,60,.3); }
.navlink .lucide { width: 15px; height: 15px; }

#bottomnav .navlink { flex-direction: column; gap: 3px; font-size: 10px; padding: 7px 4px; flex: 1; border-radius: 9px; }
#bottomnav .navlink .lucide { width: 19px; height: 19px; }

/* KPI */
.kpi-ico { width: 34px; height: 34px; border-radius: 9px; display:flex; align-items:center; justify-content:center; flex:none; }
.kpi-ico .lucide { width: 17px; height: 17px; }

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.reveal { animation: rise .5s cubic-bezier(.22,1,.36,1) both; }
.reveal-1 { animation-delay: .04s; } .reveal-2 { animation-delay: .09s; }
.reveal-3 { animation-delay: .14s; } .reveal-4 { animation-delay: .19s; }
.reveal-5 { animation-delay: .24s; } .reveal-6 { animation-delay: .29s; }

@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-panel { animation: pop .28s cubic-bezier(.22,1,.36,1) both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-backdrop { animation: fade .2s ease both; }

@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
.toast { animation: toastIn .25s cubic-bezier(.22,1,.36,1) both; }
.toast.out { transition: opacity .25s ease, transform .25s ease; opacity: 0; transform: translateY(8px); }

@keyframes barSlide { from { transform: translateX(-100%); } to { transform: translateX(320%); } }
#busy { position: fixed; top: 0; left: 0; right: 0; height: 2.5px; z-index: 200; background: transparent; pointer-events: none; opacity: 0; transition: opacity .2s; }
#busy.on { opacity: 1; }
#busy > i { display: block; height: 100%; width: 32%; background: linear-gradient(90deg, transparent, var(--brand), transparent); animation: barSlide 1.1s ease-in-out infinite; }

@keyframes pulseDot { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.dot-live { animation: pulseDot 2s ease infinite; }

/* ---------- Modal / lightbox / toast ---------- */
#modal-root { position: fixed; inset: 0; z-index: 100; display: none; }
#modal-root.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5,6,8,.72); backdrop-filter: blur(6px); }
.modal-wrap { position: absolute; inset: 0; overflow-y: auto; display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px 60px; }
.modal-panel { position: relative; width: 100%; margin-top: 4vh; }
@media (max-width: 640px) {
  .modal-wrap { padding: 0; align-items: flex-end; }
  .modal-panel { margin-top: 0; border-radius: 16px 16px 0 0 !important; max-height: 94vh; overflow-y: auto; }
}

#lightbox-root { position: fixed; inset: 0; z-index: 120; display: none; }
#lightbox-root.open { display: flex; align-items: center; justify-content: center; }

#toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 150; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(94vw, 460px); }
@media (max-width: 767px) { #toast-root { bottom: 84px; } }

/* FAB mobile */
#fab { position: fixed; right: 16px; bottom: 78px; z-index: 60;
  width: 54px; height: 54px; border-radius: 16px; background: var(--brand); color: #14100a;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 26px -6px rgba(242,163,60,.5); cursor: pointer; border: none;
  transition: transform .15s ease; }
#fab:active { transform: scale(.93); }
#fab .lucide { width: 24px; height: 24px; }
/* ID selector display:flex đè lên class md:hidden của Tailwind — ẩn FAB trên desktop bằng media query đồng bộ breakpoint md */
@media (min-width: 768px) { #fab { display: none; } }

/* Chart box */
.chart-box { position: relative; width: 100%; }

/* Attachment thumb */
.att-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 1px solid var(--ink-700); cursor: zoom-in; background: var(--ink-800); }

/* Tiền */
.money-in { color: var(--ok); }
.money-out { color: var(--paper); }

/* Divider mảnh kiểu bản vẽ */
.hairline { border-top: 1px solid var(--ink-700); }

/* Tiêu đề section gạch chân amber */
.sec-title { display: flex; align-items: center; gap: 10px; }
.sec-title::before { content: ""; width: 4px; height: 18px; background: var(--brand); border-radius: 2px; flex: none; }

@media print {
  #topbar, #mainnav, #bottomnav, #fab, #demo-banner, .no-print { display: none !important; }
  body { background: #fff; color: #111; }
}