/* =========================================================================
   SOFIA App — Avatar 12 năm
   Bảng màu vàng – cam – đen của SOFIA, bố cục 2 cột trên desktop.
   ========================================================================= */

:root {
  /* --- Font: MỘT stack duy nhất cho toàn bộ trang --------------------- */
  --font-sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial,
    "Noto Sans", "Liberation Sans", sans-serif;

  /* --- Màu ------------------------------------------------------------ */
  --yellow: #ffc60b;
  --yellow-soft: #ffe9a8;
  --yellow-tint: #fff8e3;
  --orange: #f28c1c;
  --orange-deep: #e2680f;
  --ink: #14110c;
  --ink-soft: #4a4238;
  --muted: #7b7062;
  --line: #ecd9a8;
  --line-soft: #eee7db;
  --surface: #ffffff;
  --canvas: #fdf7ea;
  --ok: #157f4a;
  --ok-bg: #e9f7ef;
  --err: #b32020;
  --err-bg: #fdecec;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(60, 42, 8, .09);
}

/* Font áp dụng cho MỌI phần tử, kể cả các control mà trình duyệt vốn dùng
   font hệ thống riêng (button, input, select, textarea, dialog...). */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  -webkit-text-size-adjust: 100%;
}

/**
 * `[hidden]` phải thắng MỌI quy tắc `display` của class.
 *
 * Quy tắc `[hidden] { display: none }` của trình duyệt có độ ưu tiên thấp hơn
 * một class selector. Thiếu dòng này, `.btn { display: inline-flex }` khiến nút
 * "Cài đặt" vẫn hiện với người dùng thường dù JS đã đặt `hidden = true` —
 * đúng loại lỗi mà tiêu chí 11 của Task cấm.
 */
[hidden] {
  display: none !important;
}

body,
h1, h2, h3, h4, h5, h6,
p, span, small, b, li, label, output, a,
button, input, select, textarea, optgroup, option, legend, dialog, fieldset,
.badge, .status, .step {
  font-family: var(--font-sans);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1100px 420px at 50% -180px, var(--yellow-soft) 0%, transparent 70%),
    var(--canvas);
  font-size: 15px;
  line-height: 1.5;
  /* Chặn horizontal overflow ở cấp trang */
  overflow-x: hidden;
}

.shell {
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: 16px;
}

img, canvas, svg { max-width: 100%; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 16px; top: 8px;
  z-index: 20;
  background: var(--ink); color: #fff;
  padding: 8px 12px; border-radius: 8px;
}

/* =========================================================================
   HEADER — compact: title 2 dòng cân đối, tối ưu khoảng trắng
   ========================================================================= */
.app-header {
  text-align: center;
  padding-top: 10px;
  padding-bottom: 4px;
}

.brand-logo {
  display: none;
}
.brand-fallback {
  display: none;
}

.app-title {
  margin: 0;
  font-weight: 800;
  letter-spacing: .01em;
  line-height: 1.18;
}
.app-title__line1 {
  display: block;
  font-size: clamp(19px, 2.6vw, 24px);
  font-weight: 800;
  color: var(--ink);
}
.app-title__line2 {
  display: block;
  font-size: clamp(19px, 2.6vw, 24px);
  font-weight: 800;
  background: linear-gradient(92deg, var(--orange-deep), var(--orange) 55%, #c9820c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.app-lede {
  display: none;
}

/* =========================================================================
   3 BƯỚC
   ========================================================================= */
.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 8px 0 0;
  padding: 0;
}
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.step__num {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--yellow), var(--orange));
  color: var(--ink);
  font-weight: 800;
  font-size: 13px;
}
.step__body { min-width: 0; }
.step__body b { display: block; font-size: 13.5px; line-height: 1.2; }
.step__body small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================================
   BỐ CỤC 2 CỘT
   ========================================================================= */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 16px;
  margin-top: 10px;
  align-items: start;
}

.card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  min-height: 28px;
}
.card__title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
}
.card__index { color: var(--orange-deep); }

/* =========================================================================
   CHỌN ẢNH
   ========================================================================= */
.picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1.5px dashed var(--yellow);
  border-radius: var(--radius-sm);
  background: var(--yellow-tint);
  cursor: pointer;
  text-align: center;
}
.picker:focus-within { outline: 2px solid var(--orange); outline-offset: 2px; }
.picker__icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: var(--orange-deep);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.picker__label { font-weight: 700; font-size: 13.5px; color: var(--ink); }
.picker__hint { color: var(--muted); font-size: 11.5px; }

/* =========================================================================
   KHUNG XEM TRƯỚC
   ========================================================================= */
.stage {
  position: relative;
  margin-top: 8px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #ffffff;
  max-width: 310px;
  margin-inline: auto;
}
.stage canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  /* Cho phép kéo bằng cảm ứng mà không bị trình duyệt cuộn trang */
  touch-action: none;
  cursor: grab;
}
.stage canvas:active { cursor: grabbing; }
.stage__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  margin: 0;
  padding: 12px;
  color: var(--muted);
  font-size: 12.5px;
}
.stage__hint {
  margin: 4px 0 6px;
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
}

/* =========================================================================
   SLIDER
   ========================================================================= */
.slider {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.slider label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.slider output { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: #e6ddcb;
  outline-offset: 4px;
}
input[type="range"]:disabled { opacity: .5; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--orange);
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--orange);
  cursor: pointer;
}

/* =========================================================================
   NÚT
   ========================================================================= */
.btn {
  /* font: inherit là chốt chặn để button không rơi về font mặc định */
  font: inherit;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 13.5px;
}
.btn svg {
  width: 16px; height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--orange-deep); outline-offset: 2px; }

.btn--primary {
  background: linear-gradient(180deg, #ffd233, var(--yellow));
  color: var(--ink);
  box-shadow: 0 6px 16px rgba(242, 140, 28, .28);
}
.btn--primary:hover:not(:disabled) { filter: brightness(1.04); }

.btn--dark { background: var(--ink); color: #fff; }
.btn--dark:hover:not(:disabled) { background: #2b241a; }

.btn--ghost {
  background: var(--yellow-tint);
  border-color: var(--line);
}
.btn--ghost:hover:not(:disabled) { background: #fff2cf; }

.btn--chip {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12.5px;
  background: var(--yellow-tint);
  border-color: var(--line);
}
.btn--chip svg { width: 14px; height: 14px; }

.btn--link {
  min-height: auto;
  padding: 2px 4px;
  font-weight: 600;
  font-size: 13px;
  color: var(--orange-deep);
  text-decoration: underline;
}

.btn--icon {
  min-height: 32px;
  width: 32px;
  padding: 0;
  border-color: var(--line-soft);
  background: #fff;
}
.btn--icon svg { width: 15px; height: 15px; }
.btn--icon.is-danger { color: var(--err); }

.btn--block { width: 100%; margin-top: 8px; }

.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 4px;
}
.button-row--end {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

/* =========================================================================
   FORM
   ========================================================================= */
.field { margin-bottom: 8px; }
.field label {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: 600;
}
.req { color: var(--err); }

/* Gợi ý dưới ô chọn — dùng cho quan hệ Chi nhánh → Phòng ban */
.field__hint {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}
.field__hint--warn { color: var(--orange-deep); font-weight: 600; }

select:disabled {
  background-color: #f7f4ee;
  color: var(--muted);
  cursor: not-allowed;
}

input[type="text"],
input[type="password"],
select,
textarea {
  font: inherit;
  color: var(--ink);
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 13.5px;
}
select {
  /* mũi tên riêng để hình thức giống nhau trên mọi trình duyệt */
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237b7062' 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 10px center;
  background-size: 16px;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
  border-color: var(--orange);
}
::placeholder { color: #a89c8b; }

/* =========================================================================
   TRẠNG THÁI & LƯU Ý
   ========================================================================= */
.status {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--ok-bg);
  border: 1px solid #bfe6cf;
  color: var(--ok);
}
.status--error {
  background: var(--err-bg);
  border-color: #f2c4c4;
  color: var(--err);
}
.status--busy {
  background: var(--yellow-tint);
  border-color: var(--line);
  color: var(--ink-soft);
}

.note {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}
.note h3 { margin: 0 0 4px; font-size: 13px; }
.note p { margin: 0 0 3px; color: var(--muted); font-size: 11.5px; line-height: 1.35; }

/* =========================================================================
   TRẠNG THÁI CHƯƠNG TRÌNH AVATAR

   Slug không tồn tại, chương trình đang ngừng sử dụng hoặc mở `/avatar` khi
   chưa chọn chương trình — cả ba đều phải nói rõ, không im lặng và tuyệt đối
   không tự nhảy sang một chương trình khác.
   ========================================================================= */
.campaign-state {
  margin-top: 10px;
}
.campaign-state__box {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.campaign-state__title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}
.campaign-state__msg {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.45;
}
.campaign-state__msg code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--yellow-tint);
  border: 1px solid var(--line);
}
.campaign-state__list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.campaign-state__list a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--yellow-tint);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.campaign-state__list a:hover { background: #fff2cf; }

/* =========================================================================
   QUẢN TRỊ CÀI ĐẶT
   ========================================================================= */
.admin {
  margin-top: 18px;
  padding-block: 16px;
}
/* Thanh phiên Admin — luôn nằm đầu khu vực Cài đặt */
.admin__session {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--yellow-tint);
}
.admin__session-user {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.admin__session-user b { color: var(--ink); }

.admin__intro {
  margin-bottom: 16px;
}
.admin__intro-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.admin__intro h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}
.admin__intro h2 svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.admin__sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.admin__who {
  margin: 0 !important;
  font-size: 13px;
}

.admin__group {
  margin-top: 20px;
}
.admin__group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.admin__group-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  color: var(--orange-deep);
  letter-spacing: .06em;
}
.admin__group-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.admin__group-action { margin-left: auto; }

.admin__group-note {
  margin: -6px 0 12px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}
.admin__group-note code {
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--yellow-tint);
  border: 1px solid var(--line);
  font-size: 12px;
}

.admin__assets-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
/* Khung Avatar đã chuyển về từng chương trình nên nhóm DÙNG CHUNG chỉ còn Logo. */
.admin__assets-grid--single { grid-template-columns: minmax(0, 480px); }

.asset-card {
  display: flex;
  flex-direction: column;
}
.asset-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.asset-card__title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
}
.asset-card__scope {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
}
.asset-card__desc {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.asset-card__preview-box {
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line-soft);
  background: #fdfbf7;
}
.asset-card__preview-canvas {
  width: 100%;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 8px;
}
.asset-card__img {
  max-width: 90%;
  max-height: 124px;
  object-fit: contain;
}
.asset-card__empty-text {
  color: var(--muted);
  font-size: 12.5px;
  font-style: italic;
  text-align: center;
  padding: 8px;
}

.checkerboard {
  background-color: #faf7f2;
  background-image:
    linear-gradient(45deg, #eee3d1 25%, transparent 25%),
    linear-gradient(-45deg, #eee3d1 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eee3d1 75%),
    linear-gradient(-45deg, transparent 75%, #eee3d1 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

.asset-card__upload {
  margin-bottom: 6px;
}
.btn--block-sm {
  width: 100%;
}
.asset-card__actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.asset-card__manage-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

/* Tình trạng vùng đặt ảnh của Khung Avatar */
.asset-card__window {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: #fdfbf7;
}
.asset-card__window-msg {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.asset-card__window-msg.is-ok { color: var(--ok); }
.asset-card__window-msg.is-warn { color: var(--orange-deep); font-weight: 600; }
.asset-card__window-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  cursor: pointer;
}
.asset-card__window-toggle input {
  width: 16px; height: 16px;
  flex: none;
  accent-color: var(--orange);
  cursor: pointer;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge--active {
  background: #e6f7ec;
  color: #147d46;
  border: 1px solid #b7e8c7;
}
.badge--inactive {
  background: #f5f3ef;
  color: #887d70;
  border: 1px solid #ded8cc;
}
.badge--preview {
  background: #fff8e3;
  color: #b36b00;
  border: 1px solid #fedb7c;
}

/**
 * Hai bảng danh mục xếp DỌC, mỗi bảng chiếm trọn chiều ngang.
 *
 * Từ Vòng 3, bảng Phòng ban có thêm cột "Chi nhánh / Khu vực". Nhét 6 cột vào
 * nửa màn hình khiến cột "Thao tác" bị đẩy ra ngoài, Admin phải cuộn ngang mới
 * bấm được nút Sửa / Xoá. Xếp dọc thì cả hai bảng luôn đủ chỗ, kể cả khi tên
 * Chi nhánh hoặc Phòng ban dài.
 */
.admin__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.catalog {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.catalog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.catalog__head h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
/* Bảng có thể cuộn ngang TRONG khối của nó, không đẩy tràn cả trang */
.catalog__scroll { overflow-x: auto; }

.catalog table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.catalog th,
.catalog td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
.catalog th {
  background: var(--yellow-tint);
  font-weight: 700;
  font-size: 12px;
  color: var(--ink-soft);
}
.catalog td.cell-name { white-space: normal; min-width: 130px; }
.catalog td.cell-parent { white-space: normal; min-width: 92px; color: var(--ink-soft); }
.catalog .cell-parent__missing {
  color: var(--orange-deep);
  font-style: italic;
  font-size: 12px;
}
.catalog tr:last-child td { border-bottom: 0; }
.catalog tr.is-inactive td.cell-name { color: var(--muted); text-decoration: line-through; }

/* Giữ ô là table-cell: đặt `display: flex` lên <td> sẽ phá bố cục hàng và
   đẩy các nút xuống thành nhiều dòng. Nút vốn đã là inline-flex nên chỉ cần
   chặn xuống dòng và tạo khoảng cách. */
.catalog .cell-actions { white-space: nowrap; }
.catalog .cell-actions .btn { vertical-align: middle; }
.catalog .cell-actions .btn + .btn { margin-left: 6px; }

.toggle {
  position: relative;
  display: inline-block;
  width: 40px; height: 22px;
  flex: none;
}
.toggle input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  margin: 0; opacity: 0; cursor: pointer;
}
.toggle span {
  position: absolute; inset: 0;
  border-radius: 999px;
  background: #cfc7ba;
  transition: background .15s ease;
  pointer-events: none;
}
.toggle span::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s ease;
}
.toggle input:checked + span { background: #22b35e; }
.toggle input:checked + span::after { transform: translateX(18px); }
.toggle input:focus-visible + span { outline: 2px solid var(--orange-deep); outline-offset: 2px; }

.catalog .in-use-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--yellow-tint);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
}

/* --- Bảng chương trình Avatar ----------------------------------------- */
.catalog td.cell-campaign { white-space: normal; min-width: 150px; }
.cell-campaign__name { font-weight: 700; }
.cell-campaign__slug {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
}
.campaign-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.campaign-link__url {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--orange-deep);
  font-size: 12.5px;
}
.campaign-frame-tag {
  font-size: 12px;
  color: var(--ok);
  font-weight: 600;
}
.campaign-frame-tag.is-missing { color: var(--err); }

/* Khu chọn khung trong hộp thoại chương trình */
.campaign-frame {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.campaign-frame__preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.campaign-frame__preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.campaign-frame__pick { min-width: 0; }

.catalog__empty { padding: 14px; color: var(--muted); font-size: 13px; }
.catalog__error {
  margin: 0;
  padding: 10px 14px;
  background: var(--err-bg);
  color: var(--err);
  font-size: 12.5px;
}

/* =========================================================================
   DIALOG
   ========================================================================= */
.dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(30, 20, 0, .28);
}
/* Biểu mẫu chương trình Avatar có nhiều trường hơn nên cần rộng hơn một chút. */
.dialog--wide {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.dialog::backdrop { background: rgba(20, 17, 12, .45); }
.dialog__body { padding: 18px; }
.dialog__body h2 { margin: 0 0 14px; font-size: 17px; }

/* =========================================================================
   FOOTER
   ========================================================================= */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-block: 18px 26px;
  color: var(--muted);
  font-size: 12.5px;
}
.app-footer p { margin: 0; }

/* =========================================================================
   MOBILE ~375px & TABLET — xếp dọc, header gọn, không tràn ngang
   ========================================================================= */
@media (max-width: 860px) {
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .stage { max-width: 360px; }
  .admin__assets-grid { grid-template-columns: minmax(0, 1fr); }
  .admin__grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  body { font-size: 14px; }
  .shell { padding-inline: 12px; }

  .app-header { padding-top: 8px; padding-bottom: 2px; }
  .app-title__line1,
  .app-title__line2 {
    font-size: clamp(17px, 4.8vw, 20px);
  }

  .steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 6px;
  }
  .step {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 3px;
    padding: 6px 4px;
  }
  .step__num { width: 22px; height: 22px; font-size: 12px; }
  .step__body b { font-size: 12px; }
  .step__body small { display: none; }

  .card { padding: 12px; }
  .picker {
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
  }
  .stage { max-width: 100%; }
  .slider { grid-template-columns: 58px minmax(0, 1fr) 38px; gap: 6px; }

  .btn { min-height: 42px; }
  input[type="text"],
  input[type="password"],
  select { min-height: 42px; }
}
