:root {
  --bg: #eef1f6;
  --bg-2: #e4e8f0;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: #e0e4ea;
  --border-strong: #cfd5de;
  --text: #121620;
  --muted: #5b6472;
  --primary: #4f46e5;
  --primary-2: #6366f1;
  --primary-soft: #eef0fe;
  --primary-text: #ffffff;
  --accent: #0ea5e9;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fcf3e3;
  --bad: #d12b2b;
  --bad-soft: #fdecec;
  --screen-bg: #0d0f12;
  --brand-grad: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #0ea5e9 100%);
  --shadow: 0 1px 2px rgb(16 22 40 / 6%), 0 4px 16px rgb(16 22 40 / 6%);
  --shadow-lg: 0 12px 40px rgb(16 22 40 / 18%);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e13;
    --bg-2: #0f1218;
    --surface: #171a21;
    --surface-2: #20242e;
    --border: #2a2f3a;
    --border-strong: #3a4150;
    --text: #e8eaef;
    --muted: #97a0ad;
    --primary: #6d6af5;
    --primary-2: #7c7cf8;
    --primary-soft: #1e2030;
    --accent: #38bdf8;
    --ok: #4ade80;
    --ok-soft: #14271c;
    --warn: #f59e0b;
    --warn-soft: #2a2211;
    --bad: #f87171;
    --bad-soft: #2a1718;
    --brand-grad: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #0891b2 100%);
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 6px 20px rgb(0 0 0 / 30%);
    --shadow-lg: 0 16px 48px rgb(0 0 0 / 55%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; margin: 0; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

input {
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}
input:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }

.btn {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.icon { padding: 6px 10px; }
.btn:disabled { opacity: .5; cursor: default; }

.toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; white-space: nowrap; }

/* Đăng nhập */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }

/* Thanh trên */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.conn { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); display: inline-block; }
.conn.on { background: var(--ok); }
.counts { color: var(--muted); }
#search { flex: 1 1 220px; max-width: 360px; }
#logout { margin-left: auto; }

.bulkbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.bulk-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }

/* Lưới máy */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  padding: 16px;
}
.tile {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.tile:hover { border-color: var(--primary); }
.tile.selected { outline: 2px solid var(--primary); outline-offset: -1px; }
.tile .shot {
  position: relative;
  aspect-ratio: 9 / 16;
  background: var(--screen-bg);
}
.tile .shot img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile .offline {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 8px;
  background: rgb(0 0 0 / 62%);
  color: #fff;
  font-size: 12px;
}
.tile .check {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 45%);
  border-radius: 6px;
}
.tile .check input { width: 16px; height: 16px; margin: 0; cursor: pointer; }
.tile .warns { position: absolute; top: 6px; right: 6px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.tile .warn {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--warn);
  color: #fff;
}
.tile .meta { padding: 8px 10px; display: grid; gap: 2px; }
.tile .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.tile .name .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.tile.online .name .dot { background: var(--ok); }
.tile .stats { display: flex; gap: 8px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.hot { color: var(--bad) !important; font-weight: 700; }
.warm { color: var(--warn) !important; }
.low { color: var(--bad) !important; }

.empty { text-align: center; padding: 60px 16px; }
.empty h2 { margin: 0 0 6px; }

/* Bảng điều khiển 1 máy */
.panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgb(0 0 0 / 55%);
  display: grid;
  place-items: center;
  padding: 16px;
}
.panel-inner {
  background: var(--surface);
  border-radius: 14px;
  display: flex;
  max-width: 100%;
  max-height: calc(100vh - 32px);
  overflow: hidden;
  box-shadow: 0 10px 40px rgb(0 0 0 / 35%);
}
.screen-wrap {
  position: relative;
  background: var(--screen-bg);
  display: grid;
  place-items: center;
  padding: 12px;
}
#screen {
  display: block;
  max-height: calc(100vh - 56px);
  max-width: min(60vw, 560px);
  touch-action: none;
  cursor: crosshair;
  border-radius: 6px;
  background: #000;
}
.screen-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #cfd3da;
  pointer-events: none;
  text-align: center;
  padding: 16px;
}
.ripple {
  position: absolute;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  border: 2px solid #fff;
  pointer-events: none;
  animation: ripple .5s ease-out forwards;
}
@keyframes ripple { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ripple { animation-duration: .01s; } }

.side {
  width: 320px;
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.side h3 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.side-head { display: flex; gap: 6px; align-items: center; }
.name-input { flex: 1; font-weight: 700; font-size: 16px; border-color: transparent; background: transparent; padding-left: 4px; }
.name-input:hover { border-color: var(--border); }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.btn-grid .btn { white-space: normal; min-width: 0; }
.row { display: flex; gap: 6px; }
.row input { flex: 1; }
.field { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.field input { flex: 1; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.ok { color: var(--ok); }
.pill.bad { color: var(--bad); }
.info { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; word-break: break-all; font-variant-numeric: tabular-nums; }
.hint { font-size: 12px; color: var(--muted); margin: 0; }

/* Danh sách app trên máy */
/* minmax(0, 1fr): dòng chữ dài không xuống dòng không được kéo cột rộng ra, chữ sẽ bị cắt bớt */
.app-list, .apk-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.app-list li, .apk-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.app-list .txt, .apk-list .txt { flex: 1; min-width: 0; }
.app-list .t1, .apk-list .t1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-list .t2, .apk-list .t2 { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-list .btn, .apk-list .btn { padding: 4px 8px; font-size: 12px; }

/* Kho APK */
.modal {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgb(0 0 0 / 55%);
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal-card {
  width: min(620px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: 14px;
  padding: 16px 18px;
  display: grid;
  gap: 10px;
  box-shadow: 0 10px 40px rgb(0 0 0 / 35%);
}
.modal-card h2 { margin: 0; font-size: 18px; flex: 1; }
.modal-card p { margin: 0; }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--primary); transition: width .2s; }

.toasts { position: fixed; bottom: 16px; right: 16px; z-index: 30; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 13px;
}
.toast.err { background: var(--bad); color: #fff; }

@media (max-width: 820px) {
  .panel { padding: 0; }
  .panel-inner { flex-direction: column; border-radius: 0; width: 100%; height: 100%; max-height: 100vh; overflow-y: auto; }
  #screen { max-width: 100%; max-height: 70vh; }
  .side { width: 100%; overflow: visible; }
  .bulk-actions { margin-left: 0; }
  #logout { margin-left: 0; }
}

/* ---- Đăng nhập: tab + form ---- */
.tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.tab {
  flex: 1; padding: 8px; border: 0; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--muted); font: inherit; font-weight: 600;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.auth-form { display: grid; gap: 10px; }

/* ---- Thanh trên: chọn cửa hàng, tên người dùng ---- */
select {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-width: 0; cursor: pointer;
}
.store-filter { max-width: 180px; }
.user-label { color: var(--muted); font-size: 13px; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }

/* ---- Cửa hàng ---- */
.modal-card.wide { width: min(760px, 100%); }
.small { font-size: 12px; }
.store-list { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 14px; }
.store-list > li { border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: grid; gap: 8px; }
.store-row { display: flex; gap: 8px; align-items: center; }
.store-row .name-input { flex: 1; font-weight: 600; }
.key-row { display: flex; gap: 6px; }
.key-input { flex: 1; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: var(--surface-2); }
.store-list .field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }

/* ---- Trang quản trị ---- */
.admin-list { list-style: none; margin: 4px 0 10px; padding: 0; display: grid; gap: 6px; }
.admin-list li {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface-2); border-radius: 8px; padding: 8px 10px;
}
.admin-list .txt { flex: 1; min-width: 0; }
.admin-list .t1 { font-weight: 600; display: flex; gap: 6px; align-items: center; }
.admin-list .t2 { font-size: 12px; color: var(--muted); }
.modal-card h3 { margin: 6px 0 0; font-size: 14px; }
.modal-card hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.admin-list .pill { font-size: 11px; padding: 1px 6px; }

/* ============================================================
   NÂNG CẤP GIAO DIỆN — lớp hoàn thiện (thương mại)
   ============================================================ */

body { background: radial-gradient(1200px 600px at 100% -10%, var(--bg-2), var(--bg)) fixed; }

/* Nút bấm cao cấp hơn */
.btn {
  border-radius: 10px;
  font-weight: 600;
  transition: background .15s, box-shadow .15s, transform .05s, border-color .15s;
}
.btn:hover { border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background-image: var(--brand-grad);
  border: 0;
  box-shadow: 0 2px 8px rgb(79 70 229 / 35%);
}
.btn.primary:hover { filter: brightness(1.05); box-shadow: 0 4px 14px rgb(79 70 229 / 45%); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: transparent; }

input, select { border-radius: 10px; transition: border-color .15s, box-shadow .15s; }
input:focus-visible, select:focus-visible { box-shadow: 0 0 0 3px var(--primary-soft); }

/* Thanh trên: logo gradient + nền mờ */
.topbar {
  padding: 12px 20px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgb(16 22 40 / 3%);
}
.brand { font-size: 17px; letter-spacing: -.01em; gap: 10px; }
.brand::before {
  content: "";
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--brand-grad);
  box-shadow: 0 2px 8px rgb(79 70 229 / 45%);
  flex: none;
}
.conn { box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 22%, transparent); }
.conn.on { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.user-label {
  background: var(--surface-2); padding: 4px 10px; border-radius: 999px;
  font-weight: 600; color: var(--text); max-width: 180px;
}
.bulkbar { padding: 12px 20px; background: color-mix(in srgb, var(--surface) 55%, transparent); }
.grid { padding: 20px; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); }

/* Thẻ máy: bo tròn, nổi, hover nhấc nhẹ */
.tile {
  border-color: transparent;
  box-shadow: var(--shadow);
  transition: transform .14s, box-shadow .14s, outline-color .14s;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: transparent; }
.tile.selected { outline: 2.5px solid var(--primary); outline-offset: 0; }
.tile .meta { padding: 10px 12px 12px; }
.tile .name { font-size: 13.5px; }
.tile .name .dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--muted) 20%, transparent); }
.tile.online .name .dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.tile .check { background: rgb(0 0 0 / 35%); backdrop-filter: blur(2px); border-radius: 8px; }
.tile .warn { box-shadow: 0 1px 4px rgb(0 0 0 / 25%); border-radius: 6px; }

/* Đăng nhập: thẻ cao cấp, dải gradient trên đỉnh */
.login { background: radial-gradient(900px 500px at 50% -20%, color-mix(in srgb, var(--primary) 16%, transparent), transparent); }
.login-card {
  width: min(400px, 100%);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px 28px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 5px; background: var(--brand-grad);
}
.login-card h1 {
  font-size: 24px; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; margin-bottom: 2px;
}
.login-card h1::before {
  content: ""; width: 30px; height: 30px; border-radius: 9px; background: var(--brand-grad);
  box-shadow: 0 3px 10px rgb(79 70 229 / 45%);
}
.login-card .btn.primary { padding: 11px; font-size: 15px; }

/* Nhãn trạng thái hạn dùng */
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px;
  white-space: nowrap; line-height: 1.5;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

/* Banner dùng thử / hết hạn */
.banner {
  margin: 14px 20px 0; padding: 11px 16px; border-radius: 12px; font-size: 13.5px;
  border: 1px solid transparent;
}
.banner.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.banner b { font-weight: 800; }

/* Trang quản trị: hàng cửa hàng + nút gia hạn */
.admin-store { flex-wrap: wrap; }
.admin-store .activate { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; width: 100%; margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--border); }
.admin-store .activate .btn { padding: 4px 10px; font-size: 12px; }

/* Modal: bo tròn & đổ bóng mạnh hơn */
.modal-card { border-radius: 18px; box-shadow: var(--shadow-lg); padding: 20px 22px; }
.modal-card h2 { letter-spacing: -.01em; }
.store-list > li { border-color: var(--border); border-radius: 14px; }
.store-row { flex-wrap: wrap; }

/* ---- Kịch bản test: ghi & phát lại ---- */
.btn.recording {
  background: var(--bad); color: #fff; border-color: transparent;
  animation: recpulse 1.1s ease-in-out infinite;
}
@keyframes recpulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 55%, transparent); } 50% { box-shadow: 0 0 0 6px transparent; } }
@media (prefers-reduced-motion: reduce) { .btn.recording { animation: none; } }
#recHint { color: var(--bad); font-weight: 700; }
.rec-steps { margin: 8px 0 4px; padding-left: 22px; max-height: 180px; overflow-y: auto; font-size: 12px; line-height: 1.5; }
#recPlayRow { margin-top: 6px; }
#recResult { margin: 6px 0 0; font-weight: 600; }
#recResult.ok { color: var(--ok, #15803d); }
#recResult.bad { color: var(--bad); }

/* Ô ẩn nhận bàn phím máy tính: gõ tới đâu gửi xuống máy tới đó */
.kb-capture { position: absolute; left: 12px; bottom: 12px; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.kb-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 4px 10px; border-radius: 999px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgb(0 0 0 / 65%); color: #fff; pointer-events: none;
}
.kb-hint.on { background: var(--primary); }
@media (pointer: coarse) { .kb-hint { display: none; } }
@media (pointer: fine) { #textSection { display: none; } }

/* Hộp thoại trong trang, nằm trên mọi bảng khác */
.ask-modal { z-index: 28; }
.ask-card { width: min(420px, 100%); display: grid; gap: 12px; }
.ask-actions { justify-content: flex-end; }

.view-quality { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.view-quality select { padding: 3px 6px; font-size: 12px; width: auto; }
.ed-tag { font-size: 11px; font-weight: 600; color: var(--primary); margin-right: 4px; }

.run-box {
  margin-top: 10px; padding: 14px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface-2); display: grid; gap: 10px;
}
.run-box h3 { margin: 0; font-size: 15px; }
.run-cfg { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.run-cfg .field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.run-cfg #runRepeat { width: 80px; }
.run-summary { min-height: 1.2em; }
.run-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 320px; overflow-y: auto; }
.run-results li {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border-radius: 8px; padding: 8px 10px;
}
.run-results .rr-name { font-weight: 600; min-width: 120px; }

/* ---- Trình dựng kịch bản ---- */
.editor {
  margin-top: 10px; padding: 14px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface-2); display: grid; gap: 10px;
}
.editor h3 { margin: 0; font-size: 15px; flex: 1; }
.ed-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; counter-reset: step; }
.ed-step {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px;
}
.ed-step::before {
  counter-increment: step; content: counter(step);
  width: 20px; height: 20px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none;
}
.ed-ico { font-size: 15px; }
.ed-name { font-weight: 600; min-width: 68px; }
.ed-body { flex: 1; min-width: 140px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ed-inp { padding: 5px 8px; font-size: 13px; width: 100%; max-width: 320px; }
.ed-inp[type="number"] { width: 64px; }
.ed-sub { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.ed-ops { display: flex; gap: 2px; margin-left: auto; }
.ed-ops .btn { padding: 3px 8px; font-size: 13px; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 0; border-top: 1px dashed var(--border); }
.palette .btn { padding: 5px 10px; font-size: 12.5px; }

/* ADB trong bảng điều khiển */
.adb-preset { width: 100%; margin: 8px 0 6px; }
.adb-output {
  margin: 8px 0 6px; padding: 8px 10px; max-height: 220px; overflow: auto; border-radius: 8px;
  background: #111827; color: #e5e7eb; font: 12px/1.45 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
}
.adb-output.err { color: #fecaca; }

/* Bảng dữ liệu của kịch bản */
.ed-data { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.ed-data-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ed-data-head h4 { margin: 0; font-size: 14px; flex: 1; min-width: 150px; }
.ed-data-wrap { overflow-x: auto; }
.ed-data-table { border-collapse: collapse; width: 100%; min-width: 420px; font-size: 13px; }
.ed-data-table th, .ed-data-table td { padding: 3px; text-align: left; vertical-align: middle; }
.ed-data-table input, .ed-data-table select { width: 100%; min-width: 90px; padding: 5px 8px; font-size: 13px; box-sizing: border-box; }
.ed-col { display: flex; align-items: center; gap: 2px; }
.ed-col input { font-weight: 600; }
.ed-data-table .btn.icon { padding: 3px 7px; font-size: 12px; }
.ed-vars { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ed-vars .btn { padding: 3px 8px; font-size: 12px; font-family: ui-monospace, Consolas, monospace; }

/* Kho ảnh */
.image-list li { display: flex; align-items: center; gap: 8px; }
.image-list .txt { flex: 1; min-width: 0; }
.image-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; background: var(--surface-2); flex: none; }
