/* ==========================================================================
   app.css — giao diện app Khảo sát nhận diện WinCommerce (2026-09-23)
   --------------------------------------------------------------------------
   Theo quy tắc chung WCM (DESIGN_SYSTEM.md bản 2, app gốc là app cửa hàng):
   cùng token, cùng kiểu topbar / đầu trang / bộ lọc / menu / thẻ số / thẻ /
   bảng / hộp thoại / đăng nhập. App có hai màn (Khảo sát, Phân tích) nên
   không dựng thanh bên: hai tab nằm ngay trên topbar (quy tắc #14).
   Thay cho design-system.css + ui-polish.css + brand-fixes.css (bản 1, đã bỏ).

   tailwind.generated.css là Tailwind v4 dựng sẵn: mọi utility nằm trong @layer,
   nên các quy tắc dưới đây (ngoài layer) luôn thắng utility. Reset control đặt
   TRONG @layer base — để ngoài layer nó sẽ đè cả cỡ chữ của utility.
   ========================================================================== */
:root {
  --paper: #F2F6FC;
  --surface: #FFFFFF;
  --sub: #F6F8FC;
  --tile: #F1F5FA;
  --line: #E7EDF6;
  --line-strong: #D3DEEC;
  --ink: #26364A;
  --ink-2: #5D6B7E;
  --faint: #8593A5;

  --red: #E81C24;            /* đỏ chữ "Win" của logo — nút chính */
  --red-deep: #C4161D;
  --red-soft: #FDECEC;
  --sky: #4A84F4;
  --sky-ink: #2D5FC4;
  --sky-wash: #EAF1FE;

  /* Màu biểu đồ (chỉ dùng trong biểu đồ và chấm chú thích) */
  --rose: #F24B64;
  --amber: #F6AA2A;
  --mint: #16B884;

  /* Chip trạng thái có nghĩa (hoàn thành / đang khảo sát / lỗi) */
  --rose-wash: #FDE8EC;  --rose-ink: #C42A3E;
  --mint-wash: #E0F5EC;  --mint-ink: #0F7C5A;
  --amber-wash: #FEF1DA; --amber-ink: #8A6008;

  --menu-shadow: 0 16px 40px -16px rgba(38, 54, 74, .28), 0 2px 6px rgba(38, 54, 74, .06);
}

@layer base {
  button, input, select, textarea { font: inherit; color: inherit; }
}

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  margin: 0; padding: 0;
  font-family: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  background: var(--paper);
  color: var(--ink);
}
body.auth-locked { overflow: hidden; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
/* Khối có display riêng (flex/grid) vẫn phải ẩn được bằng class "hidden" mà JS bật tắt. */
.hidden, [hidden] { display: none !important; }

/* ---- Topbar + tab ---- */
.wcm-topbar {
  position: sticky; top: 0; z-index: 30;
  height: 58px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.wcm-topbar__left, .wcm-topbar__right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.wcm-topbar__left { gap: 14px; }
.wcm-topbar__logo { display: block; height: 32px; width: auto; margin-left: -6px; flex: none; }
.wcm-topbar__divider { width: 1px; height: 22px; background: var(--line); flex: none; }
.wcm-tabs { display: flex; align-items: center; gap: 4px; }
.wcm-tab {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px;
  border: 0; border-radius: 9px; background: transparent; color: var(--ink-2);
  font-size: 13.5px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.wcm-tab > i { font-size: 14px; color: var(--faint); width: 16px; text-align: center; transition: color .15s ease; }
.wcm-tab:hover { background: var(--tile); color: var(--ink); }
.wcm-tab.is-active { background: var(--sky-wash); color: var(--sky-ink); font-weight: 600; }
.wcm-tab.is-active > i { color: var(--sky-ink); }
.wcm-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px; max-width: 340px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink-2); font-size: 12px; font-weight: 500; white-space: nowrap;
}
.wcm-chip > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.wcm-chip__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.wcm-chip[data-tone="ok"] .wcm-chip__dot { background: var(--mint); }
.wcm-chip[data-tone="warn"] .wcm-chip__dot { background: var(--amber); }
.wcm-chip[data-tone="error"] .wcm-chip__dot { background: var(--rose); }
.wcm-chip[data-tone="busy"] .wcm-chip__dot { background: var(--sky); }
.wcm-role { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--tile); color: var(--ink-2); }
.wcm-role[data-role="admin"] { background: var(--red-soft); color: var(--red); }
.wcm-logout {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface);
  color: var(--ink-2); font-size: 12.5px; font-weight: 500; cursor: pointer; transition: background-color .15s ease;
}
.wcm-logout:hover { background: var(--tile); color: var(--ink); }
.wcm-logout:disabled { opacity: .6; cursor: not-allowed; }

/* ---- Vùng nội dung ---- */
.wcm-main { max-width: 1480px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.wcm-view { display: flex; flex-direction: column; gap: 16px; }

/* ---- Đầu trang ---- */
.wcm-pagehead { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 20px; }
.wcm-pagehead__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.wcm-pagehead__title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; }
.wcm-pagehead__title h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
.wcm-eyebrow { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--tile); color: var(--ink-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.wcm-pagehead__meta { font-size: 12.5px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.wcm-pagehead__meta::before { content: '·'; margin-right: 8px; color: var(--faint); }
.wcm-pagehead__actions { display: flex; align-items: center; gap: 8px; }
/* Bộ lọc chỉ áp cho màn Khảo sát; màn Phân tích có cách lọc riêng (bấm khu vực). */
body[data-view="analytics"] [data-work-only] { display: none !important; }

/* ---- Nút ---- */
.wcm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 500;
  white-space: nowrap; cursor: pointer; transition: background-color .15s ease, color .15s ease;
}
.wcm-btn:hover:not(:disabled) { background: var(--tile); color: var(--ink); }
.wcm-btn:disabled { opacity: .55; cursor: not-allowed; }
.wcm-btn > i { font-size: 13px; color: var(--faint); }
.wcm-btn:hover:not(:disabled) > i { color: var(--ink-2); }
.wcm-btn--primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; }
.wcm-btn--primary > i, .wcm-btn--primary:hover:not(:disabled) > i { color: currentColor; }
.wcm-btn--primary:hover:not(:disabled) { background: var(--red-deep); border-color: var(--red-deep); color: #fff; }
.wcm-btn--danger { background: var(--rose-ink); border-color: var(--rose-ink); color: #fff; font-weight: 600; }
.wcm-btn--danger > i, .wcm-btn--danger:hover:not(:disabled) > i { color: currentColor; }
.wcm-btn--danger:hover:not(:disabled) { background: #A82233; border-color: #A82233; color: #fff; }
.wcm-btn--sm { height: 28px; padding: 0 9px; border-radius: 7px; font-size: 12px; gap: 5px; }
.wcm-btn--sm > i { font-size: 11px; }
.wcm-btn--icon { width: 34px; padding: 0; }
.wcm-btn__chev, .wcm-filter-toggle__chev { font-size: 10px !important; transition: transform .2s ease; }
[aria-expanded="true"] > .wcm-btn__chev { transform: rotate(180deg); }
.wcm-filter-toggle[aria-expanded="false"] .wcm-filter-toggle__chev { transform: rotate(-90deg); }
.wcm-filter-toggle__count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--sky); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }

/* ---- Menu "Thao tác dữ liệu" ---- */
.wcm-menu-wrap { position: relative; }
.wcm-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  width: 264px; padding: 4px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--menu-shadow);
}
.wcm-menu__item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border: 0; border-radius: 6px; background: transparent; color: var(--ink);
  font-size: 13px; font-weight: 500; text-align: left; white-space: nowrap; cursor: pointer;
}
.wcm-menu__item > i { width: 16px; text-align: center; font-size: 14px; color: var(--faint); flex: none; }
.wcm-menu__item:hover:not(:disabled), .wcm-menu__item:focus-visible { background: var(--tile); outline: none; }
.wcm-menu__item:disabled { opacity: .55; cursor: not-allowed; }
.wcm-menu__item--danger, .wcm-menu__item--danger > i { color: var(--rose-ink); }
.wcm-menu__item--danger:hover:not(:disabled), .wcm-menu__item--danger:focus-visible { background: var(--rose-wash); }
.wcm-menu__sep { height: 1px; margin: 4px 6px; background: var(--line); }
/* Mục chỉ dành cho Admin: Staff không thấy (server vẫn chặn lại lần nữa). */
body:not([data-access="admin"]) [data-admin-only] { display: none !important; }

/* ---- Bộ lọc ---- */
.wcm-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.wcm-filters.is-collapsed { display: none; }
.wcm-field {
  display: flex; align-items: center; gap: 8px; flex: 1 1 160px; min-width: 0;
  height: 34px; padding: 0 4px 0 10px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); transition: border-color .15s ease, box-shadow .15s ease; cursor: pointer;
}
.wcm-field--search { flex: 2 1 220px; padding-right: 10px; cursor: text; }
.wcm-field--lookup { flex: 1.6 1 220px; padding-right: 3px; cursor: text; }
.wcm-field:hover { border-color: #BCCBDD; }
.wcm-field:focus-within { border-color: var(--sky); box-shadow: 0 0 0 3px var(--sky-wash); }
.wcm-field__icon { font-size: 13px; color: var(--faint); flex: none; }
.wcm-field select, .wcm-field input {
  flex: 1; min-width: 0; height: 32px; border: 0; background: transparent; outline: none;
  color: var(--ink); font-size: 13px; font-weight: 500; cursor: inherit;
}
.wcm-field input::placeholder { color: var(--faint); font-weight: 400; }
.wcm-field select:focus-visible, .wcm-field input:focus-visible { outline: none; }
.wcm-field__hint { font-size: 11.5px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.wcm-field__hint:empty { display: none; }
.wcm-field .wcm-btn--sm { flex: none; }
.wcm-check {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
  color: var(--ink-2); font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer;
}
.wcm-check > i { font-size: 14px; color: var(--faint); }
.wcm-check:hover { background: var(--tile); color: var(--ink); }
.wcm-check.is-on { background: var(--sky-wash); border-color: #C9DAFB; color: var(--sky-ink); }
.wcm-check.is-on > i { color: var(--sky-ink); }

/* ---- Thẻ số ---- */
.wcm-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 1024px) { .wcm-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.wcm-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; min-width: 0; }
.wcm-kpi__label { margin: 0; display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wcm-kpi__label > i { font-size: 12px; color: var(--faint); width: 14px; text-align: center; flex: none; }
.wcm-kpi__value { margin: 6px 0 0; font-size: 24px; font-weight: 600; line-height: 1.2; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.wcm-kpi__line { display: flex; align-items: center; gap: 12px; }
/* Thanh tiến độ trong thẻ số là một biểu đồ nhỏ: màu mint = hoàn thành. */
.wcm-progress { flex: 1; height: 6px; margin-top: 6px; border-radius: 999px; background: var(--tile); overflow: hidden; }
.wcm-progress > div { height: 100%; border-radius: inherit; background: var(--mint); transition: width .4s ease; }

/* ---- Thẻ ---- */
.wcm-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; min-width: 0; }
.wcm-card--flush { padding: 0; overflow: hidden; }
.wcm-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.wcm-card__head--bar { margin: 0; padding: 14px 16px; border-bottom: 1px solid var(--line); align-items: center; }
.wcm-card__title { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--ink); }
.wcm-card__title > i { font-size: 14px; color: var(--faint); width: 16px; text-align: center; }
.wcm-card__desc { margin: 3px 0 0 24px; font-size: 12px; color: var(--ink-2); }
.wcm-card__desc b { font-weight: 600; color: var(--ink); }
.wcm-card__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wcm-card__aside { flex: none; display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; background: var(--tile); color: var(--ink-2); font-size: 12px; font-weight: 500; white-space: nowrap; }

/* ---- Màn Khảo sát: danh sách + báo cáo ---- */
.wcm-work { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (min-width: 1024px) {
  .wcm-work { grid-template-columns: minmax(320px, 4fr) minmax(0, 8fr); }
  .wcm-work.is-list-hidden { grid-template-columns: minmax(0, 1fr); }
}
.wcm-work.is-list-hidden #store-list-panel { display: none; }
.wcm-list { display: flex; flex-direction: column; height: 780px; }
.wcm-list__body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.wcm-report { display: flex; flex-direction: column; min-height: 780px; }
.wcm-report__body { flex: 1; display: flex; flex-direction: column; padding: 16px 20px 20px; gap: 16px; }

.wcm-store {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  cursor: pointer; transition: border-color .15s ease, background-color .15s ease;
}
.wcm-store:hover { border-color: var(--line-strong); background: #FAFBFD; }
.wcm-store.active { border-color: #BFD3FA; background: var(--sky-wash); }
.wcm-store__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.wcm-store__tags { display: flex; flex-wrap: wrap; gap: 4px; }
.wcm-store__name { margin: 6px 0 2px; font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wcm-store__addr { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); min-width: 0; }
.wcm-store__addr > i { font-size: 11px; color: var(--faint); flex: none; }
.wcm-store__addr > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wcm-store__actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.wcm-store.active .wcm-store__actions { border-top-color: #D3E1FB; }
.wcm-store.active .wcm-tag { background: var(--surface); }

.wcm-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: #F9FAFD; border-top: 1px solid var(--line); font-size: 12px; font-weight: 500; color: var(--ink-2); }
.wcm-pager button { padding: 5px 10px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: var(--ink-2); font-size: 12px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.wcm-pager button:hover:not(:disabled) { background: var(--tile); color: var(--ink); }
.wcm-pager button:disabled { opacity: .45; cursor: not-allowed; }

/* Thông tin cửa hàng đang chọn */
.wcm-storehead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 14px 16px; background: var(--sub); border: 1px solid var(--line); border-radius: 10px; }
.wcm-storehead h3 { margin: 6px 0 4px; font-size: 17px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.wcm-storehead p { margin: 0; display: flex; align-items: flex-start; gap: 6px; font-size: 13px; color: var(--ink-2); }
.wcm-storehead p > i { margin-top: 3px; font-size: 12px; color: var(--faint); }
.wcm-empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 380px; padding: 24px; text-align: center; }
.wcm-empty-state > i { font-size: 22px; color: var(--faint); margin-bottom: 4px; }
.wcm-empty-state strong { font-size: 14px; font-weight: 600; color: var(--ink); }
.wcm-empty-state p { margin: 0; max-width: 380px; font-size: 13px; line-height: 1.55; color: var(--ink-2); }
.wcm-empty-state p b { font-weight: 600; color: var(--ink); }

/* Form khảo sát */
.wcm-form { display: flex; flex-direction: column; gap: 16px; }
.wcm-form__grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 768px) {
  .wcm-form__grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .wcm-form__grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.wcm-section { padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.wcm-section__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -2px 0 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.wcm-section__title { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink); }
.wcm-section__title > i { font-size: 12px; color: var(--faint); width: 14px; text-align: center; }
.wcm-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.wcm-label .wcm-req { color: var(--rose-ink); margin-left: 2px; }
.wcm-input, .wcm-select, .wcm-textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
  color: var(--ink); font-size: 13px; font-weight: 500; outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.wcm-input, .wcm-select { height: 36px; padding: 0 10px; }
.wcm-textarea { padding: 10px 12px; line-height: 1.55; resize: vertical; min-height: 84px; }
.wcm-input::placeholder, .wcm-textarea::placeholder { color: var(--faint); font-weight: 400; }
.wcm-input:focus, .wcm-select:focus, .wcm-textarea:focus { border-color: var(--sky); box-shadow: 0 0 0 3px var(--sky-wash); }
.wcm-input:disabled, .wcm-select:disabled, .wcm-textarea:disabled, .wcm-input[readonly] { background: var(--sub); color: var(--ink-2); cursor: default; opacity: 1; }

.wcm-photo { position: relative; height: 136px; display: flex; align-items: center; justify-content: center; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--sub); text-align: center; }
.wcm-photo.border-dashed { border-style: dashed; }
.wcm-photo__empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 12px; pointer-events: none; }
.wcm-photo__empty i { font-size: 18px; color: var(--faint); }
.wcm-photo__empty p { margin: 0; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.wcm-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; cursor: zoom-in; }
.wcm-photo__btn { position: absolute; z-index: 2; display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: rgba(255, 255, 255, .96); color: var(--ink); font-size: 12px; font-weight: 500; cursor: pointer; }
.wcm-photo__btn > i { font-size: 11px; color: var(--ink-2); }
.wcm-photo__btn:hover { background: #fff; border-color: #BCCBDD; }
.wcm-photo__btn--view { left: 8px; bottom: 8px; }
.wcm-photo__btn--upload { right: 8px; bottom: 8px; }
.wcm-photo__btn--remove { right: 8px; top: 8px; width: 26px; padding: 0; justify-content: center; }
.wcm-photo__btn--remove > i { color: var(--rose-ink); }

/* Chip trạng thái — chỉ dùng cho trạng thái có nghĩa */
.wcm-status { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--tile); color: var(--ink-2); }
.wcm-status--ok { background: var(--mint-wash); color: var(--mint-ink); }
.wcm-status--warn { background: var(--amber-wash); color: var(--amber-ink); }
.wcm-status--bad { background: var(--rose-wash); color: var(--rose-ink); }
.wcm-status--lg { height: 26px; padding: 0 10px; font-size: 12.5px; }
.wcm-tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; background: var(--tile); color: var(--ink-2); font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.wcm-tag--strong { color: var(--ink); font-weight: 600; }

/* ---- Màn Phân tích ---- */
.wcm-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 1024px) {
  .wcm-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .wcm-span-2 { grid-column: span 2; }
}
.wcm-chart-box { position: relative; width: 100%; }
.wcm-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 768px) { .wcm-split { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } }
.wcm-legend { display: grid; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.wcm-legend__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink-2); }
.wcm-legend__name { display: flex; align-items: center; gap: 8px; }
.wcm-legend__name::before { content: ''; width: 10px; height: 10px; border-radius: 3px; background: var(--dot); flex: none; }
.wcm-legend__value { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wcm-legend__value small { font-size: 12px; font-weight: 500; color: var(--ink-2); margin-left: 4px; }

.wcm-regionlist { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.wcm-regionlist__head { display: flex; justify-content: space-between; padding: 0 12px 4px; font-size: 12px; font-weight: 500; color: var(--faint); }
.wcm-region-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  color: var(--ink); font-size: 13px; font-weight: 500; text-align: left; cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.wcm-region-btn:hover { border-color: var(--line-strong); background: #FAFBFD; }
.wcm-region-btn.is-active { border-color: #BFD3FA; background: var(--sky-wash); color: var(--sky-ink); font-weight: 600; }
.wcm-region-btn__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wcm-region-btn__nums { display: flex; align-items: center; gap: 12px; flex: none; font-variant-numeric: tabular-nums; }
.wcm-region-btn__nums span { color: var(--ink-2); font-weight: 500; }
.wcm-region-btn__nums b { min-width: 44px; text-align: right; font-weight: 600; color: var(--ink); }
.wcm-region-btn.is-active .wcm-region-btn__nums span, .wcm-region-btn.is-active .wcm-region-btn__nums b { color: var(--sky-ink); }

.wcm-province { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 1024px) { .wcm-province { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); } }
.wcm-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.wcm-province .wcm-table-wrap { max-height: 420px; }
.wcm-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.wcm-table th { position: sticky; top: 0; z-index: 1; padding: 9px 12px; background: var(--sub); border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--ink-2); text-align: left; white-space: nowrap; }
.wcm-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); color: var(--ink); white-space: nowrap; }
.wcm-table tbody tr:last-child td { border-bottom: 0; }
.wcm-table tbody tr:hover td { background: #FAFBFD; }
.wcm-table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.wcm-table .is-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.wcm-table .is-sub { display: block; font-size: 11.5px; color: var(--ink-2); }
.wcm-province-chart { border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-height: 420px; }

/* ---- Hộp thoại ---- */
.wcm-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(38, 54, 74, .45); overscroll-behavior: contain; }
.wcm-modal__box { position: relative; width: 100%; max-width: 460px; max-height: min(88vh, 760px); overflow: auto; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 60px -24px rgba(38, 54, 74, .4); }
.wcm-modal__close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--faint); cursor: pointer; }
.wcm-modal__close:hover { background: var(--tile); color: var(--ink); }
.wcm-modal__head { display: flex; align-items: center; gap: 12px; padding-right: 32px; margin-bottom: 10px; }
.wcm-modal__icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 50%; font-size: 15px; background: var(--sky-wash); color: var(--sky-ink); }
/* Icon do từng lời gọi truyền vào kèm class màu Tailwind: bỏ màu riêng, lấy màu theo tông hộp thoại. */
.wcm-modal__icon i { color: inherit !important; }
.wcm-modal__icon[data-tone="error"] { background: var(--rose-wash); color: var(--rose-ink); }
.wcm-modal__icon[data-tone="warn"] { background: var(--amber-wash); color: var(--amber-ink); }
.wcm-modal__icon[data-tone="success"] { background: var(--mint-wash); color: var(--mint-ink); }
.wcm-modal__title { margin: 0; font-size: 18px; font-weight: 600; color: var(--ink); }
.wcm-modal__message { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--ink-2); white-space: pre-line; }
.wcm-modal__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.wcm-modal__password { width: 100%; margin-top: 14px; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; font-size: 14px; letter-spacing: .2em; text-align: center; outline: none; }
.wcm-modal__password:focus { border-color: var(--sky); box-shadow: 0 0 0 3px var(--sky-wash); }
.wcm-modal__error { margin: 8px 0 0; font-size: 12.5px; font-weight: 500; color: var(--rose-ink); }

/* Xem ảnh phóng to */
.wcm-lightbox { position: fixed; inset: 0; z-index: 120; align-items: center; justify-content: center; padding: 16px; background: rgba(20, 28, 40, .82); }
.wcm-lightbox__inner { position: relative; max-width: 1100px; width: 100%; max-height: 92vh; display: flex; align-items: center; justify-content: center; }
.wcm-lightbox img { max-width: 100%; max-height: 88vh; object-fit: contain; border-radius: 12px; background: #fff; }
.wcm-lightbox__close { position: absolute; top: -10px; right: -10px; z-index: 2; width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--ink); cursor: pointer; }
.wcm-lightbox__loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px; color: #fff; font-size: 13px; font-weight: 500; }

/* Thông báo góc màn hình */
.wcm-toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; display: flex; align-items: flex-start; gap: 12px; width: min(380px, calc(100vw - 32px)); padding: 12px 16px 12px 14px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--mint); border-radius: 10px; box-shadow: var(--menu-shadow); }
.wcm-toast[data-tone="error"] { border-left-color: var(--rose); }
.wcm-toast > i { margin-top: 2px; font-size: 15px; color: var(--mint); }
.wcm-toast[data-tone="error"] > i { color: var(--rose); }
.wcm-toast p { margin: 0; }
.wcm-toast #toast-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.wcm-toast #toast-msg { margin-top: 2px; font-size: 12.5px; line-height: 1.45; color: var(--ink-2); }
@keyframes wcmToastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast-enter { animation: wcmToastIn .2s ease-out both; }

/* ---- Màn đăng nhập ----
   Lớp .wcm-auth-gate giữ tên cũ: auth.js bật tắt nó và qa/auth-flow-regression.test.js
   kiểm dòng bất biến ẩn cổng ngay dưới đây. */
.wcm-auth-gate { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; background: var(--paper); }
.wcm-auth-gate.hidden { display: none !important; }
.wcm-auth-card { width: min(100%, 430px); padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 60px -32px rgba(31, 36, 48, .35); }
.wcm-auth-logo { display: block; height: 40px; width: auto; margin: 0 0 18px -6px; }
.wcm-auth-title { margin: 0; font-size: 20px; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.wcm-auth-desc { margin: 6px 0 20px; font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.wcm-auth-label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.wcm-auth-input-wrap { position: relative; }
.wcm-auth-input-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--faint); pointer-events: none; }
.wcm-auth-input {
  width: 100%; height: 44px; padding: 0 44px 0 38px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 14px; outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.wcm-auth-input::placeholder { color: var(--faint); }
.wcm-auth-input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(232, 28, 36, .12); }
.wcm-auth-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--faint); cursor: pointer; }
.wcm-auth-toggle:hover { background: var(--tile); color: var(--ink); }
.wcm-auth-error { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--rose-wash); color: var(--rose-ink); font-size: 12.5px; font-weight: 500; line-height: 1.45; }
.wcm-auth-submit { margin-top: 14px; width: 100%; height: 44px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; background: var(--red); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; transition: background-color .15s ease; }
.wcm-auth-submit:hover:not(:disabled) { background: var(--red-deep); }
.wcm-auth-submit:disabled { opacity: .7; cursor: progress; }

/* ---- Thanh cuộn ---- */
.wcm-list__body::-webkit-scrollbar, .wcm-table-wrap::-webkit-scrollbar, .wcm-regionlist::-webkit-scrollbar { width: 8px; height: 8px; }
.wcm-list__body::-webkit-scrollbar-thumb, .wcm-table-wrap::-webkit-scrollbar-thumb, .wcm-regionlist::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 2px solid var(--surface); }

/* ---- Màn hẹp ---- */
@media (max-width: 1100px) {
  .wcm-chip--data { display: none; }
}
@media (max-width: 760px) {
  .wcm-topbar { padding: 0 12px; height: 54px; gap: 8px; }
  .wcm-topbar__logo { height: 24px; }
  .wcm-topbar__divider { display: none; }
  .wcm-topbar__left { gap: 8px; }
  .wcm-tab { padding: 0 9px; height: 34px; }
  .wcm-tab > span { display: none; }
  .wcm-role { display: none; }
  .wcm-logout span { display: none; }
  .wcm-logout { width: 32px; padding: 0; justify-content: center; }
  .wcm-main { padding: 16px; gap: 12px; }
  .wcm-view { gap: 12px; }
  .wcm-pagehead { padding: 14px 16px; }
  .wcm-pagehead__actions { width: 100%; }
  .wcm-pagehead__actions > .wcm-btn { flex: 1; }
  .wcm-pagehead__actions .wcm-menu-wrap { flex: 1; display: flex; }
  .wcm-pagehead__actions .wcm-menu-wrap > .wcm-btn { flex: 1; }
  .wcm-field, .wcm-field--search, .wcm-field--lookup { flex-basis: 100%; }
  .wcm-check { flex: 1 1 100%; justify-content: center; }
  .wcm-card { padding: 16px; }
  .wcm-card--flush { padding: 0; }
  .wcm-card__head { flex-direction: column; }
  .wcm-card__head--bar { padding: 14px 16px; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .wcm-card__desc { margin-left: 0; }
  .wcm-kpi__value { font-size: 20px; }
  .wcm-list { height: 560px; }
  .wcm-report { min-height: 0; }
  .wcm-report__body { padding: 14px 16px 16px; }
  .wcm-storehead { flex-direction: column; }
  .wcm-auth-card { padding: 22px; }
  .wcm-toast { right: 16px; bottom: 16px; }
}

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

/* Lớp "Đang cập nhật số liệu…" (DESIGN_SYSTEM.md §4.10) — cùng thông số app bảo trì:
   nền trang mờ nhẹ phía sau, thẻ trắng nhỏ ở giữa, vòng quay xanh 18px. */
.wcm-loading { position: fixed; inset: 0; z-index: 9000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(244, 247, 251, .7); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.wcm-loading.hidden { display: none !important; }
.wcm-loading__card { display: flex; align-items: center; gap: 12px; padding: 15px 20px; background: #FFFFFF; border-radius: 14px; font-size: 13px; font-weight: 600; color: #26364A; }
.wcm-loading__spinner { flex: none; width: 18px; height: 18px; border: 2.5px solid #E7EDF6; border-top-color: #4A84F4; border-radius: 50%; animation: wcm-loading-spin .7s linear infinite; }
@keyframes wcm-loading-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .wcm-loading__spinner { animation-duration: 2s; } }
@media print { .wcm-loading { display: none !important; } }
