/* ZAFAGO GMV — giao diện dashboard hiện đại (dark mặc định + light). Nhận diện: cam Shopee + mint TikTok Shop.
   Mọi màn hình dùng các biến này; không tự đặt màu cứng ngoài khối biến. Đổi theme: <html data-theme="dark|light">. */
:root {
  --shopee: #EE4D2D;
  --shopee-dark: #C93A1D;
  --shopee-soft: #FDECE8;
  --tiktok-mint: #25F4EE;
  --tiktok-mint-dark: #0FA8A3;
  --tiktok-mint-text: #08736F;
  --tiktok-mint-soft: #E3FDFC;
  --brand-gradient: linear-gradient(120deg, var(--shopee) 0%, #F6A08D 45%, #8FF8F5 70%, var(--tiktok-mint) 100%);
  --ink: #141A2E;
  --muted: #5A6382;
  --line: #E1E5EF;
  --bg: #F4F6FB;
  --surface: #FFFFFF;
  --surface-2: #EEF1F8;
  --hover: #F7F8FC;
  --ok: #1AA260;
  --ok-soft: #E6F6EE;
  --ok-text: #127A47;
  --warn: #B7791F;
  --warn-soft: #FEF6E7;
  --err: #C93A1D;
  --err-soft: #FDECE8;
  --btn-border: #C8CEDD;
  --soon: #A0A6BC;
  --glow: radial-gradient(60rem 28rem at 8% -8%, rgb(238 77 45 / .09), transparent 60%), radial-gradient(50rem 26rem at 96% -6%, rgb(37 244 238 / .12), transparent 60%);
  --shadow: 0 6px 24px rgb(20 26 46 / .08);
  --overlay: rgb(20 26 46 / .45);
  --glass: rgb(255 255 255 / .75);
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --shopee-soft: rgb(238 77 45 / .16);
  --tiktok-mint-soft: rgb(37 244 238 / .12);
  --tiktok-mint-text: #5FF3EE;
  --shopee-dark: #FF8266;
  --ink: #E8ECFA;
  --muted: #98A3C4;
  --line: rgb(255 255 255 / .09);
  --bg: #0A0F1E;
  --surface: #111933;
  --surface-2: #172044;
  --hover: #162043;
  --ok: #4ADE80;
  --ok-soft: rgb(74 222 128 / .13);
  --ok-text: #6EE7A0;
  --warn: #F0BE5A;
  --warn-soft: rgb(240 190 90 / .13);
  --err: #FF8A78;
  --err-soft: rgb(255 138 120 / .13);
  --btn-border: rgb(255 255 255 / .16);
  --soon: #5E6A8E;
  --glow: radial-gradient(60rem 28rem at 8% -8%, rgb(238 77 45 / .22), transparent 60%), radial-gradient(50rem 26rem at 96% -6%, rgb(37 244 238 / .15), transparent 60%);
  --shadow: 0 10px 34px rgb(0 0 0 / .4);
  --overlay: rgb(3 6 16 / .65);
  --glass: rgb(17 25 51 / .72);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--glow), var(--bg); background-repeat: no-repeat; background-attachment: fixed; min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--shopee-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
:root[data-theme="dark"] a { color: var(--tiktok-mint-text); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.main > * { animation: fadein .22s ease both; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- Đăng nhập ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: radial-gradient(40rem 26rem at 20% 15%, rgb(238 77 45 / .35), transparent 62%), radial-gradient(38rem 26rem at 82% 85%, rgb(37 244 238 / .28), transparent 62%), var(--bg); }
.login-card { background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 400px; }
.login-card .logo { font-size: 30px; }
.login-card .btn.primary { background: linear-gradient(100deg, var(--shopee), #F6785A); box-shadow: 0 6px 20px rgb(238 77 45 / .35); height: 40px; }
.logo { font-weight: 800; font-size: 24px; letter-spacing: .02em; margin: 0; }
.logo .z { color: var(--shopee); }
.logo .g { color: var(--tiktok-mint-dark); }
:root[data-theme="dark"] .logo .g { color: var(--tiktok-mint); }

/* ---- Khung ứng dụng ---- */
.topbar { height: 56px; display: flex; align-items: center; gap: 14px; padding: 0 18px; background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--brand-gradient); opacity: .85; }
.topbar .logo { font-size: 19px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--shopee), #7A5CFA 60%, var(--tiktok-mint-dark)); flex: none; }
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidenav { width: 224px; flex-shrink: 0; background: var(--glass); border-right: 1px solid var(--line); padding: 10px 10px; transition: width .15s; }
.sidenav .group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 16px 10px 6px; font-weight: 600; }
.sidenav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; position: relative; transition: background .12s; }
.sidenav a svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.sidenav a:hover { background: var(--hover); }
.sidenav a.active { background: var(--shopee-soft); color: var(--shopee-dark); font-weight: 600; }
.sidenav a.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--shopee); }
.sidenav a.soon { color: var(--soon); pointer-events: none; }
.navtoggle { width: 100%; justify-content: flex-start; margin-bottom: 4px; }
body.nav-collapsed .sidenav { width: 64px; }
body.nav-collapsed .sidenav .group { visibility: hidden; height: 6px; margin: 8px 0; }
body.nav-collapsed .sidenav a span, body.nav-collapsed .navtoggle span { display: none; }
body.nav-collapsed .sidenav a { justify-content: center; }
.main { flex: 1; padding: 24px 28px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; flex: 1; letter-spacing: -.01em; }

/* ---- Thành phần ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.btn { border: 1px solid var(--btn-border); background: var(--surface); padding: 7px 14px; min-height: 36px; border-radius: 10px; cursor: pointer; transition: border-color .12s, background .12s, transform .12s, box-shadow .12s; }
.btn:hover { border-color: var(--tiktok-mint-dark); background: var(--hover); }
.btn.primary { background: var(--shopee); border-color: var(--shopee); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #F4603F; border-color: #F4603F; box-shadow: 0 6px 18px rgb(238 77 45 / .35); }
.btn.mint { background: var(--tiktok-mint); border-color: var(--tiktok-mint); color: #08202A; font-weight: 600; }
.btn.small { padding: 3px 10px; font-size: 13px; min-height: 28px; }
.btn.icon { padding: 4px 9px; min-height: 32px; }
.btn.danger { background: #C93A1D; border-color: #C93A1D; color: #fff; font-weight: 700; }
.btn.danger:hover { background: #A92F16; border-color: #A92F16; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--btn-border); background: var(--surface); box-shadow: none; }
.btn.primary:disabled:hover { background: var(--shopee); border-color: var(--shopee); }
textarea:disabled, input:disabled { opacity: .6; cursor: not-allowed; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  border: 1px solid var(--btn-border); border-radius: 10px; padding: 7px 11px; min-height: 36px; background: var(--surface-2); min-width: 0; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--tiktok-mint-dark); box-shadow: 0 0 0 3px rgb(37 244 238 / .25); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); }
.field .req { color: var(--shopee); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

table.data { width: 100%; border-collapse: collapse; background: var(--surface); }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; z-index: 1; font-weight: 600; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover td { background: var(--hover); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 10px; color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge.shopee { background: var(--shopee-soft); color: var(--shopee-dark); }
.badge.tiktok { background: var(--tiktok-mint-soft); color: var(--tiktok-mint-text); }
.badge.ok { background: var(--ok-soft); color: var(--ok-text); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }

.msg { padding: 9px 13px; border-radius: 10px; margin-bottom: 12px; }
.msg.err { background: var(--err-soft); color: var(--err); }
.msg.ok { background: var(--ok-soft); color: var(--ok-text); }
.msg.info { background: var(--tiktok-mint-soft); color: var(--tiktok-mint-text); }

.modal-bg { position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; width: 100%; max-width: 560px; box-shadow: 0 24px 70px rgb(0 0 0 / .4); animation: fadein .18s ease both; }
.modal header { padding: 15px 20px; border-bottom: 1px solid var(--line); font-weight: 700; display: flex; }
.modal header .x { margin-left: auto; cursor: pointer; border: 0; background: none; font-size: 18px; color: var(--muted); }
.modal .body { padding: 18px 20px; }
.modal footer { padding: 13px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.modal.confirm { max-width: 480px; }
.modal.confirm .body p { margin: 0 0 8px; line-height: 1.5; }
.modal.confirm .body p:last-child { margin-bottom: 0; }
.modal.confirm .body ul { margin: 4px 0 8px; padding-left: 20px; line-height: 1.5; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; z-index: 60; max-width: calc(100vw - 32px); }
.toast { padding: 10px 15px; border-radius: 12px; color: #fff; background: #1E2A52; border: 1px solid rgb(255 255 255 / .12); z-index: 60; box-shadow: 0 10px 28px rgb(0 0 0 / .35); animation: fadein .18s ease both; }
.toast.err { background: #B33A24; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 9px 15px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--shopee-dark); border-bottom-color: var(--shopee); font-weight: 600; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.muted { color: var(--muted); }

/* Tổng quan (dùng cho chi tiết cửa hàng trong hệ thống) */
.filters { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.filters input, .filters select { min-width: 150px; }
.kpi-wrap { display: grid; gap: 14px; margin-bottom: 18px; }
.kpi-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; border-top: 3px solid var(--line); box-shadow: var(--shadow); transition: transform .15s; }
.kpi-group:hover { transform: translateY(-2px); }
.kpi-group.total { border-top-color: transparent; border-image: var(--brand-gradient) 1; border-image-slice: 1 0 0 0; }
.kpi-group.shopee { border-top-color: var(--shopee); }
.kpi-group.tiktok { border-top-color: var(--tiktok-mint); }
.kpi-group h3 { margin: 0 0 10px; font-size: 15px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 2px 0; overflow-wrap: anywhere; letter-spacing: -.01em; }
.kpi-sub { font-size: 12px; }
.delta { font-weight: 600; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--err); }
.delta.up::before { content: "▲ "; font-size: .8em; }
.delta.down::before { content: "▼ "; font-size: .8em; }
.note { font-size: 12px; margin: 10px 0 0; }
.seg { display: flex; gap: 6px; margin-bottom: 10px; }
.chart { margin-bottom: 12px; }
.chart svg { width: 100%; height: 180px; display: block; background: var(--surface-2); border-radius: 10px; }
.chart-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Hỏi đáp */
.chat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-height: 240px; max-height: 60vh; overflow-y: auto; margin-bottom: 10px; box-shadow: var(--shadow); }
.chat-msg { display: flex; flex-direction: column; margin-bottom: 12px; }
.chat-msg.user { align-items: flex-end; }
.chat-bubble { max-width: 85%; padding: 9px 13px; border-radius: 14px; overflow-wrap: anywhere; }
.chat-msg.user .chat-bubble { background: var(--shopee-soft); color: var(--ink); border-bottom-right-radius: 4px; }
.chat-msg.assistant .chat-bubble { background: var(--surface-2); border-bottom-left-radius: 4px; }
.chat-msg.pending .chat-bubble { color: var(--muted); font-style: italic; }
.chat-bubble p { margin: 4px 0; }
.chat-bubble .table-wrap { margin: 6px 0; }
.chat-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { flex: 1; resize: vertical; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidenav, body.nav-collapsed .sidenav { width: auto; border-right: 0; border-bottom: 1px solid var(--line); display: flex; overflow-x: auto; gap: 4px; padding: 8px; }
  .sidenav .group, .navtoggle { display: none; }
  .sidenav a, body.nav-collapsed .sidenav a { white-space: nowrap; justify-content: flex-start; }
  body.nav-collapsed .sidenav a span { display: inline; }
  .sidenav a.active::before { display: none; }
  .main { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .filters input, .filters select { min-width: 0; width: 100%; }
  .filters label { flex: 1 1 140px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 19px; }
  .chat-bubble { max-width: 100%; }
  .topbar .who { display: none; }
  table.data td, table.data th { white-space: nowrap; }
}

/* ---- Khung cố định: header + menu đứng yên, chỉ vùng dữ liệu cuộn (desktop) ---- */
@media (min-width: 761px) {
  html, body { height: 100%; }
  body { overflow: hidden; }
  #app { height: 100%; display: flex; flex-direction: column; }
  .layout { flex: 1; min-height: 0; }
  .sidenav { overflow-y: auto; }
  .main { overflow-y: auto; }
  .table-wrap.fit { overflow: auto; }
  .table-wrap.fit table.data th { box-shadow: 0 1px 0 var(--line); }
}

/* Bảo mật tài khoản */
.security-grid { display: grid; gap: 18px; }
.security-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.security-card-head h2 { font-size: 17px; margin: 0 0 4px; }
.security-card-head p { margin: 0; }
.security-sessions { min-width: 0; }
.mfa-qr { display: flex; justify-content: center; margin: 4px 0 18px; }
.mfa-qr img { display: block; width: 220px; height: 220px; max-width: 100%; border-radius: 10px; background: #fff; padding: 8px; }
.mfa-secret { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
