/* ATC-ACCOUNTING – giao diện giống phần mềm lô tô Ninh Bình: menu ngang trên cùng, nền giấy xanh nhạt, chữ Unicode. */
:root {
  --paper: #eaf0f6;
  --sheet: #f8fbfd;
  --surface: #ffffff;
  --ink: #17283a;
  --muted: #5b6b7d;
  --rule: #c5d3e1;
  --rule-strong: #93a9c0;
  --accent: #1d68ad;
  --ok: #2e7d4f;
  --bad: #c62828;
  --bad-bg: #fde9e7;
  --focus: #fff1b8;
  --font: 'Be Vietnam Pro', 'Segoe UI', system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--ink); background: var(--paper); font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 21px; } h2 { font-size: 17px; font-weight: 600; }

/* ───── Khung: menu ngang (máy tính), menu dọc gập (điện thoại) ───── */
.app { display: grid; grid-template-rows: auto 1fr; min-height: 100%; }
.topbar { display: flex; align-items: stretch; gap: 4px; background: var(--ink); color: #d9e4ee; padding: 0 12px; min-height: 42px; position: sticky; top: 0; z-index: 40; }
.tb-brand { align-self: center; color: #fff; text-decoration: none; font-weight: 700; font-size: 15px; margin-right: 14px; white-space: nowrap; }
.tb-menu { display: flex; align-items: stretch; }
.tb-item { position: relative; display: flex; }
.tb-btn { background: none; border: 0; color: #d9e4ee; font-size: 14.5px; padding: 0 14px; cursor: pointer; white-space: nowrap; }
.tb-btn span { font-size: 11px; color: #8fa6bb; }
.tb-btn:hover, .tb-btn[aria-expanded='true'] { background: var(--accent); color: #fff; }
.tb-btn.cur { color: #fff; font-weight: 600; box-shadow: inset 0 -3px 0 #6fb1f0; }
.tb-drop { position: absolute; top: 100%; left: 0; min-width: 260px; background: var(--surface); color: var(--ink); border: 1px solid var(--rule); border-top: 0; border-radius: 0 0 10px 10px; box-shadow: 0 12px 28px rgba(23, 40, 58, .22); padding: 8px; display: flex; flex-direction: column; }
.tb-subrow { position: relative; }
.tb-subbtn { width: 100%; display: flex; justify-content: space-between; gap: 16px; background: none; border: 0; padding: 7px 10px; border-radius: 6px; cursor: pointer; text-align: left; white-space: nowrap; }
.tb-subrow.on > .tb-subbtn, .tb-subbtn:hover { background: #e1edf8; }
.tb-fly { position: absolute; left: 100%; top: -8px; min-width: 300px; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; box-shadow: 0 12px 28px rgba(23, 40, 58, .22); padding: 8px; display: flex; flex-direction: column; }
.tb-drop a, .tb-fly a { color: var(--ink); text-decoration: none; padding: 7px 10px; border-radius: 6px; white-space: nowrap; font-size: 14.5px; }
.tb-drop a:hover, .tb-fly a:hover, .tb-drop a:focus-visible, .tb-fly a:focus-visible { background: var(--accent); color: #fff; outline: none; }
.tb-drop a[aria-current='page'], .tb-fly a[aria-current='page'] { background: #e1edf8; font-weight: 600; }
.tb-cur { align-self: center; margin-left: 10px; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.18); color: #9fb3c6; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-who { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; color: #9fb3c6; white-space: nowrap; }
.tb-who button { background: none; border: 0; color: #d9e4ee; cursor: pointer; text-decoration: underline; padding: 0; }
.tb-toggle { display: none; }
main { padding: 18px 24px 40px; min-width: 0; }
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; padding: 6px 10px; }
  .tb-toggle { display: inline-block; background: none; border: 1px solid #5d7590; color: #fff; border-radius: 6px; padding: 2px 10px; margin-left: auto; }
  .tb-menu { display: none; width: 100%; flex-direction: column; }
  .topbar.open .tb-menu { display: flex; }
  .tb-item { flex-direction: column; }
  .tb-btn { text-align: left; padding: 9px 6px; }
  .tb-drop, .tb-fly { position: static; box-shadow: none; border: 0; min-width: 0; }
  .tb-cur { display: none; }
  .tb-who { width: 100%; margin: 4px 0; flex-wrap: wrap; }
  main { padding: 12px 12px 32px; }
}

/* ───── Thành phần chung ───── */
.page-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head p { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea, input.in, select.in { border: 1px solid var(--rule-strong); background: var(--surface); border-radius: 5px; padding: 5px 8px; font-size: 15px; color: var(--ink); min-width: 0; }
input:focus, select:focus, textarea:focus { background: var(--focus); outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.btn { border: 1px solid var(--rule-strong); background: var(--surface); border-radius: 5px; padding: 6px 13px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 2px 8px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 14px 16px; }
.notice { padding: 9px 12px; border-radius: 6px; font-size: 14px; margin: 8px 0; }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.ok { background: #e5f3ea; color: var(--ok); }
.notice.info { background: #e4eef8; color: var(--accent); }
.muted { color: var(--muted); }
.num { text-align: right; white-space: nowrap; }
.table-wrap { overflow: auto; max-height: 68vh; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data th, table.data td { padding: 5px 9px; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); background: var(--sheet); position: sticky; top: 0; z-index: 1; }
table.data th.num { text-align: right; }
table.data tr.total td { font-weight: 700; border-top: 2px solid var(--rule-strong); background: var(--sheet); }
table.data tbody tr:hover td { background: #f3f7fb; }
table.data tr.pick { cursor: pointer; }
table.data tr.sel td { background: #dcebf9 !important; }
table.data tr.lv1 td { font-weight: 700; }
table.data tr.lv2 td { font-weight: 600; }
.tag { display: inline-block; font-size: 11.5px; padding: 0 6px; border-radius: 99px; border: 1px solid var(--rule-strong); color: var(--muted); }
.home { display: grid; place-items: center; min-height: 60vh; text-align: center; gap: 8px; }
.home h1 { font-size: 30px; }

/* ───── Hộp thoại ───── */
.dialog-back { position: fixed; inset: 0; background: rgba(23, 40, 58, .35); display: grid; place-items: center; z-index: 100; padding: 12px; }
.dialog { background: var(--surface); border-radius: 10px; padding: 18px 20px; width: min(640px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 12px; }
.dialog .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 560px) { .dialog .grid2 { grid-template-columns: 1fr; } }

/* ───── Đăng nhập ───── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(180deg, #5b9ff0 0%, #5d9ff0 45%, #b9d6f7 68%, #f4f8fd 85%, #fff 100%); }
.login form { background: #fff; border-radius: 12px; padding: 26px 28px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; box-shadow: 0 18px 40px rgba(23, 40, 58, .25); }
.login .brand { font-size: 24px; font-weight: 800; color: var(--accent); letter-spacing: .02em; }

/* ───── Màn hình chứng từ (giống form PSTM của FoxPro) ───── */
.voucher { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 14px; align-items: start; }
.vform { display: grid; grid-template-columns: 110px 130px minmax(0, 1fr) 90px 130px; gap: 6px 8px; align-items: center; }
.vform label { font-size: 13.5px; color: var(--muted); }
.vform input, .vform select { border: 1px solid var(--rule-strong); border-radius: 4px; padding: 4px 7px; min-width: 0; width: 100%; background: #fff; }
.vform .name { font-size: 13.5px; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vform .span3 { grid-column: span 3; }
.vform .span4 { grid-column: span 4; }
.vform input.money { text-align: right; font-weight: 600; }
.vside { display: flex; flex-direction: column; gap: 8px; }
.vside .btn { width: 100%; text-align: left; }
.vinfo { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; font-size: 13.5px; }
.vinfo b { text-align: right; white-space: nowrap; }
.vsec { margin-top: 10px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
@media (max-width: 860px) {
  .voucher { grid-template-columns: minmax(0, 1fr); }
  .vform { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .vform > * { grid-column: 1 / -1 !important; }
  .vform > label { margin-top: 6px; }
  .vform > span:empty { display: none; }
}

/* ───── Bản in ───── */
.print-head { display: none; }
@media print {
  @page { size: A4; margin: 12mm 10mm; }
  body { background: #fff; font-size: 12px; }
  .topbar, .no-print, .page-head .row, .btn { display: none !important; }
  main { padding: 0; }
  .print-head { display: block; text-align: center; margin-bottom: 8px; }
  .table-wrap { max-height: none; overflow: visible; border: 0; }
  table.data { font-size: 11px; }
  table.data th, table.data td { border: 1px solid #555; padding: 2px 4px; }
  table.data th { position: static; }
}

/* In phiếu thu / chi: chỉ in khối phiếu */
.print-area { display: none; }
@media print {
  body.printing > *:not(.print-area) { display: none !important; }
  body.printing .print-area { display: block; font-size: 13px; }
  body.printing .print-area p { margin: 4px 0; }
}
