/* ==========================================================================
   AnyProduct — Product Platform Admin Design System
   ========================================================================== */
#adm-root {
  --brand: #9D2933;
  --brand-hover: #822029;
  --brand-soft: #FDF2F3;
  --brand-border: #EACAD0;
  --blue: #0F6CBD;
  --blue-soft: #EEF6FC;
  --ok: #157F4B;
  --ok-soft: #EAF7F0;
  --warn: #B45309;
  --warn-soft: #FEF6E7;
  --err: #C81E1E;
  --err-soft: #FDECEC;

  --bg: #F5F7FA;
  --card: #FFFFFF;
  --sub: #F8FAFC;
  --line: #E6EAF0;
  --line-soft: #F0F3F7;
  --ink: #181D26;
  --ink-2: #344054;
  --muted: #667085;
  --muted-2: #98A2B3;

  --sb-bg: #141821;
  --sb-line: #232A38;
  --sb-text: #9BA4B5;
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.04);
  --shadow-drawer: -12px 0 36px rgba(15, 23, 42, 0.14);
  --shadow-modal: 0 20px 50px rgba(15, 23, 42, 0.22);

  font-family: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

#adm-root.is-dark {
  --brand: #E05260;
  --brand-hover: #EB6875;
  --brand-soft: rgba(224, 82, 96, 0.14);
  --brand-border: rgba(224, 82, 96, 0.34);
  --blue: #52A8F8;
  --blue-soft: rgba(82, 168, 248, 0.14);
  --ok: #34D399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --warn: #FBBF24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --err: #F87171;
  --err-soft: rgba(248, 113, 113, 0.14);

  --bg: #0E1218;
  --card: #161C26;
  --sub: #1C2431;
  --line: #283244;
  --line-soft: #202938;
  --ink: #ECF1F8;
  --ink-2: #C8D2E3;
  --muted: #8B97AB;
  --muted-2: #647287;
  --shadow-drawer: -14px 0 42px rgba(0, 0, 0, 0.5);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; background: #F5F7FA; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
h1, h2, h3, p { margin: 0; }

.mono {
  font-family: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* Login View */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 18% 12%, var(--brand-soft) 0%, var(--bg) 52%);
}
.login-card {
  width: min(410px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px 32px;
  box-shadow: var(--shadow-modal);
  display: grid;
  gap: 20px;
}

/* App Shell */
.adm-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
}
.adm-sidebar {
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  user-select: none;
}
.sb-brand {
  height: 60px; padding: 0 18px;
  display: flex; align-items: center; gap: 11px;
  border-bottom: 1px solid var(--sb-line);
}
.sb-logo {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, #B3313C, #861E27);
  display: grid; place-items: center; color: #fff;
}
.sb-brand b { color: #fff; font-size: 15px; font-weight: 650; }

.sb-nav { padding: 14px 12px; display: grid; gap: 5px; }
.sb-item {
  width: 100%; height: 40px; padding: 0 12px; border: 0; border-radius: 8px;
  background: transparent; color: var(--sb-text);
  display: flex; align-items: center; gap: 11px; text-align: left;
  transition: background 0.14s, color 0.14s;
}
.sb-item svg { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.sb-item:hover { background: rgba(255,255,255,0.05); color: #EAEFF7; }
.sb-item.active { background: rgba(157, 41, 51, 0.24); color: #FFFFFF; font-weight: 600; }
.sb-item.active svg { color: #F47682; opacity: 1; }

.sb-spacer { flex: 1; }
.sb-user {
  margin: 12px; padding: 12px; border-radius: 10px;
  background: #1B212E; border: 1px solid var(--sb-line);
  display: grid; gap: 9px;
}
.sb-user-top { display: flex; align-items: center; gap: 9px; }
.sb-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #2B3448;
  color: #fff; font-weight: 600; font-size: 12px; display: grid; place-items: center; flex: none;
}
.sb-user-info b { display: block; color: #F1F5F9; font-size: 12.5px; }
.sb-user-info small { display: block; color: #8492A6; font-size: 11px; }
.sb-user-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sb-mini-btn {
  height: 27px; border-radius: 6px; border: 1px solid #2E384D;
  background: #141821; color: #C0CADB; font-size: 11.5px;
}
.sb-mini-btn:hover { border-color: #4D5B7A; color: #fff; }

/* Topbar & Main */
.adm-main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.pwd-banner {
  background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line);
  padding: 8px 32px; font-size: 12.5px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.adm-topbar {
  height: 60px; padding: 0 32px; background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  position: sticky; top: 0; z-index: 20;
}
.tb-title { font-size: 17px; font-weight: 650; color: var(--ink); }
.tb-search {
  width: min(380px, 40vw); height: 36px; padding: 0 12px;
  border-radius: 9px; border: 1px solid var(--line); background: var(--sub);
  color: var(--muted); display: flex; align-items: center; gap: 9px; text-align: left;
}
.tb-search:hover { border-color: var(--muted-2); background: var(--card); color: var(--ink); }
.tb-search svg { width: 15px; height: 15px; flex: none; }
.tb-search span { flex: 1; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-search kbd {
  font-family: Consolas, monospace; font-size: 11px; padding: 1px 6px;
  border-radius: 5px; border: 1px solid var(--line); background: var(--card);
}

.adm-body {
  padding: 28px 32px 40px;
  display: grid;
  gap: 20px;
  align-content: start;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* Controls */
.btn {
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap; transition: all 0.14s; text-decoration: none;
}
.btn:hover:not(:disabled) { border-color: var(--muted-2); background: var(--sub); }
.btn-sm { height: 29px; padding: 0 11px; font-size: 12px; border-radius: 7px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn-danger { color: var(--err); border-color: transparent; background: var(--err-soft); }
.btn-danger:hover:not(:disabled) { border-color: var(--err); }

.seg {
  display: inline-flex; padding: 3px; border-radius: 9px;
  background: var(--sub); border: 1px solid var(--line); gap: 3px;
}
.seg button {
  height: 29px; padding: 0 14px; border: 0; border-radius: 7px;
  background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 500;
}
.seg button.active {
  background: var(--card); color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.chip {
  height: 31px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-size: 12.5px;
}
.chip:hover { color: var(--ink); border-color: var(--muted-2); }
.chip.active {
  background: var(--brand-soft); border-color: var(--brand-border);
  color: var(--brand); font-weight: 600;
}

.input, .select {
  height: 36px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink); padding: 0 12px; font-size: 13px; outline: none; width: 100%;
}
.filter-select { width: auto; min-width: 156px; height: 35px; }
.date-input { width: 148px; height: 35px; }
.filter-form input[type="search"] { width: min(280px, 100%); }
.filter-form input[name="cat"] { width: 130px; }
.diag-event { display: grid; gap: 5px; }
.input:focus, .select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}

.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 23px; padding: 0 9px;
  border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-err { background: var(--err-soft); color: var(--err); }
.tag-blue { background: var(--blue-soft); color: var(--blue); }
.tag-brand { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.tag-muted { background: var(--sub); color: var(--muted); }

/* Cards & Layouts */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-sm); min-width: 0;
}
.card-p { padding: 22px 24px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 18px;
}
.card-head h2 { font-size: 15px; font-weight: 650; color: var(--ink); }

.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.kpi-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 22px; display: grid; gap: 8px; text-align: left; width: 100%;
}
button.kpi-box { transition: border-color 0.14s, transform 0.14s; }
button.kpi-box:hover { border-color: var(--brand); transform: translateY(-1px); }
.kpi-label { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.kpi-num { font-size: 30px; font-weight: 700; color: var(--ink); line-height: 1.15; letter-spacing: -0.02em; }
.kpi-sub { font-size: 12px; color: var(--muted); }

.ov-cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; }
.todo-list { display: grid; gap: 10px; }
.todo-row {
  width: 100%; padding: 13px 15px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--sub); display: flex; align-items: center; justify-content: space-between;
  gap: 12px; text-align: left; transition: border-color 0.14s, background 0.14s;
}
button.todo-row:hover { border-color: var(--brand); background: var(--card); }

.tbl-wrap { overflow-x: auto; width: 100%; }
table.adm-tbl { width: 100%; border-collapse: collapse; text-align: left; }
table.adm-tbl th {
  padding: 12px 18px; font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--sub); border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.adm-tbl td {
  height: 53px; padding: 5px 18px; border-bottom: 1px solid var(--line-soft);
  vertical-align: middle; font-size: 13.5px;
}
table.adm-tbl tbody tr:last-child td { border-bottom: 0; }
table.adm-tbl tbody tr.clickable { cursor: pointer; transition: background 0.12s; }
table.adm-tbl tbody tr.clickable:hover { background: var(--sub); }
.adm-tbl td .actions { flex-wrap: nowrap; }

.link-btn { border: 0; background: none; padding: 0; color: var(--blue); font-weight: 500; }
.link-btn:hover { text-decoration: underline; }

.split-layout {
  display: grid; grid-template-columns: 350px minmax(0, 1fr);
  gap: 20px; align-items: start;
}
.q-list { display: grid; gap: 9px; max-height: calc(100vh - 220px); overflow-y: auto; }
.q-item {
  width: 100%; text-align: left; padding: 13px 15px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); display: grid; gap: 6px;
}
.q-item:hover { background: var(--sub); }
.q-item.active {
  border-color: var(--brand); background: var(--brand-soft);
  box-shadow: 0 0 0 1px var(--brand);
}
.q-item b { overflow-wrap: anywhere; min-width: 0; }

.topic-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px;
  background: var(--sub); display: grid; gap: 12px;
}
.topic-card.checked { background: var(--card); border-color: var(--brand-border); }
.dur-pill {
  height: 30px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink-2); font-size: 12.5px;
}
.dur-pill:hover { border-color: var(--brand); color: var(--brand); }
.dur-pill.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* QR Delivery Box */
.delivery-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 236px;
  gap: 20px;
  align-items: start;
}
.qr-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--sub);
  padding: 14px;
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
}
.qr-img {
  width: 200px;
  height: 200px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #ffffff;
  display: block;
}
.qr-modal-wrap {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}
.qr-modal-wrap .qr-img {
  width: 260px;
  height: 260px;
}

.code-pre {
  background: #131822; color: #DCE4F0; border-radius: 10px; padding: 12px 14px;
  font-family: "JetBrains Mono", Consolas, monospace; font-size: 11.5px; line-height: 1.55;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all; width: 100%; text-align: left;
}

/* Slide-over Drawer */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.28);
  z-index: 60; opacity: 0; pointer-events: none; transition: opacity 0.18s;
}
.drawer-mask.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 92vw);
  background: var(--card); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-drawer); z-index: 70;
  display: flex; flex-direction: column;
  transform: translateX(102%); transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  padding: 20px 24px; border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.drawer-tabs {
  padding: 0 24px; border-bottom: 1px solid var(--line); display: flex; gap: 22px;
}
.drawer-tabs button {
  padding: 12px 0; border: 0; border-bottom: 2px solid transparent;
  background: none; color: var(--muted); font-size: 13px; font-weight: 500;
}
.drawer-tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px 24px; display: grid; align-content: start; gap: 18px; }
.drawer-body h3 { font-size: 13.5px; margin-bottom: 8px; }
.drawer-body .adm-tbl th, .drawer-body .adm-tbl td { padding-left: 10px; padding-right: 10px; }
.drawer-body details summary { cursor: pointer; margin-bottom: 8px; font-weight: 600; }

/* Modal & Toast */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.42);
  z-index: 90; display: grid; place-items: start center; padding-top: 9vh;
}
.modal-mask[hidden] { display: none !important; }
.modal-box {
  width: min(460px, 92vw); max-height: 82vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-modal);
}
.modal-box.wide { width: min(640px, 94vw); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 15px; }
.modal-content { padding: 18px 20px; }

.adm-toast {
  position: fixed; bottom: 26px; right: 28px; z-index: 110;
  background: #181D26; color: #fff; padding: 11px 18px; border-radius: 9px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.22); font-size: 13px;
  opacity: 0; transform: translateY(10px); pointer-events: none; transition: all 0.18s;
}
.adm-toast.show { opacity: 1; transform: translateY(0); }

.muted { color: var(--muted); }
.second { display: block; font-size: 12px; }
.stack { display: grid; gap: 14px; min-width: 0; }
.two, .three { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.toolbar, .between, .actions, .chips, .inline-form, .login-brand, .check-label, .topic-check, .pagination {
  display: flex; align-items: center; gap: 9px; min-width: 0;
}
.toolbar, .between { justify-content: space-between; }
.toolbar, .actions, .chips, .between { flex-wrap: wrap; }
.toolbar + .q-list, .queue-body, .card-head + .stack { margin-top: 5px; }
.queue-body { margin-top: 17px; }
.pagination { justify-content: flex-end; margin-top: 12px; }
.field { display: grid; gap: 6px; color: var(--muted); min-width: 0; align-content: start; }
textarea.input { padding: 8px 12px; height: auto; resize: vertical; }
.field .input, .field .select { color: var(--ink); }
.form-error { color: var(--err); line-height: 1.55; }
.login-brand { gap: 12px; }
.login-brand b { font-size: 17px; }
.login-brand .sb-logo { width: 36px; height: 36px; }
.login-submit { height: 40px; }
.password-field { display: grid; align-items: end; grid-template-columns: 1fr auto; gap: 8px; }
.password-field button { height: 36px; }
.empty { min-height: 80px; display: grid; place-items: center; padding: 16px; text-align: center; }
.ellipsis, .line-clamp { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.preline { white-space: pre-wrap; overflow-wrap: anywhere; }
.soft-row { padding: 10px 13px; border-radius: 8px; background: var(--sub); }
.drop-zone { display: grid; gap: 6px; padding: 18px 12px; border: 1px dashed var(--brand-border); border-radius: 10px; background: var(--sub); }
.drop-zone.drag { border-color: var(--brand); background: var(--brand-soft); }
.drop-zone input { max-width: 100%; }
.date-field { width: 145px; height: 30px; }
.license-identity { margin-bottom: 14px; }
.topic-check input, .check-label input { accent-color: var(--brand); width: 16px; height: 16px; }
.topic-preview strong { color: var(--ok); }
.topic-tags { display: flex; flex-wrap: wrap; gap: 5px; }

@media (max-width: 1080px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .ov-cols, .split-layout, .delivery-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .adm-shell { grid-template-columns: 64px minmax(0, 1fr); }
  .sb-brand b, .sb-item span, .sb-user-top { display: none; }
  .sb-item { justify-content: center; padding: 0; }
  .sb-user { display: grid; margin: 4px; padding: 3px; }
  .sb-user-actions { display: grid; grid-template-columns: 1fr; gap: 4px; }
  .sb-mini-btn { font-size: 10px; padding: 0; }
  .adm-topbar { padding: 0 12px; gap: 8px; }
  .tb-search { min-width: 0; }
  .tb-search kbd { display: none; }
  .adm-body { padding: 18px; }
  .card-p { padding: 14px; }
  .three, .two { grid-template-columns: 1fr; }
  .pwd-banner { padding: 6px 12px; }
  .seg { flex-wrap: wrap; }
  table.adm-tbl, table.adm-tbl tbody, table.adm-tbl tr, table.adm-tbl td { display: block; width: 100%; }
  table.adm-tbl thead { display: none; }
  table.adm-tbl tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.adm-tbl tbody tr:last-child { border-bottom: 0; }
  table.adm-tbl td {
    height: auto; min-height: 30px; border-bottom: 0; padding: 4px 14px;
    display: grid; grid-template-columns: minmax(0, 1fr); align-items: center;
  }
  .adm-tbl td .actions, .filter-form { flex-wrap: wrap; }
  .filter-form input[type="search"], .date-input, .filter-select { width: 100%; }
}
