/* SKG 泰国线下销售 · 管理看板 —— 手写 CSS，无外链 */
:root {
  --brand: #0E9F8F;
  --brand-dark: #0b8478;
  --brand-weak: #e2f4f1;
  --bg: #f5f7f7;
  --card: #ffffff;
  --line: #e4eae9;
  --text: #22312f;
  --muted: #74857f;
  --red: #d5504b;
  --red-weak: #fbeceb;
  --amber: #b97d1c;
  --amber-weak: #fcf3e2;
  --green: #1c8f56;
  --green-weak: #e5f5ec;
  --blue: #3572c6;
  --blue-weak: #e8f0fb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(30, 60, 55, .06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans Thai", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
a { color: var(--brand); text-decoration: none; }
img { max-width: 100%; }

/* ---------- 登录 ---------- */
#login-view, #clerk-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef7f5 0%, var(--bg) 55%);
  padding: 24px;
}
#login-view.hidden, #clerk-view.hidden { display: none; }
.login-card {
  width: 360px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 8px 30px rgba(14, 159, 143, .10);
  padding: 32px 32px 28px;
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-logo { width: 68px; height: 68px; border-radius: 16px; display: inline-block;
  box-shadow: 0 4px 14px rgba(14, 159, 143, .25); }
.login-title { margin-top: 12px; font-size: 16px; font-weight: 600; }
.login-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; background: #fbfdfd; color: var(--text);
}
.field input:focus { outline: none; border-color: var(--brand); background: #fff; }
.remember { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin: 4px 0 14px; cursor: pointer; }
.login-error {
  background: var(--red-weak); color: var(--red); border-radius: 8px;
  padding: 8px 11px; font-size: 13px; margin-bottom: 12px;
}

/* ---------- 布局 ---------- */
#app-view { display: flex; min-height: 100vh; }
#sidebar {
  width: 196px; flex: 0 0 196px; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; border-bottom: 1px solid var(--line); }
.brand-logo { width: 32px; height: 32px; border-radius: 8px; flex: none; }
.brand-text b { display: block; font-size: 14px; }
.brand-text span { font-size: 11px; color: var(--muted); }
#nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
#nav a {
  display: flex; align-items: center; gap: 9px; color: var(--text);
  padding: 9px 12px; border-radius: 8px; margin-bottom: 2px; font-size: 14px;
}
#nav a:hover { background: var(--bg); }
#nav a.active { background: var(--brand-weak); color: var(--brand-dark); font-weight: 600; }
.nav-ico { width: 18px; text-align: center; color: var(--muted); font-size: 13px; }
#nav a.active .nav-ico { color: var(--brand-dark); }
.side-foot { border-top: 1px solid var(--line); padding: 12px 14px; }
.me-name { font-size: 13px; font-weight: 600; }
.me-role { font-size: 11px; color: var(--muted); margin: 1px 0 8px; }
#main { flex: 1; min-width: 0; padding: 20px 24px 40px; }

/* ---------- 通用组件 ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-title { font-size: 18px; font-weight: 700; }
.page-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar label { font-size: 12px; color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 7px 14px; font-size: 13px; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { background: #fff; border-color: #eccfce; color: var(--red); }
.btn-danger:hover { background: var(--red-weak); }
.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; padding: 10px; font-size: 15px; }
input[type=date], input[type=text], input[type=number], input[type=password], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 13px;
  background: #fff; color: var(--text); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
textarea { width: 100%; resize: vertical; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.section { margin-bottom: 18px; }
.section-title { font-size: 14px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.section-title .hint { font-weight: 400; font-size: 12px; color: var(--muted); }

/* 统计卡 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { padding: 14px 16px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -.3px; }
.stat-note { font-size: 11px; color: var(--muted); margin-top: 3px; }
.stat-card.accent { border-top: 3px solid var(--brand); }

/* 待审核提醒条 */
.alert-pending {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: var(--amber-weak); border: 1px solid #f0dcb2; color: var(--amber);
  border-radius: var(--radius); padding: 11px 16px; margin-bottom: 16px; font-size: 13px;
}
.alert-pending b { font-size: 15px; }
.alert-pending .go { margin-left: auto; font-weight: 600; }
.alert-none { background: var(--green-weak); border-color: #cdeadb; color: var(--green); cursor: default; }
.alert-danger { background: var(--red-weak); border-color: #eccfce; color: var(--red); }

/* 图表区 */
.chart-row { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr); gap: 12px; }
@media (max-width: 980px) { .chart-row { grid-template-columns: 1fr; } }
.chart-card { padding: 14px 16px; }
.chart-card h3 { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.chart-card canvas { width: 100%; height: 220px; display: block; }

/* 横条图 */
.hbar-list { display: flex; flex-direction: column; gap: 9px; }
.hbar-item { display: grid; grid-template-columns: 110px 1fr 60px; gap: 8px; align-items: center; font-size: 12px; }
.hbar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { background: var(--bg); border-radius: 5px; height: 14px; overflow: hidden; }
.hbar-fill { background: var(--brand); height: 100%; border-radius: 5px; min-width: 2px; }
.hbar-val { text-align: right; color: var(--muted); }
.hbar-empty { color: var(--muted); font-size: 12px; padding: 12px 0; }

/* 排行 */
.rank-row { display: grid; grid-template-columns: 30px minmax(140px, 220px) 1fr 70px 110px 100px; gap: 10px; align-items: center; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 13px; }
.rank-row:first-child { border-top: none; }
.rank-row.head { color: var(--muted); font-size: 12px; background: #fafcfb; border-radius: var(--radius) var(--radius) 0 0; }
.rank-no { font-weight: 700; color: var(--muted); }
.rank-no.top { color: var(--brand); }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-name small { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button {
  border: none; background: none; padding: 8px 14px; font-size: 14px; cursor: pointer;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--brand-dark); font-weight: 600; border-bottom-color: var(--brand); }
.tabs .count-badge { background: var(--red); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; margin-left: 4px; }

/* 表格 */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafcfb; white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid #eef2f1; vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #fafdfc; }
.tbl .num { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

/* 状态徽章 */
.badge { display: inline-block; border-radius: 6px; padding: 1px 8px; font-size: 12px; white-space: nowrap; }
.badge.pending { background: var(--amber-weak); color: var(--amber); }
.badge.approved { background: var(--green-weak); color: var(--green); }
.badge.rejected { background: var(--red-weak); color: var(--red); }
.badge.settled { background: var(--blue-weak); color: var(--blue); }
.badge.draft { background: var(--amber-weak); color: var(--amber); }
.badge.gray { background: #eef1f0; color: var(--muted); }
.badge.ok { background: var(--green-weak); color: var(--green); }
.badge.fail { background: var(--red-weak); color: var(--red); }
.badge.warn { background: var(--amber-weak); color: var(--amber); }

/* 校验徽章行 */
.checks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.check-pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 6px; padding: 2px 8px; font-size: 12px; border: 1px solid transparent; }
.check-pill.pass { background: var(--green-weak); color: var(--green); }
.check-pill.fail { background: var(--red-weak); color: var(--red); }
.check-pill.na { background: #eef1f0; color: var(--muted); }
.check-detail { margin-top: 6px; font-size: 12px; color: var(--red); }

/* 审核卡片 */
.review-card { display: flex; gap: 14px; padding: 14px 16px; margin-bottom: 12px; }
.receipt-thumb {
  flex: 0 0 96px; width: 96px; height: 128px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); background: var(--bg); cursor: zoom-in;
}
.receipt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.receipt-none {
  flex: 0 0 96px; width: 96px; height: 128px; border-radius: 8px; border: 1px dashed var(--line);
  display: flex; align-items: center; justify-content: center; text-align: center;
  color: var(--muted); font-size: 12px; background: #fafcfb; padding: 6px;
}
.review-body { flex: 1; min-width: 0; }
.review-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; margin-bottom: 8px; align-items: baseline; }
.review-meta .rid { font-weight: 700; }
.review-meta .kv { color: var(--muted); }
.review-meta .kv b { color: var(--text); font-weight: 600; }
.review-actions { display: flex; flex-direction: column; gap: 8px; justify-content: flex-start; flex: 0 0 auto; }
.items-tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.items-tbl th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.items-tbl td { padding: 4px 8px; border-bottom: 1px dashed #eef2f1; }
.conf-hi { color: var(--green); }
.conf-mid { color: var(--amber); }
.conf-lo { color: var(--red); }

/* 结算 */
.settle-foot { display: flex; align-items: center; gap: 14px; padding: 12px 16px; font-size: 13px; }
.settle-foot .spacer { flex: 1; }

/* 周对账 */
.stat-value.c-green { color: var(--green); }
.stat-value.c-red { color: var(--red); }
.stat-value.c-amber { color: var(--amber); }
#rc-preview { margin-top: 10px; }
#rc-preview .tbl-wrap { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; }

/* 产品卡片 */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.prod-card { padding: 12px; cursor: pointer; transition: box-shadow .12s, transform .12s; position: relative; }
.prod-card:hover { box-shadow: 0 4px 14px rgba(14, 159, 143, .14); transform: translateY(-1px); }
.prod-img { width: 100%; height: 130px; border-radius: 8px; background: var(--bg); object-fit: cover; display: block; }
.prod-img.ph { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.prod-sku { font-weight: 700; font-size: 13px; margin-top: 8px; }
.prod-name { font-size: 12px; color: var(--muted); margin-top: 2px; height: 34px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.prod-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 13px; }
.prod-price { font-weight: 700; }
.prod-rebate { color: var(--brand-dark); font-size: 12px; }
.prod-card .badge.draft { position: absolute; top: 18px; right: 18px; }

/* 抽屉 */
#drawer-mask { position: fixed; inset: 0; background: rgba(25, 40, 37, .35); z-index: 40; }
#drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 94vw); z-index: 41;
  background: #fff; border-left: 1px solid var(--line); box-shadow: -8px 0 30px rgba(0,0,0,.12);
  overflow-y: auto; padding: 20px 22px 40px;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.drawer-title { font-size: 16px; font-weight: 700; }
.form-row { margin-bottom: 12px; }
.form-row > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form-row input[type=text], .form-row input[type=number], .form-row select { width: 100%; }
.form-inline { display: flex; gap: 8px; }
.form-inline > * { flex: 1; }
.spec-row { display: flex; gap: 6px; margin-bottom: 6px; }
.spec-row input.k { flex: 0 0 38%; }
.spec-row input.v { flex: 1; }
.media-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.media-strip img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.media-strip .vid { display: inline-flex; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 12px; color: var(--muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-foot { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); margin: 18px -22px -40px; padding: 12px 22px; display: flex; gap: 10px; justify-content: flex-end; }

/* 账号/门店表单 */
.acct-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; padding: 14px 16px; }
.acct-form .fi { display: flex; flex-direction: column; gap: 4px; }
.acct-form .fi > span { font-size: 11px; color: var(--muted); }
.import-box { padding: 14px 16px; }
.import-box textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.import-box .hint { font-size: 12px; color: var(--muted); margin: 6px 0 8px; }

/* 大图弹层 */
#lightbox {
  position: fixed; inset: 0; background: rgba(20, 30, 28, .8); z-index: 60;
  display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 30px;
}
#lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; background: #fff; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: rgba(30, 45, 42, .92); color: #fff; border-radius: 8px;
  padding: 9px 18px; font-size: 13px; z-index: 70; max-width: 80vw;
}
#toast.err { background: rgba(180, 55, 50, .95); }

.empty { text-align: center; color: var(--muted); padding: 34px 0; font-size: 13px; }
.loading { text-align: center; color: var(--muted); padding: 30px 0; font-size: 13px; }

/* 邮箱登录 */
.login-hint2 { color: var(--muted); font-size: 12px; line-height: 1.5; margin: -4px 0 4px; }
.clerk-note { color: var(--ink); font-size: 14px; line-height: 1.7; margin: 2px 0 16px; text-align: center; }
.clerk-note b { color: var(--brand); }
.login-alt { display: block; text-align: center; font-size: 12.5px; color: var(--muted); text-decoration: none; margin-top: 2px; }
.login-alt:hover { color: var(--brand); }

/* ---------- 手机适配（≤820px：侧边栏变顶栏、导航横滑、审核卡纵排） ---------- */
@media (max-width: 820px) {
  #app-view { display: block; }
  #sidebar { position: sticky; top: 0; z-index: 40; width: 100%; height: auto; flex: none;
    display: flex; flex-direction: row; align-items: center;
    border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { border-bottom: 0; padding: 8px 10px; flex: none; }
  .brand-text { display: none; }
  #nav { display: flex; align-items: center; padding: 0 4px; overflow-x: auto; overflow-y: hidden;
    white-space: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  #nav::-webkit-scrollbar { display: none; }
  #nav a { flex: none; padding: 13px 9px; margin: 0; border-radius: 0; font-size: 13px; gap: 5px; }
  #nav a.active { background: none; box-shadow: inset 0 -2px 0 var(--brand); }
  .side-foot { margin-left: auto; border-top: 0; padding: 6px 10px; flex: none;
    display: flex; align-items: center; }
  .side-foot .me { display: none; }
  #main { padding: 14px 12px 44px; }
  .review-card { flex-direction: column; gap: 10px; }
  .receipt-thumb, .receipt-none { width: 120px; height: 160px; flex: none; }
  .review-actions { flex-direction: row; }
  .review-actions .btn { flex: 1; }
  .settle-foot { flex-wrap: wrap; gap: 8px; }
  #drawer { width: 100vw; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.badge.withdrawn { background: #eef1f0; color: var(--muted); }
