/* 柠檬云配置中心 · 设计语言参考 shadcn-admin（new-york / slate） */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --secondary: 240 4.8% 95.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --radius: 8px;
  --canvas: 240 5% 96.5%;
  --sidebar: 0 0% 100%;
  --success: 142 71% 45%;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: 240 10% 3.9%;
    --foreground: 0 0% 98%;
    --card: 240 10% 5.9%;
    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%;
    --secondary: 240 3.7% 15.9%;
    --primary: 0 0% 98%;
    --primary-foreground: 240 5.9% 10%;
    --destructive: 0 62.8% 50%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 3.7% 15.9%;
    --input: 240 3.7% 15.9%;
    --ring: 240 4.9% 83.9%;
    --canvas: 240 10% 3.9%;
    --sidebar: 240 10% 4.9%;
  }
}

:root[data-theme="dark"] {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 10% 5.9%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --secondary: 240 3.7% 15.9%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 5.9% 10%;
  --destructive: 0 62.8% 50%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --ring: 240 4.9% 83.9%;
  --canvas: 240 10% 3.9%;
  --sidebar: 240 10% 4.9%;
}

html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: hsl(var(--canvas));
  color: hsl(var(--foreground));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 600; }
p { margin: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
button { font-family: inherit; }

/* ---------------- 登录 ---------------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(700px 340px at 50% -10%, hsl(var(--muted)) 0%, transparent 70%),
    hsl(var(--canvas));
}
.login-card {
  width: min(400px, 100%);
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 4px);
  padding: 28px;
  box-shadow: 0 1px 2px hsl(240 10% 4% / .05), 0 12px 32px hsl(240 10% 4% / .08);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-title { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.login-sub { font-size: 12px; color: hsl(var(--muted-foreground)); margin-top: 2px; }
.login-note { margin-top: 18px; font-size: 12px; line-height: 1.6; color: hsl(var(--muted-foreground)); }
.brand-mark {
  width: 36px; height: 36px; flex: 0 0 36px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 16px; font-weight: 600;
}

/* ---------------- 布局 ---------------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 16px 12px;
  background: hsl(var(--sidebar));
  border-right: 1px solid hsl(var(--border));
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; }
.brand-text span { font-size: 11.5px; color: hsl(var(--muted-foreground)); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 36px; padding: 0 10px;
  border: 0; border-radius: 6px;
  background: transparent; color: hsl(var(--muted-foreground));
  font-size: 13px; text-align: left; cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.nav-item svg { width: 16px; height: 16px; flex: 0 0 16px; }
.nav-item:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.nav-item.active { background: hsl(var(--secondary)); color: hsl(var(--foreground)); font-weight: 500; }
.sidebar-foot {
  margin-top: auto; display: flex; flex-direction: column; gap: 8px;
  padding: 12px 8px 4px; border-top: 1px solid hsl(var(--border));
}
.side-meta { font-size: 11.5px; color: hsl(var(--muted-foreground)); display: flex; gap: 6px; }
.dot-sep { opacity: .6; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: 56px; flex: 0 0 56px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 24px;
  background: hsl(var(--background) / .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid hsl(var(--border));
}
.crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.crumb-muted { color: hsl(var(--muted-foreground)); font-weight: 400; }
.crumb-sep { color: hsl(var(--muted-foreground)); opacity: .6; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.dirty-badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px;
  border-radius: 999px; border: 1px solid hsl(var(--border));
  background: hsl(var(--muted)); color: hsl(var(--muted-foreground));
  font-size: 11.5px; white-space: nowrap;
}
.dirty-badge i { width: 6px; height: 6px; border-radius: 50%; background: hsl(38 92% 50%); }

.content { padding: 24px; max-width: 1080px; width: 100%; margin: 0 auto; }
.page { display: flex; flex-direction: column; gap: 16px; }
.page-head { margin-bottom: 4px; }
.page-head h1 { font-size: 20px; letter-spacing: -.02em; }
.page-head p { margin-top: 6px; font-size: 13px; color: hsl(var(--muted-foreground)); }

/* ---------------- 卡片 ---------------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat {
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 4px); padding: 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-label { font-size: 12px; color: hsl(var(--muted-foreground)); }
.stat-value { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.card {
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 1px 2px hsl(240 10% 4% / .04);
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 18px 20px 0;
}
.card-title { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.card-desc { margin-top: 3px; font-size: 12.5px; color: hsl(var(--muted-foreground)); }
.card-body { padding: 18px 20px 20px; }
.badge {
  height: 22px; padding: 0 8px; display: inline-flex; align-items: center;
  border-radius: 6px; border: 1px solid hsl(var(--border));
  background: hsl(var(--muted)); color: hsl(var(--muted-foreground));
  font-size: 11px; font-family: ui-monospace, Menlo, Consolas, monospace;
}

.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.check-list li {
  position: relative; padding: 9px 0 9px 24px; font-size: 13px;
  border-bottom: 1px solid hsl(var(--border) / .6);
}
.check-list li:last-child { border-bottom: 0; }
.check-list li::before {
  content: ""; position: absolute; left: 4px; top: 15px;
  width: 10px; height: 6px; border-left: 1.6px solid hsl(var(--success));
  border-bottom: 1.6px solid hsl(var(--success)); transform: rotate(-45deg);
}
.check-list b { font-weight: 600; }
.kv { display: flex; gap: 12px; padding: 7px 0; font-size: 12.5px; border-bottom: 1px dashed hsl(var(--border)); }
.kv:last-child { border-bottom: 0; }
.kv > span:first-child { flex: 0 0 84px; color: hsl(var(--muted-foreground)); }
.kv code { color: hsl(var(--foreground)); word-break: break-all; }

/* ---------------- 表单 ---------------- */
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 12.5px; font-weight: 500; }
.hint { font-size: 11.5px; color: hsl(var(--muted-foreground)); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input {
  width: 100%; height: 36px;
  padding: 0 10px;
  border: 1px solid hsl(var(--input));
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-family: inherit; font-size: 13px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input-wrap .input { padding-right: 54px; }
.input:focus-visible, .code-editor:focus-visible {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / .12);
}
.input[readonly] { color: hsl(var(--muted-foreground)); }
.unit {
  position: absolute; right: 10px;
  font-size: 11.5px; color: hsl(var(--muted-foreground));
  pointer-events: none; white-space: nowrap;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.preview {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed hsl(var(--border));
  font-size: 12.5px; color: hsl(var(--muted-foreground));
}
.product-card + .product-card { margin-top: 0; }

/* ---------------- 列表（折扣） ---------------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-head {
  display: grid; grid-template-columns: 110px 110px minmax(0, 1fr) 32px;
  gap: 10px; padding: 0 0 8px;
  font-size: 11.5px; color: hsl(var(--muted-foreground));
}
.list-head.promo-head { grid-template-columns: minmax(0, 1fr) 110px 32px; }
.list-row { display: grid; grid-template-columns: 110px 110px minmax(0, 1fr) 32px; gap: 10px; align-items: center; }
.list-row.promo-row { grid-template-columns: minmax(0, 1fr) 110px 32px; }
.list-row .input { height: 34px; }
.list-empty {
  padding: 18px; text-align: center; font-size: 12.5px;
  color: hsl(var(--muted-foreground));
  border: 1px dashed hsl(var(--border)); border-radius: 8px;
}
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- 表格 ---------------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 500;
  color: hsl(var(--muted-foreground));
  padding: 0 10px 8px; border-bottom: 1px solid hsl(var(--border));
}
.table td { padding: 7px 10px; border-bottom: 1px solid hsl(var(--border) / .6); }
.table tr:last-child td { border-bottom: 0; }
.table .input { height: 34px; max-width: 220px; }
.table .right { text-align: right; width: 44px; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: hsl(var(--foreground));
  font-size: 13px; font-weight: 500; white-space: nowrap;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
}
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-primary:hover:not(:disabled) { opacity: .9; }
.btn-outline { border-color: hsl(var(--border)); background: hsl(var(--background)); }
.btn-outline:hover:not(:disabled) { background: hsl(var(--muted)); }
.btn-ghost { color: hsl(var(--muted-foreground)); }
.btn-ghost:hover:not(:disabled) { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.btn-danger { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); }
.btn-danger:hover:not(:disabled) { opacity: .9; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 34px; height: 34px; flex: 0 0 34px;
  display: inline-grid; place-items: center;
  border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: hsl(var(--muted-foreground));
  cursor: pointer;
}
.icon-btn:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.danger:hover { color: hsl(var(--destructive)); background: hsl(var(--destructive) / .08); }
.icon-btn.danger svg { width: 15px; height: 15px; }

/* ---------------- 主题图标 ---------------- */
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* ---------------- 提示 ---------------- */
.form-error {
  margin-top: 10px; padding: 8px 10px;
  border: 1px solid hsl(var(--destructive) / .35);
  border-radius: 6px;
  background: hsl(var(--destructive) / .07);
  color: hsl(var(--destructive));
  font-size: 12.5px; white-space: pre-line;
}
.toasts {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(400px, calc(100vw - 40px));
}
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px;
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: 8px;
  box-shadow: 0 8px 24px hsl(240 10% 4% / .16);
  font-size: 13px;
  animation: toast-in .18s ease-out;
}
.toast.out { animation: toast-out .18s ease-in forwards; }
.toast-dot { width: 8px; height: 8px; flex: 0 0 8px; margin-top: 6px; border-radius: 50%; background: hsl(var(--success)); }
.toast.error .toast-dot { background: hsl(var(--destructive)); }
.toast-body { white-space: pre-line; word-break: break-word; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 16px;
  background: hsl(240 10% 4% / .45);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(420px, 100%);
  background: hsl(var(--card)); border: 1px solid hsl(var(--border));
  border-radius: 10px; padding: 22px;
  box-shadow: 0 24px 48px hsl(240 10% 4% / .24);
}
.modal-title { font-size: 15px; }
.modal-body { margin-top: 8px; font-size: 13px; color: hsl(var(--muted-foreground)); line-height: 1.6; }
.modal-actions { margin-top: 20px; display: flex; justify-content: flex-end; gap: 8px; }

/* ---------------- 高级工具 ---------------- */
.code-editor {
  width: 100%; min-height: 380px; resize: vertical;
  padding: 12px 14px;
  border: 1px solid hsl(var(--input)); border-radius: 8px;
  background: hsl(var(--muted) / .4);
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.6; tab-size: 2;
}
.backup-list { display: flex; flex-direction: column; }
.backup-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid hsl(var(--border) / .6);
  font-size: 12.5px;
}
.backup-row:last-child { border-bottom: 0; }
.backup-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.backup-name { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.backup-meta { color: hsl(var(--muted-foreground)); font-size: 11.5px; }
.backup-empty { padding: 18px; text-align: center; font-size: 12.5px; color: hsl(var(--muted-foreground)); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto;
    border-right: 0; border-bottom: 1px solid hsl(var(--border));
    padding: 12px;
  }
  .brand { padding: 2px 4px 10px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 2px; }
  .nav-item { width: auto; flex: 0 0 auto; padding: 0 12px; }
  .sidebar-foot { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .list-head, .list-row { grid-template-columns: 90px 90px minmax(0, 1fr) 32px; }
  .list-head.promo-head, .list-row.promo-row { grid-template-columns: minmax(0, 1fr) 90px 32px; }
}
@media (max-width: 620px) {
  .crumb-muted, .crumb-sep { display: none; }
  .dirty-badge { display: none; }
  .page-head h1 { font-size: 18px; }
}
