/* Dilacos Spa — phong cách Frigate: navy là bề mặt, giấy ngà, góc vuông, không đổ bóng. Điện thoại là chuẩn. */
:root {
  --navy: #171D4E; --navy-2: #20285F; --paper: #FBFAF8; --mist: #EDF0F6; --quiet: #F4F6FA; --white: #fff;
  --ink: #3C4160; --muted: #6B7291; --signal: #D9232E; --line: rgba(23,29,78,.13); --line-2: rgba(23,29,78,.22);
  --green: #2F7D4F; --green-soft: #E6F2EA; --plum: #8A3F6B; --plum-soft: #F5E8F0; --teal: #1F7A7A; --teal-soft: #E2F1F1;
  --amber: #9A6208; --amber-soft: #FBF0DC; --red: #C22B2B; --red-soft: #FBE6E6; --navy-soft: #E7EAF4;
  --display: 'Josefin Sans', 'Helvetica Neue', Arial, sans-serif; --body: 'Nunito', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --tabbar: 62px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 16px/1.5 var(--body); -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
h1, h2, h3 { font-family: var(--display); color: var(--navy); font-weight: 400; margin: 0; letter-spacing: -.01em; line-height: 1.2; }
h1 { font-size: 26px; } h2 { font-size: 20px; } h3 { font-size: 17px; font-weight: 600; }
a { color: var(--navy); }
p { margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; border-radius: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13.5px; } .grow { flex: 1; min-width: 0; } .nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.label { font: 600 11.5px/1.3 var(--display); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Khung app */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 52px; position: sticky; top: 0; z-index: 20; }
.topbar .brand { font: 600 14px var(--display); letter-spacing: .2em; text-transform: uppercase; }
.topbar .brand i { display: inline-block; width: 22px; height: 1px; background: var(--signal); vertical-align: middle; margin-right: 10px; }
.topbar .who { margin-left: auto; font-size: 14px; color: #fff; background: none; border: 1px solid rgba(255,255,255,.22); padding: 6px 10px; cursor: pointer; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell { display: block; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--white); border-top: 1px solid var(--line-2); display: flex; z-index: 30; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--muted); font: 600 10.5px var(--display); letter-spacing: .06em; text-transform: uppercase; min-width: 0; border-top: 3px solid transparent; }
.nav a svg { width: 22px; height: 22px; }
.nav a.active { color: var(--navy); border-top-color: var(--signal); }
.nav a.desk-only, .nav .nav-sep { display: none; }
.main { padding: 16px 16px calc(var(--tabbar) + 28px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head .eyebrow { display: block; margin-bottom: 4px; }
.page-head .eyebrow::before { content: ''; display: inline-block; width: 26px; height: 1px; background: var(--signal); vertical-align: middle; margin-right: 10px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Nút */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 14px; border: 1px solid var(--line-2); background: var(--white); color: var(--navy); font: 600 12px var(--display); letter-spacing: .12em; text-transform: uppercase; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--navy); }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-2); }
.btn-green { background: var(--green); color: #fff; border-color: var(--green); }
.btn-danger { color: var(--red); border-color: var(--red); }
.btn-sm { min-height: 34px; padding: 0 10px; font-size: 11px; }
.btn:disabled { opacity: .5; cursor: default; }
.chip { display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border: 1px solid var(--line-2); background: var(--white); color: var(--ink); font-size: 14px; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Thẻ khối: trắng + vạch màu 4px + dải tiêu đề nền nhạt */
.card { background: var(--white); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--navy)); margin-bottom: 14px; }
.card > .card-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--cs, var(--navy-soft)); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card > .card-head h3 { color: var(--c, var(--navy)); }
.card > .card-head .ico { width: 30px; height: 30px; border-radius: 50%; background: var(--c, var(--navy)); color: #fff; display: grid; place-items: center; flex: none; }
.card > .card-head .ico svg { width: 16px; height: 16px; }
.card > .card-body { padding: 14px; }
.card.flush > .card-body { padding: 0; }
.c-green { --c: var(--green); --cs: var(--green-soft); } .c-plum { --c: var(--plum); --cs: var(--plum-soft); } .c-teal { --c: var(--teal); --cs: var(--teal-soft); }
.c-amber { --c: var(--amber); --cs: var(--amber-soft); } .c-red { --c: var(--red); --cs: var(--red-soft); } .c-navy { --c: var(--navy); --cs: var(--navy-soft); }

/* Ô số liệu */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--white); border: 1px solid var(--line); border-top: 3px solid var(--c, var(--navy)); padding: 12px 12px 10px; min-width: 0; }
.stat .value { font: 400 23px/1.15 var(--display); color: var(--navy); margin: 6px 0 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .hint { font-size: 13px; color: var(--ink); }
.stat .value.neg { color: var(--red); } .stat .value.pos { color: var(--green); }

/* Bảng kiểu Excel: kẻ lưới, ô sát, cột đầu và hàng tên cột ghim */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { border-collapse: collapse; width: 100%; font-size: 14.5px; background: var(--white); }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 7px 9px; vertical-align: top; text-align: left; }
table.grid th { background: var(--mist); font: 600 11px var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--navy); white-space: nowrap; position: sticky; top: 0; }
table.grid th.num, table.grid td.num { text-align: right; }
table.grid td:first-child, table.grid th:first-child { position: sticky; left: 0; z-index: 1; background: var(--white); }
table.grid th:first-child { background: var(--mist); z-index: 2; }
table.grid tr.clickable { cursor: pointer; }
table.grid tr.clickable:hover td { background: var(--quiet); }
table.grid tr.total td { background: var(--mist); font-weight: 700; color: var(--navy); }
table.grid tr.day td { background: var(--navy-soft); font-weight: 700; color: var(--navy); }
table.grid td b { color: var(--navy); }
.debt { color: var(--red); font-weight: 700; }
.tag { display: inline-block; padding: 1px 7px; margin: 1px 3px 1px 0; background: var(--mist); color: var(--navy); font-size: 12.5px; white-space: nowrap; }
.badge { display: inline-block; padding: 1px 7px; font: 600 10.5px var(--display); letter-spacing: .08em; text-transform: uppercase; background: var(--mist); color: var(--navy); white-space: nowrap; }
.badge.b-red { background: var(--red-soft); color: var(--red); } .badge.b-green { background: var(--green-soft); color: var(--green); } .badge.b-amber { background: var(--amber-soft); color: var(--amber); }
.empty { padding: 26px 14px; text-align: center; color: var(--ink); }

/* Ô nhập */
.f { display: block; margin-bottom: 12px; min-width: 0; }
.f > span { display: block; margin-bottom: 4px; font: 600 11.5px var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.f em { color: var(--signal); font-style: normal; }
input:not([type=checkbox]):not([type=radio]), select, textarea { width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line-2); background: var(--white); font-size: 16px; -webkit-appearance: none; appearance: none; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--navy) 50%), linear-gradient(135deg, var(--navy) 50%, transparent 50%); background-position: calc(100% - 17px) 19px, calc(100% - 12px) 19px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .chip:focus-visible { outline: 2px solid var(--navy); outline-offset: 1px; }
input.money { text-align: right; font-variant-numeric: tabular-nums; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label { display: inline-flex; align-items: center; min-height: 34px; padding: 0 10px; border: 1px solid var(--line-2); background: var(--white); font-size: 14px; cursor: pointer; }
.checks input { position: absolute; opacity: 0; pointer-events: none; }
.checks label:has(input:checked) { background: var(--navy); color: #fff; border-color: var(--navy); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters .dates { display: flex; gap: 6px; align-items: center; }
.filters .dates input { width: 150px; min-height: 34px; padding: 4px 8px; font-size: 14.5px; }
.search { position: relative; flex: 1; min-width: 180px; }

/* Gợi ý khi gõ */
.suggest { position: relative; }
.suggest-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 5; background: var(--white); border: 1px solid var(--navy); border-top: 0; max-height: 260px; overflow-y: auto; }
.suggest-list button { display: flex; width: 100%; gap: 8px; text-align: left; padding: 10px; border: 0; border-bottom: 1px solid var(--line); background: var(--white); cursor: pointer; font-size: 15px; }
.suggest-list button:hover, .suggest-list button.hl { background: var(--mist); }
.suggest-list .new { color: var(--green); font-weight: 700; }
.picked { display: flex; align-items: center; gap: 8px; padding: 9px 10px; background: var(--plum-soft); border: 1px solid var(--line-2); border-left: 4px solid var(--plum); }

/* Dòng hoá đơn */
.lines { border: 1px solid var(--line); margin-bottom: 12px; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 6px 8px; padding: 9px 10px; border-bottom: 1px solid var(--line); align-items: center; }
.line:last-child { border-bottom: 0; }
.line .nm { font-weight: 700; color: var(--navy); grid-column: 1; }
.line .rm { grid-column: 2; grid-row: 1; border: 0; background: none; color: var(--red); font-size: 20px; width: 34px; height: 34px; cursor: pointer; }
.line .ctl { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; }
.line .qty { display: flex; align-items: center; border: 1px solid var(--line-2); }
.line .qty button { width: 36px; height: 40px; border: 0; background: var(--mist); font-size: 18px; color: var(--navy); cursor: pointer; }
.line .qty input { width: 44px; min-height: 40px; border: 0; text-align: center; padding: 0; }
.line .ctl input.money { min-height: 40px; }
.sumbox { background: var(--quiet); border: 1px solid var(--line); padding: 10px 12px; margin-bottom: 12px; }
.sumbox .r { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.sumbox .r.big { font: 400 22px var(--display); color: var(--navy); border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 8px; }

/* Bảng lãi lỗ */
.pl-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.pl-row b { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--navy); }
.pl-row.sub { background: var(--quiet); padding: 7px 8px; font-weight: 700; }
.pl-row.total { background: var(--navy); color: #fff; padding: 10px; border: 0; font-weight: 700; }
.pl-row.total b { color: #fff; font: 400 20px var(--display); }
.pl-row.minus b { color: var(--ink); }

/* Biểu đồ cột một dãy */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding: 22px 4px 0; border-bottom: 1px solid var(--line-2); }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; position: relative; }
.bars .bar { width: 100%; max-width: 46px; background: var(--navy); min-height: 1px; }
.bars .col:hover .bar { background: var(--navy-2); outline: 2px solid var(--white); }
.bars .v { font-size: 11.5px; color: var(--ink); margin-bottom: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bars-x { display: flex; gap: 10px; padding: 4px 4px 0; }
.bars-x span { flex: 1; text-align: center; font-size: 12.5px; color: var(--muted); }
.meter { height: 8px; background: var(--mist); margin-top: 3px; }
.meter i { display: block; height: 100%; background: var(--navy); }

/* Hộp thoại: toàn màn hình trên điện thoại */
.overlay { position: fixed; inset: 0; background: rgba(23,29,78,.45); z-index: 50; display: flex; align-items: stretch; justify-content: center; }
.modal { background: var(--paper); width: 100%; display: flex; flex-direction: column; max-height: 100dvh; }
.modal > header { background: var(--navy); color: #fff; padding: 0 8px 0 16px; min-height: 52px; display: flex; align-items: center; gap: 10px; flex: none; }
.modal > header h2 { color: #fff; font-size: 17px; flex: 1; }
.modal > header button { background: none; border: 0; color: #fff; font-size: 26px; width: 44px; height: 44px; cursor: pointer; }
.modal > .modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal > footer { display: flex; gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line-2); background: var(--white); flex: none; }
.modal > footer .btn-primary, .modal > footer .btn-green { flex: 1; }
#toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom)); z-index: 80; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: var(--navy); color: #fff; padding: 10px 14px; font-size: 15px; max-width: 520px; border-left: 4px solid var(--green); }
.toast.err { border-left-color: var(--signal); } .toast.warn { border-left-color: #E0A526; }

/* Đăng nhập */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: var(--navy); }
.gate .box { width: 100%; max-width: 400px; background: var(--paper); padding: 26px 22px; }
.gate h1 { margin: 6px 0 4px; font-weight: 300; font-size: 30px; }
.note { background: var(--amber-soft); border-left: 4px solid var(--amber); padding: 9px 12px; margin-bottom: 12px; font-size: 14.5px; }
.note.info { background: var(--navy-soft); border-left-color: var(--navy); }
.list-item { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.list-item:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 15px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 619px) {
  .page-head .actions { width: 100%; margin-left: 0; }
  .page-head .actions .btn { flex: 1; padding: 0 8px; }
  .filters .chip { padding: 0 9px; font-size: 13.5px; }
  .filters .dates { flex: 1 1 100%; }
  .filters .dates input { flex: 1; width: auto; min-width: 0; }
  .stat.wide { grid-column: 1 / -1; }
  table.grid { font-size: 13.5px; }
  table.grid th, table.grid td { padding: 6px 7px; }
  table.grid td:first-child { max-width: 124px; overflow-wrap: anywhere; }
}
@media (min-width: 620px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .stat.wide { grid-column: span 2; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .full { grid-column: 1 / -1; }
  .overlay { align-items: center; padding: 20px; }
  .modal { max-width: 640px; max-height: calc(100dvh - 40px); border: 1px solid var(--navy); }
  .modal.wide { max-width: 860px; }
  .line { grid-template-columns: 1fr auto auto; }
  .line .ctl { grid-column: 2; grid-row: 1; } .line .rm { grid-column: 3; }
  .line .ctl input.money { width: 140px; }
}
@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100dvh - 52px); }
  .nav { position: sticky; top: 52px; height: calc(100dvh - 52px); flex-direction: column; border-top: 0; border-right: 1px solid var(--line-2); padding: 12px 0; overflow-y: auto; }
  .nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 18px; font-size: 12px; letter-spacing: .12em; border-top: 0; border-left: 3px solid transparent; }
  .nav a.active { border-left-color: var(--signal); background: var(--mist); }
  .nav a span { line-height: 1.45; }
  .nav a.desk-only { display: flex; } .nav a.phone-only { display: none; }
  .nav .nav-sep { display: block; padding: 14px 18px 4px; font: 600 10.5px var(--display); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
  .main { padding: 24px 28px 40px; margin: 0; max-width: 1240px; }
  h1 { font-size: 32px; }
  #toasts { bottom: 20px; }
  .two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
}
@media print {
  .topbar, .nav, .overlay, #toasts, .main { display: none !important; }
  #print { display: block !important; }
}
#print { display: none; padding: 10mm; font-size: 12pt; color: #000; }
#print h1 { font-size: 18pt; color: #000; } #print table { width: 100%; border-collapse: collapse; margin: 8px 0; } #print td, #print th { border-bottom: 1px solid #999; padding: 4px 2px; text-align: left; } #print .num { text-align: right; }
