:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-muted: #475467;
  --text-soft: #667085;
  --primary: #2155cd;
  --primary-hover: #1944a8;
  --primary-soft: #eef3ff;
  --success: #079455;
  --success-hover: #067a45;
  --warning: #b54708;
  --warning-bg: #fffaeb;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --neutral-bg: #f2f4f7;
  --header-bg: #ffffff;
  --header-border: #e4e7ec;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  position: sticky; top: 0; z-index: 30;
  box-shadow: 0 1px 0 var(--header-border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  background: var(--primary); color: white; border-radius: 9px;
  box-shadow: 0 1px 2px rgba(16,24,40,.08);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-weight: 600; font-size: 15px; color: var(--text); letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ---------- Buttons ---------- */
.btn, .btn-ghost, .btn-icon, .btn-save, .btn-page {
  border: 1px solid transparent; border-radius: 7px; cursor: pointer;
  font-size: 13.5px; font-weight: 500; font-family: inherit;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.btn { background: var(--primary); color: white; padding: 8px 14px; }
.btn:hover { background: var(--primary-hover); }
.btn:disabled { background: var(--neutral-bg); color: var(--text-soft); cursor: not-allowed; }

.btn-ghost {
  background: transparent; color: var(--text-muted);
  border-color: var(--border-strong); padding: 7px 12px;
}
.btn-ghost:hover { background: var(--neutral-bg); color: var(--text); }

.btn-page { padding: 7px 12px; background: white; color: var(--text-muted); border-color: var(--border); }
.btn-page:hover:not(:disabled) { background: var(--neutral-bg); color: var(--text); }
.btn-page:disabled { background: var(--neutral-bg); color: var(--text-soft); border-color: var(--border); }

.btn-save {
  background: var(--neutral-bg); color: var(--text-soft);
  padding: 7px 14px; min-width: 72px; font-weight: 600; justify-content: center;
  border-color: var(--border);
}
.btn-save:not(:disabled) {
  background: var(--success); color: white; border-color: var(--success);
  box-shadow: 0 1px 2px rgba(7,148,85,.18);
}
.btn-save:not(:disabled):hover { background: var(--success-hover); border-color: var(--success-hover); }
.btn-save.saved { background: var(--success-hover) !important; border-color: var(--success-hover) !important; color: white !important; }

.btn-delete-product {
  background: #fff; color: #b91c1c;
  border: 1px solid #fecaca;
  width: 32px; height: 32px;
  padding: 0; margin-top: 10px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  vertical-align: middle;
}
.btn-delete-product:hover { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-delete-product:disabled { opacity: .5; cursor: wait; }
tr.deleting { opacity: .5; pointer-events: none; transition: opacity .2s ease; }
tr.deleting input, tr.deleting button { pointer-events: none; }

/* ---------- Filters ---------- */
.filters {
  display: flex; gap: 10px; padding: 14px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  flex-wrap: wrap; align-items: center;
  position: sticky; top: 63px; z-index: 25;
}
.field {
  position: relative; display: flex; align-items: center;
  background: white; border: 1px solid var(--border-strong); border-radius: 7px;
  transition: border-color .15s, box-shadow .15s;
  height: 36px;
}
.field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(33,85,205,.12);
}
.field-grow { flex: 1; min-width: 240px; }
.field-icon {
  color: var(--text-soft); margin-left: 10px; flex-shrink: 0;
}
.field input {
  border: none; outline: none; background: transparent;
  padding: 8px 10px; font-size: 13.5px; font-family: inherit; color: var(--text);
  flex: 1; min-width: 0;
  width: 220px;
}
.field-grow input { width: 100%; }
.field input::placeholder { color: var(--text-soft); }
.field-clear {
  border: none; background: transparent; padding: 6px 10px;
  color: var(--text-soft); cursor: pointer; display: flex; align-items: center;
  border-radius: 5px; margin-right: 2px;
}
.field-clear:hover { background: var(--neutral-bg); color: var(--text); }
#clearSearch { display: none; }
#clearSearch.show { display: flex; }

#limitSelect {
  height: 36px; padding: 0 32px 0 12px;
  border: 1px solid var(--border-strong); border-radius: 7px;
  background: white;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
  font-family: inherit; font-size: 13.5px; color: var(--text);
  -webkit-appearance: none; appearance: none;
}
#limitSelect:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(33,85,205,.12); }

/* Autosave toggle as inline switch */
.autosave {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px;
  background: white; border: 1px solid var(--border-strong); border-radius: 7px;
  cursor: pointer; user-select: none;
  font-size: 13px; color: var(--text-muted); font-weight: 500;
}
.autosave input { display: none; }
.autosave .slider {
  position: relative; width: 28px; height: 16px;
  background: var(--border-strong); border-radius: 999px; transition: background .2s;
}
.autosave .slider::before {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; background: white; border-radius: 50%;
  transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.autosave input:checked + .slider { background: var(--primary); }
.autosave input:checked + .slider::before { transform: translateX(12px); }
.autosave:hover { border-color: var(--text-soft); }

/* ---------- Main ---------- */
main {margin: 0 auto; }

.table-wrap {
  background: var(--surface); border-radius: 10px; overflow: auto;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
th, td {
  padding: 11px 14px; text-align: left; vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
thead th {
  background: #fafbfc;
  font-weight: 600; color: var(--text-muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: none; }
tr.dirty {
  background: var(--warning-bg) !important;
  box-shadow: inset 3px 0 0 #f79009;
}

.col-img { width: 52px; padding-right: 0; }
.col-title { min-width: 300px; max-width: 480px; }
.col-type { width: 130px; color: var(--text-soft); }
.col-price { width: 140px; }
.col-qty { width: 86px; }
.col-stock { width: 240px; }
.col-action { width: 88px; text-align: center; }

.thumb {
  width: 40px; height: 40px; object-fit: cover; border-radius: 6px;
  background: var(--neutral-bg); display: block;
  border: 1px solid var(--border);
}
.thumb-empty {
  width: 40px; height: 40px; border-radius: 6px;
  background: var(--neutral-bg); border: 1px solid var(--border);
}

.product-link {
  color: var(--text); text-decoration: none; font-weight: 500;
  display: inline-flex; align-items: center; gap: 4px; line-height: 1.4;
}
.product-link:hover { color: var(--primary); }
.product-link .ext { color: var(--text-soft); flex-shrink: 0; }
.product-link:hover .ext { color: var(--primary); }

.variant-title { font-size: 12px; color: var(--text-soft); margin-top: 3px; }
.variant-title code {
  background: var(--neutral-bg); padding: 1px 6px; border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px;
  color: var(--text-muted);
}

input.price, input.qty {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--border-strong); border-radius: 6px;
  font-size: 13.5px; text-align: right; font-family: inherit; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  background: white;
}
input.price:focus, input.qty:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(33,85,205,.12);
}
input.price { font-weight: 600; font-variant-numeric: tabular-nums; }
input.qty { font-variant-numeric: tabular-nums; }

.stock-cell {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}

.badge {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  line-height: 1.4;
}
.badge.in { background: #ecfdf3; color: var(--success); }
.badge.out { background: var(--danger-bg); color: var(--danger); }
.badge.continue { background: var(--primary-soft); color: var(--primary-hover); }
.badge.neutral { background: var(--neutral-bg); color: var(--text-soft); }

/* Row switch */
.switch {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 12.5px; color: var(--text-muted); user-select: none;
}
.switch input { display: none; }
.switch .slider {
  position: relative; width: 30px; height: 17px;
  background: var(--border-strong); border-radius: 999px; transition: background .2s;
}
.switch .slider::before {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 13px; height: 13px; background: white; border-radius: 50%;
  transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(13px); }

.loading, .empty {
  text-align: center; padding: 60px 20px;
  color: var(--text-soft); font-style: normal; font-size: 14px;
}

.pagination {
  display: flex; gap: 12px; align-items: center; justify-content: center;
  padding: 20px 0 24px;
}
#pageInfo {
  font-size: 13px; color: var(--text-muted); min-width: 180px; text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 11px 18px; border-radius: 8px;
  background: var(--text); color: white; font-size: 13.5px; font-weight: 500;
  box-shadow: 0 8px 20px rgba(16,24,40,.18);
  opacity: 0; transform: translateY(12px); transition: all .22s;
  pointer-events: none; z-index: 100; max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ---------- Login page ---------- */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background: #0b1224;
  position: relative; overflow: hidden;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Animated background orbs */
.login-bg {
  position: absolute; inset: 0; overflow: hidden; z-index: 0;
}
.login-bg .orb {
  position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: .55;
  will-change: transform;
}
.login-bg .orb-1 {
  width: 480px; height: 480px;
  background: radial-gradient(circle at 30% 30%, #5b8def, #2155cd 60%);
  top: -120px; left: -100px;
  animation: orbFloat1 18s ease-in-out infinite;
}
.login-bg .orb-2 {
  width: 520px; height: 520px;
  background: radial-gradient(circle at 30% 30%, #a872ff, #6739c8 60%);
  bottom: -150px; right: -120px;
  animation: orbFloat2 22s ease-in-out infinite;
}
.login-bg .orb-3 {
  width: 380px; height: 380px;
  background: radial-gradient(circle at 30% 30%, #36d1b1, #1d8c70 60%);
  top: 30%; right: 8%;
  animation: orbFloat3 26s ease-in-out infinite;
  opacity: .35;
}
.login-bg .orb-4 {
  width: 340px; height: 340px;
  background: radial-gradient(circle at 30% 30%, #ff8db1, #d23478 60%);
  bottom: 18%; left: 14%;
  animation: orbFloat4 30s ease-in-out infinite;
  opacity: .3;
}
@keyframes orbFloat1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(120px, 80px) scale(1.12); }
}
@keyframes orbFloat2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-100px, -60px) scale(1.08); }
}
@keyframes orbFloat3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-80px, 60px) scale(1.15); }
}
@keyframes orbFloat4 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, -90px) scale(1.1); }
}

/* Card */
.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 400px;
  padding: 40px 36px 28px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, .45),
    inset 0 1px 0 rgba(255, 255, 255, .15);
  animation: cardIn .7s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.login-card.shake { animation: shake .5s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  margin: 0 auto 18px; padding: 14px 22px;
  border-radius: 14px;
  box-shadow:
    0 10px 28px rgba(33, 85, 205, .45),
    inset 0 1px 0 rgba(255, 255, 255, .25);
  animation: brandFloat 4s ease-in-out infinite;
}
.login-brand-mark img {
  height: 45px; width: auto; display: block;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .15));
}
.login-brand { display: flex; flex-direction: column; align-items: center; }
@keyframes brandFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.login-title {
  margin: 0 0 6px; color: white; font-size: 22px; font-weight: 600;
  letter-spacing: -0.015em;
}
.login-sub {
  margin: 0; color: rgba(255, 255, 255, .65); font-size: 13.5px;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

/* Floating label input */
.field-float {
  position: relative;
}
.field-float input {
  width: 100%;
  height: 54px;
  padding: 22px 14px 8px 44px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 10px;
  background: rgba(255, 255, 255, .06);
  color: white; font-size: 15px; font-family: inherit;
  transition: border-color .2s, background .2s, box-shadow .2s;
  outline: none;
  -webkit-text-fill-color: white;
  caret-color: white;
}
.field-float input:focus {
  border-color: #5b8def;
  background: rgba(255, 255, 255, .1);
  box-shadow: 0 0 0 4px rgba(91, 141, 239, .18);
}
.field-float input:-webkit-autofill,
.field-float input:-webkit-autofill:focus {
  -webkit-text-fill-color: white;
  transition: background-color 9999s ease-out 0s;
  -webkit-box-shadow: 0 0 0px 1000px rgba(255, 255, 255, .06) inset;
}
.field-float label {
  position: absolute; left: 44px; top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, .55); font-size: 14.5px;
  pointer-events: none;
  transition: top .18s, font-size .18s, color .18s, transform .18s;
}
.field-float input:focus + label,
.field-float input:not(:placeholder-shown) + label,
.field-float input:not(:focus):valid + label,
.field-float:has(input:focus) label,
.field-float:has(input:not(:placeholder-shown)) label,
.field-float:has(input:not(:focus):valid) label {
  top: 8px; transform: translateY(0);
  font-size: 11px; font-weight: 500;
  color: rgba(255, 255, 255, .8);
  letter-spacing: .04em; text-transform: uppercase;
}
.field-float-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: rgba(255, 255, 255, .5); pointer-events: none;
}
.field-float input:focus ~ .field-float-icon,
.field-float:has(input:focus) .field-float-icon { color: #5b8def; }

/* Submit button */
.login-btn {
  position: relative;
  height: 50px;
  border: none; border-radius: 10px;
  background: linear-gradient(135deg, #5b8def, #2155cd);
  color: white; font-size: 15px; font-weight: 600;
  font-family: inherit; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  overflow: hidden;
  box-shadow:
    0 6px 18px rgba(33, 85, 205, .35),
    inset 0 1px 0 rgba(255, 255, 255, .2);
  transition: transform .12s, box-shadow .2s;
}
.login-btn:hover {
  box-shadow:
    0 10px 24px rgba(33, 85, 205, .5),
    inset 0 1px 0 rgba(255, 255, 255, .2);
  transform: translateY(-1px);
}
.login-btn:active { transform: translateY(0); }
.login-btn:disabled { cursor: not-allowed; }
.login-btn::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .25), transparent);
  transform: translateX(-100%);
  transition: transform .6s;
}
.login-btn:hover::before { transform: translateX(100%); }

.login-btn-arrow { transition: transform .2s; }
.login-btn:hover .login-btn-arrow { transform: translateX(3px); }

.login-btn-spinner {
  display: none;
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255, 255, 255, .3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.login-btn.loading .login-btn-text,
.login-btn.loading .login-btn-arrow { display: none; }
.login-btn.loading .login-btn-spinner { display: block; }
.login-btn.done {
  background: linear-gradient(135deg, #16a34a, #059669);
  box-shadow: 0 6px 18px rgba(16, 163, 74, .4);
}
.login-btn.done .login-btn-text { display: inline; }
.login-btn.done .login-btn-text::before { content: '✓ '; }
.login-btn.done .login-btn-arrow,
.login-btn.done .login-btn-spinner { display: none; }

.login-error {
  font-size: 13px; color: #fca5a5;
  min-height: 18px; text-align: center;
  opacity: 0; transform: translateY(-4px);
  transition: opacity .2s, transform .2s;
}
.login-error.show { opacity: 1; transform: translateY(0); }

.login-foot {
  margin-top: 22px;
  text-align: center;
  color: rgba(255, 255, 255, .35);
  font-size: 12px; letter-spacing: .03em;
}

@media (max-width: 480px) {
  .login-card { padding: 32px 22px 22px; max-width: 100%; border-radius: 16px; }
  .login-brand-mark { padding: 12px 18px; }
  .login-brand-mark img { height: 30px; }
  .login-title { font-size: 20px; }
  .login-bg .orb { filter: blur(60px); }
}

@media (max-width: 960px) {
  .filters { padding: 10px 14px; }
  .field input, .field-grow { width: auto; min-width: 160px; }
  main { padding: 12px 14px 0; }
  th, td { padding: 9px 8px; }
  .col-type { display: none; }
}

/* ---------- User menu (dropdown in topbar) ---------- */
.user-menu { position: relative; }
.user-trigger {
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid var(--border);
  padding: 5px 10px 5px 5px; border-radius: 999px; cursor: pointer;
  color: var(--text); font-family: inherit; font-size: 13.5px; font-weight: 500;
  transition: background .15s, border-color .15s;
}
.user-trigger:hover { background: var(--neutral-bg); border-color: var(--border-strong); }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #5b8def, #2155cd); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: white; border: 1px solid var(--border); border-radius: 9px;
  box-shadow: 0 12px 28px rgba(16,24,40,.12);
  min-width: 220px; padding: 5px; z-index: 50;
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.user-dropdown.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.dd-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 6px; text-decoration: none;
  color: var(--text); font-size: 13.5px; font-family: inherit; font-weight: 500;
  background: transparent; border: none; cursor: pointer; width: 100%; text-align: left;
}
.dd-item:hover { background: var(--neutral-bg); }
.dd-item svg { color: var(--text-soft); }
.dd-sep { height: 1px; background: var(--border); margin: 5px 0; }

/* ---------- Role badges ---------- */
.role-badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
}
.role-admin { background: #fce7f3; color: #9d174d; }
.role-editor { background: #dbeafe; color: #1e40af; }
.role-viewer { background: #f3f4f6; color: #4b5563; }

.action-tag {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11.5px; font-weight: 500; background: #f1f5f9; color: #475569;
}
.action-tag.action-variant_update { background: #dbeafe; color: #1e40af; }
.action-tag.action-login_success, .action-tag.action-login_success_2fa { background: #dcfce7; color: #15803d; }
.action-tag.action-login_fail, .action-tag.action-2fa_fail { background: #fee2e2; color: #b91c1c; }
.action-tag.action-user_create, .action-tag.action-user_update { background: #fef3c7; color: #92400e; }
.action-tag.action-user_delete { background: #fee2e2; color: #b91c1c; }
.action-tag.action-2fa_enable, .action-tag.action-2fa_disable { background: #f3e8ff; color: #6b21a8; }

.diff s { color: #94a3b8; text-decoration: line-through; }
.diff em { color: #16a34a; font-style: normal; font-weight: 600; }
.diff { margin-right: 12px; display: inline-block; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
  backdrop-filter: blur(4px);
}
.modal-card {
  background: white; border-radius: 12px; padding: 24px;
  max-width: 460px; width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
  animation: modalIn .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes modalIn { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-card h3 { margin: 0 0 14px; font-size: 17px; color: var(--text); }
.modal-card label.m-label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em; margin: 12px 0 5px;
}
.modal-card input, .modal-card select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 7px;
  font-size: 14px; font-family: inherit; color: var(--text); background: white;
}
.modal-card input:focus, .modal-card select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(33,85,205,.15);
}
.m-err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 16px; }
.m-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ---------- /me.html cards ---------- */
.me-card {
  background: white; padding: 22px; border-radius: 10px;
  border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.me-card h3 { margin: 0 0 16px; font-size: 16px; color: var(--text); }
.me-card .kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.me-card .kv:last-child { border-bottom: none; }
.me-card .kv span { color: var(--text-soft); font-size: 13.5px; }
.me-card .kv b { color: var(--text); font-weight: 500; }
.me-card label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin: 12px 0 5px; }
.me-card input, .me-card select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 7px;
  font-size: 14px; font-family: inherit;
}
.me-card input:focus, .me-card select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(33,85,205,.15); }
.me-card .btn { margin-top: 14px; }
.me-card .btn-ghost { margin-top: 14px; margin-left: 8px; }

/* ---------- Login OTP step ---------- */
.otp-row { display: flex; justify-content: center; }
.otp-row input {
  width: 100%; max-width: 260px;
  text-align: center; font-size: 28px; font-weight: 600;
  letter-spacing: 0.5em; padding: 14px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 10px;
  background: rgba(255, 255, 255, .06);
  color: white; font-family: ui-monospace, "SF Mono", monospace;
  outline: none; transition: border-color .2s, background .2s, box-shadow .2s;
}
.otp-row input:focus {
  border-color: #5b8def;
  background: rgba(255, 255, 255, .1);
  box-shadow: 0 0 0 4px rgba(91, 141, 239, .18);
}
.login-back {
  background: transparent; border: none; color: rgba(255, 255, 255, .65);
  font-size: 13px; cursor: pointer; padding: 4px; font-family: inherit;
}
.login-back:hover { color: white; }

/* ---------- Password show/hide eye ---------- */
.pw-wrap {
  position: relative; display: block; width: 100%;
}
.pw-wrap input { width: 100%; padding-right: 42px !important; }
.pw-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; padding: 6px 8px;
  color: var(--text-soft); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.pw-eye:hover { background: var(--neutral-bg); color: var(--text); }
.pw-eye:focus { outline: none; }

/* Override for dark login glass card */
.login-page .pw-wrap input { padding-right: 46px !important; }
.login-page .pw-eye { color: rgba(255, 255, 255, .55); }
.login-page .pw-eye:hover { background: rgba(255, 255, 255, .1); color: white; }

/* Keep floating label icon left, eye right */
.field-float .pw-wrap { position: static; }
.field-float .pw-wrap input { padding-left: 44px !important; }

/* ---------- Mobile (card layout) ---------- */
@media (max-width: 720px) {
  .topbar { padding: 10px 14px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 8px; }
  .brand-mark svg { width: 18px; height: 18px; }
  .brand-title { font-size: 14px; }
  .brand-sub { font-size: 11px; display: block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .btn-ghost span { display: none; }
  .btn-ghost { padding: 7px 9px; }

  .filters {
    flex-wrap: wrap;
    padding: 10px 12px; gap: 8px;
    top: 55px;
  }
  .field, .field-grow { flex: 1 1 100%; min-width: 0; }
  .field input { width: 100%; }
  .filters #limitSelect { flex: 1 1 100px; min-width: 0; height: 38px; }
  .filters .autosave { flex: 1 1 110px; min-width: 0; height: 38px; justify-content: center; }
  .filters #reloadBtn { flex: 0 1 auto; height: 38px; padding: 0 14px; }

  main { padding: 12px 12px 0; max-width: 100%; }

  /* Convert table -> card list */
  .table-wrap { background: transparent; border: none; box-shadow: none; overflow: visible; }
  table, tbody { display: block; }
  thead { display: none; }
  tr {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    column-gap: 12px; row-gap: 10px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 12px;
    align-items: start;
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
  }
  tr:hover { background: white; }
  tr.dirty { background: var(--warning-bg) !important; box-shadow: inset 3px 0 0 #f79009, 0 1px 2px rgba(16,24,40,.04); }
  td { display: block; border: none; padding: 0; width: auto; vertical-align: top; }

  .col-img { grid-column: 1; grid-row: 1; align-self: center; }
  .col-title { grid-column: 2; grid-row: 1; min-width: 0; max-width: none; align-self: center; }
  .col-action { grid-column: 3; grid-row: 1; align-self: center; }
  .col-action .btn-save { padding: 8px 14px; min-width: 64px; }
  .col-type { display: none; }
  .product-link { font-size: 13.5px; line-height: 1.35; }
  .variant-title { font-size: 11.5px; }

  .col-price, .col-qty, .col-stock {
    grid-column: 1 / -1;
    width: 100%;
    box-sizing: border-box;
    border-top: 1px dashed var(--border);
    padding-top: 9px;
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    align-items: center;
    column-gap: 12px;
    justify-self: stretch;
  }

  .col-price::before, .col-qty::before, .col-stock::before {
    font-size: 11.5px; font-weight: 600;
    color: var(--text-soft); text-transform: uppercase; letter-spacing: .04em;
  }
  .col-price::before { content: 'Giá (đ)'; }
  .col-qty::before { content: 'Số lượng'; }
  .col-stock::before { content: 'Trạng thái'; align-self: start; padding-top: 4px; }

  input.price, input.qty {
    width: 100%;
    text-align: right; font-size: 15px; padding: 9px 12px;
  }
  .stock-cell {
    display: flex; flex-direction: column; align-items: flex-start;
    gap: 8px;
  }
  .stock-cell > .badge { order: 1; }
  .switch { order: 2; }
  .product-link {
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
    overflow: hidden; text-overflow: ellipsis;
  }
  .product-link .ext { display: inline-block; vertical-align: middle; margin-left: 4px; }

  .pagination { padding: 14px 0 20px; gap: 8px; flex-wrap: wrap; justify-content: space-between; }
  .btn-page { flex: 1; justify-content: center; padding: 9px 12px; }
  #pageInfo { width: 100%; order: 3; min-width: 0; padding-top: 4px; }
}

@media (max-width: 380px) {
  .brand-sub { max-width: 130px; }
  .topbar { padding: 9px 12px; }
  .brand-text { gap: 0; }
  .filters { padding: 8px 10px; }
  tr { padding: 10px; column-gap: 10px; }
  input.price, input.qty { max-width: 150px; font-size: 14.5px; }
}
