/* Web quản lý PicPal Photobooth
   Bộ màu sáng/tối + chuyển động lấy cảm hứng từ Lucian UX/UI Prompt (lucianlabs.dev, MIT):
   phản hồi ngay khi bấm, báo tiến trình khi chờ, xác nhận khi xong; tôn trọng prefers-reduced-motion. */
:root {
  color-scheme: light;
  --page: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eceef3;
  --ink: #1b1d26;
  --ink-2: #555a69;
  --ink-3: #8b90a0;
  --line: rgba(27, 29, 38, .09);
  --line-2: rgba(27, 29, 38, .17);
  --primary: #1677ff;
  --primary-soft: rgba(22, 119, 255, .1);
  --primary-ink: #ffffff;
  --cta: #ec9a2b;
  --cta-ink: #ffffff;
  --ok: #119c72;
  --ok-soft: rgba(17, 156, 114, .12);
  --warn: #d6731e;
  --warn-soft: rgba(214, 115, 30, .12);
  --danger: #d93a55;
  --danger-soft: rgba(217, 58, 85, .1);
  --lut: #8b5cf6;
  --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 4px 14px rgba(20, 24, 40, .05);
  --shadow-lg: 0 18px 50px rgba(20, 24, 40, .16);
  --radius: 14px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.45, .64, 1);
  --pop: cubic-bezier(.34, 1.7, .5, 1);
  --shake: cubic-bezier(.36, .07, .19, .97);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0b0c12; --surface: #14151d; --surface-2: #1a1b25; --surface-3: #252632;
    --ink: #f1efe9; --ink-2: rgba(241, 239, 233, .7); --ink-3: rgba(241, 239, 233, .45);
    --line: rgba(255, 255, 255, .08); --line-2: rgba(255, 255, 255, .16);
    --primary: #6ea8ff; --primary-soft: rgba(110, 168, 255, .15); --primary-ink: #0b0c12;
    --cta: #ffb65c; --cta-ink: #1b1306; --ok: #7ee8c0; --ok-soft: rgba(126, 232, 192, .13);
    --warn: #ffb26b; --warn-soft: rgba(255, 178, 107, .14); --danger: #ff7d8c; --danger-soft: rgba(255, 125, 140, .13); --lut: #b7a4ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3); --shadow-lg: 0 20px 60px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0c12; --surface: #14151d; --surface-2: #1a1b25; --surface-3: #252632;
  --ink: #f1efe9; --ink-2: rgba(241, 239, 233, .7); --ink-3: rgba(241, 239, 233, .45);
  --line: rgba(255, 255, 255, .08); --line-2: rgba(255, 255, 255, .16);
  --primary: #6ea8ff; --primary-soft: rgba(110, 168, 255, .15); --primary-ink: #0b0c12;
  --cta: #ffb65c; --cta-ink: #1b1306; --ok: #7ee8c0; --ok-soft: rgba(126, 232, 192, .13);
  --warn: #ffb26b; --warn-soft: rgba(255, 178, 107, .14); --danger: #ff7d8c; --danger-soft: rgba(255, 125, 140, .13); --lut: #b7a4ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3); --shadow-lg: 0 20px 60px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif; font-size: 14px; color: var(--ink); background: var(--page); letter-spacing: -.005em; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

/* ---------- Đăng nhập ---------- */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(1200px 600px at 10% -10%, var(--primary-soft), transparent), radial-gradient(900px 500px at 110% 110%, rgba(236, 154, 43, .14), transparent), var(--page); }
.login-box { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 12px; animation: rise .5s var(--ease) both; }
.login-box.shake { animation: shake .5s var(--shake); }
.login-logo { display: block; width: auto; max-width: 78%; height: 62px; margin: 2px auto 0; object-fit: contain; animation: pop .6s var(--pop) .1s both; }
.login-box h1 { text-align: center; font-size: 22px; }
.login-box p { text-align: center; margin: 0 0 6px; }
.error { color: var(--danger); min-height: 18px; font-size: 13px; }

/* ---------- Khung trang ---------- */
.layout { display: flex; min-height: 100%; }
.sidebar { width: 264px; flex: 0 0 264px; background: var(--surface-2); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto; padding-bottom: 20px; }
.side-brand { height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 22px; font-weight: 700; font-size: 16px; border-bottom: 1px solid var(--line); }
.side-brand img { height: 34px; max-width: 140px; object-fit: contain; }
nav { padding: 10px 8px; }
.menu-item { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px; color: var(--ink); cursor: pointer; font-size: 15px; user-select: none; transition: background-color .2s var(--ease), color .2s var(--ease), transform .25s var(--spring); }
.menu-item:hover { background: var(--surface-3); }
.menu-item:active { transform: scale(.98); }
.menu-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.menu-item.active::before { content: ''; position: absolute; left: -8px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--primary); animation: grow .35s var(--spring); }
.menu-item.open-group { color: var(--primary); }
.menu-item svg { width: 18px; height: 18px; flex: 0 0 18px; }
.menu-item .chev { margin-left: auto; transition: transform .3s var(--spring); width: 14px; height: 14px; }
.menu-item.collapsed .chev { transform: rotate(180deg); }
.submenu { margin: 2px 0 6px; animation: fade .3s var(--ease); }
.submenu .menu-item { padding-left: 44px; font-size: 14.5px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 28px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.crumb { font-weight: 600; color: var(--ink-3); }
.top-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), #7b61ff); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.user-name { display: flex; flex-direction: column; line-height: 1.2; }
.user-name small { color: var(--ink-3); font-size: 11.5px; }
.view { padding: 24px 28px 80px; }
.view > div { animation: rise .38s var(--ease) both; }
.mobile-only { display: none; }
.sync-btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 20px; border: 0; background: var(--primary-soft); color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; transition: transform .25s var(--spring), background-color .2s; }
.sync-btn:hover { background: color-mix(in srgb, var(--primary) 18%, transparent); }
.sync-btn:active { transform: scale(.96); }
.sync-btn svg { width: 18px; height: 18px; }
.sync-btn.spin svg { animation: spin .8s linear infinite; }

/* Công tắc sáng / tối kiểu ngày–đêm: ngày = trời xanh, mặt trời, mây · đêm = trời đêm, mặt trăng, sao */
.daynight { --w: 66px; --h: 34px; --pad: 4px; --k: calc(var(--h) - 2 * var(--pad));
  position: relative; flex: none; width: var(--w); height: var(--h); padding: 0; border: 0; border-radius: 999px; overflow: hidden; cursor: pointer; isolation: isolate;
  background: linear-gradient(180deg, #3d9bff, #8fd1ff); box-shadow: inset 0 2px 5px rgba(0, 0, 0, .22), 0 1px 0 rgba(255, 255, 255, .06);
  transition: transform .3s var(--spring), box-shadow .3s var(--ease); }
.daynight::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, #0b1433, #27336b); opacity: 0; transition: opacity .55s var(--ease); }
.daynight[aria-checked="true"]::before { opacity: 1; }
.daynight:hover { box-shadow: inset 0 2px 5px rgba(0, 0, 0, .22), 0 0 0 4px var(--primary-soft); }
.daynight:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.dn-sky { position: absolute; inset: 0; }
.dn-knob { position: absolute; z-index: 2; top: var(--pad); left: var(--pad); width: var(--k); height: var(--k); border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fff7c2, #ffd84a 46%, #f5a524);
  box-shadow: 0 0 0 5px rgba(255, 255, 255, .2), 0 0 0 11px rgba(255, 255, 255, .1), 0 2px 6px rgba(0, 0, 0, .28);
  transition: transform .6s var(--spring), background .45s var(--ease), box-shadow .45s var(--ease); }
.daynight:hover .dn-knob { transform: scale(1.06); }
.daynight:active .dn-knob { transform: scale(.92, .86); transition-duration: .12s; }
.daynight[aria-checked="true"] .dn-knob { transform: translateX(calc(var(--w) - var(--h)));
  background: radial-gradient(circle at 34% 30%, #ffffff, #e3e7f2 52%, #b8c0d6);
  box-shadow: 0 0 0 5px rgba(255, 255, 255, .07), 0 0 0 11px rgba(255, 255, 255, .04), 0 2px 6px rgba(0, 0, 0, .45); }
.daynight[aria-checked="true"]:hover .dn-knob { transform: translateX(calc(var(--w) - var(--h))) scale(1.06); }
.daynight[aria-checked="true"]:active .dn-knob { transform: translateX(calc(var(--w) - var(--h))) scale(.92, .86); }
.dn-crater { position: absolute; border-radius: 50%; background: #a7b0c8; box-shadow: inset 1px 1px 1px rgba(0, 0, 0, .12); opacity: 0; transform: scale(.4); transition: opacity .3s var(--ease) .12s, transform .4s var(--spring) .12s; }
.daynight[aria-checked="true"] .dn-crater { opacity: 1; transform: none; }
.dn-crater.k1 { width: 8px; height: 8px; top: 5px; left: 12px; }
.dn-crater.k2 { width: 5px; height: 5px; top: 14px; left: 6px; }
.dn-crater.k3 { width: 4px; height: 4px; top: 17px; left: 15px; }
.dn-cloud { position: absolute; height: 9px; border-radius: 9px; background: #fff; transition: transform .55s var(--ease), opacity .4s var(--ease); }
.dn-cloud::before, .dn-cloud::after { content: ''; position: absolute; border-radius: 50%; background: inherit; }
.dn-cloud.c1 { width: 24px; right: 5px; bottom: 4px; }
.dn-cloud.c1::before { width: 12px; height: 12px; left: 3px; top: -6px; }
.dn-cloud.c1::after { width: 10px; height: 10px; left: 11px; top: -4px; }
.dn-cloud.c2 { width: 18px; right: 18px; bottom: 9px; background: rgba(255, 255, 255, .72); transition-delay: .05s; }
.dn-cloud.c2::before { width: 9px; height: 9px; left: 3px; top: -5px; }
.dn-cloud.c2::after { width: 7px; height: 7px; left: 9px; top: -3px; }
.daynight[aria-checked="true"] .dn-cloud { transform: translateY(18px); opacity: 0; }
.dn-star { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #fff; box-shadow: 0 0 4px rgba(255, 255, 255, .8); opacity: 0; transform: scale(.2); transition: opacity .3s var(--ease), transform .45s var(--spring); }
.dn-star.s1 { top: 7px; left: 10px; } .dn-star.s2 { top: 17px; left: 18px; width: 2px; height: 2px; }
.dn-star.s3 { top: 9px; left: 26px; width: 2px; height: 2px; } .dn-star.s4 { top: 22px; left: 8px; width: 2px; height: 2px; }
.daynight[aria-checked="true"] .dn-star { opacity: 1; transform: none; animation: twinkle 2.6s ease-in-out infinite; }
.daynight[aria-checked="true"] .dn-star.s1 { transition-delay: .18s; } .daynight[aria-checked="true"] .dn-star.s2 { transition-delay: .26s; animation-delay: .8s; }
.daynight[aria-checked="true"] .dn-star.s3 { transition-delay: .34s; animation-delay: 1.5s; } .daynight[aria-checked="true"] .dn-star.s4 { transition-delay: .42s; animation-delay: 2.1s; }
@keyframes twinkle { 50% { opacity: .35; } }
.login { position: relative; }
.login-theme { position: absolute; top: 18px; right: 18px; }
/* Đổi giao diện: giao diện mới lan ra thành vòng tròn từ công tắc (View Transitions) */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-desc { margin: -8px 0 18px; color: var(--ink-2); max-width: 880px; line-height: 1.55; }

/* ---------- Nút ---------- */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background-color .2s var(--ease), border-color .2s var(--ease), transform .3s var(--spring), box-shadow .2s; }
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn:active { transform: scale(.96); transition-duration: .1s; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--primary) 88%, #000); box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 30%, transparent); }
.btn.cta { background: var(--cta); border-color: var(--cta); color: var(--cta-ink); font-weight: 600; }
.btn.cta:hover { background: color-mix(in srgb, var(--cta) 90%, #000); box-shadow: 0 6px 18px color-mix(in srgb, var(--cta) 35%, transparent); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; height: 44px; font-size: 15px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn .lbl { transition: opacity .2s var(--ease), transform .3s var(--ease); }
.btn.loading .lbl, .btn.done .lbl { opacity: 0; transform: scale(.9); }
.btn .state { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.btn .spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .75s linear infinite; }
.btn .check { width: 18px; height: 18px; animation: pop .5s var(--pop); }
.btn .check path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw .38s var(--ease) .12s forwards; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-3); font-size: 16px; transition: background-color .2s, color .2s, transform .3s var(--spring); }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn:active { transform: scale(.9); }
.icon-btn.del { color: var(--danger); }

/* ---------- Thẻ, lưới ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card > h3, .card-title { font-size: 16px; font-weight: 650; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.card-sub { color: var(--ink-3); font-size: 13px; margin: -8px 0 14px; line-height: 1.5; }
.grid { display: grid; gap: 14px 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Trường nhập ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.field small { color: var(--ink-3); font-size: 12px; line-height: 1.4; }
input, select, textarea { font: inherit; color: var(--ink); border: 1px solid var(--line-2); border-radius: 9px; padding: 0 11px; height: 36px; background: var(--surface); outline: none; min-width: 0; width: 100%; transition: border-color .2s var(--ease), box-shadow .2s var(--ease); }
textarea { padding: 9px 11px; height: auto; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type=color] { padding: 3px; width: 64px; cursor: pointer; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
input[type=range] { padding: 0; height: 24px; border: 0; box-shadow: none; accent-color: var(--primary); }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=text] { width: 110px; font-family: Consolas, monospace; }
.shake { animation: shake .45s var(--shake); }

/* Công tắc: núm trượt có độ nảy */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 22px; background: var(--surface-3); border: 1px solid var(--line-2); position: relative; transition: background-color .25s var(--ease), border-color .25s; flex: 0 0 38px; }
.switch .track::after { content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0004; transition: transform .45s var(--spring), width .2s var(--ease); }
.switch:active .track::after { width: 20px; }
.switch input:checked + .track { background: var(--ok); border-color: var(--ok); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch:active input:checked + .track::after { transform: translateX(12px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Nhãn */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.blue { background: var(--primary-soft); color: var(--primary); }
.badge.lut { background: var(--lut); color: #fff; }
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok .bdot, .badge.blue .bdot { animation: pulse 2s ease-in-out infinite; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--ink-3); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: ping 2.2s var(--ease) infinite; }

/* Bảng */
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 600; color: var(--ink-2); background: var(--surface-2); font-size: 13px; position: sticky; top: 0; }
.table th, .table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background-color .15s; }
.table tr.click { cursor: pointer; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--primary) 4%, transparent); }
.table td input, .table td select { height: 32px; }
.table .actions { display: flex; gap: 2px; justify-content: flex-end; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.table-wrap .table tr:last-child td { border-bottom: 0; }
.table .code { word-break: normal; white-space: nowrap; }
.nowrap .row { flex-wrap: nowrap; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 12px; }

/* Tab dạng viên trượt */
.tabs { position: relative; display: inline-flex; gap: 2px; padding: 4px; border-radius: 12px; background: var(--surface-3); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { position: relative; z-index: 1; border: 0; background: none; padding: 8px 16px; font: inherit; font-weight: 550; color: var(--ink-2); cursor: pointer; border-radius: 9px; transition: color .25s var(--ease); }
.tabs button.active { color: var(--ink); }
.tabs .ind { position: absolute; z-index: 0; top: 4px; bottom: 4px; border-radius: 9px; background: var(--surface); box-shadow: var(--shadow); transition: left .45s var(--spring), width .45s var(--spring); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills button { border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); border-radius: 20px; padding: 6px 14px; font: inherit; cursor: pointer; transition: background-color .2s, color .2s, border-color .2s, transform .3s var(--spring); }
.pills button:active { transform: scale(.95); }
.pills button.active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }

/* Lưới thẻ (filter, nhãn dán, khung...) */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 18px; }
.tile-grid > * { animation: rise .42s var(--ease) both; animation-delay: calc(var(--i, 0) * 30ms); }
.tile { position: relative; background: var(--surface); border: 2px solid var(--line); border-radius: 16px; padding: 18px 12px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 196px; transition: border-color .2s, box-shadow .25s var(--ease), transform .35s var(--spring); cursor: pointer; }
.tile:hover { box-shadow: 0 10px 26px rgba(20, 24, 40, .1); transform: translateY(-3px); }
.tile:active { transform: scale(.98); }
.tile.lut { border-color: color-mix(in srgb, var(--lut) 45%, transparent); }
.tile.off { opacity: .55; }
.tile .tag { position: absolute; top: -11px; left: 12px; }
.tile .del { position: absolute; top: 8px; right: 8px; }
.tile .name { font-weight: 600; text-align: center; font-size: 14px; }
.tile .foot { align-self: stretch; display: flex; justify-content: space-between; align-items: center; margin-top: auto; font-size: 12px; }
.tile .on-label { color: var(--ok); font-weight: 600; }
.tile .off-label { color: var(--ink-3); }
.tile.add { border: 2px dashed var(--line-2); justify-content: center; color: var(--ink-3); background: var(--surface-2); }
.tile.add:hover { border-color: var(--primary); color: var(--primary); }
.tile.add .plus { font-size: 30px; color: var(--primary); animation: bob 2.6s ease-in-out infinite; }
.avatar-prev { width: 104px; height: 104px; border-radius: 50%; object-fit: cover; background: var(--surface-3); transition: transform .4s var(--spring); }
.tile:hover .avatar-prev { transform: scale(1.05); }
.thumb-prev { width: 100%; height: 130px; object-fit: contain; border-radius: 8px; }
.checker { background-color: var(--surface); background-image: linear-gradient(45deg, var(--surface-3) 25%, transparent 25%), linear-gradient(-45deg, var(--surface-3) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--surface-3) 75%), linear-gradient(-45deg, transparent 75%, var(--surface-3) 75%); background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.frame-card canvas { width: 100%; height: 190px; object-fit: contain; }
.frame-card .meta2 { align-self: stretch; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; font-size: 12px; }
.frame-card .meta2 span { color: var(--ink-3); }
.frame-card .meta2 b { font-weight: 600; font-size: 13px; }
.sample-btn { display: inline-flex; align-items: center; gap: 10px; height: 46px; padding: 0 16px 0 4px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface-2); color: var(--ink); cursor: pointer; font: inherit; transition: transform .3s var(--spring); }
.sample-btn:active { transform: scale(.97); }
.sample-btn img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }

/* Khung kéo thả tải file */
.dropzone { position: relative; border: 2px dashed var(--line-2); border-radius: 16px; background: var(--surface-2); padding: 26px 16px; text-align: center; color: var(--ink-2); cursor: pointer; transition: background-color .25s var(--ease), border-color .25s var(--ease), transform .5s var(--spring); }
.dropzone:hover { border-color: var(--primary); }
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); transform: scale(1.015); background-image: repeating-linear-gradient(90deg, transparent 0 10px, transparent 10px 20px); animation: march 1s linear infinite; }
.dropzone .dz-icon { font-size: 28px; color: var(--primary); display: inline-block; animation: bob 2.6s ease-in-out infinite; }
.dropzone.over .dz-icon { animation: none; transform: translateY(-4px) scale(1.15); transition: transform .4s var(--pop); }
.dropzone b { display: block; margin: 6px 0 2px; color: var(--ink); }
.dropzone small { color: var(--ink-3); }
.upload-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.upload-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; font-size: 12.5px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; animation: drop .55s var(--spring) both; }
.upload-item .bar { grid-column: 1 / -1; height: 5px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.upload-item .bar i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 5px; transition: width .3s var(--ease); }
.upload-item.done .bar i { background: var(--ok); }
.upload-item.err .bar i { background: var(--danger); width: 100% !important; }
.img-drop { transition: transform .4s var(--spring), box-shadow .2s; }
.img-drop.over { transform: scale(1.06); box-shadow: 0 0 0 3px var(--primary); }

/* KPI & biểu đồ */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); animation: rise .4s var(--ease) both; }
.kpi .label { color: var(--ink-3); font-size: 13px; }
.kpi .value { font-size: 24px; font-weight: 700; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12px; font-weight: 600; }
.kpi .sub { font-size: 12.5px; color: var(--ink-3); line-height: 1.55; }
.kpi .sub b { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.kpi .sub.up, .plus { color: var(--ok); font-weight: 600; }
.plus .muted { font-weight: 400; }
.warn-text, .kpi .sub.warn-text { color: var(--danger); font-weight: 600; }
.table tr.row-alert td { background: color-mix(in srgb, var(--danger) 7%, transparent); }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--primary); transform-box: fill-box; transform-origin: bottom; animation: barup .7s var(--spring) both; }
.chart .bar:hover { fill: color-mix(in srgb, var(--primary) 80%, #000); }
.chart text { font-size: 11px; fill: var(--ink-3); }
.chart line { stroke: var(--line); }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar .track { height: 10px; background: var(--surface-3); border-radius: 10px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--primary); border-radius: 10px; animation: fillx .95s cubic-bezier(.22, .9, .24, 1) both; transform-origin: left; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Thanh dung lượng */
.meter { height: 14px; border-radius: 14px; background: var(--surface-3); overflow: hidden; display: flex; }
.meter i { display: block; height: 100%; animation: fillx .95s cubic-bezier(.22, .9, .24, 1) both; transform-origin: left; }
.meter i + i { border-left: 2px solid var(--surface); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Trạng thái rỗng, đang tải */
.empty { text-align: center; color: var(--ink-3); padding: 34px 10px; }
.empty .e-icon { font-size: 40px; display: block; margin-bottom: 8px; animation: bob 3s ease-in-out infinite; }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.skeleton { display: grid; gap: 14px; }
.sk { border-radius: 12px; background: linear-gradient(100deg, var(--surface-3) 30%, color-mix(in srgb, var(--surface-3) 50%, var(--surface)) 50%, var(--surface-3) 70%); background-size: 300% 100%; animation: shimmer 1.3s linear infinite; }
.callout { background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent); color: var(--ink); border-radius: 12px; padding: 12px 14px; line-height: 1.6; font-size: 13.5px; }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.callout.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.code { font-family: Consolas, monospace; background: var(--surface-3); padding: 2px 7px; border-radius: 6px; font-size: 13px; word-break: break-all; }

/* Bảng giá: mỗi cỡ ảnh 1 hàng */
.price-row { display: grid; grid-template-columns: 160px 1fr; gap: 14px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.price-row:last-child { border-bottom: 0; }
.pr-name { display: flex; flex-direction: column; gap: 2px; padding-top: 6px; }
.pr-items { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.pr-item { position: relative; display: grid; grid-template-columns: 1fr; gap: 4px; width: 130px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px 6px; animation: rise .3s var(--ease) both; }
.pr-item label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }
.pr-item label input { width: 54px; height: 28px; padding: 0 6px; }
.pr-item > input { height: 32px; font-weight: 700; }
.pr-item .del { position: absolute; top: 2px; right: 2px; width: 24px; height: 24px; font-size: 12px; }
@media (max-width: 760px) { .price-row { grid-template-columns: 1fr; } }

/* Trình sửa khung */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.editor-canvas { background: #2b2e36; border-radius: var(--radius); padding: 18px; display: flex; justify-content: center; position: sticky; top: 84px; }
.editor-canvas canvas { max-width: 100%; max-height: calc(100vh - 160px); box-shadow: 0 8px 30px #0006; cursor: crosshair; touch-action: none; }
.editor-side .card { padding: 14px 16px; }
.slot-row { display: grid; grid-template-columns: 22px repeat(4, minmax(0, 1fr)) 28px; gap: 6px; align-items: center; margin-bottom: 6px; font-size: 12px; }
.slot-row input { height: 30px; padding: 0 6px; }
.slot-row.sel { background: var(--primary-soft); border-radius: 6px; }

/* Bố cục chủ đề (xem trước màn hình máy chụp, kéo để sắp xếp) */
.layout-board { background: #f6f3f4; border-radius: 16px; padding: 18px; border: 1px solid var(--line); }
.layout-board .lb-title { text-align: center; font-weight: 700; color: #2b2b30; margin-bottom: 12px; letter-spacing: .02em; }
.layout-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 70px; grid-auto-flow: dense; gap: 10px; }
.lg-card { grid-row: span 3; border-radius: 12px; overflow: hidden; background: #fff; box-shadow: 0 4px 12px #0002; cursor: grab; position: relative; transition: transform .35s var(--spring), box-shadow .2s, opacity .2s; }
.lg-card.wide { grid-column: span 2; grid-row: span 1; }
.lg-card img, .lg-card .lg-ph { width: 100%; height: 100%; object-fit: cover; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #c2185b; background: #fde3ec; }
.lg-card .lg-name { position: absolute; left: 6px; bottom: 6px; background: #000a; color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.lg-card.dragging { opacity: .35; }
.lg-card.over { transform: scale(1.04); box-shadow: 0 0 0 3px var(--primary); }

/* Hộp thoại & thông báo */
.modal-back { position: fixed; inset: 0; background: rgba(10, 12, 20, .45); backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 100; overflow-y: auto; animation: fade .2s var(--ease); }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); animation: modalin .42s var(--spring) both; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 650; font-size: 16px; }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
#toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column-reverse; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; position: relative; overflow: hidden; display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 420px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); padding: 12px 16px 14px 12px; border-radius: 14px; box-shadow: var(--shadow-lg); font-size: 14px; animation: toastin .55s var(--spring) both; }
.toast.out { animation: toastout .3s var(--ease) forwards; }
.toast .t-icon { flex: 0 0 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary); animation: pop .5s var(--pop) .08s both; }
.toast.ok .t-icon { background: var(--ok-soft); color: var(--ok); }
.toast.err .t-icon { background: var(--danger-soft); color: var(--danger); }
.toast .t-icon svg { width: 16px; height: 16px; }
.toast .t-icon path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw .4s var(--ease) .22s forwards; }
.toast .t-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: currentColor; opacity: .25; transform-origin: left; }
.toast.ok .t-bar { color: var(--ok); }
.toast.err .t-bar { color: var(--danger); }
.save-bar { position: sticky; bottom: 0; margin: 18px -28px -80px; padding: 12px 28px; background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; z-index: 10; }
.mock-screen { aspect-ratio: 16/10; border-radius: 12px; overflow: hidden; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; background-size: cover; background-position: center; }
.mock-screen .t { font-size: 26px; font-weight: 800; }
.mock-screen .b { margin-top: 10px; padding: 10px 26px; border-radius: 30px; font-weight: 700; }
.phone { width: 300px; border: 10px solid #111; border-radius: 34px; overflow: hidden; height: 560px; background: #f6f6f9; }
.phone iframe { width: 100%; height: 100%; border: 0; }
.slides { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.slide { position: relative; border-radius: 10px; overflow: hidden; background: #000; aspect-ratio: 16/10; animation: rise .4s var(--ease) both; }
.slide.portrait { aspect-ratio: 9/16; }
.slide img, .slide video { width: 100%; height: 100%; object-fit: cover; display: block; }
.slide .bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; padding: 4px; background: linear-gradient(transparent, #000a); }
.slide .bar button { background: #fff; color: #222; border: 0; border-radius: 6px; cursor: pointer; padding: 2px 8px; }
.machine-card { display: flex; flex-direction: column; gap: 10px; }
.machine-card .top { display: flex; align-items: center; gap: 10px; }
.machine-card .meta { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; font-size: 13px; }
.machine-card .meta span:nth-child(odd) { color: var(--ink-3); }
.hw { display: flex; flex-wrap: wrap; gap: 4px; }
.mchecks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; max-height: 220px; overflow: auto; padding: 4px 2px; }
.mchecks label { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; }
.info-grid .k { color: var(--ink-3); font-size: 12.5px; }
.info-grid .v { font-weight: 600; font-size: 16px; margin-top: 2px; }
.stat-box { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; background: var(--surface-2); border-radius: 12px; padding: 16px 18px; }
.stat-box .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.code-list { display: flex; flex-direction: column; gap: 10px; max-height: 520px; overflow: auto; }
.code-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; transition: border-color .2s; animation: rise .35s var(--ease) both; }
.code-item:hover { border-color: var(--line-2); }
.code-item .c { font-family: Consolas, monospace; font-size: 16px; font-weight: 700; letter-spacing: .06em; display: flex; align-items: center; gap: 6px; }

/* Chuyển động */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { 0% { transform: scale(.3); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes bob { 50% { transform: translateY(-5px); } }
@keyframes grow { from { transform: scaleY(0); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 8px transparent; } }
@keyframes shimmer { to { background-position: -150% 0; } }
@keyframes march { to { background-position: 20px 0; } }
@keyframes drop { 0% { opacity: 0; transform: translateY(-14px) scale(.96); } }
@keyframes modalin { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes toastin { from { opacity: 0; transform: translateY(24px) scale(.94); } }
@keyframes toastout { to { opacity: 0; transform: translateX(30px) scale(.96); } }
@keyframes barup { from { transform: scaleY(0); } }
@keyframes fillx { from { transform: scaleX(0); } }
@keyframes countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (max-width: 1100px) {
  .editor { grid-template-columns: 1fr; }
  .editor-canvas { position: static; }
  .cols { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .35s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .mobile-only { display: inline-flex; }
  .view { padding: 16px 16px 80px; }
  .topbar { padding: 0 12px; }
  .g2, .g3, .g4, .info-grid { grid-template-columns: 1fr; }
  .save-bar { margin: 18px -16px -80px; padding: 12px 16px; }
  .page-head h1 { font-size: 22px; }
  .user-name, .sync-btn .lbl-text { display: none; }
}
