:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --line: #d7e0e9;
  --text: #1f2933;
  --muted: #5b6b7a;
  --primary: #2c5e8a;
  --primary-dark: #1f4465;
  --accent: #b46a2b;
  --green: #2f7d5c;
  --red: #a13c3c;
  --amber: #9a6a12;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 14px rgba(16, 24, 40, 0.06);
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  background: #173b57;
  color: #dcebf7;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  transition: transform 0.2s ease;
}
.brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 700;
  font-size: 16px;
  color: #fff;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: #d9a441;
  color: #173b57;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
}
.nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-title {
  font-size: 11px;
  letter-spacing: 0;
  color: #8fb3d2;
  padding: 8px 10px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 7px;
  color: #dcebf7;
  margin-bottom: 2px;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); }
.nav-item.active { background: rgba(255, 255, 255, 0.16); color: #fff; }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  color: #bfd7eb;
}

.main { flex: 1; margin-left: 232px; min-width: 0; }
.topbar {
  height: 64px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 19px; margin: 0; }
.topbar-meta { color: var(--muted); font-size: 13px; }
.hamburger { display: none; }

.content { padding: 24px; max-width: 1440px; }
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-head h2 { margin: 0 0 4px; font-size: 20px; }
.page-head p { margin: 0; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
}
.btn:hover { border-color: #aabccc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--red); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; }

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.todo-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.kpi {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 26px; font-weight: 800; line-height: 1.1; }
.kpi-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.kpi.blue .kpi-value { color: var(--primary); }
.kpi.green .kpi-value { color: var(--green); }
.kpi.amber .kpi-value { color: var(--amber); }
.kpi.red .kpi-value { color: var(--red); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-head h3 { margin: 0; font-size: 16px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; background: #f7f9fb; white-space: nowrap; }
td.number, th.number { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fafcfe; }
.empty { padding: 34px 18px; text-align: center; color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.blue { background: #e3eefb; color: #1f4d78; }
.badge.green { background: #e4f2eb; color: #1f6a49; }
.badge.amber { background: #fbefd8; color: #7a5508; }
.badge.red { background: #f7e4e4; color: #8f2f2f; }
.badge.gray { background: #eef1f4; color: #52606d; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
}
.modal {
  width: min(680px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px 22px; }
.modal-foot {
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 11px;
  background: #fff;
  width: 100%;
}
.field textarea { height: 74px; padding: 9px 11px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(44, 94, 138, 0.22); border-color: var(--primary); }

.thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #eef2f6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--primary);
  font-size: 15px;
}
.thumb.small { width: 32px; height: 32px; font-size: 12px; }
.image-preview {
  display: flex;
  align-items: center;
  gap: 12px;
}
.image-preview img, .image-preview .thumb.large {
  width: 76px;
  height: 76px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.line-editor { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.line-editor table { min-width: 560px; }
.line-editor th { background: #f2f6fa; }
.line-editor input, .line-editor select { height: 32px; border: 1px solid #d9e1e9; border-radius: 6px; padding: 0 8px; width: 100%; }
.add-line {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #f7f9fb;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.add-line select { width: 220px; height: 34px; }
.add-line input { width: 90px; height: 34px; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  padding: 20px;
  background:
    radial-gradient(1000px 520px at 86% -12%, rgba(217, 164, 65, 0.22), transparent 60%),
    radial-gradient(760px 420px at -6% 112%, rgba(49, 95, 117, 0.55), transparent 60%),
    linear-gradient(135deg, #0f2b44 0%, #173b57 55%, #22485f 100%);
}
.login-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
}
.login-card {
  position: relative;
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px 24px;
  box-shadow: 0 30px 80px rgba(6, 20, 32, 0.45);
}
.login-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.login-logo {
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #d9a441, #f0c166);
  color: #173b57;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(217, 164, 65, 0.35);
  overflow: hidden;
}
.login-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 14px; }
.login-card h1 { margin: 0; font-size: 24px; letter-spacing: 1px; }
.login-card .login-sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.login-card .field { margin-bottom: 14px; }
.login-btn { width: 100%; height: 44px; margin-top: 8px; font-size: 15px; letter-spacing: 6px; border-radius: 8px; }
.login-foot {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #eef1f4;
  font-size: 12px;
  color: var(--muted);
}
.login-tip {
  margin-top: 12px;
  padding: 10px 12px;
  background: #f2f6fa;
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}

.toast {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 200;
  background: #173b57;
  color: #fff;
  padding: 11px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-6px);
  transition: 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

.splash {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #173b57;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity 0.35s ease;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash-logo {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: #d9a441;
  color: #173b57;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 800;
  overflow: hidden;
}
.splash-logo img { width: 100%; height: 100%; object-fit: contain; }
.splash h2 { margin: 4px 0 0; font-size: 24px; }
.splash p { margin: 0; color: #b9d2e8; font-size: 14px; }

@media (max-width: 980px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .todo-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); width: 240px; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(15, 23, 42, 0.35); }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
  .page-head .btn { width: 100%; }
  .grid.cols-4 { grid-template-columns: 1fr; }
  .todo-grid { grid-template-columns: repeat(2, 1fr); }
}

.mobile-nav { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: #173b57; box-shadow: 0 -2px 10px rgba(0,0,0,.18); }
.mobile-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px 4px 10px; font-size: 11px; font-weight: 600; color: #cfe0ee; background: none; border: 0; border-top: 2px solid transparent; cursor: pointer; }
.mobile-nav button:active { color: #fff; background: rgba(255,255,255,.06); }
.mobile-nav button svg { width: 22px; height: 22px; }

@media (max-width: 760px) {
  .content { padding-bottom: 84px; }
  .mobile-nav { display: flex; }
  .mobile-search { width: 100%; box-sizing: border-box; padding: 11px 12px; font-size: 16px; border: 1px solid #cfd8e3; border-radius: 8px; margin-bottom: 12px; }
  .mcard { border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #fff; }
  .mcard-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
  .mcard-row + .mcard-row { margin-top: 6px; }
  .mcard .mprice { font-size: 18px; font-weight: 700; color: #173b57; }
  .mcard .mstock { font-size: 12px; color: #64748b; }
  .stock-low { color: #dc2626; font-weight: 700; }
}

/* 统一登录页（左右分栏） */
.auth { min-height: 100vh; display: flex; background: #f0f3f7; }
.auth-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px;
  background: linear-gradient(180deg, #f7f9fc 0%, #eef1f6 100%);
}
.auth-illu { width: min(460px, 82%); }
.auth-illu img { width: 100%; height: auto; }
.auth-left-info { text-align: center; }
.auth-mini { display: flex; justify-content: center; margin-bottom: 8px; }
.auth-mini .brand-mark { width: 34px; height: 34px; font-size: 17px; }
.auth-left-info h2 { margin: 0; font-size: 26px; }
.auth-left-info p { margin: 6px 0 0; color: var(--muted); }
.auth-right { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 36px 34px 30px;
  box-shadow: 0 18px 50px rgba(30, 50, 70, 0.12);
}
.auth-card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.auth-logo { width: 52px; height: 52px; flex: none; border-radius: 14px; overflow: hidden; display: grid; place-items: center; background: #173b57; }
.auth-logo img { width: 100%; height: 100%; object-fit: contain; }
.auth-logo:has(img) { background: transparent; }
.auth-logo .brand-mark { width: 46px; height: 46px; font-size: 21px; }
.auth-card-head h1 { margin: 0; font-size: 24px; }
.auth-card-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.brand-mark:has(img) { background: transparent; }
.auth-mini:has(img) { background: transparent; }
.splash-logo:has(img) { background: transparent; }
.auth-tabs { display: flex; gap: 26px; margin-bottom: 22px; }
.auth-tab {
  font-size: 17px;
  font-weight: 600;
  color: #8a94a2;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 6px 0;
  position: relative;
}
.auth-tab.active { color: #0b0d0e; }
.auth-tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 3px; background: #0b0d0e; border-radius: 2px; }
.ai {
  width: 100%;
  box-sizing: border-box;
  padding: 14px;
  font-size: 15px;
  border: 1px solid #dcdfe4;
  border-radius: 8px;
  margin-bottom: 14px;
  background: #fff;
  color: #0b0d0e;
}
.ai::placeholder { color: #a7b0bc; }
.ai:focus { outline: none; border-color: #1f6fb3; box-shadow: 0 0 0 3px rgba(31, 111, 179, 0.12); }
.code-row { position: relative; }
.code-row .ai { padding-right: 118px; }
.code-btn {
  position: absolute;
  right: 6px;
  top: 6px;
  bottom: 6px;
  border: 0;
  background: #f2f5f8;
  color: #1f6fb3;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  padding: 0 12px;
}
.agree {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  color: #8a94a2;
  line-height: 1.6;
  margin: 2px 0 16px;
}
.agree input { margin-top: 2px; }
.agree a { color: #1f6fb3; text-decoration: none; }
.auth-login {
  width: 100%;
  height: 46px;
  background: #0b0d0e;
  color: #fff;
  border: 0;
  border-radius: 8px;
  font-size: 16px;
  letter-spacing: 2px;
  cursor: pointer;
}
.auth-login:hover { background: #222; }
.auth-wechat { display: flex; justify-content: center; margin: 20px 0 8px; }
.auth-wechat svg { background: #22b75e; border-radius: 50%; padding: 6px; box-sizing: content-box; box-shadow: 0 4px 10px rgba(34, 183, 94, 0.35); }
.auth-forgot { text-align: center; }
.auth-forgot a { color: #1f6fb3; text-decoration: none; font-size: 14px; }
@media (max-width: 900px) {
  .auth { flex-direction: column; }
  .auth-left { order: 2; padding: 24px 20px; gap: 8px; }
  .auth-illu { max-width: 300px; }
  .auth-left-info h2 { font-size: 20px; }
  .auth-right { order: 1; padding: 28px 18px; }
}
