* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: #f0f2f5;
  color: #333;
}
a { text-decoration: none; color: inherit; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
}
.login-box {
  width: 400px;
  background: #fff;
  border-radius: 12px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-box h1 { font-size: 24px; text-align: center; margin-bottom: 6px; color: #1e3a8a; }
.login-box .sub { text-align: center; color: #888; font-size: 13px; margin-bottom: 28px; }
.login-box label { display: block; font-size: 13px; color: #555; margin: 14px 0 6px; }
.login-box input {
  width: 100%; padding: 11px 12px; border: 1px solid #d9d9d9; border-radius: 6px;
  font-size: 14px; outline: none; transition: border .2s;
}
.login-box input:focus { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,.15); }
.login-box button {
  width: 100%; margin-top: 24px; padding: 12px; border: none; border-radius: 6px;
  background: #1e3a8a; color: #fff; font-size: 15px; cursor: pointer; transition: background .2s;
}
.login-box button:hover { background: #2c4fae; }
.login-box button:disabled { opacity: .6; cursor: not-allowed; }
#loginMsg { text-align: center; margin-top: 12px; font-size: 13px; color: #dc2626; min-height: 18px; }
.login-tip { margin-top: 18px; padding: 10px; background: #f6f8ff; border-radius: 6px; font-size: 12px; color: #6b7280; line-height: 1.8; }

/* ---------- Layout ---------- */
.topbar {
  background: #1e3a8a; color: #fff; display: flex; align-items: center;
  padding: 0 20px; height: 56px; position: sticky; top: 0; z-index: 50;
}
.topbar .brand { font-size: 18px; font-weight: 700; margin-right: 28px; white-space: nowrap; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav button {
  background: transparent; border: none; color: rgba(255,255,255,.85);
  padding: 8px 16px; font-size: 14px; cursor: pointer; border-radius: 6px;
}
.topbar nav button.active { background: rgba(255,255,255,.18); color: #fff; }
.topbar nav button:hover { background: rgba(255,255,255,.12); }
.topbar .user { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.topbar .user .role-tag {
  background: rgba(255,255,255,.2); padding: 3px 8px; border-radius: 4px; font-size: 12px;
}
.topbar .user button {
  background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.35);
  padding: 5px 12px; border-radius: 6px; font-size: 12px; cursor: pointer;
}
.topbar .user button:hover { background: rgba(255,255,255,.28); }

.page { padding: 20px; max-width: 1600px; margin: 0 auto; }
.page h2 { font-size: 20px; margin-bottom: 16px; color: #1e3a8a; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.page-head h2 { margin-bottom: 0; }

.card {
  background: #fff; border-radius: 8px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.08);
  margin-bottom: 18px;
}

/* ---------- Stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: #fff; border-radius: 8px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.stat-card .num { font-size: 28px; font-weight: 700; color: #1e3a8a; margin: 6px 0 2px; }
.stat-card .label { font-size: 13px; color: #888; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; border-bottom: 1px solid #eee; text-align: left; }
th { background: #fafafa; color: #555; font-weight: 600; white-space: nowrap; }
tr:hover td { background: #f8faff; }
.empty { text-align: center; color: #999; padding: 40px !important; }

/* ---------- Forms & buttons ---------- */
input[type=text], input[type=number], input[type=password], input[type=search], select {
  padding: 8px 10px; border: 1px solid #d9d9d9; border-radius: 5px; font-size: 13px; outline: none;
}
input:focus, select:focus { border-color: #3b82f6; }
.btn {
  display: inline-block; padding: 8px 16px; border: none; border-radius: 5px; font-size: 13px;
  cursor: pointer; transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: #1e3a8a; color: #fff; }
.btn-blue { background: #3b82f6; color: #fff; }
.btn-green { background: #16a34a; color: #fff; }
.btn-orange { background: #f59e0b; color: #fff; }
.btn-red { background: #dc2626; color: #fff; }
.btn-gray { background: #6b7280; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; }
.badge.pending { background: #fef3c7; color: #b45309; }
.badge.confirmed { background: #dbeafe; color: #1d4ed8; }
.badge.shipped { background: #e0e7ff; color: #4338ca; }
.badge.completed { background: #dcfce7; color: #15803d; }
.badge.cancelled { background: #fee2e2; color: #b91c1c; }

.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-row label { font-size: 13px; color: #555; }

/* ---------- Modal ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none;
  align-items: center; justify-content: center; z-index: 100;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 10px; width: 520px; max-width: 94vw;
  max-height: 90vh; overflow-y: auto; padding: 24px;
}
.modal h3 { margin-bottom: 18px; color: #1e3a8a; }
.modal .field { margin-bottom: 14px; }
.modal .field label { display: block; font-size: 13px; color: #555; margin-bottom: 5px; }
.modal .field input, .modal .field select, .modal .field textarea { width: 100%; }
.modal .field textarea { padding: 8px; border: 1px solid #d9d9d9; border-radius: 5px; font-size: 13px; resize: vertical; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ---------- Cart ---------- */
.cart { display: flex; flex-direction: column; gap: 8px; }
.cart-item {
  display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid #e5e7eb;
  border-radius: 6px; font-size: 13px;
}
.cart-item .name { flex: 1; }
.cart-item input { width: 70px; text-align: center; }
.cart-total { margin-top: 12px; text-align: right; font-size: 15px; font-weight: 600; }
.cart-total span { color: #dc2626; }

/* ---------- Order detail ---------- */
.order-detail h4 { color: #1e3a8a; margin-bottom: 10px; }
.order-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; font-size: 13px; margin-bottom: 14px; }
.order-meta div { background: #f8faff; padding: 8px 10px; border-radius: 5px; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs button {
  padding: 7px 16px; border: 1px solid #d9d9d9; background: #fff; border-radius: 6px;
  font-size: 13px; cursor: pointer; color: #555;
}
.tabs button.active { background: #1e3a8a; color: #fff; border-color: #1e3a8a; }

.search-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.product-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px;
  display: flex; flex-direction: column; transition: box-shadow .2s;
}
.product-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.product-card .p-name { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.product-card .p-spec { font-size: 12.5px; color: #888; margin-bottom: 10px; }
.product-card .p-info { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 12px; }
.product-card .p-price { color: #dc2626; font-size: 18px; font-weight: 700; }
.product-card .p-price small { font-size: 12px; font-weight: 400; color: #888; }
.product-card .p-stock { color: #6b7280; }
.product-card .p-stock.low { color: #f59e0b; }
.product-card .p-stock.out { color: #dc2626; }
.product-card .p-actions { display: flex; gap: 8px; margin-top: auto; }
.product-card .p-actions input { width: 60px; text-align: center; }

.toast-wrap { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #fff; padding: 10px 20px; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.15);
  font-size: 13px; border-left: 4px solid #3b82f6;
}
.toast.error { border-left-color: #dc2626; }
.toast.success { border-left-color: #16a34a; }