:root {
  --navy: #14365c; --navy-2: #1f4f82; --ink: #1b2430; --muted: #66717f; --line: #e3e7ec;
  --bg: #f4f6f9; --card: #fff; --orange: #e8730c; --blue: #1d6fd6; --green: #1f8a4c;
  --red: #c62828; --amber: #b7791f; --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* Khung */
.shell { min-height: 100vh; display: flex; }
.side { width: 230px; background: var(--navy); color: #fff; flex: none; display: none; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand b { display: block; font-size: 17px; letter-spacing: .3px; }
.brand span { font-size: 12px; opacity: .75; }
.side nav { padding: 8px; flex: 1; overflow: auto; }
.side a { display: flex; align-items: center; gap: 10px; color: #dce6f2; padding: 10px 12px; border-radius: 8px; margin-bottom: 2px; }
.side a.on, .side a:hover { background: rgba(255,255,255,.12); color: #fff; }
.side .who { padding: 12px 18px; font-size: 13px; border-top: 1px solid rgba(255,255,255,.12); }
.side .who button { background: none; border: 0; color: #9fc3ec; padding: 0; cursor: pointer; }
.badge { background: var(--orange); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; margin-left: auto; font-weight: 600; }
.main { flex: 1; min-width: 0; padding-bottom: 76px; }
.top { background: var(--navy); color: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 500; }
.top h1 { font-size: 16px; margin: 0; flex: 1; font-weight: 600; }
.top .back { color: #fff; font-size: 22px; line-height: 1; padding: 0 6px 0 0; }
.page { padding: 14px; max-width: 1180px; margin: 0 auto; }
.bottom { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); display: flex; z-index: 600; padding-bottom: env(safe-area-inset-bottom); }
.bottom a { flex: 1; text-align: center; padding: 8px 2px 7px; color: var(--muted); font-size: 11.5px; position: relative; }
.bottom a i { display: block; font-style: normal; font-size: 20px; line-height: 1.2; }
.bottom a.on { color: var(--navy); font-weight: 600; }
.bottom .badge { position: absolute; top: 2px; left: 55%; margin: 0; }
@media (min-width: 900px) {
  .side { display: flex; } .bottom { display: none; } .main { padding-bottom: 24px; }
  .top { position: static; background: transparent; color: var(--ink); padding: 18px 22px 0; }
  .top h1 { font-size: 21px; } .top .back { color: var(--ink); }
  .page { padding: 16px 22px; }
}

/* Thẻ & lưới */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.card h2 .r { margin-left: auto; font-weight: 400; font-size: 13px; }
.grid { display: grid; gap: 12px; }
@media (min-width: 700px) { .g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(5, 1fr); } }
.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; display: block; color: var(--ink); }
.kpi > b { display: block; font-size: 24px; line-height: 1.2; }
.kpi span { font-size: 12.5px; color: var(--muted); }
.kpi.warn > b { color: var(--orange); } .kpi.bad > b { color: var(--red); } .kpi.ok > b { color: var(--green); }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 140px; }
.sp { flex: 1; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

/* Form */
label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.f > span.req::after { content: " *"; color: var(--red); }
input, select, textarea { width: 100%; padding: 10px 11px; border: 1px solid #cfd6de; border-radius: 9px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3f0; border-color: var(--blue); }
textarea { min-height: 76px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 9px; padding: 10px 15px;
  background: var(--navy); color: #fff; font-weight: 600; cursor: pointer; text-align: center; }
.btn.sec { background: #e9eef4; color: var(--navy); }
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid #cfd6de; }
.btn.red { background: var(--red); } .btn.green { background: var(--green); } .btn.orange { background: var(--orange); } .btn.blue { background: var(--blue); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { background: #c9cfd6 !important; color: #fff !important; cursor: not-allowed; }
.big { padding: 16px; font-size: 17px; border-radius: 12px; }
.seg { display: flex; background: #e9eef4; border-radius: 10px; padding: 3px; gap: 3px; overflow-x: auto; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; white-space: nowrap; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13.5px; }
.seg button.on { background: #fff; color: var(--navy); box-shadow: var(--shadow); }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 6px; }
.choices label { border: 1px solid #cfd6de; border-radius: 9px; padding: 9px 10px; display: flex; gap: 7px; align-items: center; cursor: pointer; font-size: 14px; }
.choices label:has(input:checked) { border-color: var(--navy); background: #eef4fb; font-weight: 600; }

/* Bảng */
.tbl-wrap { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: #f7f9fc; }
td.num, th.num { text-align: right; white-space: nowrap; }

/* Danh sách */
.list { display: flex; flex-direction: column; }
.item { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); color: var(--ink); align-items: flex-start; }
.item:last-child { border-bottom: 0; }
.item .body { flex: 1; min-width: 0; }
.item .t1 { font-weight: 600; }
.item .t2 { font-size: 13px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin-top: 6px; background: #b7c0ca; }
.dot.g { background: var(--green); } .dot.o { background: var(--orange); } .dot.r { background: var(--red); } .dot.b { background: var(--blue); }

/* Nhãn trạng thái */
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #e9eef4; color: var(--navy); white-space: nowrap; }
.tag.g { background: #e3f4ea; color: var(--green); } .tag.o { background: #fdf0e3; color: #b25a06; }
.tag.r { background: #fde8e8; color: var(--red); } .tag.b { background: #e5effc; color: var(--blue); } .tag.x { background: #eee; color: #777; }

/* Chấm công */
.clock { text-align: center; }
.clock .now { font-size: 40px; font-weight: 700; letter-spacing: 1px; color: var(--navy); line-height: 1.1; }
.clock .date { color: var(--muted); margin-bottom: 12px; }
.clock .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.clock .state { font-size: 13px; margin-top: 6px; color: var(--muted); }
.alert { padding: 10px 12px; border-radius: 9px; background: #fff7e6; color: #7a4b00; font-size: 14px; margin-bottom: 10px; }
.alert.r { background: #fde8e8; color: #8e1c1c; } .alert.g { background: #e3f4ea; color: #145c33; } .alert.b { background: #e5effc; color: #123f78; }

/* Ảnh */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.ph { position: relative; aspect-ratio: 1; border-radius: 9px; overflow: hidden; background: #e9eef4; cursor: zoom-in; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph .x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; border: 0; cursor: pointer; }
.ph .sus { position: absolute; left: 4px; bottom: 4px; background: var(--red); color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 5px; }
.addph { aspect-ratio: 1; border: 2px dashed #b9c4d0; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-direction: column; color: var(--navy); cursor: pointer; font-size: 13px; text-align: center; }
.addph i { font-style: normal; font-size: 26px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 2000; display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 100%; max-height: 100%; }

/* Bản đồ */
.map { height: 340px; border-radius: 10px; overflow: hidden; z-index: 1; }
.map.sm { height: 220px; }

/* Hộp thoại */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1500; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 16px; }
@media (min-width: 700px) { .modal-bg { align-items: center; } .modal { border-radius: 16px; } }
.modal h3 { margin: 0 0 12px; font-size: 17px; }
.modal .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* Đăng nhập */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, var(--navy), #0b2340); }
.login .box { background: #fff; width: 100%; max-width: 380px; border-radius: 16px; padding: 24px; }
.login .logo { width: 54px; height: 54px; border-radius: 12px; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; letter-spacing: .5px; margin-bottom: 12px; }
.login h1 { margin: 0; font-size: 20px; } .login p { margin: 4px 0 18px; color: var(--muted); }

#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #1b2430; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 3000; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 92vw; text-align: center; }
#toast.on { opacity: 1; } #toast.err { background: var(--red); }
.items-edit .it { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; position: relative; }
.items-edit .it .rm { position: absolute; top: 6px; right: 6px; }
.items-edit .g4 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.total { font-size: 17px; font-weight: 700; text-align: right; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 10px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.timeline { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 14px; }
.timeline div { position: relative; padding-bottom: 10px; font-size: 14px; }
.timeline div::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--navy); }
.empty { text-align: center; color: var(--muted); padding: 22px 10px; }
.more-menu a { display: block; padding: 13px 4px; border-bottom: 1px solid var(--line); color: var(--ink); }

/* Hành trình */
.tbar { position: relative; height: 38px; background: #f1f4f8; border-radius: 8px; overflow: hidden; }
.tb { position: absolute; top: 0; bottom: 0; }
.tb.v { display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 13px; border-left: 1px solid #fff; border-right: 1px solid #fff; }
.tb.g { background: #c9d1db; top: 14px; bottom: 14px; }
.tb.g.bad { background: repeating-linear-gradient(45deg, #c62828 0 6px, #ef9a9a 6px 12px); top: 10px; bottom: 10px; }
.tbar-ax { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }
.journey { display: flex; flex-direction: column; }
.jstep { display: flex; gap: 12px; color: var(--ink); padding: 6px 0; }
a.jstep:hover .jbody { background: #f7f9fc; }
.jdot { width: 30px; height: 30px; border-radius: 50%; color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; font-size: 14px; }
.jdot.mark { background: var(--navy); font-size: 11px; }
.jbody { flex: 1; min-width: 0; border-radius: 8px; padding: 2px 6px; }
.jt { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.jgap { display: flex; gap: 12px; align-items: stretch; min-height: 34px; }
.jline { width: 30px; flex: none; display: flex; justify-content: center; }
.jline::before { content: ""; width: 0; border-left: 3px dotted #b7c0ca; }
.jgap.bad .jline::before { border-left: 3px solid var(--red); }
.jtxt { font-size: 13px; color: var(--muted); padding: 7px 6px; }
.jgap.bad .jtxt { color: #8e1c1c; background: #fde8e8; border-radius: 8px; margin: 2px 0; }
.jpin { width: 28px; height: 28px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
