/* Trang sửa thông số game (design.html). Dùng biến màu của style.css. */

:root {
  --chg: #d29922;
  --chg-bg: rgba(210, 153, 34, 0.13);
  --chg-line: rgba(210, 153, 34, 0.55);
}

.dz-header__inner { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.dz-header__links { display: flex; gap: 8px; flex-wrap: wrap; }
.dz-link a { color: var(--accent); font-weight: 600; }
.dz-main { max-width: 1280px; padding-bottom: 120px; }
/* A table whose columns do not fit 1280px (labels: wide) takes the whole window and packs its cells tighter. */
.dz-main--wide { max-width: none; }
@media (min-width: 821px) { .dz-main--wide .dz-layout { grid-template-columns: 220px minmax(0, 1fr); } }
.dz-main--wide .dz-grid__name:has(.dz-row__sprite) { min-width: 190px; }
.dz-main--wide .dz-grid .dz-input { min-width: 64px; }
.dz-main--wide .dz-grid select.dz-input { min-width: 116px; }

.dz-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 0 0 16px; padding: 12px 16px;
  color: var(--text); background: var(--danger-bg);
  border: 1px solid var(--danger); border-radius: 10px; font-size: 14px;
}
.dz-banner[hidden], .dz-notice[hidden] { display: none; }

.dz-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; }

/* ---- sidebar ---- */
.dz-side { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; padding-right: 4px; }
.dz-select {
  display: none; width: 100%; padding: 10px 12px; font: inherit; font-size: 15px;
  color: var(--text); background: var(--bg-card); border: 1px solid var(--border); border-radius: 9px;
}
.dz-nav { display: flex; flex-direction: column; gap: 2px; }
.dz-nav__group {
  margin: 16px 0 6px; padding: 0 10px; font-size: 12px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim);
}
.dz-nav__group:first-child { margin-top: 0; }
.dz-nav__item {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "t d" "c c";
  align-items: center; gap: 2px 8px; width: 100%; text-align: left; font: inherit;
  padding: 8px 10px; color: var(--text); background: transparent;
  border: 1px solid transparent; border-radius: 9px; cursor: pointer;
}
.dz-nav__item:hover { background: var(--bg-elev); }
.dz-nav__item.is-active { background: var(--bg-elev); border-color: var(--accent); }
.dz-nav__title { grid-area: t; font-size: 14px; font-weight: 600; }
.dz-dot { grid-area: d; width: 9px; height: 9px; border-radius: 50%; background: var(--chg); }
.dz-dot[hidden] { display: none; }
.dz-chip { grid-area: c; justify-self: start; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.dz-chip--live { color: var(--ok); background: var(--ok-bg); }
.dz-chip--missing { color: var(--text-dim); background: var(--bg); border: 1px solid var(--border); }

/* ---- main pane ---- */
.dz-pane { min-width: 0; }
.dz-loading { color: var(--text-dim); }
.dz-pane__head { margin-bottom: 16px; }
.dz-pane__title { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.01em; }
.dz-pane__blurb { margin: 6px 0 0; color: var(--text-dim); max-width: 70ch; }
.dz-pane__effect {
  margin: 10px 0 0; padding: 8px 12px; font-size: 14px; max-width: 70ch;
  background: var(--bg-elev); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px;
}
.dz-notice {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; padding: 12px 16px;
  font-size: 14px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
}
.dz-notice--warn { background: var(--warn-bg); border-color: var(--warn); }
#dz-missing { border-left: 3px solid var(--chg); }

/* ---- form (settings table / row detail) ---- */
.dz-form { display: flex; flex-direction: column; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 20px; }
.dz-form--detail { border: 0; background: transparent; padding: 4px 0; }
.dz-fld { display: grid; grid-template-columns: minmax(160px, 240px) minmax(0, 1fr); gap: 6px 20px; padding: 14px 0; border-bottom: 1px solid var(--border); align-items: start; }
.dz-form > .dz-fld:last-child, .dz-form > .dz-group:last-child { border-bottom: 0; }
.dz-fld__label { font-size: 14px; font-weight: 600; padding-top: 7px; }
.dz-fld__ctl { min-width: 0; }
.dz-help { margin: 4px 0 0; font-size: 12.5px; color: var(--text-dim); max-width: 64ch; }
.dz-group { margin: 12px 0; padding: 4px 16px 4px; border: 1px solid var(--border); border-radius: 10px; min-width: 0; }
.dz-group legend { padding: 0 8px; font-size: 13px; font-weight: 700; color: var(--text-dim); }
.dz-group .dz-fld:last-child { border-bottom: 0; }

/* ---- inputs ---- */
.dz-cell { display: block; width: fit-content; max-width: 100%; min-width: 0; padding: 2px; border-radius: 8px; }
.dz-grid .dz-cell, .dz-sub .dz-cell, .dz-slot .dz-cell { width: 100%; }
.dz-cell__box { display: flex; align-items: center; gap: 8px; }
.dz-input {
  width: 340px; max-width: 100%; min-width: 0; padding: 7px 10px; font: inherit; font-size: 14px;
  color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
.dz-input--num { width: 140px; max-width: 140px; text-align: right; font-variant-numeric: tabular-nums; }
.dz-cell--wide { width: 100%; }
.dz-input--area { width: 100%; max-width: 680px; resize: vertical; line-height: 1.45; }
.dz-input:focus-visible, .dz-search:focus-visible, .dz-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dz-unit { font-size: 13px; color: var(--text-dim); white-space: nowrap; }
.dz-readonly { font-size: 14px; color: var(--text-dim); padding: 7px 0; }
.dz-readonly--pre { font-family: ui-monospace, Consolas, monospace; font-size: 12px; line-height: 1.15; margin: 0; padding: 8px 10px; overflow: auto; max-height: 340px; white-space: pre; border: 1px solid rgba(128, 128, 128, .35); border-radius: 6px; }
.dz-switch { appearance: none; -webkit-appearance: none; flex: 0 0 auto; width: 40px; height: 22px; margin: 0; border-radius: 999px; background: var(--border); position: relative; cursor: pointer; transition: background 0.12s; }
.dz-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.12s; }
.dz-switch:checked { background: var(--accent-strong); }
.dz-switch:checked::after { transform: translateX(18px); }
.dz-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dz-switch__text { font-size: 13px; color: var(--text-dim); }

.dz-cell.is-changed { background: var(--chg-bg); box-shadow: inset 0 0 0 1px var(--chg-line); }
.dz-cell.is-changed .dz-input { border-color: var(--chg); }
.dz-cell__old { margin-top: 3px; padding: 0 2px; font-size: 12px; color: var(--chg); font-variant-numeric: tabular-nums; }
.dz-cell__err { margin-top: 3px; padding: 0 2px; font-size: 12px; font-weight: 600; color: var(--danger); }
.dz-cell__old[hidden], .dz-cell__err[hidden] { display: none; }
.dz-cell.is-invalid .dz-input { border-color: var(--danger); }

.dz-slots { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.dz-slot { display: flex; flex-direction: column; gap: 3px; min-width: 110px; }
.dz-slot__label { font-size: 12px; color: var(--text-dim); }
.dz-fld--wide { grid-template-columns: 1fr; gap: 4px; }
.dz-fld--wide > .dz-fld__label { padding-top: 0; }

/* ---- sub table (array of objects) ---- */
.dz-sub { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.dz-sub__table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.dz-sub__table th { text-align: left; padding: 8px 10px; font-size: 12px; color: var(--text-dim); background: var(--bg-elev); }
.dz-sub__table td { padding: 6px 8px; border-top: 1px solid var(--border); vertical-align: top; }
.dz-sub__table .dz-input { min-width: 90px; }
.dz-sub__table .dz-input--num { min-width: 70px; }
.dz-sub__n { width: 32px; color: var(--text-dim); text-align: center !important; }
.dz-sub__add { padding: 8px 10px; border-top: 1px solid var(--border); }
.dz-sub__table select.dz-input { min-width: 150px; }
.dz-sub__table td[data-col="text"] { min-width: 190px; }
/* The column header already carries the unit. */
.dz-sub .dz-unit { display: none; }

/* ---- list grid ---- */
.dz-list__tools { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.dz-search { flex: 0 1 320px; padding: 8px 12px; font: inherit; font-size: 14px; color: var(--text); background: var(--bg-card); border: 1px solid var(--border); border-radius: 9px; }
.dz-list__count { font-size: 13px; color: var(--text-dim); }
.dz-grid__wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
.dz-grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.dz-grid > thead th { text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 700; color: var(--text-dim); background: var(--bg-elev); white-space: nowrap; border-bottom: 1px solid var(--border); }
.dz-grid > tbody > tr > td { padding: 8px 12px; border-top: 1px solid var(--border); vertical-align: top; }
.dz-grid > tbody > tr:first-child > td { border-top: 0; }
.dz-grid__name { min-width: 150px; }
.dz-row__title { display: block; font-weight: 600; padding-top: 7px; }
.dz-row__sprite { --dz-sprite: 48px; box-sizing: content-box; float: left; width: var(--dz-sprite); height: var(--dz-sprite); margin: 2px 10px 2px 0; overflow: hidden;
  border-radius: 6px; background: var(--bg-elev); border: 1px solid var(--border); }
.dz-row__sprite[hidden] { display: none; }
.dz-grid__name:has(.dz-row__sprite) { min-width: 240px; }
.dz-row__sprite img { display: block; height: var(--dz-sprite); width: auto; max-width: none; image-rendering: pixelated; }
.dz-row__sprite--smooth img { image-rendering: auto; }
.dz-row__id { display: block; font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--text-dim); }
.dz-row.is-changed .dz-row__title::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--chg); vertical-align: 1px; }
.dz-grid__more { width: 1%; white-space: nowrap; text-align: right; }
.dz-more { margin-top: 3px; }
.dz-more[aria-expanded="true"] { border-color: var(--accent); }
.dz-more__badge { margin-left: 6px; padding: 0 6px; border-radius: 999px; color: #1a1d24; background: var(--chg); font-size: 11px; }
.dz-more__badge[hidden] { display: none; }
.dz-detail > td { background: var(--bg); padding: 4px 20px 12px; }
.dz-detail[hidden], .dz-row[hidden] { display: none; }
.dz-detail.is-filtered { display: none; }
.dz-grid .dz-input, .dz-sub .dz-input { width: 100%; min-width: 80px; }
.dz-sub .dz-input--num { min-width: 64px; }
.dz-grid .dz-input--num { max-width: 120px; }

/* ---- sticky bar ---- */
.dz-bar { position: sticky; bottom: 0; z-index: 20; background: var(--bg-elev); border-top: 1px solid var(--border); box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.25); }
.dz-bar[hidden], .dz-bar [hidden] { display: none; }
.dz-bar__inner { display: flex; align-items: center; gap: 10px; max-width: 1280px; margin: 0 auto; padding: 12px 24px; }
.dz-bar__count { font-weight: 700; font-size: 14px; }
.dz-bar__spacer { flex: 1 1 auto; }

/* ---- dialog ---- */
.dz-dialog { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 22px 24px; color: var(--text); background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); }
.dz-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.dz-dialog h2 { margin: 0 0 12px; font-size: 19px; }
.dz-changes { margin: 0 0 14px; padding: 0; list-style: none; max-height: 40vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
.dz-changes li { padding: 8px 12px; font-size: 14px; border-top: 1px solid var(--border); }
.dz-changes li:first-child { border-top: 0; }
.dz-dialog__status { margin: 0 0 16px; font-size: 14px; color: var(--text-dim); }
.dz-dialog__status.is-error { color: var(--danger); font-weight: 600; }
.dz-dialog__actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---- toasts ---- */
.dz-toasts { position: fixed; left: 50%; bottom: 84px; z-index: 40; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.dz-toast { padding: 9px 16px; font-size: 14px; font-weight: 600; color: #fff; background: #2a2f3a; border: 1px solid var(--border); border-radius: 999px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); transition: opacity 0.3s; }
.dz-toast.is-out { opacity: 0; }

/* ---- narrow screens ---- */
@media (max-width: 820px) {
  .dz-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .dz-side { position: static; max-height: none; }
  .dz-select { display: block; }
  .dz-nav { display: none; }
  .dz-main { padding: 20px 14px 120px; }
  .dz-fld { grid-template-columns: 1fr; }
  .dz-fld__label { padding-top: 0; }
  .dz-form { padding: 2px 14px; }
  .dz-bar__inner { padding: 10px 14px; flex-wrap: wrap; }
  .dz-grid__wrap { overflow: visible; border: 0; background: transparent; }
  .dz-grid > thead { display: none; }
  .dz-grid, .dz-grid > tbody, .dz-grid > tbody > tr { display: block; }
  .dz-row { margin-top: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card); padding: 6px 0; }
  .dz-row[hidden], .dz-detail[hidden] { display: none; }
  .dz-grid > tbody > tr > td { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px; align-items: center; border-top: 0; padding: 4px 14px; }
  .dz-grid > tbody > tr > td[data-label]::before { content: attr(data-label); font-size: 12.5px; color: var(--text-dim); }
  .dz-grid > tbody > tr > td.dz-grid__name { display: flow-root; }
  .dz-grid > tbody > tr > td.dz-grid__more { display: block; text-align: left; width: auto; }
  .dz-detail { margin: -4px 0 0; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 12px 12px; background: var(--bg); }
  .dz-detail > td { display: block; padding: 4px 14px 10px; }
  .dz-grid .dz-input--num { max-width: 100%; }
}

/* Grid items default to min-width:auto, which lets a wide sub table push the whole row past the screen. */
.dz-fld, .dz-form, .dz-group { min-width: 0; }
.dz-fld--wide { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 820px) {
  .dz-fld { grid-template-columns: minmax(0, 1fr); }
  .dz-grid > tbody > tr.dz-detail > td { display: block; min-width: 0; }
}

.dz-section { margin-top: 24px; }
.dz-section:first-of-type { margin-top: 16px; }
.dz-section__title { margin: 0; font-size: 16px; }
.dz-section__note { margin: 4px 0 10px; color: var(--text-dim); max-width: 70ch; font-size: 14px; }
/* The column header already carries the unit; repeating it in every cell pushed columns off-screen. */
.dz-grid .dz-row > td .dz-unit { display: none; }

.dz-addrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 14px; }
.dz-addrow .dz-input { width: 9rem; }
.dz-addrow .dz-help, .dz-addrow .dz-cell__err { flex-basis: 100%; margin: 0; }

/* ---- cost guard ---- */
.dz-guards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; align-items: start; }
.dz-guard { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; min-width: 0; }
.dz-guard__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.dz-guard__title { margin: 0; font-size: 17px; }
.dz-guard__cost { margin: 8px 0 6px; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dz-guard__muted, .dz-guard__note { margin: 6px 0; font-size: 13px; color: var(--text-dim); }
.dz-guard__stale { margin: 6px 0; font-size: 13px; color: var(--warn); }
.dz-guard__err { margin: 8px 0 0; font-size: 13px; color: var(--danger); }
.dz-guard__actions { margin-top: 12px; }
.dz-guard__prices { margin-top: 8px; }
.dz-guard__prices summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-dim); padding: 6px 0; }
.dz-pill { padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; border: 1px solid var(--border); white-space: nowrap; }
.dz-pill--open { color: #1a7f37; border-color: #1a7f37; }
.dz-pill--closed { color: var(--danger); border-color: var(--danger); }
.dz-pill--idle { color: var(--text-dim); }
.dz-meter { height: 10px; border-radius: 999px; background: var(--border); overflow: hidden; }
.dz-meter__fill { height: 100%; background: #1a7f37; }
.dz-meter.is-near .dz-meter__fill { background: var(--warn); }
.dz-meter.is-over .dz-meter__fill { background: var(--danger); }
.dz-stats { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 12px 0 4px; }
.dz-stats__item dt { font-size: 12px; color: var(--text-dim); }
.dz-stats__item dd { margin: 0; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- client gate (Phát hành & bảo trì) ---- */
.dz-gate { display: flex; flex-direction: column; gap: 16px; max-width: 900px; }
.dz-input--area { display: block; width: 100%; max-width: 560px; min-height: 76px; resize: vertical; line-height: 1.45; }
.dz-input--when { width: 230px; }
.dz-gate__row { flex-wrap: wrap; }
.dz-gate__hub { font-size: 13px; color: var(--text-dim); }
.dz-gate .dz-input.is-invalid { border-color: var(--danger); }
.dz-sub__add .btn + .btn { margin-left: 8px; }
.dz-sub__n { white-space: nowrap; }

/* Nút nghe thử tiếng cạnh ô độ to (audio.vol.*, voice.duck) */
.dz-play { margin-left: 8px; min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--dz-line, #3a3f4b); border-radius: 6px;
  background: transparent; color: inherit; cursor: pointer; font-size: 12px; line-height: 1; }
.dz-play:hover:not(:disabled) { background: rgba(255, 255, 255, .08); }
.dz-play.is-busy { opacity: .6; }
.dz-play.is-locked, .dz-play:disabled { opacity: .3; cursor: not-allowed; }
