:root {
  --bg: #f6f5f2; --card: #ffffff; --ink: #1f2328; --muted: #6b7280; --line: #e5e3de;
  --accent: #8a6d3b; --accent-ink: #ffffff; --red: #c0392b; --green: #2e7d4f; --amber: #b7791f; --blue: #2b6cb0;
}
* { box-sizing: border-box; }
html, body { overflow-x: hidden; }
body { margin: 0; font-family: 'Be Vietnam Pro', system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; padding: 6px 12px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--red); border-color: var(--red); }
button.link { border: none; background: none; color: var(--muted); text-decoration: underline; padding: 0; }
input, select, textarea { font: inherit; width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
textarea { min-height: 70px; resize: vertical; }

/* Trang chào + đăng nhập */
.login { min-height: 100vh; min-height: 100svh; display: grid; width: 100%; max-width: 100vw; overflow-x: hidden; grid-template-columns: minmax(0, 1fr) 420px; background: #1f1b17; }
.login.hidden { display: none !important; }
.welcome { min-width: 0; position: relative; overflow: hidden; min-height: 100vh; }
.ws-stage, .ws-img { position: absolute; inset: 0; width: 100%; height: 100%; }
.ws-img { object-fit: cover; opacity: 0; transform: scale(1.04); transition: opacity 1.1s ease, transform 6s ease; }
.ws-img.on { opacity: 1; transform: scale(1); }
.ws-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.18) 0%, rgba(0,0,0,0) 22%, rgba(0,0,0,0) 50%, rgba(0,0,0,.6) 100%); pointer-events: none; }
.ws-caption { position: absolute; left: 40px; bottom: 80px; right: 40px; color: #fff; font-family: "Playfair Display", Georgia, serif; font-size: 34px; font-weight: 500; line-height: 1.2; letter-spacing: .01em; text-shadow: 0 1px 12px rgba(0,0,0,.35); }
.ws-caption small { display: block; font-family: "Be Vietnam Pro", system-ui, sans-serif; font-size: 12px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; opacity: .82; margin-top: 10px; }
.ws-tag { position: absolute; top: 24px; left: 40px; color: #fff; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; padding: 5px 10px; border: 1px solid rgba(255,255,255,.55); border-radius: 999px; background: rgba(0,0,0,.18); }
.lc-logo { width: 132px; height: auto; margin-bottom: 4px; }
.ws-nav { position: absolute; left: 40px; bottom: 28px; display: flex; align-items: center; gap: 10px; }
.ws-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,.6); background: rgba(0,0,0,.25); color: #fff; font-size: 20px; line-height: 1; padding: 0; }
.ws-dots { display: flex; gap: 6px; }
.ws-dots button { width: 8px; height: 8px; padding: 0; border-radius: 50%; border: none; background: rgba(255,255,255,.5); }
.ws-dots button[aria-selected="true"] { background: #fff; width: 22px; border-radius: 4px; }
.login-card { min-width: 0; background: var(--card); padding: 40px 32px 24px; display: flex; flex-direction: column; justify-content: center; gap: 14px; text-align: left; min-height: 100vh; border-radius: 0; border: none; max-width: none; }
.lc-brand { font-size: 12px; letter-spacing: .3em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.login-card h1 { margin: 0; font-family: "Playfair Display", Georgia, serif; font-weight: 600; font-size: 32px; letter-spacing: .01em; }
.lc-sub { margin: 0; color: var(--muted); line-height: 1.5; }
.lc-box { border: 1px solid var(--line); border-radius: 12px; padding: 18px; background: #fbfaf7; }
.lc-label { font-size: 13px; font-weight: 600; margin-bottom: 12px; }
#gbtn { min-height: 44px; }
.ws-thumbs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: thin; }
.ws-thumbs button { flex: none; width: 64px; height: 64px; padding: 0; border-radius: 8px; overflow: hidden; border: 2px solid transparent; opacity: .7; }
.ws-thumbs button.on { border-color: var(--accent); opacity: 1; }
.ws-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lc-foot { margin: 0; font-size: 12px; color: var(--muted); }
@media (max-width: 860px) {
  .login { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; }
  .welcome { min-height: 52vh; min-height: 52svh; }
  .ws-caption { bottom: 60px; font-size: 22px; }
  .ws-caption small { font-size: 10.5px; letter-spacing: .1em; line-height: 1.6; }
  .ws-tag { font-size: 10px; letter-spacing: .12em; max-width: calc(100% - 32px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ws-dots { flex-wrap: wrap; }
  .login-card h1 { font-size: 28px; }
  .ws-thumbs button { width: 56px; height: 56px; }
  .ws-caption { left: 16px; right: 16px; }
  .ws-tag { left: 16px; top: 16px; }
  .lc-logo { width: 104px; }
  .ws-nav { left: 16px; bottom: 18px; }
  .login-card { min-height: 0; padding: 24px 16px 28px; }
}
@media (prefers-reduced-motion: reduce) { .ws-img { transition: none; transform: none; } }
#gbtn { display: flex; justify-content: center; margin: 20px 0 8px; }

.top { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 16px; padding: 8px 16px 0; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; font-size: 16px; }
.me { color: var(--muted); justify-self: end; font-size: 13px; white-space: nowrap; }
/* Thanh điều hướng một dòng, vuốt ngang trên điện thoại thay vì xuống dòng */
nav { grid-column: 1 / -1; display: flex; gap: 2px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
nav::-webkit-scrollbar { display: none; }
nav button { border: none; background: none; padding: 10px 12px; border-bottom: 2px solid transparent; border-radius: 0; flex: none; }
nav button.active { font-weight: 600; border-bottom-color: var(--accent); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

main { padding: 16px; max-width: 1280px; margin: 0 auto; }
h2 { font-size: 18px; margin: 8px 0 12px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar select, .toolbar input { width: auto; min-width: 140px; }
.spacer { flex: 1; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: left; }
button.card { cursor: pointer; width: 100%; }
button.card:hover { border-color: var(--accent); }
.card.act.red { border-left: 4px solid var(--red); } .card.act.amber { border-left: 4px solid var(--amber); } .card.act.blue { border-left: 4px solid var(--blue); }
.card.zero .v { color: var(--muted); }
.toolbar.section { margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.note { font-size: 12px; color: var(--muted); margin: -8px 0 20px; line-height: 1.5; }
.empty { color: var(--muted); padding: 16px; background: var(--card); border: 1px dashed var(--line); border-radius: 12px; }
.alert { background: #fde2e0; color: var(--red); padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.warn { color: var(--red); }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.tab { flex: none; border-radius: 999px; padding: 6px 12px; background: var(--card); }
.tab.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab b { font-weight: 600; margin-left: 2px; }
label.check { display: flex; flex-direction: row !important; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); white-space: nowrap; }
label.check input { width: auto; }
.card .k { color: var(--muted); font-size: 12px; }
.card .v { font-size: 24px; font-weight: 600; margin-top: 4px; }
.card .s { font-size: 12px; color: var(--muted); margin-top: 2px; }

.tbl-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 20px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f3f3f3; font-weight: 600; font-size: 12px; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
/* Cột đầu dính khi cuộn ngang để không mất tên căn / tên khách */
th.sticky, td.sticky { position: sticky; left: 0; background: inherit; z-index: 1; }
td.sticky { background: var(--card); font-weight: 500; white-space: nowrap; }
th.sticky { background: #f3f3f3; }
table.tasks td.title { min-width: 280px; font-weight: 500; }
td .sub { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; }
td .sub.warn { color: var(--red); }
.mob { display: none; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #faf8f4; }
tr.total td { font-weight: 600; border-top: 2px solid var(--line); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #eee; white-space: nowrap; }
.pill.red { background: #fde2e0; color: var(--red); }
.pill.green { background: #def3e6; color: var(--green); }
.pill.amber { background: #fdf0d5; color: var(--amber); }
.pill.blue { background: #dde9f7; color: var(--blue); }
.up { color: var(--green); } .down { color: var(--red); }

.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.col { background: #efede8; border-radius: 12px; padding: 10px; min-height: 120px; }
.col h4 { margin: 0 0 8px; font-size: 13px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; cursor: pointer; }
.item .t { font-weight: 500; }
.item .m { font-size: 12px; color: var(--muted); margin-top: 4px; }

dialog { border: none; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.35); }
#dlgForm { padding: 18px; }
#dlgForm h3 { margin: 0 0 12px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.grid-form label.full { grid-column: 1 / -1; }
.dlg-actions { display: flex; gap: 8px; margin-top: 16px; }
dialog { max-height: calc(100vh - 32px); }
.task-box { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; font-size: 13px; }
.task-box h4 { margin: 8px 0 0; }
.op-area { display: grid; gap: 8px; background: #faf8f4; padding: 10px; border-radius: 10px; }
.op-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.op-btns button { min-height: 40px; }
ul.hist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
ul.hist li { border-left: 2px solid var(--line); padding-left: 8px; }
ul.hist small { color: var(--muted); word-break: break-word; }

.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 20; }

@media (max-width: 700px) {
  .grid-form { grid-template-columns: 1fr; }
  main { padding: 12px; }
  .desk { display: none !important; }
  .mob { display: block; }
  .cardlist .item { padding: 12px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .card { padding: 10px; } .card .v { font-size: 20px; }
  .toolbar select, .toolbar input { min-width: 0; flex: 1 1 140px; }
  h2 { font-size: 16px; }
  dialog { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; margin: 0; }
  input, select, textarea { font-size: 16px; } /* tránh iPhone tự phóng to */
}

.summary .t { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.summary .m { font-size: 13px; margin-top: 4px; }
details summary { cursor: pointer; font-weight: 600; margin-top: 6px; }

/* ---------- Icon, thẻ ---------- */
.ic { width: 16px; height: 16px; stroke-width: 1.75; vertical-align: -3px; }
.card .k .ic { margin-right: 6px; color: var(--muted); }
.card.act.red .k .ic { color: var(--red); } .card.act.amber .k .ic { color: var(--amber); } .card.act.blue .k .ic, .card.blue .k .ic { color: var(--blue); }
.card.zero { background: transparent; border-style: dashed; }
.card.zero .k, .card.zero .s { opacity: .75; }
.card.blue { border-left: 4px solid var(--blue); }
nav button .ic { margin-right: 4px; }
h3 { font-size: 14px; margin: 4px 0 8px; }

/* ---------- Biểu đồ ---------- */
.viz-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-bottom: 16px; }
figure.viz { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
figure.viz figcaption { font-weight: 600; font-size: 13px; margin-bottom: 8px; }
figure.viz svg { width: 100%; height: auto; display: block; overflow: visible; }
figure.viz .grid { stroke: #ecebe7; stroke-width: 1; }
figure.viz .ax { font-size: 11px; fill: var(--muted); }
figure.viz .lbl { font-size: 12px; fill: var(--ink); font-weight: 600; }
.viz-empty { color: var(--muted); font-size: 13px; padding: 12px; background: var(--card); border: 1px dashed var(--line); border-radius: 12px; }
.viz-tip { position: fixed; z-index: 30; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; line-height: 1.45; padding: 6px 9px; border-radius: 8px; max-width: 260px; }
.hbars { display: grid; gap: 6px; }
.hb, .sb { display: grid; grid-template-columns: 112px 1fr auto; align-items: center; gap: 8px; font-size: 12px; padding: 2px 0; }
.hb-l { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-t { height: 12px; background: #f1f0ec; border-radius: 0 4px 4px 0; overflow: hidden; }
.hb-b { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.hb-v { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; min-width: 64px; }
.sb-t { display: flex; gap: 2px; height: 18px; }
.sb-s { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 600; min-width: 2px; }
.sb-s:first-child { border-radius: 4px 0 0 4px; } .sb-s:last-child { border-radius: 0 4px 4px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.gd-wrap { overflow-x: auto; }
.gd { display: grid; gap: 2px; font-size: 11px; min-width: 560px; }
.gd-c0 { position: sticky; left: 0; background: var(--card); padding-right: 8px; white-space: nowrap; font-size: 12px; display: flex; align-items: center; }
.gd-h { text-align: center; color: var(--muted); line-height: 1.1; padding-bottom: 2px; }
.gd-h small { display: block; font-size: 9px; }
.gd-h.we { color: var(--ink); font-weight: 600; }
.gd-c { height: 22px; border-radius: 3px; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 10px; }
.gd-booked, .legend i.gd-booked { background: #2a78d6; color: #fff; }
.gd-maint, .legend i.gd-maint { background: #eb6834; color: #fff; }
.gd-unknown, .legend i.gd-unknown { background: #9ec5f4; color: #0d366b; }
.gd-free, .legend i.gd-free { background: #f1f0ec; }
.gd-x { font-size: 12px; padding-left: 8px; display: flex; align-items: center; white-space: nowrap; }
.occ { display: inline-flex; align-items: center; gap: 6px; }
.occ i { display: inline-block; width: 44px; height: 6px; background: #f1f0ec; border-radius: 3px; overflow: hidden; }
.occ i b { display: block; height: 100%; background: #2a78d6; border-radius: 0 3px 3px 0; }
.up::before { content: '▲ '; font-size: 9px; } .down::before { content: '▼ '; font-size: 9px; }
.copy-row { display: flex; gap: 6px; } .copy-row input { flex: 1; }
@media (max-width: 700px) { .hb, .sb { grid-template-columns: 88px 1fr auto; } .viz-row { grid-template-columns: 1fr; } }
.tab .ic { margin-right: 4px; }

/* Bảo dưỡng: chọn hạng mục và lên lịch */
h3.grp { margin: 18px 0 6px; font-size: 15px; }
table.assets td.pick, table.assets th.pick { width: 36px; text-align: center; }
table.assets td.pick input { width: 20px; height: 20px; margin: 0; }
table.assets tr.on td { background: #fbf6ec; }
.small { font-size: 12px; }
button.link .ic { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; }
.toolbar button .ic { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
ul.sched-list { margin: 6px 0 0; padding-left: 18px; }
.dchips { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 6px 0; }
.dchip { padding: 4px 0; font-size: 11px; line-height: 1.2; text-align: center; border-radius: 6px; border: 2px solid transparent; }
.dchip b { display: block; font-size: 12px; }
.dchip.free { background: #def3e6; color: #1d5a37; }
.dchip.turn { background: #fdf0d5; color: #7a5212; }
.dchip.busy { background: #2a78d6; color: #fff; }
.dchip.on { border-color: var(--ink); }
.legend i.dchip { padding: 0; border: none; }
.msg { padding: 8px 10px; border-radius: 8px; margin: 0; background: #f1f0ec; }
.msg.ok { background: #def3e6; color: var(--green); }
.msg.warn { background: #fdf0d5; color: #7a5212; }

/* Chăm sóc khách hàng */
a.btn { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; padding: 6px 12px; text-decoration: none; }
a.btn .ic, button .ic { margin-right: 4px; }
.prog { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: #eceae4; vertical-align: middle; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--green); }
#dlgExtra .summary { margin-bottom: 8px; }
fieldset.steps { border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px 10px; margin: 0 0 10px; }
fieldset.steps legend { font-weight: 600; padding: 0 4px; }
label.step { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-bottom: 1px dashed var(--line); font-weight: 400; cursor: pointer; }
label.step:last-child { border-bottom: none; }
label.step input { width: 20px; height: 20px; flex: none; margin: 1px 0 0; }
label.step small { display: block; font-size: 12px; }
label.step.done span { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
label.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-weight: 400; font-size: 13px; cursor: pointer; }
label.chip input { margin: 0; }
label.chip:has(input:checked) { background: #fdf0d5; border-color: #e8c98a; }
ul.ex-list { margin: 4px 0 8px; padding-left: 18px; }
td.pick input { width: 20px; height: 20px; margin: 0; }
/* Hồ sơ cơ sở, Về SPartner */
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.site-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; scroll-margin-top: 90px; }
.site-card header { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.site-card h3 { margin: 2px 0 8px; font-size: 16px; }
.site-acts { display: flex; gap: 6px; flex: none; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0 0 10px; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; }
.links { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.site-card details summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
.sb-sec h4 { margin: 10px 0 4px; font-size: 13px; }
.pre { white-space: pre-wrap; }
.about { max-width: 820px; }
.about .lead { font-size: 15px; line-height: 1.6; }
.about h3 { margin: 22px 0 8px; font-size: 15px; }
.brand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
ul.plain { list-style: none; padding: 0; margin: 0; } ul.plain li { padding: 4px 0; }
.about ol li { margin-bottom: 4px; line-height: 1.5; }
@media (max-width: 600px) { .site-grid { grid-template-columns: 1fr; } }
label.chip, label.step { width: auto; }
label.chip { flex-direction: row; white-space: nowrap; margin: 0; }
label.chip input, label.step input, td.pick input { width: auto; min-width: 0; padding: 0; }
.date-filter { align-items: center; }
.date-filter label.check input { width: auto; min-width: 140px; }
button.chip-btn { border-radius: 999px; padding: 4px 10px; font-size: 13px; }
button.chip-btn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
