/* Giao diện web của chương trình cân xe — THIẾT KẾ CHO ĐIỆN THOẠI TRƯỚC.
   Kiểu dáng bắt chước cửa sổ Windows: nền DeepSkyBlue, hộp nhóm WinForms,
   nút xám cổ điển, đèn LED bảy đoạn (màu lấy từ Form1.Designer.cs). */

:root {
  --form-bg:      #00bfff;   /* DeepSkyBlue - nền cửa sổ Windows */
  --text:         #000000;
  --text-dim:     #083a52;

  --seg-frame:    #778899;   /* LightSlateGray */
  --seg-live-bg:  #87cefa;   /* LightSkyBlue   */
  --seg-sm-bg:    #f0ffff;   /* Azure          */
  --seg-on:       #e00000;   /* Red            */

  --btn-face-1:   #f4f4f4;
  --btn-face-2:   #dfdfdf;
  --btn-border:   #8e8f8f;
  --ctl-border:   #7a7a7a;

  --highlight:    #0078d7;   /* SystemColors.Highlight */
  --warn:         #b3261e;
  --ok:           #1c8a3c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--form-bg);
  color: var(--text);
  font-family: Tahoma, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 8px 74px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

button, input, select { font-family: inherit; }

/* ---------------- đăng nhập ---------------- */

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 340px;
  background: #f0f0f0;
  border: 1px solid #5c9fd0;
  border-radius: 6px;
  padding: 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 3px 14px rgba(0, 40, 60, .35);
  overflow: hidden;
}

.login-box h1 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  background: linear-gradient(#ffffff, #dce9f5);
  border-bottom: 1px solid #b5cadb;
  padding: 10px 14px;
}

.login-box label { font-size: 13px; padding: 0 16px; }

.login-box input {
  margin: 0 16px;
  font-size: 17px;
  padding: 12px 10px;
  border: 1px solid var(--ctl-border);
  border-radius: 3px;
  background: #fff;
}

/* o mat khau + nut con mat hien/an */
.pw-wrap { position: relative; }
.pw-wrap input {
  width: auto;
  display: block;
  padding-right: 46px;   /* chua cho cho con mat */
}
.pw-eye {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 24px;           /* 16px le + 8px */
  width: 34px;
  margin: 0;
  border: 0;
  background: none;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  opacity: .55;
  padding: 0;
}
.pw-eye.on { opacity: 1; }

.login-box button {
  margin: 4px 16px 0;
  font-size: 16px;
  padding: 13px;
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  background: linear-gradient(var(--btn-face-1), var(--btn-face-2));
  color: #000;
  cursor: pointer;
}

.login-box button:disabled { opacity: .6; }

.login-error { margin: 0; padding: 0 16px; color: var(--warn); font-size: 14px; }

/* ---------------- đèn LED bảy đoạn ---------------- */

.seg-panel {
  border: 4px solid var(--seg-frame);
  box-shadow: inset 1px 1px 0 rgba(0, 0, 0, .25);
  padding: 5px;
  display: flex;
  justify-content: center;
}

.seg-panel svg { display: block; width: 100%; height: auto; }

.seg-live  { background: var(--seg-live-bg); }
.seg-small { background: var(--seg-sm-bg); }

.live {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 2px;
}

.seg-live { flex: 1 1 auto; }
.seg-live svg { max-height: 84px; }

/* ---- man hinh chinh: so can to + 2 nut ---- */
.live-big { flex-direction: column; align-items: stretch; gap: 6px; padding: 10px 4px 4px; }
.live-caption { font-size: 14px; font-weight: 700; color: #06364a; text-align: center; }
.live-big .seg-live svg { max-height: 120px; }
.live-big .live-unit { text-align: center; font-size: 34px; }

.home-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 6px 2px; }
.bigbtn {
  min-height: 96px; border: 0; border-radius: 12px; color: #fff;
  font-family: inherit; font-size: 26px; font-weight: 800; cursor: pointer;
  box-shadow: 0 3px 8px rgba(0,0,0,.28);
}
.bigbtn:active { filter: brightness(.93); }
.bigbtn-new { background: linear-gradient(#28a745, #1c8a3c); }
.bigbtn-old { background: linear-gradient(#2f7fd1, #1c5fa8); }

.home-tools { display: flex; justify-content: center; margin: 2px; }
.tool-btn {
  border: 1px solid var(--btn-border); border-radius: 6px;
  background: linear-gradient(var(--btn-face-1), var(--btn-face-2)); color: #000;
  font-family: inherit; font-size: 14px; padding: 9px 16px; cursor: pointer;
}

/* ---- hop can ---- */
.box-body { flex: 1 1 auto; min-height: 0; padding: 10px 12px; overflow: auto; background: #f0f0f0; }
/* tieu de nho gon (khong con thanh + nut X - dung nut Thoat ben duoi) */
.box-head { text-align: center; font-size: 14px; font-weight: 700; color: #06364a; margin-bottom: 4px; }
.box-live { text-align: center; margin-bottom: 8px; }
.box-live-num {
  font-size: 88px; line-height: 1; font-weight: 800; color: #c00000;
  font-family: Consolas, "Courier New", monospace;
}
.box-live-unit { font-size: 30px; font-weight: 700; color: var(--text-dim); }

/* KL: 3 o gon tren MOT hang cho do ton cho; KL Hang noi bat mau xanh */
.box-kl { margin: 2px 0 10px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.kl-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  text-align: center; background: #fff; border: 1px solid var(--ctl-border);
  border-radius: 6px; padding: 5px 3px;
}
.kl-lbl { font-size: 11px; font-weight: 700; color: #5c6469; line-height: 1.05; }
/* So KL TO nhu Bien so va co mau rieng cho de doc */
.kl-val { font-size: 29px; font-weight: 800; line-height: 1.05; }
.kl-val b { color: #0b3d6e; }
#klGross { color: #0b3d6e; }   /* KL xe+hàng: xanh dương */
#klTare  { color: #9c4f08; }   /* KL xe: cam */
.kl-net { background: #eafaf1; border-color: #1c8a3c; }
.kl-net .kl-lbl { color: #0b5e2b; }
.kl-net .kl-val { font-size: 31px; }
.kl-net .kl-val b, #klNet { color: #0b5e2b; }   /* KL hàng: xanh lá */

/* nhap nhay xanh khi Cân xong cho de nhan biet */
.kl-item.flash { animation: klflash 1s ease-out 1; }
@keyframes klflash {
  0% { background: #7ee29a; } 55% { background: #c8f5d5; } 100% { background: #fff; }
}
.kl-net.flash { animation: klflashnet 1s ease-out 1; }
@keyframes klflashnet {
  0% { background: #7ee29a; } 55% { background: #c8f5d5; } 100% { background: #eafaf1; }
}

/* trang thai in hien ngay trong hop can */
.box-print-status {
  margin: 0 0 2px; padding: 9px 11px; border: 1px solid; border-radius: 4px;
  font-size: 14.5px; font-weight: 700; text-align: center;
}
.box-print-status.busy { border-color: #9db8c6; background: #eef5fb; color: #23485c; }
.box-print-status.ok   { border-color: var(--ok); background: #e9f8ee; color: #10521f; }
.box-print-status.err  { border-color: var(--warn); background: #fdeceb; color: #8c1d18; }

.box-actions { grid-template-columns: 1fr 1fr; }
/* Tat ca nut trong hop can chu TO nhu Can: In Phieu / Lich su / Sua / Thoat */
.box-actions .btn-main { font-size: 30px; }
.box-actions .btn-sub { font-size: 12px; }
.box-actions .box-old-only .btn-main { font-size: 30px; }
/* nut Cân la chinh: chu that to */
#boxCan { min-height: 72px; }
#boxCan .btn-main { font-size: 32px; }
/* nut Thoát mau do nhat; chi chiem CA HANG trong hop can (nhieu nut),
   con o form 2 nut (sua/xem truoc) thi nam canh nut kia cho can doi. */
.btn-exit { background: linear-gradient(#fbe9e9, #f3d2d2); border-color: #c98a8a; }
.box-actions .btn-exit { grid-column: 1 / -1; }
.btn-exit .btn-main { font-size: 18px; color: #8c1d18; }
.box-actions .btn-exit .btn-main { font-size: 30px; }

/* ---- danh sach chon phieu cu (nhe, cuon doc de) ---- */
.pick-search { padding: 8px; background: #f0f0f0; border-bottom: 1px solid #d0d0d0; display: flex; gap: 8px; }
.pick-search input {
  flex: 1 1 auto; min-width: 0; font-size: 16px; padding: 10px 12px;
  border: 1px solid var(--ctl-border); border-radius: 4px; text-transform: uppercase;
}
.pick-exit-top {
  flex: 0 0 auto; border: 1px solid #c98a8a; border-radius: 4px;
  background: linear-gradient(#fbe9e9, #f3d2d2); color: #8c1d18;
  font-family: inherit; font-size: 15px; font-weight: 700; padding: 0 16px; cursor: pointer;
}
.pick-list { flex: 1 1 auto; overflow-y: auto; background: #fff; -webkit-overflow-scrolling: touch; min-height: 40vh; }
.pick-item {
  padding: 10px 12px; border-bottom: 1px solid #e6e6e6; cursor: pointer;
  display: flex; align-items: baseline; gap: 8px;
}
.pick-item:active { background: #cce4f7; }
/* dòng vừa chọn -> tô xanh đậm để biết đang mở phiếu nào */
.pick-item.sel { background: #1d6fb8; }
.pick-item.sel .pick-plate,
.pick-item.sel .pick-sub,
.pick-item.sel .pick-kl { color: #fff; }
.pick-main { flex: 1 1 auto; min-width: 0; }
.pick-plate { font-size: 25px; font-weight: 800; color: #06364a; letter-spacing: .3px; }
.pick-sub { font-size: 12.5px; color: #5c6469; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-kl { flex: 0 0 auto; font-size: 25px; font-weight: 800; color: #0b5e2b; }
.pick-foot { display: flex; align-items: center; gap: 8px; padding: 8px; background: #f0f0f0; border-top: 1px solid #d0d0d0; }
.pick-foot .pick-note { flex: 1 1 auto; }
.pick-foot .btn-exit { flex: 0 0 auto; min-height: 0; padding: 9px 18px; }

.live-unit {
  font-size: 38px;
  color: #000;
  flex: 0 0 auto;
  line-height: 1;
}

/* điện thoại: ba ô khối lượng xếp dọc, nhãn bên trái */
.weights {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 2px;
}

.weight-cell { display: flex; align-items: center; gap: 10px; }

.weight-label {
  font-size: 14px;
  font-weight: 700;
  flex: 0 0 118px;
}

.seg-small { flex: 1 1 auto; }
.seg-small svg { max-height: 44px; }

/* ---------------- hộp nhóm WinForms ---------------- */

fieldset.group {
  margin: 0;
  padding: 10px;
  border: 1px solid #57a8cc;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55);
  border-radius: 4px;
  min-width: 0;
}

fieldset.group legend {
  font-size: 14px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 12px;
  background: #f0f0f0;
  border: 1px solid var(--btn-border);
  border-radius: 2px;
  padding: 1px 8px;
}

.badge.on { background: var(--highlight); border-color: #005a9e; color: #fff; }

.hint { font-size: 12px; color: var(--text-dim); }

/* ---------------- form nhập liệu (giống các TextBox của Windows) ---------------- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.frow { display: flex; align-items: center; gap: 8px; min-width: 0; }

.fkey {
  font-size: 14px;
  flex: 0 0 92px;
  color: #000;
}

.frow input, .frow select {
  flex: 1 1 auto;
  min-width: 0;
  /* 16px+ để iPhone không tự phóng to trang khi bấm vào ô */
  font-size: 16px;
  padding: 11px 10px;
  border: 1px solid var(--ctl-border);
  border-radius: 3px;
  background: #fff;
  color: #000;
}

.frow input:disabled, .frow select:disabled { background: #a9a9a9; color: #5c5c5c; }

/* Ô Biển số to & đậm - DÙNG CHUNG cho hộp cân và form Sửa dữ liệu (cùng cỡ). */
input.plate {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 10px;
}

.frow select {
  appearance: auto;
  -webkit-appearance: menulist;
  height: 44px;
}

.times {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 10px 0;
}

.times > div { display: flex; gap: 8px; align-items: baseline; }

.tkey { font-size: 12.5px; color: var(--text-dim); flex: 0 0 128px; }

.tval {
  font-size: 13.5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- nút bấm xám cổ điển, cỡ ngón tay ---------------- */

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 62px;
  padding: 9px 10px;
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  cursor: pointer;
  background: linear-gradient(var(--btn-face-1), var(--btn-face-2));
  color: #000;
  touch-action: manipulation;
}

.btn:active:not(:disabled) { background: #cce4f7; border-color: #005a9e; }

.btn:disabled { color: #838383; background: #efefef; cursor: not-allowed; }

.btn-main { font-size: 19px; font-weight: 800; }
.btn-sub  { font-size: 12.5px; color: #444; }

/* ---- Màu nền riêng cho từng loại nút để dễ nhận ra ---- */
.btn-weigh   { background: linear-gradient(#e4f7ea, #c4ecd0); border-color: #62b981; }
.btn-print   { background: linear-gradient(#e6f0fc, #cadff5); border-color: #7facdd; }
.btn-print .btn-main { color: #0b3d6e; }
.btn-history { background: linear-gradient(#eef1f5, #d8dfe8); border-color: #a3b1c1; }
.btn-edit    { background: linear-gradient(#fdeed6, #f7d7a4); border-color: #de9e44; }
.btn-edit .btn-main { color: #9c4f08; }
.btn-save    { background: linear-gradient(#e4f7ea, #c1ebce); border-color: #57b877; }
.btn-download { background: linear-gradient(#e0f4f0, #c1e7de); border-color: #6fc2b4; }
.btn-download:not(.disabled) .btn-main { color: #0a5b50; }
.btn:disabled .btn-sub { color: #909090; }

.btn-weigh:not(:disabled) .btn-main { color: #c00000; }
.btn-save:not(:disabled)  .btn-main { color: #0b5e2b; }

.msg {
  margin: 10px 0 0;
  padding: 9px 11px;
  border: 1px solid;
  border-radius: 3px;
  font-size: 14px;
  line-height: 1.4;
  background: #fff;
}

.msg.ok   { border-color: var(--ok);   color: #10521f; }
.msg.err  { border-color: var(--warn); color: #8c1d18; }
.msg.busy { border-color: #9db8c6;     color: #23485c; }

/* ---------------- bảng phiếu (DataGridView) ---------------- */

.table-wrap {
  overflow: auto;
  max-height: 44vh;
  border: 1px solid var(--ctl-border);
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

table { border-collapse: collapse; width: 100%; white-space: nowrap; }

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0f0f0;
  font-weight: 700;
  font-size: 12px;
  text-align: left;
  padding: 8px 9px;
  border-right: 1px solid #d4d4d4;
  border-bottom: 1px solid #ababab;
}

thead th:first-child, tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #f0f0f0;
}

tbody td:first-child {
  font-weight: 700;
  font-size: 12px;
  border-right: 1px solid #ababab;
}

thead th:first-child { z-index: 3; }

tbody tr { cursor: pointer; }

tbody td {
  font-family: "Times New Roman", Times, serif;
  font-size: 14px;
  padding: 10px 9px;         /* cao hơn một chút cho dễ bấm bằng ngón tay */
  border-right: 1px solid #e3e3e3;
  border-bottom: 1px solid #e3e3e3;
  background: #fff;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

tbody tr.sel td { background: var(--highlight); color: #fff; }
tbody tr.sel td:first-child { background: #005a9e; color: #fff; }

/* Trình duyệt KHÔNG áp max-width lên ô bảng (table auto layout), nên phần chữ
   trong ô được bọc vào span.cell rồi giới hạn bề rộng ở đó. */
tbody td .cell {
  display: block;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* cột Chủ hàng (cột dữ liệu đầu tiên sau STT) gọn hơn hẳn */
tbody td:nth-child(2) .cell { max-width: 88px; }

/* khung lịch sử phiếu */
.his-text {
  margin: 0;
  padding: 12px;
  overflow: auto;
  background: #fff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1 1 auto;
  min-height: 120px;
}

.btn-history:not(:disabled) .btn-main { color: #0b3d6e; }

/* bang goi y tu lich su (tu hien khi go) */
.ac-list {
  /* nằm trong luồng, ngay dưới ô đang gõ (không "fixed" -> không trôi trên điện thoại) */
  margin: -2px 0 4px;
  background: #fff8db;                 /* nền vàng nhạt cho dễ nhận ra là ô gợi ý */
  border: 2px solid #e0b400;
  border-radius: 5px;
  max-height: 300px;                   /* cao hơn -> cuộn xem nhiều gợi ý */
  overflow-y: auto;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .3);
  -webkit-overflow-scrolling: touch;
  grid-column: 1 / -1;   /* trải hết bề ngang khi lưới 2 cột (màn to) */
}

.ac-item {
  padding: 14px 14px;
  font-size: 21px;                     /* chữ to hơn cho dễ đọc trên điện thoại */
  font-weight: 700;
  color: #06364a;
  letter-spacing: .4px;
  border-bottom: 1px solid #e7d488;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-item:last-child { border-bottom: 0; }
.ac-item:active, .ac-item.hi { background: #ffe08a; }

/* nut cam "Sua du lieu" - dat canh tieu de "Danh sach phieu can" */
.edit-fab {
  background: linear-gradient(#ff9d2e, #f47a10);
  color: #fff;
  border: 1px solid #d5670a;
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 5px 12px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.edit-fab:active { filter: brightness(.93); }

/* nut Lich su (canh Sua du lieu) - mau xanh */
.hist-fab { background: linear-gradient(#4a90d9, #2f6fb0); border-color: #245a91; }
.edit-fab:disabled { opacity: .45; cursor: not-allowed; }

/* nut Tao phieu moi (xanh la) va Cap nhat so can cu (tim) */
.btn-new:not(:disabled) .btn-main { color: #0b6b2e; }
.btn-reweigh:not(:disabled) .btn-main { color: #6a2da8; }
.btn-reweigh.arm { background: linear-gradient(#efe0ff, #dcc6f5); border-color: #6a2da8; }

/* chon kieu can (radio) giong Windows */
.weigh-mode {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  background: #ffffff;
  border: 1px solid var(--ctl-border);
  border-radius: 4px;
  padding: 5px 9px;
  margin-bottom: 2px;
}
.wm-label { font-weight: 700; font-size: 12px; }
.wm-opt { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; }
.wm-opt input { width: 15px; height: 15px; }

.pv-narrow { max-width: 420px; }

/* khung sua du lieu */
.edit-body { padding: 12px; overflow: auto; background: #f0f0f0; }
.erow { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ekey { flex: 0 0 108px; font-size: 13px; }
.erow input, .erow select {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 16px;
  padding: 9px 10px;
  border: 1px solid var(--ctl-border);
  border-radius: 3px;
  background: #fff;
}
.eunit { flex: 0 0 auto; font-size: 13px; color: var(--text-dim); }

/* Dòng cần nổi bật trong form Sửa: TL Xe và hàng / TL Xe / Biển số - chữ & ô TO hơn */
.erow-big .ekey { font-size: 17px; font-weight: 700; color: #06364a; }
.erow-big input { font-size: 23px; font-weight: 800; padding: 10px; }
.erow-big .eunit { font-size: 16px; font-weight: 700; }
/* So trong luong to va co mau (dong bo voi 3 o KL trong hop can) */
#edGross { color: #0b3d6e; }   /* TL xe+hàng: xanh dương */
#edTare  { color: #9c4f08; }   /* TL xe: cam */
.edit-hint { margin: 4px 0 0; font-size: 12px; color: var(--text-dim); }

/* ---- hộp XÁC NHẬN sửa phiếu: dòng nào ĐỔI thì tô ĐỎ, to hơn ---- */
.ec-body { padding: 12px; overflow: auto; background: #f0f0f0; }
.ec-note { margin: 0 0 10px; font-size: 15px; font-weight: 700; color: #06364a; }
.ec-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 6px; border-bottom: 1px solid #e2e2e2; font-size: 16px;
}
.ec-row .ec-lbl { color: #333; }
.ec-row .ec-val { font-weight: 700; text-align: right; }
.ec-row.chg { background: #fdeceb; border-radius: 4px; }
.ec-row.chg .ec-lbl { color: #8c1d18; }
.ec-row.chg .ec-val { color: #d01414; font-size: 21px; font-weight: 800; }
.ec-old { display: block; font-size: 12.5px; font-weight: 600; color: #8a8a8a; text-decoration: line-through; }

.empty-row td { text-align: center; color: #666; padding: 22px; cursor: default; }

/* ---------------- thanh trạng thái ---------------- */

.status {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  padding-bottom: calc(9px + env(safe-area-inset-bottom, 0px));
  background: #f0f0f0;
  border-top: 1px solid #b5b5b5;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #6d6d6d;
  background: #c0c0c0;
  flex: 0 0 auto;
}

.dot.good { background: #2ecc40; border-color: #1e8a2c; }
.dot.bad  { background: #ff4136; border-color: #a8271f; }
.dot.busy { background: #2f7fd1; border-color: #1c5fa8; animation: dotblink 1s linear infinite; }

@keyframes dotblink {
  50% { opacity: .35; }
}

.sep { opacity: .4; }

/* điện thoại hẹp: giấu đồng hồ ở thanh dưới để nút Thoát không bị tràn ra ngoài */
.status-time { display: none; }

.link-btn {
  background: none;
  border: 0;
  color: #0063b1;
  text-decoration: underline;
  font-size: 12.5px;
  cursor: pointer;
  padding: 6px 2px;
  flex: 0 0 auto;
}

.link-btn.logout { margin-left: auto; }

/* nút hiện số: luôn bấm được, đổi màu khi trạm cân đang che mờ */
.btn-reveal:not(:disabled) .btn-main { color: #5b2d8a; }
.btn-reveal.hiding { background: #fff3cd; border-color: #b58900; }
.btn-reveal.hiding .btn-main { color: #7a5c00; }

/* ---------------- xem trước phiếu in ---------------- */

.pv-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 30, 45, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.pv-box {
  width: 100%;
  max-width: 760px;
  /* 100vh trên điện thoại CAO HƠN vùng nhìn thấy (tính cả chỗ thanh địa chỉ),
     làm nút dưới cùng bị khuất. Dùng dvh (chiều cao thật) để không bị che. */
  max-height: calc(100vh - 20px);
  max-height: calc(100dvh - 20px);
  background: #f0f0f0;
  border: 1px solid #5c9fd0;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
}

.pv-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 700;
  background: linear-gradient(#ffffff, #dce9f5);
  border-bottom: 1px solid #b5cadb;
  padding: 8px 8px 8px 14px;
}

.pv-x {
  border: 1px solid var(--btn-border);
  border-radius: 3px;
  background: linear-gradient(var(--btn-face-1), var(--btn-face-2));
  font-size: 15px;
  line-height: 1;
  padding: 7px 12px;
  cursor: pointer;
}

.pv-imgwrap {
  overflow: auto;
  background: #8a959d;
  padding: 10px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 120px;
  -webkit-overflow-scrolling: touch;
}

.pv-imgwrap img {
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .4);
}

.pv-loading { color: #fff; font-size: 14px; padding: 30px 0; }

.pv-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
  background: #f0f0f0;
  border-top: 1px solid #d0d0d0;
}

.btn-download { text-decoration: none; }
.btn-download:not(.disabled) .btn-main { color: #0b3d6e; }
.btn-download.disabled { pointer-events: none; color: #838383; background: #efefef; }

/* nut "In ra giay" / "Tai ve file" trong khung xem truoc: chu to hon */
#preview .pv-actions .btn-main { font-size: 21px; }
#preview .pv-actions .btn-sub { font-size: 12px; }

/* ---------------- màn hình rộng (máy tính) ---------------- */

@media (min-width: 640px) {
  main { padding: 10px 10px 70px; }
  .status-time { display: inline; }
  .seg-live svg { max-height: 100px; }
  .live-unit { font-size: 46px; }
  .weights { flex-direction: row; }
  .weight-cell { flex: 1 1 0; display: block; }
  .weight-label { margin-bottom: 4px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .times { flex-direction: row; gap: 24px; }
  .actions { grid-template-columns: repeat(4, 1fr); }
  .table-wrap { max-height: 46vh; }
}
