/* ===== Giao diện "Dashboard tối" ===== */
:root {
  /* ===== Tông màu Shopee ===== */
  --bg: #f5f5f5;            /* nền trang xám nhạt */
  --panel: #ffffff;         /* khung trắng */
  --line: #ececec;
  --input-line: #dcdcdc;
  --input-line-strong: #c4c4c4;
  --text: #222222;
  --ink: #222222;           /* chữ đậm, tiêu đề, số */
  --muted: #6b6b6b;
  --soft: #444444;
  --accent: #ee4d2d;        /* cam Shopee: biểu đồ, viền, số lớn */
  --btn: #d9381a;           /* nút: cam đậm hơn 1 chút để chữ trắng dễ đọc */
  --btn-hover: #c4371c;
  --accent-ink: #ffffff;
  --accent-bg: #fff1ee;     /* nền cam rất nhạt (mục đang chọn) */
  --accent-text: #c4371c;   /* chữ cam trên nền nhạt */
  --link: #d73211;
  --link-hover: #a8290d;
  --danger: #d0011b;
  --side-1: #d9381a;        /* sidebar cam */
  --side-2: #bf3014;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font-family: Inter, system-ui, sans-serif; font-size: 15px; }
a { color: var(--link); } a:hover { color: var(--link-hover); }
.font-display { font-family: "Space Grotesk", sans-serif; }

/* Khung chính: sidebar + nội dung */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex: 0 0 230px; background: var(--panel); border-right: 1px solid var(--line);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh;
}
.brand { font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 22px; padding: 0 12px 20px; color: var(--ink); text-decoration: none; }
.brand span { color: var(--accent); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 10px; color: var(--soft); text-decoration: none; }
.nav-item:hover { background: var(--line); color: var(--ink); }
.nav-item.active { background: var(--accent-bg); color: var(--accent-text); font-weight: 600; }
.nav-item svg { flex: 0 0 auto; }
.btn-accent { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px;
  border: none; border-radius: 10px; background: var(--btn); color: var(--accent-ink); font: 700 15px Inter, sans-serif; text-decoration: none; cursor: pointer; }
.btn-accent:hover { background: var(--btn-hover); color: var(--accent-ink); }
.btn-accent:disabled { opacity: .6; cursor: wait; }

.content { flex: 1; min-width: 0; padding: 32px 4%; display: flex; flex-direction: column; gap: 24px; }
.page-title { margin: 0; font-family: "Space Grotesk", sans-serif; font-size: 32px; color: var(--ink); }
.page-sub { margin: 6px 0 0; color: var(--muted); }

/* Ô số liệu */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-family: "Space Grotesk", sans-serif; font-size: 30px; color: var(--ink); margin-top: 6px; }
.stat-value.accent { color: var(--accent); }
.stat-link { font-size: 16px; color: var(--ink); margin-top: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; text-decoration: none; }

/* Form */
.form { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--soft); }
.field.full { grid-column: 1 / -1; }
.field .err { color: var(--danger); font-size: 12px; min-height: 0; }
.input { height: 44px; padding: 0 14px; background: var(--bg); border: 1px solid var(--input-line); border-radius: 10px;
  color: var(--ink); font: 15px Inter, sans-serif; width: 100%; }
.input.lg { height: 48px; }
.input::placeholder { color: #8a8a8a; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(238,77,45,.2); }
.input.invalid { border-color: var(--danger); }
.drop { position: relative; display: flex; align-items: center; gap: 8px; height: 44px; background: var(--bg);
  border: 1px dashed var(--input-line-strong); border-radius: 10px; padding: 0 6px 0 14px; }
.drop.dragover { border-color: var(--accent); background: var(--accent-bg); }
.drop .input { border: none; padding: 0; height: 40px; box-shadow: none; background: transparent; }
.drop .pick { flex: 0 0 auto; height: 32px; padding: 0 12px; border: 1px solid var(--input-line); border-radius: 8px;
  background: transparent; color: var(--soft); font: 13px Inter, sans-serif; cursor: pointer; }
.drop .pick:hover { border-color: var(--accent); color: var(--ink); }
.file-chip { display: none; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); min-width: 0; flex: 1; }
.file-chip.show { display: flex; }
.file-chip b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; }
.submit-cell { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.submit-cell .btn-accent { min-width: 220px; }
.terms { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--muted); }

/* Bảng link */
.table-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow-x: auto; }
.table-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 4px; gap: 12px; flex-wrap: wrap; }
.table-head h2 { margin: 0; font: 600 16px Inter, sans-serif; color: var(--ink); }
.table-head small { color: var(--muted); }
table { width: 100%; min-width: 600px; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 500; padding: 14px 18px; }
td { padding: 12px 18px; border-top: 1px solid var(--line); }
td.short a { font-weight: 600; text-decoration: none; }
td.long { color: var(--muted); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.num { color: var(--ink); font-weight: 600; }
td.num small { color: var(--accent); font-weight: 500; margin-left: 4px; }
td.actions { text-align: right; white-space: nowrap; }
.icon-btn { width: 40px; height: 40px; border: 1px solid var(--input-line); border-radius: 8px; background: transparent;
  color: var(--soft); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; margin-left: 4px; }
.icon-btn:hover { border-color: var(--accent); color: var(--ink); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.thumb { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; background: var(--line); vertical-align: middle; margin-right: 10px; }
.empty { padding: 32px 18px; text-align: center; color: var(--muted); }

/* QR */
dialog.qr { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(340px, 92vw); }
dialog.qr::backdrop { background: rgba(0,0,0,.6); }
dialog.qr h3 { margin: 0 0 4px; font-family: "Space Grotesk", sans-serif; color: var(--ink); }
dialog.qr .url { font-size: 13px; color: var(--muted); word-break: break-all; margin-bottom: 14px; }
.qr-box { background: #fff; border-radius: 12px; padding: 14px; display: flex; justify-content: center; }
.qr-box img, .qr-box canvas { max-width: 100%; }
.qr-actions { display: flex; gap: 8px; margin-top: 16px; }
.qr-actions > * { flex: 1; }
.btn-ghost { height: 44px; border: 1px solid var(--input-line); border-radius: 10px; background: transparent; color: var(--soft); font: 15px Inter, sans-serif; cursor: pointer; }
.btn-ghost:hover { color: var(--ink); border-color: var(--soft); }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); opacity: 0; transition: .2s;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 10px 18px; border-radius: 10px; z-index: 50; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* Điện thoại / máy tính bảng */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: auto; flex: none; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; border-right: none; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 8px; margin-right: auto; }
  .nav-item { padding: 10px; }
  .nav-item .label { display: none; }
  .content { padding: 20px 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats .card:last-child { grid-column: 1 / -1; }
  .form { grid-template-columns: 1fr; }
}

/* ===== Sidebar: chấm "trực tiếp" + công tắc thông báo ===== */
.nav-item { position: relative; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--input-line-strong); margin-left: auto; }
.live-dot.on { background: var(--accent); box-shadow: 0 0 0 0 rgba(238,77,45,.6); animation: ping 2s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(238,77,45,.55); } 80%,100% { box-shadow: 0 0 0 8px rgba(238,77,45,0); } }
.side-settings { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding-top: 12px; border-top: 1px solid var(--line); }
.side-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 12px 4px; }
.switch { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--soft); font-size: 14px; cursor: pointer; }
.switch:hover { background: var(--line); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch i { margin-left: auto; width: 34px; height: 20px; border-radius: 999px; background: #cfcfcf; position: relative; transition: .2s; flex: 0 0 auto; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { left: 17px; background: var(--accent-ink); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== Thông báo click trực tiếp (góc phải dưới) ===== */
.live-toasts { position: fixed; right: 20px; bottom: 20px; z-index: 70; display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100vw - 40px)); }
.live-toast { display: flex; gap: 12px; align-items: flex-start; background: var(--accent-bg); border: 1px solid var(--accent-bg); 
  border-radius: 12px; padding: 12px 14px; box-shadow: 0 12px 30px rgba(0,0,0,.12); animation: slideIn .25s ease-out; transition: .3s; }
.live-toast.out { opacity: 0; transform: translateX(20px); }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.pulse { flex: 0 0 auto; width: 10px; height: 10px; margin-top: 4px; border-radius: 50%; background: var(--accent); animation: ping 1.6s infinite; }
.lt-title { color: var(--ink); font-size: 14px; }
.lt-title b { color: var(--accent); }
.lt-meta { color: var(--muted); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }

/* Nháy dòng / số khi có click mới */
tr.flash td { animation: fresh 2.5s ease-out; }
@keyframes fresh { 0% { background: rgba(238,77,45,.22); } 100% { background: transparent; } }
.stat-value.bump { animation: bump .5s ease-out; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 860px) {
  .side-settings { margin: 0; padding: 0; border: none; flex-direction: row; }
  .side-title { display: none; }
  .switch .label { display: none; }
  .live-dot { margin-left: 4px; }
}


/* ===================== Tông Shopee: sidebar cam ===================== */
.sidebar { background: linear-gradient(180deg, var(--side-1), var(--side-2)); border-right: none; color: #fff; }
.sidebar .brand { color: #fff; }
.sidebar .brand span { color: #fff; }
.sidebar .nav-item { color: #fff; }
.sidebar .nav-item:hover { background: rgba(255,255,255,.14); color: #fff; }
.sidebar .nav-item.active { background: #fff; color: var(--accent-text); }
.sidebar .live-dot { background: rgba(255,255,255,.45); }
.sidebar .live-dot.on { background: #fff; box-shadow: none; animation: pingW 2s infinite; }
.sidebar .nav-item.active .live-dot.on { background: var(--accent); }
@keyframes pingW { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.7); } 80%,100% { box-shadow: 0 0 0 8px rgba(255,255,255,0); } }
.sidebar .side-settings { border-top-color: rgba(255,255,255,.25); }
.sidebar .side-title { color: #fff; opacity: .9; }
.sidebar .switch { color: #fff; }
.sidebar .switch:hover { background: rgba(255,255,255,.14); }
.sidebar .switch i { background: rgba(255,255,255,.35); }
.sidebar .switch i::after { background: #fff; }
.sidebar .switch input:checked + i { background: #fff; }
.sidebar .switch input:checked + i::after { background: var(--accent); }
.sidebar .switch input:focus-visible + i { outline-color: #fff; }
.side-user { margin-top: 8px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.25); display: flex; flex-direction: column; gap: 2px; }
.side-user .who { display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-weight: 600; color: #fff; overflow: hidden; }
.side-user .who .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-btn { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: none; border-radius: 10px; background: transparent; color: #fff; font: 14px Inter, sans-serif; cursor: pointer; text-align: left; }
.side-btn:hover { background: rgba(255,255,255,.14); }

/* Khung & ô nhập trên nền sáng */
.card, .form, .table-box { box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.input { background: #fff; color: var(--ink); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(238,77,45,.15); }
.page-title { color: var(--ink); }
.stat-value.accent { color: var(--accent); }
.icon-btn { background: #fff; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent-text); }
.btn-ghost { background: #fff; color: var(--soft); }
.btn-ghost:hover { color: var(--accent-text); border-color: var(--accent); }
dialog.qr, dialog.crop { box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.toast { color: #fff; background: var(--btn); }
.live-toast { background: #fff; border: 1px solid #ffd3c9; }
.lt-title b, td.num small { color: var(--accent-text); }
td.short a { color: var(--link); }

/* Nhiều link sản phẩm */
.field-hint { color: var(--muted); font-size: 12px; }
.dest-list { display: flex; flex-direction: column; gap: 8px; }
.dest-row { display: flex; align-items: center; gap: 8px; }
.dest-row .input { flex: 1; min-width: 0; }
.dest-no { flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--accent-bg); color: var(--accent-text); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.add-dest { align-self: flex-start; margin-top: 2px; border-style: dashed; }
.add-dest:disabled { opacity: .5; cursor: default; }
.badge { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: var(--accent-bg); color: var(--accent-text); font-size: 11px; font-weight: 600; white-space: nowrap; vertical-align: middle; }
td.long { cursor: pointer; }

/* Hộp sửa link */
dialog.edit { width: min(600px, 94vw); max-height: 92vh; overflow-y: auto; }
dialog.edit h3 { margin: 0 0 6px; font-family: "Space Grotesk", sans-serif; color: var(--ink); }
.qr-actions { margin-top: 12px; }
dialog.edit h3 .code { color: var(--accent-text); font-weight: 600; }
.edit-grid { display: flex; flex-direction: column; gap: 14px; margin-bottom: 8px; }
.edit-img { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.edit-img img { width: 180px; aspect-ratio: 1.91 / 1; object-fit: cover; border-radius: 8px; background: var(--line); border: 1px solid var(--line); }
.edit-img-actions { flex: 1 1 220px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; }
.edit-img-actions .input { flex: 1 1 100%; }
.btn-ghost.sm { height: 38px; padding: 0 12px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }

@media (max-width: 860px) {
  .side-user { margin: 0; padding: 0; border: none; flex-direction: row; }
  .side-user .who, .side-btn .label { display: none; }
}

/* 2 ô số liệu nhỏ gọn ở trang Rút gọn link */
.stats.two { display: flex; flex-wrap: wrap; gap: 12px; }
.stats.two .card { flex: 0 1 auto; min-width: 170px; padding: 10px 16px; display: flex; align-items: baseline; justify-content: space-between; gap: 16px; border-radius: 12px; }
.stats.two .stat-label { font-size: 13px; }
.stats.two .stat-value { font-size: 22px; margin-top: 0; }
@media (max-width: 860px) { .stats.two .card { flex: 1 1 140px; grid-column: auto; } }
