/* ============================================================
   GoBranding · styles
   Dark-mode mặc định, accent đỏ thương hiệu (Thanh Wheel red).
   Mobile-first.
   ============================================================ */

:root {
  --bg: #0b0b0d;
  --bg-2: #131318;
  --bg-3: #1c1c24;
  --surface: #181820;
  --surface-2: #21212c;
  --border: #2a2a36;
  --text: #f4f4f7;
  --text-dim: #a4a4b0;
  --muted: #6c6c7a;
  --accent: #fb5a0c;       /* GoBranding orange */
  --accent-2: #ff9a1f;
  --accent-glow: rgba(255, 122, 16, 0.38);
  --danger: #f04438;
  --success: #16a34a;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-1: 0 6px 18px rgba(0,0,0,.35);
  --shadow-2: 0 12px 40px rgba(0,0,0,.55);
  --font-sans: 'Inter', 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: linear-gradient(180deg, var(--bg), var(--bg-2));
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
button { font-family: inherit; }
a { color: inherit; }

.muted { color: var(--text-dim); }
.muted.small { font-size: 12px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(11, 11, 13, 0.75);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  letter-spacing: .2px;
}
.brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px var(--accent-glow));
}
.brand-name { font-size: 16px; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Buttons ---------- */
.btn, .btn-ghost, .lang-toggle {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #fff;
  box-shadow: 0 6px 18px var(--accent-glow);
}
.btn-primary:hover { filter: brightness(1.05); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: #3a3a48; background: #262633; }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(240,68,56,.4);
}
.btn-danger:hover { background: rgba(240,68,56,.1); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  padding: 8px 10px;
  border: 1px solid transparent;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border); }

.lang-toggle {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 12.5px;
  letter-spacing: .4px;
}
.lang-toggle.is-en .vi { opacity: .45; }
.lang-toggle .sep { opacity: .35; margin: 0 4px; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--text-dim); }
.field > span { font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
.field > span em { font-style: normal; color: var(--text); font-weight: 600; font-size: 12px; }
.field input[type="email"],
.field input[type="password"],
.field input[type="text"],
.field input[type="number"],
.field select {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,122,16,.22);
}
.field input[type="color"] {
  width: 100%;
  height: 40px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
}
.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.password-field {
  position: relative;
  display: grid;
}
.password-field input {
  width: 100%;
  padding-right: 52px;
}
.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--text);
  background: rgba(245, 184, 97, .10);
}
.password-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.password-toggle .icon-eye-off { display: none; }
.password-toggle.is-visible .icon-eye { display: none; }
.password-toggle.is-visible .icon-eye-off { display: block; }
.login-option {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}
.login-option input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.brand-upload-field { min-width: 0; }
.file-dropzone {
  min-height: 76px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 13px 14px;
  border: 1px dashed rgba(232, 215, 166, .26);
  border-radius: 8px;
  background: rgba(7, 7, 9, .54);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.file-dropzone:hover,
.file-dropzone.is-dragging {
  border-color: rgba(245, 184, 97, .72);
  background: rgba(245, 184, 97, .08);
  box-shadow: inset 0 0 0 1px rgba(245, 184, 97, .18);
}
.file-dropzone-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}
.file-dropzone-hint {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-error {
  background: rgba(240,68,56,.1);
  border: 1px solid rgba(240,68,56,.35);
  color: #ffb4ad;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

/* ---------- Login ---------- */
.login-shell {
  min-height: calc(100% - 56px);
  display: grid;
  place-items: center;
  padding: 24px 18px 48px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 22px;
  box-shadow: var(--shadow-2);
}
.login-card-head {
  text-align: center;
  margin-bottom: 20px;
}
.login-logo {
  width: 100%;
  max-width: 248px;
  height: auto;
  margin: 0 auto 14px;
  border-radius: 16px;
  filter: drop-shadow(0 10px 30px var(--accent-glow));
}
.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: .2px;
}

/* ---------- Editor ---------- */
.editor-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
  min-height: calc(100dvh - 56px);
}
.canvas-wrap {
  position: relative;
  background:
    linear-gradient(45deg, #15151c 25%, transparent 25%) 0 0 / 20px 20px,
    linear-gradient(-45deg, #15151c 25%, transparent 25%) 0 10px / 20px 20px,
    linear-gradient(45deg, transparent 75%, #15151c 75%) 10px -10px / 20px 20px,
    linear-gradient(-45deg, transparent 75%, #15151c 75%) -10px 0 / 20px 20px,
    var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  padding: 8px;
}
#canvas {
  max-width: 100%;
  max-height: calc(100dvh - 220px);
  touch-action: none;
  user-select: none;
  cursor: grab;
  box-shadow: var(--shadow-1);
  border-radius: 6px;
  background: #000;
}
#canvas.is-dragging { cursor: grabbing; }

.canvas-empty {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
}
.canvas-empty-mark {
  width: 118px;
  height: 118px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--accent), #f5c142);
  box-shadow: 0 22px 48px rgba(232, 93, 36, .26);
}
.canvas-empty img { width: 62px; opacity: .92; filter: none; }
.canvas-empty h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}
.canvas-empty p { color: var(--text-dim); margin: 0; }
.canvas-empty-drop {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.canvas-wrap.is-file-over {
  border-color: rgba(245, 184, 97, .72);
  box-shadow: inset 0 0 0 2px rgba(245, 184, 97, .20), 0 18px 54px rgba(232, 93, 36, .18);
}

/* Toolbar (mobile = bottom panel; desktop = right column) */
.toolbar {
  display: grid;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.tool-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tool-group.panel {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.tool-group .btn { flex: 1 1 auto; min-width: 120px; }
.tool-section {
  display: grid;
  gap: 10px;
}
.tool-section + .tool-section,
.tool-section.panel,
.tool-group.panel {
  padding-top: 12px;
  border-top: 1px dashed rgba(232, 215, 166, .18);
}
.tool-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.tool-section-head em {
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
}
.editor-action-grid,
.export-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.editor-action-grid .btn:first-child,
.editor-action-grid .btn:nth-child(3) {
  grid-column: 1 / -1;
}
.brand-kit-strip {
  display: grid;
  gap: 8px;
}
.brand-kit-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.brand-kit-chip {
  width: 100%;
  min-height: 54px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid rgba(232, 215, 166, .16);
  border-radius: 8px;
  background: rgba(255,255,255,.035);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.brand-kit-chip:hover,
.brand-kit-more:hover {
  border-color: rgba(245, 184, 97, .44);
  background: rgba(245, 184, 97, .08);
}
.brand-kit-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: #060608;
}
.brand-kit-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand-kit-text {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.brand-kit-text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.2;
}
.brand-kit-text em {
  color: var(--text-dim);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}
.brand-kit-more {
  min-height: 44px;
  border: 1px solid rgba(232, 215, 166, .16);
  border-radius: 8px;
  background: rgba(255,255,255,.035);
  color: var(--gold-soft);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}
.placement-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.placement-grid .btn-mini {
  min-width: 0;
  min-height: 38px;
  padding: 6px 7px;
  font-size: 11px;
}
.tool-group.compact {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.tool-group.compact .btn,
.export-grid .btn,
.editor-action-grid .btn {
  min-width: 0;
}

@media (min-width: 960px) {
  .editor-shell {
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
  }
  .toolbar { position: sticky; top: 70px; max-height: calc(100dvh - 90px); overflow: auto; }
  #canvas { max-height: calc(100dvh - 100px); }
}

/* ---------- Admin ---------- */
.admin-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 64px;
  display: grid;
  gap: 16px;
}
.admin-head h1 { margin: 0 0 6px; font-size: 24px; }
.admin-head { display: grid; gap: 10px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.admin-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 720px;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table thead th {
  background: var(--bg-3);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .6px;
}
.admin-table tbody tr:hover { background: rgba(255,255,255,.02); }
.admin-table .pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .4px;
  text-transform: uppercase;
}
.pill-admin { background: rgba(255,122,16,.20); color: #ffb27a; }
.pill-user  { background: rgba(255,255,255,.08); color: var(--text-dim); }
.pill-on    { background: rgba(22,163,74,.18); color: #5be39b; }
.pill-off   { background: rgba(240,68,56,.18); color: #ffb4ad; }

.admin-table select, .admin-table input[type="checkbox"] {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
}
.admin-table input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-1);
  z-index: 50;
}
.toast.is-error { border-color: rgba(240,68,56,.45); color: #ffb4ad; }
.toast.is-ok { border-color: rgba(22,163,74,.45); color: #5be39b; }

/* ---------- Misc helpers ---------- */
[hidden] { display: none !important; }

::selection { background: rgba(255,122,16,.45); color: #fff; }

/* Focus outline */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* iOS safe areas */
@supports (padding: max(0px)) {
  .topbar { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .editor-shell, .admin-shell { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}

/* ============================================================
   v2 — mobile/iPad layout, núm kéo, bảng chọn logo
   ============================================================ */

/* Editor: khóa cuộn trang, để canvas + toolbar tự co giãn (mobile-first) */
.page-editor { height: 100dvh; overflow: hidden; overscroll-behavior: none; }
.editor-shell {
  height: calc(100dvh - 57px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
}
.canvas-wrap { flex: 1 1 auto; min-height: 0; touch-action: none; }
#canvas { max-width: 100%; max-height: 100%; }
.toolbar {
  flex: 0 0 auto;
  max-height: 46dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.tip-gesture { margin: 2px 0 0; line-height: 1.45; }

/* Nút đủ lớn để chạm trên điện thoại/iPad */
.btn { min-height: 46px; }
.tool-group .btn { min-width: 110px; }

@media (min-width: 960px) {
  .page-editor { overflow: hidden; }
  .editor-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: stretch;
    height: calc(100dvh - 57px);
    padding: 12px;
  }
  .toolbar {
    max-height: calc(100dvh - 81px);
    position: sticky;
    top: 73px;
  }
  .btn { min-height: 44px; }
}

/* ---------- Modal chọn logo ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 60;
  padding: 16px;
}
.modal {
  width: 100%;
  max-width: 560px;
  max-height: 86dvh;
  overflow: auto;
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 18px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-close {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
}
.modal-close:hover { border-color: var(--accent); }

.logo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
@media (min-width: 520px) { .logo-grid { grid-template-columns: repeat(3, 1fr); } }

.logo-card {
  position: relative;
  display: grid;
  gap: 10px;
  justify-items: center;
  align-content: start;
  padding: 16px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-2);
  cursor: pointer;
  text-align: center;
  font: inherit;
  color: var(--text);
  transition: border-color .15s ease, transform .08s ease, background .15s ease;
}
.logo-card:hover { border-color: var(--accent); background: #1d1d26; }
.logo-card:active { transform: translateY(1px); }
.logo-thumb {
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-thumb.placeholder {
  border-radius: 12px;
  background: repeating-linear-gradient(45deg, #1c1c24, #1c1c24 6px, #20202a 6px, #20202a 12px);
  font-size: 26px;
}
.logo-name { font-size: 13px; font-weight: 600; }
.logo-meta {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
}
.logo-card-back {
  min-height: 126px;
  align-content: center;
  color: var(--gold-soft);
  font-weight: 800;
}
.logo-card.is-locked { cursor: not-allowed; opacity: .55; }
.logo-card.is-locked:hover { border-color: var(--border); background: var(--bg-2); transform: none; }
.logo-card.is-locked .logo-name { color: var(--text-dim); }
.lock-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, .5);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .3px;
  padding: 2px 8px;
  color: var(--text-dim);
}

/* ---------- Admin: tạo tài khoản + thao tác ---------- */
.admin-create {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.admin-create h2 { margin: 0 0 12px; font-size: 16px; }
.create-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  align-items: end;
}
@media (min-width: 720px) {
  .create-grid { grid-template-columns: 2.2fr 2fr 1.1fr auto; }
}
.create-grid .btn { min-height: 46px; }
.admin-create .muted.small { margin: 10px 0 0; }

.admin-actions-bar { display: flex; flex-wrap: wrap; gap: 8px; }

.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.btn-mini {
  padding: 7px 11px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 8px;
  min-height: 36px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.btn-mini:hover { border-color: var(--accent); }
.btn-mini:disabled { opacity: .4; cursor: not-allowed; }
.btn-mini.danger { color: var(--danger); border-color: rgba(240,68,56,.4); background: transparent; }
.btn-mini.danger:hover { background: rgba(240,68,56,.1); }

/* ---------- Login: 2 tab Thành viên / Admin ---------- */
.login-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
}
.login-tab {
  flex: 1;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-weight: 600;
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.login-tab.is-active {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* ---------- Modal copy tài khoản ---------- */
.cred-text {
  width: 100%;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font: inherit;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  resize: vertical;
}
.cred-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

/* ---------- CMS thương hiệu ---------- */
.brand-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  margin-top: 14px;
  align-items: start;
}
@media (min-width: 640px) { .brand-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .brand-grid { grid-template-columns: repeat(3, 1fr); } }
.brand-card {
  position: relative;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  grid-template-areas:
    "thumb info"
    "actions actions";
  gap: 12px;
  align-items: start;
  align-self: start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-2);
}
.brand-card.is-dragging-files {
  border-color: rgba(245, 184, 97, .72);
  background: rgba(245, 184, 97, .08);
}
.brand-card.is-dragging-files::after {
  content: attr(data-drop-label);
  position: absolute;
  inset: 8px;
  display: grid;
  place-items: center;
  padding: 14px;
  border: 1px dashed rgba(245, 184, 97, .82);
  border-radius: 8px;
  background: rgba(8, 8, 10, .86);
  color: #ffe2aa;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  pointer-events: none;
  z-index: 2;
}
.brand-thumb {
  grid-area: thumb;
  width: 56px; height: 56px;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: #0d0d12;
  border-radius: 10px;
  overflow: hidden;
}
.brand-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.brand-thumb.empty { color: var(--muted); font-size: 10px; text-align: center; }
.brand-info {
  grid-area: info;
  min-width: 0;
  display: grid;
  gap: 8px;
}
.brand-cardname {
  font-weight: 800;
  font-size: 15px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-status {
  margin-top: -5px;
  font-size: 12px;
  color: var(--text-dim);
}
.brand-status.locked { color: #ffb27a; }
.brand-card-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(232, 215, 166, .12);
}
.brand-card-actions .btn-mini {
  width: 100%;
  min-width: 0;
  text-align: center;
}
.brand-logo-list {
  display: grid;
  gap: 8px;
  max-height: 198px;
  overflow: auto;
  padding-right: 2px;
  overscroll-behavior: contain;
}
.brand-logo-list:has(.brand-empty) {
  max-height: none;
  overflow: visible;
}
.brand-inline-dropzone {
  min-height: 52px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 8px 10px;
  border: 1px dashed rgba(232, 215, 166, .22);
  border-radius: 8px;
  background: rgba(7, 7, 9, .36);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.brand-inline-dropzone:hover,
.brand-inline-dropzone.is-dragging {
  border-color: rgba(245, 184, 97, .72);
  background: rgba(245, 184, 97, .08);
  box-shadow: inset 0 0 0 1px rgba(245, 184, 97, .14);
}
.brand-inline-dropzone-title {
  font-size: 12px;
  font-weight: 900;
  color: #ffe2aa;
}
.brand-inline-dropzone-hint {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand-logo-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border: 1px solid rgba(232, 215, 166, .14);
  border-radius: 8px;
  background: rgba(255,255,255,.035);
}
.brand-logo-item .btn-mini {
  min-height: 34px;
  padding: 6px 9px;
}
.brand-logo-item.is-primary {
  border-color: rgba(245, 184, 97, .36);
  background: rgba(245, 184, 97, .075);
}
.brand-logo-mini {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 8px;
  background: #050507;
}
.brand-logo-mini img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand-logo-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
}
.brand-logo-primary {
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(245, 184, 97, .12);
  color: #ffe2aa;
  font-size: 10.5px;
  font-weight: 900;
  text-transform: uppercase;
}

/* ---------- Modal phân quyền ---------- */
.perm-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 14px; }
.perm-brands {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 4px;
}
.perm-brand { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.perm-brands input[type="checkbox"], .perm-row input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--accent); flex: 0 0 auto;
}

/* ---------- Editor: nút tải logo cá nhân trong modal ---------- */
.logo-personal { margin: 6px 0 10px; }
.logo-personal .btn { width: 100%; }

/* ============================================================
   v6 — Cinematic luxury polish + admin account upgrades
   ============================================================ */
:root {
  --bg: #08080a;
  --bg-2: #101014;
  --bg-3: #17171d;
  --surface: rgba(20, 20, 25, .88);
  --surface-2: rgba(30, 30, 38, .92);
  --border: rgba(226, 217, 196, .16);
  --text: #f7f3ea;
  --text-dim: #c7beb0;
  --muted: #8c857b;
  --accent: #e85d24;
  --accent-2: #f5b861;
  --accent-glow: rgba(232, 93, 36, .30);
  --gold-soft: #e8d7a6;
  --steel: #a8b7c7;
  --success: #40c982;
  --radius: 8px;
  --radius-sm: 8px;
  --shadow-1: 0 14px 34px rgba(0,0,0,.38);
  --shadow-2: 0 24px 80px rgba(0,0,0,.62);
}

body {
  background:
    linear-gradient(135deg, rgba(232, 215, 166, .045) 0 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(180deg, #070708 0%, #121216 44%, #09090b 100%);
  min-width: 320px;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(255,255,255,.035), transparent 24%, rgba(232,93,36,.045) 50%, transparent 72%, rgba(232,215,166,.03)),
    repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 4px);
  mix-blend-mode: screen;
  opacity: .42;
}

.topbar {
  min-height: 64px;
  padding: 12px 18px;
  background: rgba(7, 7, 8, .74);
  border-bottom: 1px solid rgba(232, 215, 166, .14);
  box-shadow: 0 12px 36px rgba(0,0,0,.28);
}

.brand-name {
  color: var(--text);
  font-weight: 800;
  letter-spacing: .5px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  filter: drop-shadow(0 8px 18px rgba(232,93,36,.30));
}

.topbar-actions {
  gap: 10px;
  min-width: 0;
}

.btn, .btn-ghost, .lang-toggle, .login-tab, .modal-close, .btn-mini {
  min-height: 44px;
  border-radius: 8px;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.btn-primary {
  background: linear-gradient(135deg, #f2c77d 0%, #e85d24 56%, #a73318 100%);
  color: #110d09;
  box-shadow: 0 12px 32px rgba(232, 93, 36, .32), inset 0 1px 0 rgba(255,255,255,.34);
}

.btn-secondary, .lang-toggle, .btn-mini {
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.025));
  border: 1px solid rgba(232, 215, 166, .18);
  color: var(--text);
}

.btn-ghost {
  border: 1px solid rgba(232, 215, 166, .12);
  color: var(--text-dim);
}

.btn-secondary:hover, .btn-ghost:hover, .btn-mini:hover, .lang-toggle:hover {
  border-color: rgba(245, 184, 97, .46);
  background: rgba(245, 184, 97, .08);
}

.field input[type="email"],
.field input[type="password"],
.field input[type="text"],
.field input[type="tel"],
.field input[type="number"],
.field input[type="file"],
.field select,
.cred-text,
.member-name-input {
  min-height: 46px;
  background: rgba(7, 7, 9, .72);
  color: var(--text);
  border: 1px solid rgba(232, 215, 166, .18);
  border-radius: 8px;
}

.field input:focus,
.field select:focus,
.cred-text:focus,
.member-name-input:focus {
  border-color: rgba(245, 184, 97, .72);
  box-shadow: 0 0 0 3px rgba(245, 184, 97, .16);
}

.login-shell {
  position: relative;
  min-height: calc(100dvh - 64px);
  padding: 28px 16px max(42px, env(safe-area-inset-bottom));
}

.login-shell::before {
  content: '';
  position: absolute;
  inset: 6% 4% auto auto;
  width: min(560px, 72vw);
  height: min(320px, 46vh);
  background: url('../assets/brand/gobranding-lockup.png') center / contain no-repeat;
  opacity: .055;
  filter: grayscale(1);
  pointer-events: none;
}

.login-card,
.toolbar,
.admin-create,
.admin-table-wrap,
.modal {
  background:
    linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.018)),
    rgba(14, 14, 18, .88);
  border: 1px solid rgba(232, 215, 166, .18);
  box-shadow: var(--shadow-2);
}

.login-card {
  max-width: 460px;
  padding: 30px 24px;
}

.login-logo {
  max-width: 276px;
  border-radius: 8px;
  filter: drop-shadow(0 18px 36px rgba(232,93,36,.22));
}

.login-card h1,
.admin-head h1,
.admin-create h2,
.modal-head h2 {
  color: var(--text);
  font-weight: 800;
  letter-spacing: .2px;
}

.login-card-head .muted,
.admin-head .muted {
  color: var(--text-dim);
}

.login-tabs {
  background: rgba(0,0,0,.22);
  border-color: rgba(232, 215, 166, .16);
}

.login-tab.is-active {
  background: linear-gradient(135deg, rgba(245,184,97,.95), rgba(232,93,36,.95));
  color: #120f0b;
}

.page-editor {
  display: flex;
  flex-direction: column;
}

.page-editor .topbar {
  flex: 0 0 auto;
}

.editor-shell {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  padding: 12px;
}

.canvas-wrap {
  border-color: rgba(232, 215, 166, .15);
  background:
    linear-gradient(45deg, rgba(255,255,255,.032) 25%, transparent 25%) 0 0 / 22px 22px,
    linear-gradient(-45deg, rgba(255,255,255,.032) 25%, transparent 25%) 0 11px / 22px 22px,
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,.032) 75%) 11px -11px / 22px 22px,
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.032) 75%) -11px 0 / 22px 22px,
    #0d0d11;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.02), var(--shadow-1);
}

#canvas {
  border-radius: 8px;
  box-shadow: 0 18px 54px rgba(0,0,0,.52);
}

.canvas-empty-mark img {
  width: 62px;
  filter: none;
}

.toolbar {
  gap: 14px;
}

.tool-group.panel {
  border-top-color: rgba(232, 215, 166, .18);
}

.admin-shell {
  max-width: 1280px;
  padding-top: 28px;
}

.admin-head {
  padding: 8px 2px;
}

.admin-head h1 {
  font-size: 30px;
}

.create-grid {
  grid-template-columns: 1fr;
}

@media (min-width: 940px) {
  #create-form.create-grid {
    grid-template-columns: 1.45fr 1.15fr 1.1fr .86fr auto;
  }

  #brand-form.create-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1.25fr) auto;
  }
}

.admin-table {
  min-width: 1060px;
}

.admin-table th,
.admin-table td {
  border-bottom-color: rgba(232, 215, 166, .12);
}

.admin-table thead th {
  background: rgba(245, 184, 97, .08);
  color: #e7d9bd;
}

.admin-table tbody tr:hover {
  background: rgba(245, 184, 97, .045);
}

.member-name-input {
  width: 190px;
  padding: 9px 10px;
  font: inherit;
  outline: none;
}

.password-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  max-width: 190px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(245, 184, 97, .24);
  background: rgba(245, 184, 97, .08);
  color: #ffe2aa;
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace;
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.password-badge.is-empty {
  color: var(--muted);
  background: rgba(255,255,255,.035);
  border-style: dashed;
  font-family: var(--font-sans);
  font-weight: 700;
}

.brand-access {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 190px;
}

.brand-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 180px;
  padding: 4px 8px 4px 5px;
  border: 1px solid rgba(232, 215, 166, .16);
  border-radius: 999px;
  background: rgba(255,255,255,.045);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.brand-chip > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-mark {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 999px;
  background: #050507;
  color: var(--gold-soft);
  font-size: 11px;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-empty,
.brand-personal,
.brand-more {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.brand-empty {
  color: var(--muted);
  border: 1px dashed rgba(232, 215, 166, .18);
}

.brand-personal {
  color: #bdebd0;
  background: rgba(64, 201, 130, .10);
  border: 1px solid rgba(64, 201, 130, .24);
}

.brand-more {
  color: var(--steel);
  border: 1px solid rgba(168, 183, 199, .22);
}

.row-actions {
  flex-wrap: wrap;
}

.modal-overlay {
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.modal {
  max-width: 640px;
}

.cred-text {
  line-height: 1.68;
  min-height: 340px;
  resize: vertical;
}

.logo-card,
.brand-card {
  border-radius: 8px;
  border-color: rgba(232, 215, 166, .16);
  background: rgba(255,255,255,.035);
}

.logo-card:hover,
.brand-card:hover {
  border-color: rgba(245, 184, 97, .44);
}

@media (max-width: 760px) {
  .topbar {
    position: sticky;
    align-items: flex-start;
    padding: 10px 12px;
  }

  .brand {
    min-height: 44px;
  }

  .brand-name {
    font-size: 14px;
  }

  .topbar-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
  }

  .btn-ghost,
  .lang-toggle {
    padding: 8px 9px;
    font-size: 12px;
  }

  .login-card {
    padding: 24px 18px;
  }

  .editor-shell {
    height: auto;
    padding: 8px;
  }

  .toolbar {
    max-height: 48dvh;
    padding: 12px;
  }

  .tool-group .btn {
    min-width: min(148px, 100%);
  }

  .admin-shell {
    padding: 18px 10px max(40px, env(safe-area-inset-bottom));
  }

  .admin-head h1 {
    font-size: 24px;
  }

  .admin-table-wrap {
    background: transparent;
    border: 0;
    box-shadow: none;
    overflow: visible;
  }

  .admin-table,
  .admin-table tbody,
  .admin-table tr,
  .admin-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .admin-table thead {
    display: none;
  }

  .admin-table tr {
    margin-bottom: 12px;
    border: 1px solid rgba(232, 215, 166, .16);
    border-radius: 8px;
    background:
      linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.018)),
      rgba(14, 14, 18, .92);
    box-shadow: var(--shadow-1);
    overflow: hidden;
  }

  .admin-table td {
    display: grid;
    grid-template-columns: minmax(108px, 36%) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 11px 12px;
  }

  .admin-table td::before {
    content: attr(data-label);
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .6px;
  }

  .admin-table td[colspan]::before {
    display: none;
  }

  .member-name-input {
    width: 100%;
  }

  .brand-access {
    min-width: 0;
  }

  .brand-card {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 10px;
  }

  .brand-thumb {
    width: 52px;
    height: 52px;
  }

  .brand-card-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .brand-card-actions .btn-mini,
  .brand-logo-item .btn-mini {
    flex: initial;
  }

  .brand-logo-list {
    max-height: 176px;
  }

  .brand-logo-item {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .brand-logo-item .btn-mini,
  .brand-logo-primary {
    grid-column: 2;
    justify-self: start;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .btn-mini {
    flex: 1 1 calc(50% - 6px);
  }

  .cred-actions {
    justify-content: stretch;
  }

  .cred-actions .btn {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .topbar {
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .topbar-actions > * {
    flex: 1 1 auto;
  }

  .login-logo {
    max-width: 228px;
  }

  .admin-table td {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .btn-mini {
    flex-basis: 100%;
  }
}
