/* ============================================================
   Cantaloupe - Khung Dashboard kiểu mới (thư mục DUALUOI_WEB, 03/11/2026): cùng kiểu với trang chủ mới.
   Giữ nguyên bố cục và chức năng; chỉ đổi phông chữ (Be Vietnam Pro, tên trang chữ có chân Lora), ô bo góc lớn hơn,
   nút bo tròn, và chế độ tối bớt tối cho cùng tông với chế độ tối của trang công cộng.
   Chỉ áp cho body class "dash-sang" (các trang sau khi đăng nhập; trang Nhận diện khi mở trong Dashboard).
   ============================================================ */

.dash-sang {
  --dm-dam: 'Be Vietnam Pro', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  --dm-serif: 'Lora', Georgia, 'Times New Roman', serif;
  font-family: var(--dm-dam);
  background: #f3f7f4;
}

/* Thanh bên: mục chọn bo tròn hẳn như nút ở trang chủ */
.dash-sang .dash-brand { font-weight: 700; letter-spacing: -0.01em; font-size: 20px; }
.dash-sang .dash-nav a { border-radius: 999px; padding: 11px 16px; font-weight: 500; }
.dash-sang .dash-nav a.active { font-weight: 600; box-shadow: 0 6px 16px rgba(22,163,74,.28); }
.dash-sang .user-chip { border-radius: 18px; }

/* Tên trang: chữ có chân, to hơn một chút */
.dash-sang .dash-topbar .greet h1 { font-family: var(--dm-serif); font-weight: 500; letter-spacing: -0.01em; font-size: 34px; line-height: 1.15; }
.dash-sang .dash-topbar .greet p { font-size: 15px; margin-top: 4px; }
.dash-sang .in-dash .section-head h2 { font-family: var(--dm-serif); font-weight: 500; letter-spacing: -0.01em; font-size: 24px; }

/* Ô, thẻ, nút, ô nhập */
.dash-sang .panel { border-radius: 24px; padding: 24px 26px; }
.dash-sang .card { border-radius: 24px; }
.dash-sang .panel-head h3 { font-weight: 700; letter-spacing: -0.005em; }
.dash-sang .dash-section-title { font-weight: 700; }
.dash-sang .btn { border-radius: 999px; font-weight: 600; }
.dash-sang .field input, .dash-sang .field textarea, .dash-sang .field select { border-radius: 12px; }
.dash-sang .modal { border-radius: 24px; }
.dash-sang .upload-box { border-radius: 22px; }
.dash-sang .stage-photo { border-radius: 18px; }

/* ---------- Điện thoại (≤820px): thanh dưới đáy kiểu ứng dụng thay cho thanh bên và nút ☰ (người dùng chọn 03/11/2026).
   js/common.js (tabDuoiDashHTML) vẽ thanh này cùng với thanh bên ---------- */
.dash-tab, .dash-them { display: none; }
@media (max-width: 820px) {
  .dash-sang .dash-sidebar, .dash-sang .mobile-menu-btn { display: none; }
  .dash-sang .dash-main { padding: 18px 16px calc(110px + env(safe-area-inset-bottom)); }
  .dash-sang .dash-topbar { margin-bottom: 18px; }
  .dash-sang .dash-topbar .greet h1 { font-size: 27px; }
  .dash-sang .dash-topbar .greet p { font-size: 14px; }
  .dash-sang .panel { border-radius: 20px; padding: 18px; }
  .dash-sang .widgets { gap: 14px; }
  /* Dải báo trên Tổng quan: biểu tượng + chữ một hàng, nút xuống dòng riêng rộng hết khung
     (trước đây nút giành chỗ nên chữ bị bóp thành cột hẹp mỗi dòng một hai chữ, người dùng chê 03/11/2026) */
  .dash-sang .alert-strip { flex-wrap: wrap; align-items: flex-start; gap: 12px 14px; padding: 16px; }
  .dash-sang .alert-strip .a-ic { width: 42px; height: 42px; }
  .dash-sang .alert-strip .a-main { flex: 1 1 0; }
  .dash-sang .alert-strip .a-main h4 { line-height: 1.35; }
  .dash-sang .alert-strip > .btn { flex: 1 1 100%; justify-content: center; }
  /* Đầu mỗi ô: tên ô và nút/nhãn bên phải được xuống dòng khi chật, khỏi bóp chữ */
  .dash-sang .panel-head { flex-wrap: wrap; gap: 8px 12px; }

  /* Tổng quan: ô nhiệt độ & độ ẩm xuống dưới cùng, "Tiến độ từng luống" lên trên nó */
  .dash-sang .o-khi-hau { order: 1; }
  /* Tổng quan, Tỷ lệ giai đoạn: vòng tròn ở giữa; chú thích bên dưới trải hết bề ngang, số canh phải, kẻ dòng mảnh
     (trước đây vòng tròn và chú thích dồn sang trái, bên phải trống, số nằm sát chữ) */
  .dash-sang .donut-wrap { flex-direction: column; align-items: stretch; gap: 14px; }
  .dash-sang #donutStage { align-self: center; }
  .dash-sang .donut-legend { gap: 0; }
  .dash-sang .donut-legend .legend-row { padding: 9px 2px; font-size: 15px; border-bottom: 1px solid rgba(148,163,184,.18); }
  .dash-sang .donut-legend .legend-row:last-child { border-bottom: 0; }
  .dash-sang .donut-legend .legend-row b { font-variant-numeric: tabular-nums; }

  /* Camera, Nhật ký nhận diện dưa: ảnh nhỏ + chữ một hàng rộng; nhãn tình trạng và nút "Chi tiết" xuống hàng dưới
     (trước đây cả 4 thứ chung một hàng nên chữ bị bóp hẹp) */
  .dash-sang .log-item { flex-wrap: wrap; align-items: flex-start; gap: 10px 14px; }
  .dash-sang .log-item .log-main { flex: 1 1 calc(100% - 70px); }
  .dash-sang .log-item > .text-center { margin-left: 70px; }
  .dash-sang .log-item > .btn { margin-left: auto; }

  /* Cài đặt > Giao diện: 3 lựa chọn thành 3 thanh ngang xếp dọc (hình thu nhỏ bên trái, tên giữa, nút chọn bên phải) */
  .dash-sang .gdien-chon { flex-direction: column; gap: 10px; }
  .dash-sang .gdien-kieu { flex-direction: row; align-items: center; gap: 14px; padding: 10px 16px 10px 10px;
    border: 1.5px solid var(--slate-200); border-radius: 16px; transition: border-color .15s, background .15s; }
  .dash-sang .gdien-kieu:has(input:checked) { border-color: var(--green-600); background: var(--green-50); }
  .dash-sang .gdien-mau { width: 76px; height: 50px; border-radius: 10px; flex: none; }
  .dash-sang .gdien-kieu input:checked ~ .gdien-mau { box-shadow: none; }
  .dash-sang .gdien-mau i { top: 8px; left: 8px; width: 8px; height: 8px; }
  .dash-sang .gdien-mau b { top: 7px; left: 20px; width: 30px; height: 11px; border-radius: 3px; }
  .dash-sang .gdien-mau em { right: 8px; bottom: 8px; width: 24px; height: 12px; border-radius: 4px; }
  .dash-sang .gdien-mau.thiet-bi b { background: linear-gradient(90deg, #fff 18px, #2f3d36 18px); }
  .dash-sang .gdien-ten { flex: 1; flex-direction: row-reverse; justify-content: space-between; font-size: 16px; }

  .dash-tab { display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; position: fixed; z-index: 300;
    left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); height: 66px; padding: 0 4px; border-radius: 22px;
    background: rgba(255,255,255,.96); box-shadow: 0 1px 2px rgba(15,23,42,.06), 0 12px 32px rgba(15,23,42,.16);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
  .dt-muc { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 0; border: 0; background: none; cursor: pointer;
    font: inherit; font-size: 11.5px; font-weight: 600; color: #64748b; text-decoration: none; }
  .dt-muc:hover { text-decoration: none; color: var(--green-800); }
  .dt-muc.dang { color: var(--green-700); }
  .dt-ic { position: relative; display: grid; place-items: center; width: 44px; height: 30px; border-radius: 999px; transition: background .2s; }
  .dt-muc.dang .dt-ic { background: var(--green-100); }
  .dt-ic .ic-svg { width: 22px; height: 22px; }
  .dt-cham { position: absolute; top: 3px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--cal-ai); border: 2px solid #fff; }
  /* Nút tròn ở giữa (Nhận diện) nhô lên khỏi thanh */
  .dt-giua { justify-self: center; width: 58px; height: 58px; margin-top: -26px; border-radius: 50%; display: grid; place-items: center;
    background: var(--green-600); color: #fff; border: 4px solid #f3f7f4; box-shadow: 0 8px 20px rgba(22,163,74,.38); }
  .dt-giua:hover { color: #fff; text-decoration: none; }
  .dt-giua .ic-svg { width: 25px; height: 25px; }
  .dt-giua.dang { background: var(--melon-600); box-shadow: 0 8px 20px rgba(234,115,23,.38); }

  /* Tấm "Thêm" trượt lên từ đáy, lớp mờ phía sau; bấm ra ngoài là đóng */
  .dash-them:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 400; }
  .dt-man { position: absolute; inset: 0; background: rgba(15,23,42,.45); animation: dtHien .2s ease; }
  .dt-tam { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(22px + env(safe-area-inset-bottom));
    border-radius: 26px 26px 0 0; background: #fff; box-shadow: 0 -10px 30px rgba(15,23,42,.15); animation: dtLen .28s cubic-bezier(.2,.7,.2,1); }
  .dt-keo { width: 44px; height: 5px; border-radius: 99px; background: #cbd5e1; margin: 2px auto 14px; }
  .dt-tam .user-chip { margin-bottom: 8px; }
  .dt-dong { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 12px; border: 0; border-radius: 14px; background: none;
    font: inherit; font-size: 16px; font-weight: 500; color: var(--ink); text-align: left; cursor: pointer; text-decoration: none; }
  .dt-dong:hover { background: var(--green-50); text-decoration: none; }
  .dt-dong.dang { background: var(--green-50); color: var(--green-800); font-weight: 600; }
  .dt-dong .ic-svg { width: 22px; height: 22px; color: var(--green-700); }
  .khoa-cuon, .khoa-cuon body { overflow: hidden; }
}
@keyframes dtLen { from { transform: translateY(100%); } }
@keyframes dtHien { from { opacity: 0; } }
@media (max-width: 700px) {
  .dash-sang .dash-topbar .greet h1 { font-size: 26px; }
}

/* ---------- Chế độ tối bớt tối (người dùng chê tối quá ở trang công cộng, 03/11/2026): cùng tông than ánh xanh ---------- */
html.che-do-toi {
  --toi-nen: #1a2320;     /* nền trang */
  --toi-o: #232d28;       /* ô, thanh bên */
  --toi-o2: #2b3631;      /* ô lồng trong ô, ô nhập, nút sáng */
  --toi-vien: rgba(255,255,255,.08);
}
.che-do-toi .field input, .che-do-toi .field textarea, .che-do-toi .field select { background: #1f2925; }
/* Thanh dưới đáy và tấm "Thêm" trên điện thoại khi tối */
.che-do-toi .dash-tab { background: rgba(35,45,40,.96); box-shadow: 0 12px 32px rgba(0,0,0,.45); }
.che-do-toi .dt-muc { color: #93a19a; }
.che-do-toi .dt-muc.dang { color: #86efac; }
.che-do-toi .dt-muc.dang .dt-ic { background: rgba(134,239,172,.14); }
.che-do-toi .dt-cham { border-color: var(--toi-o); }
.che-do-toi .dt-giua { border-color: var(--toi-nen); }
.che-do-toi .dt-tam { background: var(--toi-o); box-shadow: 0 -10px 30px rgba(0,0,0,.4); }
.che-do-toi .dt-keo { background: rgba(255,255,255,.2); }
.che-do-toi .dt-man { background: rgba(0,0,0,.55); }

/* ---------- Cài đặt thông báo (03/11/2026): nút gạt không bị bóp méo khi chữ dài (trên điện thoại núm tròn từng lòi ra ngoài) ---------- */
.dash-sang .switch { flex: none; }
.dash-sang .tb-dong { gap: 16px; }

/* ---------- Cài đặt > Lịch sử thông báo ---------- */
.tb-ngay { margin: 18px 0 4px; font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--slate-500); }
.tb-ngay:first-child { margin-top: 0; }
.tb-muc { display: flex; align-items: flex-start; gap: 14px; padding: 12px 0; border-bottom: 1px solid rgba(148,163,184,.18); }
.tb-muc:last-child { border-bottom: 0; }
.tb-ic { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--green-100); color: var(--green-700); }
.tb-ic .ic-svg { width: 20px; height: 20px; }
.tb-muc.stage .tb-ic { background: #f3e8ff; color: #7c3aed; }
.tb-muc.alert .tb-ic { background: #fee2e2; color: #b91c1c; }
.tb-muc.info .tb-ic { background: #dbeafe; color: #1d4ed8; }
.tb-than { flex: 1; min-width: 0; }
.tb-than b { font-size: 15px; }
.tb-than .tag-demo { margin-left: 8px; }
.tb-than .muted { margin-top: 2px; font-size: 14px; line-height: 1.5; }
.tb-gio { flex: none; padding-top: 2px; font-size: 13px; color: var(--slate-500); font-variant-numeric: tabular-nums; }
.che-do-toi .tb-muc.stage .tb-ic { background: rgba(139,92,246,.2); color: #c4b5fd; }
.che-do-toi .tb-muc.alert .tb-ic { background: rgba(220,38,38,.18); color: #fca5a5; }
.che-do-toi .tb-muc.info .tb-ic { background: rgba(37,99,235,.2); color: #93c5fd; }

/* ---------- Chuông nhỏ nằm trong khung chủ vườn, bên phải (máy tính: cuối thanh bên; điện thoại: tấm "Thêm"), 03/11/2026.
   Bấm mở Cài đặt > Lịch sử thông báo; chấm đỏ khi có thông báo chưa xem (cả trên nút "Thêm" của thanh dưới đáy) ---------- */
.dash-sidebar .user-chip { gap: 10px; }
.dash-sidebar .user-chip .nut-chuong { width: 36px; height: 36px; }
.dash-sidebar .user-chip .nut-chuong .ic-svg { width: 18px; height: 18px; }
.dash-sidebar .user-chip .chuong-cham { top: 6px; right: 7px; }
.tb-cham { background: var(--cal-alert); }
.nut-chuong { position: relative; flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  color: var(--green-800); background: #f5f9f6; border: 1px solid rgba(15,23,42,.06); transition: background .15s, color .15s; }
.nut-chuong:hover { background: var(--green-50); color: var(--green-700); text-decoration: none; }
.nut-chuong .ic-svg { width: 20px; height: 20px; }
.chuong-cham { position: absolute; top: 9px; right: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--cal-alert); border: 2px solid #fff; }
.user-chip .nut-chuong { margin-left: auto; background: #fff; }
.che-do-toi .nut-chuong { background: var(--toi-o2); border-color: var(--toi-vien); }
.che-do-toi .user-chip .nut-chuong { background: var(--toi-o); }
.che-do-toi .chuong-cham { border-color: var(--toi-o2); }

/* ---------- Cài đặt trên điện thoại (03/11/2026): các mục là danh sách dọc (biểu tượng, tên, mũi tên); bấm một mục thì danh sách
   ẩn đi, hiện nội dung mục đó và nút "‹ Quay lại" (account.html thêm class cd-xem-o vào body) ---------- */
.cd-quay-lai { display: none; }
@media (max-width: 820px) {
  .dash-sang .cd-tabs { flex-direction: column; flex-wrap: nowrap; gap: 0; margin: 0 0 18px; overflow: hidden;
    background: #fff; border: 1px solid rgba(15,23,42,.07); border-radius: 20px; box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.05); }
  .dash-sang .cd-tabs button, .dash-sang .cd-tabs button.active {
    display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 18px; border: 0; border-bottom: 1px solid rgba(148,163,184,.18);
    border-radius: 0; background: none; color: var(--ink); font-size: 16px; font-weight: 500; text-align: left; }
  .dash-sang .cd-tabs button:last-child { border-bottom: 0; }
  .dash-sang .cd-tabs button::after { content: "›"; margin-left: auto; font-size: 24px; line-height: 1; color: var(--slate-400); }
  .dash-sang .cd-tabs button .ic-svg { width: 22px; height: 22px; color: var(--green-700); }
  .dash-sang .cd-tabs button:active { background: var(--green-50); }
  body.dash-sang:not(.cd-xem-o) .cd-o { display: none; }
  body.dash-sang.cd-xem-o .cd-tabs { display: none; }
  body.dash-sang.cd-xem-o .cd-quay-lai { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 12px -6px; padding: 6px 12px 6px 6px;
    border: 0; border-radius: 999px; background: none; color: var(--green-700); font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; }
  body.dash-sang.cd-xem-o .cd-quay-lai:active { background: var(--green-50); }
  .che-do-toi .dash-sang .cd-tabs { background: var(--toi-o); border-color: var(--toi-vien); box-shadow: none; }
  .che-do-toi .dash-sang .cd-tabs button:not(.active), .che-do-toi .dash-sang .cd-tabs button.active { background: none; color: var(--ink); }
}

/* ---------- Cài đặt: các khung nội dung rộng hết màn hình (trước đây chỉ rộng 760px, người dùng muốn "toàn màn hình cho sang",
   03/11/2026). Nội dung bên trong xếp lại cho đầy khung ---------- */
.dash-sang .cd-o { max-width: none; }
.vm-luoi { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.vm-o { padding: 16px 18px; border-radius: 16px; background: #f5f9f6; border: 1px solid rgba(15,23,42,.05); }
.vm-o span { display: block; margin-bottom: 4px; font-size: 13px; color: var(--slate-500); }
.vm-o b { font-size: 18px; color: var(--green-900); }
.che-do-toi .vm-o { background: var(--toi-o2); border-color: var(--toi-vien); }
@media (min-width: 821px) {
  .dash-sang .cd-o { padding: 28px 32px; }
  /* Thông tin cá nhân: 2 cột ô nhập */
  .dash-sang #profileForm { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
  .dash-sang #profileForm .btn { grid-column: 1 / -1; justify-self: start; }
  /* Giao diện: 3 lựa chọn chia đều bề ngang, mỗi lựa chọn một ô viền, ô đang chọn viền xanh */
  .dash-sang .gdien-chon { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .dash-sang .gdien-kieu { padding: 22px 16px 18px; border: 1.5px solid var(--slate-200); border-radius: 18px; transition: border-color .15s, background .15s; }
  .dash-sang .gdien-kieu:has(input:checked) { border-color: var(--green-600); background: var(--green-50); }
}
@media (max-width: 820px) {
  .vm-luoi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .vm-o { padding: 14px; }
  .vm-o b { font-size: 16px; }
}

/* ============================================================
   12/11/2026: sửa theo danh sách rà soát người dùng chọn (A6, A9, B18) và nhãn hiện sẵn ở khung xem camera.
   ============================================================ */
/* B18. Chữ 10–11px nâng lên 12–12,5px: nhãn "Minh hoạ", tên việc trong ô lịch, chữ "+2 nữa", thước ngày ở Nhật ký sinh trưởng */
.tag-demo { font-size: 12.5px; padding: 2px 9px; }
.cal-event { font-size: 12.5px; }
.cal-more { font-size: 12px; }
.gantt-today span, .gantt-scale { font-size: 12px; }
.cam-the small { font-size: 12.5px; }
/* Ghi chú dài cuối trang Camera: 13px → 14px, giãn dòng cho dễ đọc */
.dash-sang .ghi-chu-cuoi { font-size: 14px; line-height: 1.6; color: var(--slate-500); max-width: 980px; }

/* A9. Ô tích việc (Tổng quan): hình vẫn 26px, vùng bấm rộng ra 40px */
.task-check { position: relative; }
.task-check::before { content: ""; position: absolute; inset: -7px; }

/* A6. Lịch tháng trên điện thoại: ô ngày quá hẹp nên không ghi tên việc (trước bị cắt còn "0…") mà hiện chấm màu;
   bấm một ngày thì ô đó sáng viền xanh và danh sách việc của ngày hiện ngay dưới lưới (js/calendar.js: chonNgay) */
.cal-dots, .cal-ngay { display: none; }
/* 14/11/2026: áp dụng cho cả máy tính bảng (≤1000px): ô ngày vẫn quá hẹp để ghi tên việc */
@media (max-width: 1000px) {
  .cal-grid { gap: 5px; }
  .cal-cell { min-height: 56px; padding: 7px 2px 6px; align-items: center; gap: 6px; border-radius: 12px; cursor: pointer; }
  .cal-cell .cal-event, .cal-cell .cal-more { display: none; }
  .cal-cell .day-num { font-size: 15px; line-height: 1; }
  .cal-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
  .cal-dots i { width: 7px; height: 7px; border-radius: 50%; }
  .cal-dots i.done { opacity: .4; }
  .dash-sang .cal-cell.chon { background: var(--green-50); border-color: var(--green-600); box-shadow: 0 0 0 1px var(--green-600); }
  .cal-ngay { display: block; margin-top: 16px; padding-top: 4px; border-top: 1px solid rgba(148,163,184,.25); }
  .view-switch button { padding: 9px 16px; }   /* A9: cao khoảng 36px */
}
.che-do-toi .dash-sang .cal-cell.chon { background: color-mix(in srgb, #16a34a 18%, var(--toi-o2)); border-color: #4ade80; box-shadow: 0 0 0 1px #4ade80; }

/* Khung xem camera (12/11/2026, người dùng yêu cầu): mở trang là thấy ngay viền tô và nhãn (giai đoạn + độ chắc) của mọi hoa,
   quả máy đã nhận ra, không cần bấm. Nhãn ".cam-the.san" do js/camera-xoay.js đặt chỗ (left/top) và cho đi theo ảnh. */
.cam-vat { fill: color-mix(in srgb, var(--c) 22%, transparent); stroke: var(--c); }
.cam-vat:hover { fill: color-mix(in srgb, var(--c) 30%, transparent); stroke: var(--c); }
.cam-vat.chon { fill: color-mix(in srgb, var(--c) 38%, transparent); stroke-width: 3.5px; }
.cam-the.san { transform: none; animation: none; left: 0; top: 0; transition: opacity .15s; }
.cam-the.san.an { opacity: 0; visibility: hidden; }
.cam-the.san.chon { box-shadow: 0 0 0 2.5px var(--c), 0 10px 28px rgba(15,23,42,.22); z-index: 1; }
/* Mũi nhỏ chỉ từ nhãn vào vật (khi nhãn nằm ngay trên hoặc ngay dưới vật): ô vuông xoay 45 độ, cùng màu nền với nhãn */
.cam-the.san.mui-duoi::before, .cam-the.san.mui-tren::before { content: ""; position: absolute; left: calc(var(--mx, 50%) - 5px);
  width: 10px; height: 10px; background: inherit; transform: rotate(45deg); border-radius: 2px; }
.cam-the.san.mui-duoi::before { bottom: -4px; }
.cam-the.san.mui-tren::before { top: -4px; }
/* Điện thoại: khung ảnh nhỏ (khoảng 300px) nên nhãn làm gọn lại: tên giai đoạn không có nền, số % nhỏ hơn */
@media (max-width: 700px) {
  .cam-the.san { padding: 4px 8px 5px; border-radius: 9px; gap: 0; box-shadow: 0 5px 16px rgba(15,23,42,.24); }
  .cam-the.san .stage-chip { background: none; padding: 0; gap: 5px; }
  .cam-the.san .stage-chip i { width: 9px; height: 9px; }
  .cam-the.san b { font-size: 15px; line-height: 1.2; }
  /* Hai dòng chữ ở góc trên khung ảnh đè lên nhau trên điện thoại: dòng bên phải chỉ còn "Ảnh chụp sẵn"
     (chữ "Minh hoạ" đã có ở nhãn cạnh tên ô) */
  .cam-hud .hud-them { display: none; }
}

/* ============================================================
   12/11/2026, đợt 2 (người dùng yêu cầu)
   ============================================================ */
/* Khung xem camera: nút chọn cách hiện kết quả, nằm bên phải tên ô. "Bấm để xem" (class chi-bam trên khung ảnh):
   viền và nhãn ẩn, chỉ vật đang rê chuột / đang chọn mới hiện như trước 12/11 */
.cam-che-do { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; }
.cam-che-do .view-switch { background: #f1f5f4; border-color: rgba(15,23,42,.06); }
.cam-che-do .view-switch button { padding: 8px 16px; white-space: nowrap; }
.cam-khung.chi-bam .cam-vat:not(.chon):not(:hover) { fill: transparent; stroke: transparent; }
.cam-khung.chi-bam .cam-the.san:not(.chon) { opacity: 0; visibility: hidden; }
@media (max-width: 700px) {
  .cam-che-do .view-switch button { padding: 9px 13px; }
}

/* Bản đồ giai đoạn sinh trưởng: mỗi luống là MỘT hàng thẳng như luống ngoài vườn, không bao giờ rớt xuống hàng thứ hai.
   Các ô cây chia đều bề ngang còn lại (lưới --so-cay cột, js/camera.js đặt), khung hẹp thì ô tự nhỏ lại; ô to nhất 26px như cũ. */
.garden-row .row-label { width: 56px; white-space: nowrap; }
.plant-cells { display: grid; grid-template-columns: repeat(var(--so-cay, 15), minmax(0, 1fr)); gap: 4px; flex: 1 1 0; min-width: 0;
  max-width: calc(var(--so-cay, 15) * 30px - 4px); }
.plant-cells .plant { width: auto; height: auto; aspect-ratio: 1; border-radius: 28%; }
.plant-cells .plant.pollinated { outline-width: 1.5px; outline-offset: 0; }
/* Máy tính: cột bản đồ rộng hơn hai cột kia để 15 ô cây của một luống đủ to khi nằm trên một hàng (trước: 1fr 1.15fr 1fr) */
@media (min-width: 1001px) { .cam-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } }   /* 13/11: còn 2 ô */

/* ============================================================
   12/11/2026, đợt 3 (người dùng yêu cầu): nút "Rút gọn" ở đầu các ô nhật ký (CT.rutGon trong js/common.js)
   ============================================================ */
/* Nút là mũi tên tròn nhỏ, không chữ; ô đang thu thì mũi tên quay xuống, danh sách ẩn hết, đầu ô không còn khoảng trống bên dưới */
.panel-head .nut-rut-gon { flex: none; margin-left: 12px; width: 38px; height: 38px; padding: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; background: #fff; border: 1px solid rgba(15,23,42,.1); color: var(--green-800);
  transition: background .15s, border-color .15s; }
.panel-head .nut-rut-gon:hover { background: var(--green-50); border-color: var(--green-600); }
.panel-head .nut-rut-gon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round;
  stroke-linejoin: round; transition: transform .2s; }
.panel-head h3 + .nut-rut-gon { margin-left: auto; }
.panel-head:has(.nut-rut-gon) .sub { margin-left: auto; }
.o-rut-gon .nut-rut-gon svg { transform: rotate(180deg); }
.da-rut-gon { display: none !important; }
.panel.o-rut-gon > .panel-head { margin-bottom: 0; }
.che-do-toi .panel-head .nut-rut-gon { background: var(--toi-o2); border-color: var(--toi-vien); color: #86efac; }
.che-do-toi .panel-head .nut-rut-gon:hover { background: color-mix(in srgb, #16a34a 18%, var(--toi-o2)); border-color: #4ade80; }

/* ============================================================
   13/11/2026: sửa theo loạt ảnh người dùng gửi
   ============================================================ */
/* Tổng quan + Thiết bị: các ô trong cùng một hàng cao bằng nhau, đáy ngang nhau (4 thẻ số liệu; "Tỷ lệ giai đoạn" và
   "Diễn biến sinh trưởng"; ...) */
.dash-sang .widgets > .w > .panel { height: 100%; }
/* 4 thẻ số liệu đồng đều: số cùng cỡ, cùng một dòng; dòng nhỏ luôn nằm sát đáy thẻ */
/* Biểu tượng nằm cố định ở góc trên phải, tên thẻ nằm bên dưới và được dùng hết bề ngang thẻ nên không thẻ nào bị rớt tên
   xuống hai dòng trong khi thẻ khác một dòng */
.dash-sang .stat .stat-top { display: block; position: relative; }
.dash-sang .stat .stat-ic { position: absolute; top: 0; right: 0; }
.dash-sang .stat .stat-val { font-size: 32px; white-space: nowrap; padding-right: 54px; }
.dash-sang .stat .stat-label { margin-top: 16px; }
.dash-sang .stat .stat-trend { margin-top: auto; padding-top: 4px; font-size: 12.5px; }
/* Tỷ lệ giai đoạn: ô cao bằng ô bên cạnh thì vòng tròn + chú thích nằm giữa theo chiều dọc */
.dash-sang .w-4 > .panel:has(.donut-wrap) { display: flex; flex-direction: column; }
.dash-sang .w-4 > .panel:has(.donut-wrap) .donut-wrap { flex: 1; align-content: center; }

/* Thiết bị: chữ trong ô chọn tần suất quét nằm giữa ô */
.tb-chon { text-align: center; text-align-last: center; width: 100%; padding: 9px 10px; border-radius: 10px; font: inherit; font-size: 14.5px;
  border: 1.5px solid rgba(148,163,184,.4); background: #fff; color: var(--ink); cursor: pointer; }
.tb-chon option { background: #fff; color: #0f172a; }
/* Chế độ tối (13/11/2026: trước đây ô nền xám sáng chữ trắng, danh sách xổ xuống nền trắng chữ trắng nên không đọc được) */
.che-do-toi .tb-chon { background: var(--toi-o2); border-color: rgba(255,255,255,.16); color: #e5ece8; color-scheme: dark; }
.che-do-toi .tb-chon option { background: #2b3631; color: #e5ece8; }
/* Nút "Hiện sẵn / Bấm để xem" ở ô Xem camera, chế độ tối: nền tối như các nút khác (trước bị nền trắng) */
.che-do-toi .cam-che-do .view-switch { background: var(--toi-o2); border-color: var(--toi-vien); }
.che-do-toi .cam-che-do .view-switch button:not(.active) { color: #c3cfc8; }

/* Lịch, kiểu xem Tuần: 7 cột ngang (js/calendar.js: renderWeek) */
.cal-dots i { width: 7px; height: 7px; border-radius: 50%; }
.cal-dots i.done { opacity: .4; }
.td-thu { font-size: 12.5px; font-weight: 700; letter-spacing: .04em; color: var(--slate-500); }
.td-so { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; font-weight: 700;
  color: var(--ink); line-height: 1; }
.today .tuan-dau .td-so { background: var(--melon-600); color: #fff; }
.today .tuan-dau .td-thu { color: var(--melon-600); }
/* Kiểu "7 cột" */
.tuan-cot { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.tuan-o { min-height: 250px; display: flex; flex-direction: column; gap: 8px; padding: 10px 7px 12px; border-radius: 16px; background: #fff;
  border: 1px solid rgba(15,23,42,.07); }
.tuan-dau { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-bottom: 8px;
  border-bottom: 1px solid rgba(148,163,184,.22); }
.tuan-viec { display: flex; flex-direction: column; gap: 6px; }
.cal-event.tuan { white-space: normal; overflow-wrap: anywhere; padding: 6px 8px; border-radius: 9px; line-height: 1.35; }
.cal-event.tuan b { display: block; font-weight: 700; opacity: .92; }
@media (max-width: 700px) {
  .tuan-cot { gap: 5px; }
  .tuan-o { min-height: 0; align-items: center; gap: 5px; padding: 8px 2px 7px; border-radius: 12px; cursor: pointer; }
  .tuan-o .tuan-viec { display: none; }
  .tuan-dau { border-bottom: 0; padding-bottom: 0; gap: 3px; }
  .tuan-o.chon { background: var(--green-50); border-color: var(--green-600); box-shadow: 0 0 0 1px var(--green-600); }
  .td-so { width: 30px; height: 30px; font-size: 15px; }
  .td-thu { font-size: 12px; }
}
.che-do-toi .tuan-o { background: var(--toi-o2); border-color: var(--toi-vien); }
.che-do-toi .td-so { color: #e5ece8; }
.che-do-toi .today .tuan-dau .td-so { color: #fff; }
.che-do-toi .tuan-o.chon { background: color-mix(in srgb, #16a34a 18%, var(--toi-o2)); border-color: #4ade80; box-shadow: 0 0 0 1px #4ade80; }

/* ============================================================
   13/11/2026: trang Giám sát Camera làm theo từng camera (js/camera.js)
   ============================================================ */
/* Sơ đồ vườn & vị trí camera: luống là hàng ô cây; lối đi có camera là hàng nút camera thẳng cột với ô cây */
.so-do { position: relative; gap: 6px; }
.loi-di .row-label { font-size: 11.5px; font-weight: 600; color: var(--slate-400); }
.loi-cam { align-items: center; min-height: 32px;
  background: repeating-linear-gradient(90deg, rgba(148,163,184,.45) 0 6px, transparent 6px 12px) center / 100% 2px no-repeat; }
.loi-trong { height: 8px; }
.cam-diem { justify-self: center; position: relative; z-index: 3; display: inline-flex; align-items: center; gap: 4px; height: 30px;
  padding: 0 10px 0 8px; border-radius: 999px; border: 1.5px solid var(--green-600); background: #fff; color: var(--green-800);
  font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; box-shadow: 0 2px 8px rgba(15,23,42,.12);
  transition: background .15s, color .15s; }
.cam-diem .ic-svg { width: 15px; height: 15px; }
.cam-diem:hover { background: var(--green-50); }
.cam-diem.chon { background: var(--green-600); color: #fff; box-shadow: 0 4px 12px rgba(22,163,74,.35); }
.cam-diem.su-kien::after { content: ""; position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--cal-ai); border: 2px solid #fff; animation: blink 1.2s infinite; }
/* Vùng camera đang chọn nhìn được: đoạn 5 cây của luống trước và luống sau */
.vung-phu { position: absolute; z-index: 2; pointer-events: none; border: 2px dashed var(--green-600); border-radius: 10px;
  background: rgba(22,163,74,.07); }
/* Ô ảnh nhỏ hiện ngay tại vị trí camera */
.cam-nhanh { position: absolute; z-index: 6; pointer-events: none; width: 220px; padding: 8px; border-radius: 16px; background: #fff;
  box-shadow: 0 14px 36px rgba(15,23,42,.28); }
.cam-nhanh[hidden] { display: none; }
.cam-nhanh::after { content: ""; position: absolute; left: calc(var(--mx, 50%) - 7px); bottom: -6px; width: 14px; height: 14px;
  background: inherit; transform: rotate(45deg); border-radius: 3px; }
.cam-nhanh.o-duoi::after { bottom: auto; top: -6px; }
.cn-dau { margin: 0 2px 6px; font-size: 13.5px; }
.cn-anh { position: relative; z-index: 1; aspect-ratio: 3 / 2; border-radius: 10px; overflow: hidden; background: #0f172a; }
.cn-anh svg { display: block; width: 100%; height: 100%; }
.cn-chu { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 8px 2px 0; font-size: 12.5px;
  color: var(--slate-500); }
/* Bảng kết quả quét & việc cần làm */
.kq-tt { margin-top: 8px; font-size: 14px; line-height: 1.9; }
@media (max-width: 700px) {
  .cam-diem { height: 28px; padding: 0 8px 0 6px; font-size: 12px; gap: 3px; }
  .cam-diem .ic-svg { width: 14px; height: 14px; }
  .cam-nhanh { width: 190px; }
}
.che-do-toi .cam-diem { background: var(--toi-o2); color: #86efac; border-color: #4ade80; }
.che-do-toi .cam-diem.chon { background: var(--green-600); color: #fff; border-color: var(--green-600); }
.che-do-toi .cam-diem.su-kien::after { border-color: var(--toi-o2); }
.che-do-toi .vung-phu { border-color: #4ade80; background: rgba(74,222,128,.08); }
.che-do-toi .cam-nhanh { background: var(--toi-o2); box-shadow: 0 14px 36px rgba(0,0,0,.5); }
.che-do-toi .loi-cam { background-image: repeating-linear-gradient(90deg, rgba(255,255,255,.18) 0 6px, transparent 6px 12px); }
/* Ảnh cắt quanh hoa, quả (camKhung trong js/camera.js) */
.cam-cat { border-radius: 14px; overflow: hidden; line-height: 0; background: #0f172a; }
.cam-cat svg { display: block; width: 100%; height: auto; }
.cn-anh .cam-cat, .log-thumb .cam-cat { border-radius: 0; height: 100%; }
.cn-anh .cam-cat svg, .log-thumb .cam-cat svg { height: 100%; }
.cn-chu { flex-wrap: wrap; row-gap: 4px; }
.cn-chu > span { white-space: nowrap; }

/* 13/11/2026: Sơ đồ vườn nằm đầu trang, rộng hết khung: sơ đồ nằm giữa, ô cây to ra (tối đa khoảng 44px) */
#soDoVuon .so-do { max-width: 780px; margin: 0 auto; }
#soDoVuon .plant-cells { max-width: none; }
/* Ô Việc cần làm: bên trái ảnh + thông tin, bên phải giai đoạn phát hiện + việc cần làm; màn hẹp thì xếp dọc */
.vcl-luoi { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 700px) { .vcl-luoi { grid-template-columns: 1fr; gap: 18px; } }   /* máy tính bảng vẫn 2 cột (14/11/2026) */
#soDoVuon .stage-legend { justify-content: center; }   /* chú thích màu nằm giữa như sơ đồ */
/* 14/11/2026 (người dùng yêu cầu): ô ảnh nhỏ trên sơ đồ, giờ chụp và nhãn giai đoạn nằm cùng một hàng: ô rộng hơn,
   không cho xuống dòng (ô này chỉ hiện khi rê chuột nên chỉ có trên máy tính) */
.cam-nhanh { width: 256px; }
.cn-chu { flex-wrap: nowrap; }
.cn-chu > span { flex: none; }
.cn-chu .stage-chip { flex: none; white-space: nowrap; }

/* 14/11/2026: nhãn trong khung xem camera không được che hoa, quả; không còn chỗ trống thì tự thu gọn (js/camera-xoay.js datNhan):
   "gon" = một dòng (giai đoạn + %), "nho" = chỉ chấm màu + % */
.cam-the.san.gon, .cam-the.san.nho { flex-direction: row; align-items: center; gap: 6px; padding: 4px 9px 4px 6px; border-radius: 999px; }
.cam-the.san.gon b, .cam-the.san.nho b { font-size: 14px; line-height: 1.2; }
.cam-the.san.gon .stage-chip { padding: 2px 8px 2px 6px; font-size: 11.5px; }
.cam-the.san.nho { gap: 4px; padding: 3px 8px 3px 7px; }
.cam-the.san.nho .stage-chip { font-size: 0; padding: 0; gap: 0; background: none; }
.cam-the.san.nho .stage-chip i { width: 9px; height: 9px; border-radius: 50%; }
.cam-the.san.nho b { font-size: 13px; }

/* 14/11/2026: ô chọn (Nhật ký sinh trưởng: chọn luống, nằm cùng hàng tên ô) */
.o-chon { padding: 9px 36px 9px 16px; border-radius: 999px; border: 1.5px solid rgba(148,163,184,.4); background: #fff; color: var(--ink);
  font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer; }
.o-chon option { background: #fff; color: #0f172a; }
.che-do-toi .o-chon { background-color: var(--toi-o2); border-color: rgba(255,255,255,.16); color: #e5ece8; color-scheme: dark; }
.che-do-toi .o-chon option { background: #2b3631; color: #e5ece8; }

/* 14/11/2026: camera mất kết nối (giả lập Camera C3) */
.cam-diem.tat { border-color: #94a3b8; color: #64748b; background: #f1f5f9; box-shadow: none; }
.cam-diem.tat::after { content: ""; position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%;
  background: #ef4444; border: 2px solid #fff; }
.cam-diem.tat.chon { background: #64748b; border-color: #64748b; color: #fff; }
.che-do-toi .cam-diem.tat { background: #333d38; border-color: #64748b; color: #94a3b8; }
.che-do-toi .cam-diem.tat.chon { background: #64748b; color: #fff; }
.che-do-toi .cam-diem.tat::after { border-color: var(--toi-o2); }
.cn-dau { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cn-tat { font-size: 12px; font-weight: 700; color: #ef4444; white-space: nowrap; }
/* Khung xem camera khi camera mất kết nối: không có hình, chỉ có màn báo */
.cam-tat-man { display: none; }
.cam-khung.offline .cam-tat-man { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; padding: 24px; text-align: center; color: #e2e8f0;
  background: repeating-linear-gradient(135deg, #111827 0 14px, #161f2e 14px 28px); }
.cam-khung.offline .cam-tam { display: none; }
.cam-tat-man .ctm-ic { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: rgba(239,68,68,.16); color: #f87171; }
.cam-tat-man .ctm-ic .ic-svg { width: 26px; height: 26px; }
.cam-tat-man b { font-size: 16px; }
.cam-tat-man small { font-size: 13px; color: #94a3b8; max-width: 340px; line-height: 1.5; }
.cam-btn:disabled, .cam-zoom .btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
/* Ô chọn luống luôn cùng hàng với tên ô, kể cả trên điện thoại (đầu ô ở điện thoại vốn được xuống dòng) */
.dash-sang .panel-head.dau-chon { flex-wrap: nowrap; }
.panel-head.dau-chon .o-chon { flex: none; }
@media (max-width: 700px) { .panel-head.dau-chon .o-chon { padding: 8px 30px 8px 12px; font-size: 14px; } }

/* ============================================================
   14/11/2026: chỉnh theo ảnh điện thoại người dùng gửi
   ============================================================ */
/* Tiến độ từng luống: chữ "Luống 2" không rớt số xuống dòng */
.row-progress .rp-name { width: auto; min-width: 62px; white-space: nowrap; }
/* Tỷ lệ giai đoạn: chú thích trải hết bề ngang ô (trước bị co lại nằm giữa, hai đầu thụt vào) */
.dash-sang .donut-wrap .donut-legend { align-self: stretch; }
@media (max-width: 820px) {
  .dash-sang .donut-wrap { flex-wrap: nowrap; }
  .dash-sang .w-4 > .panel:has(.donut-wrap) .donut-wrap { align-content: normal; }
  .dash-sang .donut-wrap .donut-legend { width: 100%; }
}
/* Điện thoại: thẻ số liệu, dòng chữ màu (Cần thụ phấn..., ▲ 59% số cây...) nằm cùng hàng với tên thẻ, canh phải */
@media (max-width: 700px) {
  .dash-sang .stat { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "val ic" "nhan xu";
    column-gap: 12px; row-gap: 0; align-items: center; }
  .dash-sang .stat .stat-top, .dash-sang .stat .stat-top > div:first-child { display: contents; }
  .dash-sang .stat .stat-val { grid-area: val; padding-right: 0; }
  .dash-sang .stat .stat-ic { grid-area: ic; position: static; justify-self: end; }
  .dash-sang .stat .stat-label { grid-area: nhan; margin-top: 12px; }
  .dash-sang .stat .stat-trend { grid-area: xu; margin-top: 12px; padding-top: 0; text-align: right; white-space: nowrap; }
}
/* Xem camera: nút Hiện sẵn / Bấm để xem nằm cùng hàng với biểu tượng và tên ô, kể cả trên điện thoại */
.dash-sang .panel-head.cam-dau { flex-wrap: nowrap; }
.cam-dau h3 { white-space: nowrap; }
.cam-dau .cam-che-do { flex: none; }
/* Điện thoại: chữ tiêu đề và nút co theo bề ngang màn hình để cả hàng vừa trong ô (kể cả máy 360px) */
@media (max-width: 700px) {
  .dash-sang .panel-head.cam-dau { gap: 6px; }
  .cam-dau h3 { font-size: clamp(12px, 3.45vw, 15px); }
  .cam-dau h3 .ic-svg { margin-right: 4px; }
  .cam-che-do .view-switch { padding: 2px; }
  .cam-che-do .view-switch button { padding: 6px 6px; font-size: clamp(10.5px, 3.05vw, 12.5px); }
}
.cam-hud { white-space: nowrap; }

/* ============================================================
   14/11/2026 (đợt 2): chỉnh theo ảnh người dùng gửi
   ============================================================ */
/* Ô chọn luống: mũi tên nằm gọn trong khung bo tròn, sát chữ (mũi tên tự vẽ, không dùng mũi tên mặc định của máy) */
.o-chon { -webkit-appearance: none; appearance: none; padding: 9px 34px 9px 16px; line-height: 1.2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 14px 14px; }
.che-do-toi .o-chon { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c3cfc8' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }
@media (max-width: 700px) { .panel-head.dau-chon .o-chon { padding: 8px 30px 8px 13px; background-position: right 10px center; } }

/* Nhật ký nhận diện: giờ chụp bên trái, luống + cây bên phải, cùng một hàng */
.log-item .log-main h4.nk-dau { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.nk-vung { font-size: 12.5px; font-weight: 400; color: var(--slate-500); }
@media (max-width: 700px) {
  .log-item .log-main h4.nk-dau { font-size: 13.5px; }
  .nk-vung { font-size: 11.5px; }
}
.che-do-toi .nk-vung { color: #95a69b; }

/* Lịch: nút Tháng / Tuần / Ngày đứng trước tên tháng */
@media (max-width: 700px) {
  .cal-toolbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .cal-toolbar .view-switch { align-self: center; }
  .cal-nav { justify-content: space-between; flex-wrap: nowrap; }
  .cal-title { min-width: 0; }
}

/* Biểu đồ Diễn biến sinh trưởng, điện thoại: chú thích gọn còn 2 hàng (4 + 3): bỏ nền ô, chỉ còn chấm màu + tên */
@media (max-width: 700px) {
  #stackLegend .stage-legend { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px 7px; }
  #stackLegend .stage-chip { flex: none; }
  #stackLegend .stage-chip { background: none; padding: 0; gap: 5px; font-size: 11.5px; white-space: nowrap; }
  #stackLegend .stage-chip i { width: 8px; height: 8px; border-radius: 50%; }
}

/* Khung xem camera, điện thoại: nút − và + nhỏ, nằm ngay dưới mép dưới khung hình, ở hai góc trái / phải */
@media (max-width: 700px) {
  .cam-xem { row-gap: 0; }
  .cam-xem > div:last-child { display: flex; flex-direction: column; }
  .cam-xem .cam-zoom { order: -1; max-width: none; margin: 8px 0 6px; justify-content: space-between; }
  .cam-xem .cam-zoom .btn { flex: none; width: 46px; height: 34px; padding: 0; font-size: 18px; }
}

/* Ô Việc cần làm: dòng Email là một nút nổi, bấm vào mở nội dung email */
.nut-email { display: inline-flex; align-items: center; margin-left: 4px; padding: 5px 12px; border-radius: 999px; font: inherit;
  font-size: 13.5px; font-weight: 600; cursor: pointer; color: var(--green-800); background: #fff; border: 1px solid rgba(15,23,42,.1);
  box-shadow: 0 2px 8px rgba(15,23,42,.12); transition: box-shadow .15s, transform .15s; }
.nut-email:hover { box-shadow: 0 6px 16px rgba(15,23,42,.18); transform: translateY(-1px); }
.che-do-toi .nut-email { background: var(--toi-o2); color: #bbf7d0; border-color: rgba(255,255,255,.12); box-shadow: 0 4px 12px rgba(0,0,0,.35); }

/* ============================================================
   14/11/2026 (đợt 3): chú thích Lịch 1 hàng, nút Tháng/Tuần/Ngày vừa khung, chú thích Nhật ký sinh trưởng 2 hàng,
   biểu tượng thẻ số liệu nằm giữa khung theo chiều dọc khi thẻ không có dòng chữ màu (trang Thiết bị)
   ============================================================ */
@media (max-width: 700px) {
  /* Lịch: 3 chú thích màu trên một hàng */
  .cal-legend { flex-wrap: nowrap; justify-content: space-between; gap: 6px; font-size: clamp(11px, 3.15vw, 13px); }
  .cal-legend .lg { gap: 5px; white-space: nowrap; }
  .cal-legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
  /* Lịch: nút Tháng / Tuần / Ngày trải vừa hết bề ngang khung, 3 nút bằng nhau */
  .cal-toolbar .view-switch { align-self: stretch; display: grid; grid-template-columns: repeat(3, 1fr); }
  .cal-toolbar .view-switch button { text-align: center; }
  /* Nhật ký sinh trưởng: chú thích màu dưới thanh tiến độ còn 2 hàng (chấm màu + tên, bỏ nền ô) */
  #ganttLegend .stage-legend { display: flex; flex-wrap: wrap; gap: 8px 7px; }
  #ganttLegend .stage-chip { flex: none; background: none; padding: 0; gap: 5px; font-size: 11.5px; white-space: nowrap; }
  #ganttLegend .stage-chip i { width: 8px; height: 8px; border-radius: 50%; }
}
/* Thẻ số liệu không có dòng chữ màu (Tổng thiết bị, Đang online, Offline): biểu tượng nằm giữa khung theo chiều dọc */
.dash-sang .stat:not(:has(.stat-trend)) .stat-ic { top: 50%; transform: translateY(-50%); }
@media (max-width: 700px) {
  .dash-sang .stat:not(:has(.stat-trend)) .stat-ic { grid-row: 1 / span 2; align-self: center; transform: none; }
}

/* ============================================================
   14/11/2026: sửa lỗi tìm được khi rà 12 trang ở 9 cỡ màn hình (360 → 1920px)
   ============================================================ */
/* Lịch tháng, máy tính (>1000px): tên việc xuống tối đa 2 dòng thay vì bị cắt cụt "Bón phân giai đoạn ra…" */
@media (min-width: 1001px) {
  .cal-event { white-space: normal; overflow: hidden; text-overflow: clip; display: -webkit-box; -webkit-box-orient: vertical;
    -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; }
}
/* Tổng quan, máy tính bảng ngang / máy tính nhỏ (≤1200px): ô "Tiến độ từng luống" và ô nhiệt độ trải hết hàng,
   nhãn "Đúng tiến độ" không lố ra ngoài khung hẹp */
@media (max-width: 1200px) {
  .dash-sang .widgets > .o-khi-hau, .dash-sang .widgets > .o-khi-hau + .w-4 { grid-column: span 12; }
}
.row-progress .badge { flex: none; white-space: nowrap; }
/* Nhật ký nhận diện, điện thoại nhỏ (360px): "Luống 3–4 · cây 6–10" không đủ chỗ thì xuống dòng nguyên cụm, không lố khung */
.log-item .log-main h4.nk-dau { flex-wrap: wrap; row-gap: 2px; }

/* ---------- Máy tính bảng (601–1200px, cả dọc lẫn ngang) — 14/11/2026 ----------
   Trước đây iPad dọc dùng bố cục điện thoại (mỗi thẻ một hàng, thừa chỗ), iPad ngang dùng bố cục máy tính (4 thẻ một hàng,
   chữ bị bóp, "23/12" bị biểu tượng che). Nay: */
@media (min-width: 601px) and (max-width: 1200px) {
  /* Tổng quan: 4 thẻ số liệu thành 2 hàng x 2 thẻ */
  .dash-sang #statCards > .w-3 { grid-column: span 6; }
  /* Thiết bị: 3 thẻ ngắn nằm chung một hàng */
  .dash-sang .widgets > .w-4:has(> .panel.stat) { grid-column: span 4; }
  /* Tỷ lệ giai đoạn và Diễn biến sinh trưởng: mỗi ô trải hết hàng; vòng tròn bên trái, chú thích bên phải */
  .dash-sang .widgets > .w-4:has(.donut-wrap), .dash-sang .widgets > .w-4:has(.donut-wrap) + .w-8 { grid-column: span 12; }
  .dash-sang .donut-wrap { flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 28px; }
  .dash-sang .donut-wrap .donut-legend { flex: 1; width: auto; }
  .dash-sang #donutStage { flex: none; }
}

/* ---------- 16/11/2026: camera chạy ray treo ----------
   Lối đi trên sơ đồ vườn vẽ là một đường ray liền (trước là nét đứt), nút trên ray là điểm chụp */
.loi-cam { background: linear-gradient(#94a3b8, #94a3b8) center / 100% 3px no-repeat; }
.che-do-toi .loi-cam { background: linear-gradient(#64748b, #64748b) center / 100% 3px no-repeat; }
/* Ô điều khiển ray dưới khung xem camera (js/camera.js, renderRay) */
.ray-dk { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--slate-200); }
.ray-dau { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; margin-bottom: 12px; }
.ray-dau b { font-size: 15px; color: var(--green-900); }
.ray-tt { font-size: 13.5px; color: var(--slate-500); }
.ray-duong { display: grid; grid-template-columns: repeat(var(--so-o), minmax(0, 1fr)); row-gap: 8px; }
.ray-vung-hang, .ray-o-hang { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(var(--so-o), minmax(0, 1fr)); }
.ray-vung { margin: 0 3px; padding: 3px 0; border-radius: 999px; text-align: center; font-size: 12px; font-weight: 700;
  color: var(--green-800); background: var(--green-50); border: 1.5px dashed transparent; white-space: nowrap; overflow: hidden; }
.ray-vung.chon { border-color: var(--green-600); }
/* Thanh ray xanh dương; xe con nằm trên thanh, trượt theo --vt (0 = bến, 1..15 = cây) */
.ray-thanh { grid-column: 1 / -1; position: relative; height: 8px; margin: 14px 0 10px; border-radius: 4px; background: #2563eb;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.ray-xe { position: absolute; top: 50%; left: calc((var(--vt) + .5) / var(--so-o) * 100%); transform: translate(-50%, -50%);
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #7c3aed; color: #fff;
  border: 2px solid #fff; box-shadow: 0 4px 12px rgba(124,58,237,.4); transition: left .3s linear; pointer-events: none; }
.ray-xe .ic-svg { width: 17px; height: 17px; }
.ray-xe.dang-chay { animation: ray-nhay .45s ease-in-out infinite alternate; }
@keyframes ray-nhay { to { box-shadow: 0 4px 20px rgba(124,58,237,.75); } }
.ray-o { margin: 0 2px; height: 34px; border-radius: 10px; border: 1.5px solid var(--slate-200); background: #fff; color: var(--slate-600);
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 0; min-width: 0; }
.ray-o:hover:not(:disabled) { border-color: var(--green-600); color: var(--green-800); }
.ray-o.ray-ben { font-size: 11.5px; background: var(--slate-100); }
.ray-o.o-xe { border-color: var(--green-600); background: var(--green-50); color: var(--green-800); }
.ray-o:disabled { cursor: default; }
.ray-duong.tat .ray-thanh { background: #94a3b8; }
.ray-duong.tat .ray-xe { background: #94a3b8; box-shadow: none; }
.ray-nut { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ray-nut .btn:disabled { opacity: .5; cursor: default; }
@media (max-width: 700px) {
  .ray-o { height: 30px; font-size: 10.5px; border-radius: 7px; margin: 0 1px; }
  .ray-o.ray-ben { font-size: 9px; }
  .ray-vung { font-size: 10.5px; margin: 0 1px; }
  .ray-xe { width: 26px; height: 26px; }
  .ray-xe .ic-svg { width: 14px; height: 14px; }
  .ray-nut .btn { flex: 1 1 calc(50% - 8px); }
}
.che-do-toi .ray-dk { border-top-color: var(--toi-vien); }
.che-do-toi .ray-dau b { color: #d9f99d; }
.che-do-toi .ray-o { background: var(--toi-o2); border-color: rgba(255,255,255,.12); color: #c3cfc8; }
.che-do-toi .ray-o.ray-ben { background: #26332c; }
.che-do-toi .ray-o.o-xe { border-color: #4ade80; color: #86efac; background: #1f3a2a; }
.che-do-toi .ray-vung { background: #1f3a2a; color: #86efac; }
.che-do-toi .ray-vung.chon { border-color: #4ade80; }
.che-do-toi .ray-xe { border-color: var(--toi-o); }
/* Ô "Bến": màn hình hẹp chỉ còn dấu ⌂ cho vừa ô */
.ray-ngan { display: none; }
@media (max-width: 480px) { .ray-dai { display: none; } .ray-ngan { display: inline; font-size: 14px; } }
