/* KAIN HOME — giao diện phẳng, co giãn cho điện thoại / máy tính bảng / máy tính.
   ĐỔI MÀU THƯƠNG HIỆU: sửa --primary / --primary-hover / --ring-focus bên dưới.
   ĐỔI FONT: sửa --app-font. */
:root {
  color-scheme: light;
  --app-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --strip-h: 0px; /* chiều cao dải "bản thử nghiệm" (0 ở bản thật) */

  /* Màu thương hiệu lấy từ logo KAIN HOME: đỏ #A3141C + vàng kim #D4A537 */
  --primary: #a3141c;
  --primary-hover: #8a1018;
  --primary-foreground: #ffffff;
  --primary-light: #fbeeee;   /* nền nhạt theo màu nhấn: mục đang chọn, avatar */
  --accent: #d4a537;          /* vàng kim thương hiệu: chỉ dùng điểm xuyết */
  --accent-light: #fbf4e0;
  --ring-focus: rgba(163, 20, 28, 0.14);
  --border-focus: var(--primary);

  --background: #f7f9fc;
  --surface: #ffffff;
  --foreground: #1f2a37;
  --muted: #667085;
  --border: #edf0f5;
  --border-strong: #dfe4ec;
  --item-hover: #f3f6fb;
  --surface-hover: #f8fafd;
  --secondary: #eef2f8;
  --secondary-hover: #e2e8f2;
  --button-hover: #f1f4f9;
  --elevation-popover: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --elevation-modal: 0 20px 25px -5px rgb(0 0 0 / 0.12), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  --danger: #c70036;
  --danger-bg: rgb(255 32 86 / 0.1);
  --danger-bg-hover: rgb(255 32 86 / 0.15);
  --error: #fb2c36;
  --error-ring: rgb(251 44 54 / 0.1);
  --error-text: #e7000b;
  --error-bg: #fef2f2;
  --error-border: #ffc9c9;
  --error-strong: #c10007;
  --success-bg: #ecfdf5;
  --success: #007a55;
  --warning-bg: #fffbeb;
  --warning: #bb4d00;
  --neutral-bg: #f4f4f5;
  --neutral: #52525c;
  --info-bg: #eff6ff;
  --info: #1447e6;

  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
  --bottom-nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px); /* tai thỏ / thanh trạng thái iPhone */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--app-font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, video { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.right { text-align: right; }
.sr-only { position: absolute; left: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* left:0 để không bị đẩy ra ngoài mép phải (làm trang rộng ra) khi nằm trong vùng cuộn ngang */

/* ---------- Bố cục ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ---------- Icon ---------- */
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 22px; height: 22px; }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease, opacity .15s ease;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--secondary); }
.btn-secondary:hover:not(:disabled) { background: var(--secondary-hover); }
.btn-outline { background: var(--surface); border-color: var(--border-strong); }
.btn-outline:hover:not(:disabled) { background: var(--button-hover); }
.btn-ghost { background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--item-hover); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-bg-hover); }
.btn-success { background: var(--success-bg); color: var(--success); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { height: 52px; padding: 0 24px; font-size: 16px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn .spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 13px; font-weight: 500; }
.label .req { color: var(--error-text); }
.hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 12px; color: var(--error-text); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 16px; /* 16px để iPhone không tự phóng to */
  transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.45; }
.select { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23707070' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--ring-focus); }
.input::placeholder, .textarea::placeholder { color: #a0a0a6; }
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--error); box-shadow: 0 0 0 3px var(--error-ring); }
.input-sm { min-height: 36px; padding: 6px 10px; font-size: 14px; border-radius: 8px; }
@media (min-width: 900px) { .input, .select, .textarea { font-size: 14px; } }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.check input { appearance: none; -webkit-appearance: none; width: 20px; height: 20px; margin: 0; flex: none;
  border: 1.5px solid #c9c9cf; border-radius: 6px; background: var(--surface); cursor: pointer; display: grid; place-content: center; }
.check input::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--primary-foreground); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.check input:checked { background: var(--primary); border-color: var(--primary); }
.check input:checked::after { opacity: 1; }
.check input:focus-visible { box-shadow: 0 0 0 3px var(--ring-focus); }
.check-lg input { width: 26px; height: 26px; border-radius: 8px; }
.check-lg input::after { width: 12px; height: 7px; }
.check-success input:checked { background: var(--success); border-color: var(--success); }

/* ---------- Card ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-pad { padding: 16px; }
@media (min-width: 640px) { .card-pad { padding: 20px; } }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-body { padding: 16px; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: none; margin: 4px 2px 8px; }

/* ---------- Badge ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error { background: var(--error-bg); color: var(--error-strong); }
.badge-info { background: var(--info-bg); color: var(--info); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Thống kê ---------- */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { padding: 14px 16px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-value.warn { color: var(--warning); }

/* ---------- Tab dạng phím ---------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--secondary); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { height: 32px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--foreground); box-shadow: 0 1px 2px rgb(0 0 0 / .06), 0 0 0 1px rgb(0 0 0 / .04); }
.seg .count { margin-left: 6px; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- Danh sách ---------- */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list-item { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-top: 1px solid var(--border); }
.list-item:first-child { border-top: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: var(--surface-hover); }
.list-item .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.list-item .meta .row { gap: 4px; }
.list-item.done .title { color: var(--muted); text-decoration: line-through; }
.list-item.selected { background: var(--primary-light); }
.title { font-weight: 600; overflow-wrap: anywhere; }

/* ---------- Bảng (máy tính) / thẻ (điện thoại) ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-hover); }
.table .num { text-align: right; }
@media (max-width: 759px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { padding: 12px 14px; border-top: 1px solid var(--border); }
  .table-cards tr:first-child { border-top: 0; }
  .table-cards td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; }
  .table-cards td::before { content: attr(data-label); color: var(--muted); font-size: 13px; }
  .table-cards td[data-label=""]::before { content: none; }
  .table-cards td.cell-head { font-weight: 600; font-size: 15px; padding-bottom: 6px; }
  .table-cards .num { text-align: right; }
}

/* ---------- Trạng thái rỗng ---------- */
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .icon { width: 28px; height: 28px; margin: 0 auto 10px; color: #b4b4ba; }
.empty .title { color: var(--foreground); margin-bottom: 4px; }
.loading { padding: 40px; display: grid; place-items: center; color: var(--muted); }
.loading::before { content: ""; width: 22px; height: 22px; border: 2px solid #d4d4d8; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }

/* ---------- Thông báo ---------- */
.banner { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; font-size: 14px; background: var(--info-bg); color: var(--info); }
.banner-warning { background: var(--warning-bg); color: var(--warning); }
.banner-error { background: var(--error-bg); color: var(--error-strong); border: 1px solid var(--error-border); }
.banner-success { background: var(--success-bg); color: var(--success); }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottom-nav-h) + 16px + var(--safe-bottom)); z-index: 1000; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
@media (min-width: 900px) { .toasts { bottom: 24px; } }
.toast { background: #1f1f22; color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--elevation-popover); animation: toast-in .2s ease; pointer-events: auto; }
.toast-error { background: #b3001b; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Hộp thoại (điện thoại: trượt từ dưới lên) ---------- */
dialog.modal { border: 0; padding: 0; background: var(--surface); color: var(--foreground); width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0; border-radius: 18px 18px 0 0; box-shadow: var(--elevation-modal); display: flex; flex-direction: column; }
dialog.modal:not([open]) { display: none; }
dialog.modal::backdrop { background: rgb(15 15 20 / .45); }
dialog.modal[open] { animation: sheet-in .22s ease; }
@keyframes sheet-in { from { transform: translateY(24px); } }
@media (min-width: 640px) {
  dialog.modal { width: min(560px, calc(100% - 48px)); margin: auto; border-radius: 16px; max-height: 88vh; }
  dialog.modal.wide { width: min(760px, calc(100% - 48px)); }
  @keyframes sheet-in { from { transform: scale(.98); } }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1 1 auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--border); flex-wrap: wrap; }
@media (max-width: 639px) { .modal-foot .btn { flex: 1 1 auto; } }

/* ---------- Ảnh đính kèm ---------- */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--background); border: 1px solid var(--border); display: grid; place-items: center; color: var(--muted); text-decoration: none; font-size: 12px; text-align: center; padding: 0; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb .remove { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgb(0 0 0 / .6); color: #fff; display: grid; place-items: center; cursor: pointer; }
.thumb .remove .icon { width: 14px; height: 14px; }
.thumb .tag { position: absolute; left: 4px; bottom: 4px; background: rgb(0 0 0 / .6); color: #fff; border-radius: 6px; padding: 0 6px; font-size: 11px; }
.dropzone { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; border: 1.5px dashed var(--border-strong); border-radius: 12px; color: var(--muted); cursor: pointer; background: var(--surface); padding: 12px; text-align: center; font-size: 14px; }
.dropzone:hover { background: var(--surface-hover); }
.dropzone input { display: none; }

/* ---------- Khung ứng dụng nhân viên ---------- */
.app-shell { min-height: 100dvh; }
.sidebar { display: none; }
.topbar { position: sticky; top: var(--strip-h); z-index: 20; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px; background: rgb(247 249 252 / .92); backdrop-filter: saturate(180%) blur(8px); -webkit-backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 17px; }
.main { padding: 16px 16px calc(var(--bottom-nav-h) + 24px + var(--safe-bottom)); max-width: 1180px; margin: 0 auto; }
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: var(--safe-bottom); }
.bottom-nav a { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--bottom-nav-h); font-size: 11px; color: var(--muted); text-decoration: none; -webkit-tap-highlight-color: transparent; min-width: 0; }
.bottom-nav a .icon { width: 22px; height: 22px; }
.bottom-nav a[aria-current="page"] { color: var(--primary); font-weight: 600; }
.bottom-nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }

@media (min-width: 900px) {
  .app-shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); } /* minmax(0,..): nội dung rộng (chip, bảng) không đẩy trang rộng ra */
  .sidebar { display: flex; flex-direction: column; position: sticky; top: var(--strip-h); height: calc(100dvh - var(--strip-h)); overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border-strong); padding: 16px 12px; gap: 2px; }
  .sidebar .brand { padding: 4px 10px 18px; }
  .sidebar a.nav { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: 9px; text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 500; }
  .sidebar a.nav:hover { background: var(--item-hover); color: var(--foreground); }
  .sidebar a.nav[aria-current="page"] { background: var(--primary-light); color: var(--primary); }
  .sidebar .nav-group { font-size: 12px; color: var(--muted); padding: 14px 10px 6px; }
  .sidebar .me { margin-top: auto; padding: 12px 10px 4px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
  .bottom-nav { display: none; }
  .topbar { height: 64px; padding: 0 28px; background: var(--background); backdrop-filter: none; border-bottom: 0; }
  .topbar h1 { font-size: 20px; }
  .topbar .mobile-only { display: none; }
  .main { padding: 4px 28px 40px; }
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: var(--primary-foreground); display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar .input, .toolbar .select { width: auto; min-height: 40px; }
.toolbar .search { flex: 1 1 220px; }
@media (max-width: 639px) { .toolbar .select, .toolbar .input[type="date"], .toolbar .input[type="month"] { flex: 1 1 140px; } }

/* Thanh hành động dính đáy (phân việc) */
.action-bar { position: sticky; bottom: calc(var(--bottom-nav-h) + 8px + var(--safe-bottom)); z-index: 15; margin-top: 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--elevation-popover); }
@media (min-width: 900px) { .action-bar { bottom: 16px; } }
.action-bar .select { flex: 1 1 180px; width: auto; min-height: 40px; }

.band { margin-bottom: 18px; }
.band-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 2px 8px; }
.band-head h3 { display: flex; align-items: center; gap: 8px; }

/* Thẻ việc của thợ */
.task { padding: 16px; }
.task + .task { border-top: 1px solid var(--border); }
.task.done { background: var(--surface-hover); }
.task.done .title { color: var(--muted); text-decoration: line-through; }
.task-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.progress { height: 6px; border-radius: 999px; background: var(--secondary); overflow: hidden; }
.progress > div { height: 100%; background: var(--success); border-radius: inherit; transition: width .3s ease; }

/* Ô phòng trong màn ghi điện nước */
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.room-tile { text-align: left; padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-height: 84px; }
.room-tile:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.room-tile .code { font-weight: 600; font-size: 16px; }
.room-tile.ok { border-color: #b7ebd5; background: #f5fdf9; }

/* Trang đăng nhập & trang khách */
.center-page { min-height: 100dvh; display: flex; flex-direction: column; }
.public-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; max-width: 760px; width: 100%; margin: 0 auto; }
.public-main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 8px 16px 40px; }
.hero { text-align: center; padding: 48px 20px; }
.hero h1 { font-size: 26px; margin-bottom: 8px; }
@media (min-width: 640px) { .hero { padding: 64px 40px; } .hero h1 { font-size: 30px; } }
.hero .btn-lg { margin-top: 28px; height: 60px; padding: 0 32px; font-size: 17px; width: 100%; max-width: 360px; }
.hero-icon { width: 64px; height: 64px; border-radius: 18px; background: var(--accent-light); color: var(--primary); display: grid; place-items: center; margin: 0 auto 20px; }
.hero-icon .icon { width: 30px; height: 30px; }
.steps { display: grid; gap: 10px; margin-top: 28px; text-align: left; }
@media (min-width: 640px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step { display: flex; gap: 10px; font-size: 13px; color: var(--muted); }
.step b { width: 22px; height: 22px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: grid; place-items: center; font-size: 12px; flex: none; }
.auth-card { width: 100%; max-width: 400px; margin: 0 auto; }
.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.kbd-link { font-size: 14px; font-weight: 500; text-decoration: none; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 8px; }
.kbd-link:hover { background: var(--item-hover); color: var(--foreground); }

.divider { height: 1px; background: var(--border); margin: 4px 0; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.pw-box { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 20px; letter-spacing: .04em; padding: 14px; text-align: center; border-radius: 10px; background: var(--background); border: 1px dashed var(--border-strong); user-select: all; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Tiện ích khoảng cách */
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }
.mb16 { margin-bottom: 16px; }
.items-start { align-items: flex-start; }
a.list-item { text-decoration: none; align-items: center; }
.warn-text { color: var(--warning); font-weight: 600; }
.text-left { text-align: left; justify-content: flex-start; cursor: pointer; border: 0; font: inherit; }
.table td .truncate { display: block; max-width: 260px; }
.meta .badge { white-space: normal; height: auto; min-height: 22px; padding-top: 2px; padding-bottom: 2px; }

/* Logo NovaCity */
.brand { color: var(--primary); }
.brand-logo { width: 34px; height: 34px; object-fit: contain; flex: none; }
.auth-logo { display: block; height: 120px; width: auto; margin: 0 auto 8px; }
.hero-logo { display: block; height: 150px; width: auto; margin: 0 auto 16px; }
.hero h1 { color: var(--foreground); }

/* Dải báo bản thử nghiệm */
.test-strip { position: fixed; top: 0; left: 0; right: 0; height: 22px; line-height: 14px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; z-index: 50; background: var(--accent); color: #3d3000; font-size: 12px; font-weight: 600; text-align: center; padding: 4px 12px; }

body.test-mode { --strip-h: 22px; padding-top: 22px; }
.sidebar .me a { text-decoration: none; color: inherit; min-width: 0; }
.sidebar .me a:hover .strong { color: var(--primary); }

/* ---------- Phân việc ---------- */
.day-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 16px; }
.day { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; min-width: 72px; height: 54px; padding: 0 10px;
  border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; color: var(--foreground); line-height: 1.25; position: relative; }
.day:hover { background: var(--surface-hover); }
.day.on { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.day .xs { opacity: .85; }
.day.other { flex-direction: row; gap: 6px; min-width: auto; }
.day.other input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.day.other input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }

.assign-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
@media (min-width: 1100px) {
  .assign-grid { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .assign-side { position: sticky; top: calc(var(--strip-h) + 76px); max-height: calc(100dvh - var(--strip-h) - 96px); overflow-y: auto; padding-right: 2px; }
}
.section-title .grow { flex: 1; }
.band-empty { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 0 2px 14px; }
.house-group + .house-group { border-top: 1px solid var(--border); }
.house-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px 6px; font-size: 13px; font-weight: 600; color: var(--primary); background: var(--surface); }
.pick { display: flex; gap: 12px; align-items: flex-start; padding: 10px 16px 12px 28px; cursor: pointer; }
.pick:hover { background: var(--surface-hover); }
.pick.selected { background: var(--primary-light); }
.pick > .grow { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pick .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 4px; font-size: 13px; color: var(--muted); }
@media (max-width: 639px) { .pick { padding-left: 16px; } }

.person { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.person-head { display: flex; align-items: center; gap: 10px; }
.progress.thin { height: 4px; }
.person-jobs { display: flex; flex-direction: column; }
.person-job { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.person-job.done .strong { color: var(--muted); text-decoration: line-through; }

/* Xếp theo cột thì KHÔNG để wrap: wrap làm hàng chip rộng theo nội dung (700px+) và kéo cả trang rộng ra trên điện thoại */
.action-bar { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 8px; min-width: 0; max-width: 100%; }
.give-row { display: flex; align-items: center; gap: 8px; overflow-x: auto; padding-bottom: 2px; min-width: 0; max-width: 100%; -webkit-overflow-scrolling: touch; }
.give-chip { flex: none; gap: 6px; padding-left: 4px; height: 36px; border-radius: 999px; }
.xs-av { width: 26px; height: 26px; font-size: 11px; }

/* Theo dõi yêu cầu */
.track-box { margin: 24px auto 8px; max-width: 420px; text-align: left; display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 14px; background: var(--primary-light); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.tl-step { display: flex; gap: 12px; position: relative; padding-bottom: 18px; }
.tl-step:last-child { padding-bottom: 0; }
.tl-step::before { content: ""; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--border-strong); }
.tl-step:last-child::before { display: none; }
.tl-dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); flex: none; display: grid; place-items: center; color: #fff; z-index: 1; }
.tl-step.done .tl-dot { background: var(--success); border-color: var(--success); }
.tl-step.done::before { background: var(--success); }
.tl-step.current .tl-dot { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring-focus); }
.tl-step:not(.done) .strong { color: var(--muted); }
.tl-step.current .strong { color: var(--foreground); }

/* ---------- Chuông thông báo ---------- */
.bell { position: relative; flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--foreground); }
.bell:hover:not(:disabled) { background: var(--button-hover); }
.bell .icon { width: 19px; height: 19px; }
.bell-badge { position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #e5243b; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 16px; text-align: center; border: 2px solid var(--background); font-variant-numeric: tabular-nums; pointer-events: none; }
.topbar { gap: 10px; }
#topActions:empty { display: none; }
@media (max-width: 639px) { .hide-sm { display: none; } }
.show-sm { display: none; }
@media (max-width: 639px) { .show-sm { display: inline; } }
.notif { display: flex; gap: 10px; width: 100%; text-align: left; padding: 12px 14px; border: 0; border-top: 1px solid var(--border); background: var(--surface); cursor: pointer; font: inherit; color: inherit; }
.notif:first-child { border-top: 0; }
.notif:hover { background: var(--surface-hover); }
.notif .grow { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-title { font-weight: 500; font-size: 14px; overflow-wrap: anywhere; }
.notif-body { font-size: 13px; color: var(--muted); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: transparent; }
.notif.unread { background: var(--primary-light); }
.notif.unread .notif-title { font-weight: 600; }
.notif.unread .notif-dot { background: var(--primary); }
.push-box { align-items: center; flex-wrap: wrap; }
.push-box .grow { flex: 1 1 200px; }

/* ---------- AI ---------- */
.badge-ai { background: var(--primary-light); color: var(--primary); }
.spinner-inline { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; margin-right: 8px; flex: none; }
.ai-card { border-color: #d6e3f7; background: linear-gradient(180deg, #f4f8fe, var(--surface) 70%); }
.ai-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px 0; color: var(--primary); }
.ai-head .muted { font-weight: 400; }
.ai-body { padding: 8px 16px 14px; }
.ai-headline { font-weight: 500; margin-bottom: 8px; }
.ai-actions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ai-actions li { display: flex; align-items: center; gap: 10px; font-size: 14px; padding: 8px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); flex-wrap: wrap; }
.ai-actions li .grow { flex: 1 1 220px; }
.ai-lvl { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--neutral-bg); color: var(--neutral); flex: none; }
.lvl-high .ai-lvl { background: var(--error-bg); color: var(--error-strong); }
.lvl-medium .ai-lvl { background: var(--warning-bg); color: var(--warning); }
.ai-inline { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--primary-light); color: var(--primary); flex-wrap: wrap; }
.ai-inline .grow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--foreground); }
.ai-wait { display: flex; gap: 12px; align-items: flex-start; padding: 12px; color: var(--primary); }
.ai-wait .spinner-inline { width: 20px; height: 20px; margin-top: 2px; }
.sg-card { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.sg-jobs { display: flex; flex-direction: column; }
.sg-job { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--border); cursor: pointer; flex-wrap: wrap; }
.sg-job .grow { display: flex; flex-direction: column; min-width: 0; flex: 1 1 180px; }
.ai-read { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--primary); background: var(--primary-light); padding: 6px 10px; border-radius: 8px; flex-wrap: wrap; }
.ai-read.conf-low { background: var(--warning-bg); color: var(--warning); }
.ai-read .grow { flex: 1 1 160px; }

/* ---------- Kỹ năng nhân viên ---------- */
.skill-line { display: flex; align-items: center; gap: 4px; color: var(--primary); margin-top: 3px; min-width: 0; }
.skill-line.none { color: var(--muted); font-style: italic; }
.skill-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.skill-chip { position: relative; cursor: pointer; }
.skill-chip input { position: absolute; opacity: 0; pointer-events: none; }
.skill-chip span { display: inline-flex; align-items: center; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 13px; font-weight: 500; color: var(--muted); }
.skill-chip input:checked + span { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.skill-chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--ring-focus); }
.give-chip.misfit { opacity: .55; border-style: dashed; }

/* ---------- Thẻ gợi ý AI ---------- */
.sg-card .person-head .btn { margin-left: 4px; }
.sg-count { font-size: 13px; font-weight: 700; color: var(--primary); background: var(--primary-light); border-radius: 999px; padding: 2px 10px; }
.sg-reason { display: flex; gap: 6px; align-items: flex-start; font-size: 13px; color: var(--primary); background: var(--primary-light); border-radius: 10px; padding: 8px 10px; margin: 0; }
.sg-reason .icon { margin-top: 2px; }
.sg-job { align-items: center; padding: 10px 0; }
.sg-tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; margin-left: auto; }
@media (max-width: 639px) { .sg-tags { width: 100%; justify-content: flex-start; padding-left: 32px; } }

/* ---------- Nút xoá ---------- */
.danger-text { color: var(--danger); }
.danger-text:hover:not(:disabled) { background: var(--danger-bg); }
.thumb-wrap { position: relative; }
.thumb-wrap .thumb { width: 100%; }
.thumb-wrap .remove { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgb(0 0 0 / .62); color: #fff; display: grid; place-items: center; cursor: pointer; }
.thumb-wrap .remove:hover { background: #c70036; }
.thumb-wrap .remove .icon { width: 15px; height: 15px; }
.row-actions { display: flex; gap: 2px; flex: none; }
.modal-foot .grow { flex: 1; }
@media (max-width: 639px) { .modal-foot .grow { display: none; } .modal-foot .btn-icon { flex: 0 0 auto; } }

/* ---------- Nhiều nhân viên ---------- */
.mb8 { margin-bottom: 8px; }
.person { gap: 8px; }
.person-head { gap: 6px; }
.person-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.person-toggle:disabled { cursor: default; }
.person-toggle .grow { display: flex; flex-direction: column; min-width: 0; }
.person-toggle:hover:not(:disabled) .person-name { color: var(--primary); }
.load { min-width: 26px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--secondary); font-size: 12px; font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.load.high { background: var(--warning-bg); color: var(--warning); }
.person:not(.open) .progress.thin { margin-top: -2px; }
.pick-person { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border: 0; border-top: 1px solid var(--border); background: var(--surface); cursor: pointer; text-align: left; font: inherit; color: inherit; }
.pick-person:first-child { border-top: 0; }
.pick-person:hover { background: var(--surface-hover); }
.pick-person .grow { display: flex; flex-direction: column; min-width: 0; }
.fit { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.fit.all { background: var(--success-bg); color: var(--success); }
.fit.some { background: var(--warning-bg); color: var(--warning); }
.fit.none { background: var(--neutral-bg); color: var(--neutral); }

/* ---------- Zalo ---------- */
.zalo-mark { width: 24px; height: 24px; border-radius: 7px; background: #0068ff; color: #fff; font-weight: 800; font-size: 14px; display: inline-grid; place-items: center; flex: none; }
.zalo-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.zalo-code { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px; border-radius: 14px; background: var(--primary-light); }
.zalo-code .code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 30px; font-weight: 700; letter-spacing: .18em; color: var(--primary); user-select: all; }
.zalo-help summary { cursor: pointer; color: var(--primary); }
.zalo-help ul { margin: 6px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.zalo-cta { text-decoration: none; align-items: center; }

/* ---------- Sửa lỗi giao diện theo báo cáo test ---------- */
.seg .count { margin-left: 8px; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 999px; background: var(--secondary-hover); color: var(--foreground); font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.seg .count.warn-text { background: var(--warning-bg); color: var(--warning); }
.toast { display: flex; align-items: center; gap: 12px; }
.toast span { flex: 1; }
.toast-action { flex: none; border: 0; background: rgb(255 255 255 / .16); color: #fff; font: inherit; font-weight: 600; padding: 4px 10px; border-radius: 8px; cursor: pointer; }
.toast-action:hover { background: rgb(255 255 255 / .28); }
.chip-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.give-chip .load { min-width: 20px; height: 18px; font-size: 11px; }
.foot-sep { width: 12px; flex: none; }
.modal-body .hint { white-space: normal; }
.list-item .skill-line .truncate { white-space: normal; overflow: visible; }

/* Số thứ tự làm việc (1, 2, 3…) — cùng số với lệnh "xong <số>" của bot Zalo */
.seq-no { display: inline-flex; align-items: center; justify-content: center; flex: none; min-width: 22px; height: 22px; padding: 0 6px;
  margin-right: 8px; border-radius: 999px; background: var(--primary-light); color: var(--primary); font-size: 12px; font-weight: 700; vertical-align: 1px; }
.person-job .seq-no { margin-right: 0; }
.order-list { display: flex; flex-direction: column; gap: 6px; }
.order-item { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 10px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); cursor: grab; }
.order-item.done .strong { color: var(--muted); text-decoration: line-through; }
.order-item.dragging { opacity: .5; }
.order-item .grow { min-width: 0; }

/* Điện thoại có tai thỏ / Dynamic Island: đẩy thanh trên cùng xuống dưới thanh trạng thái, không bị che */
.topbar { padding-top: var(--safe-top); height: calc(56px + var(--safe-top)); }
.public-top { padding-top: calc(var(--safe-top) + 12px); }
.sidebar { padding-top: calc(16px + var(--safe-top)); }
@media (min-width: 900px) { .topbar { height: calc(64px + var(--safe-top)); } }
/* Hộp sắp xếp: dòng vừa chuyển nháy nền + viền màu, nhãn "trước: số 3" */
.order-item.just-moved { border-color: var(--primary); animation: moved-flash 1.2s ease-out; position: relative; z-index: 1; }
@keyframes moved-flash { 0% { background: var(--accent-light); box-shadow: 0 0 0 3px var(--ring-focus); } 100% { background: var(--surface); box-shadow: 0 0 0 0 transparent; } }
.order-item.just-moved .seq-no { background: var(--primary); color: var(--primary-foreground); }
.moved-tag { font-weight: 600; }
.moved-tag.up { color: var(--success); }
.moved-tag.down { color: var(--warning); }
.order-status { min-height: 18px; margin-top: 8px; color: var(--primary); font-weight: 600; }
[data-mv="top"] { position: relative; }
[data-mv="top"] .stack-up { position: absolute; top: 4px; }
@media (prefers-reduced-motion: reduce) { .order-item.just-moved { animation: none; background: var(--accent-light); } }
/* Nhà & phòng: số yêu cầu trên từng phòng, phòng tự thêm, lịch sử phòng */
.room-chip { gap: 6px; }
.room-count { display: inline-flex; align-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--secondary); color: var(--muted); font-size: 11px; font-weight: 700; justify-content: center; }
.room-count.open { background: var(--danger-bg); color: var(--danger); }
.auto-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.room-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.room-stats > div { display: flex; flex-direction: column; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-hover); min-width: 0; }
.room-stats b { font-size: 17px; }
.room-stats span { font-size: 12px; color: var(--muted); }
@media (max-width: 520px) { .room-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 10px 6px; text-align: left; background: none; border: 0; border-top: 1px solid var(--border); cursor: pointer; border-radius: 8px; color: inherit; font: inherit; }
.tl-item:first-child { border-top: 0; }
.tl-item:hover { background: var(--item-hover); }
.tl-item > .grow { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tl-dot { flex: none; width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: var(--border-strong); }
.tl-dot.open { background: var(--warning); }
.tl-dot.done { background: var(--success); }
.room-info summary { cursor: pointer; list-style: none; }
.room-info summary::-webkit-details-marker { display: none; }

/* Vùng cuộn ngang: là mốc định vị để các phần tử ẩn bên trong bị cắt theo vùng, không tràn ra trang */
.give-row, .seg, .day-strip { position: relative; }

.main { min-width: 0; }
