/* ============================================================
   TAIZE ERP 样式（品牌蓝 #104490）
   ============================================================ */
:root {
  --primary: #104490;
  --primary-dark: #0b2d5c;
  --bg: #f1f5f9;
  --card: #fff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --sidebar-w: 220px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--primary-dark); color: #fff; position: fixed; top: 0; bottom: 0; display: flex; flex-direction: column; }
.main { flex: 1; margin-left: var(--sidebar-w); padding: 22px 26px; max-width: 100%; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px; font-size: 16px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav-item { padding: 10px 12px; color: #cbd5e1; cursor: pointer; font-size: 14px; display: flex; align-items: center; gap: 9px; border-radius: 8px; margin-bottom: 2px; line-height: 1.55; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-group { padding: 12px 12px 4px; font-size: 11px; color: #8ba7cc; letter-spacing: .5px; }
.sidebar-user { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; line-height: 1.4; }
.sidebar-user .name { color: #fff; font-weight: 600; }
.sidebar-user .role { font-size: 12px; color: #8ba7cc; }
.sidebar-user .logout { color: #8ba7cc; cursor: pointer; font-size: 12px; margin-top: 3px; display: inline-block; }
.sidebar-user .logout:hover { color: #fff; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0b2d5c 0%, #104490 60%, #1d4ed8 100%); padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 34px 32px 32px; box-shadow: 0 20px 60px rgba(0,0,0,.3); text-align: center; }
.login-card .login-logo { width: 56px; height: 56px; border-radius: 12px; display: block; margin: 0 auto 16px; }
.login-card h1 { font-size: 20px; line-height: 1.4; margin: 0 0 8px; color: #0b2d5c; font-weight: 700; }
.login-card .sub { color: #64748b; font-size: 13px; line-height: 1.4; margin: 0 0 24px; }
.login-card .field { text-align: left; margin-bottom: 16px; }
.login-card .field label { display: block; font-size: 13px; color: #64748b; margin-bottom: 6px; line-height: 1.4; font-weight: 400; }
.login-card .field input { width: 100%; height: 42px; padding: 0 12px; font-size: 14px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; color: #0f172a; }
.login-card .field input:focus { outline: 2px solid #104490; border-color: transparent; }
.login-card .btn { width: 100%; height: 42px; padding: 0 16px; font-size: 14px; font-weight: 600; border: none; border-radius: 8px; background: #104490; color: #fff; cursor: pointer; display: block; }

/* ---------- 组件 ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-head h2 { font-size: 20px; color: var(--primary-dark); }
.card { background: var(--card); border-radius: 10px; border: 1px solid var(--border); }
.card.pad { padding: 16px 18px; }
.card.stat { padding: 16px 18px; }
.card.stat .label { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.card.stat .num { font-size: 26px; font-weight: 700; color: var(--primary-dark); }
.card h3 { font-size: 15px; margin-bottom: 10px; color: var(--primary-dark); }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.btn { border: none; border-radius: 8px; padding: 9px 16px; font-size: 13.5px; cursor: pointer; background: var(--primary); color: #fff; font-weight: 600; }
.btn:hover { opacity: .9; }
.btn.secondary { background: #e2e8f0; color: var(--text); }
.btn.green { background: var(--green); }
.btn.danger { background: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }

.field { margin-bottom: 12px; }
.field label { display: block; margin-bottom: 5px; font-size: 13px; color: var(--muted); font-weight: 600; }
input, select, textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { min-height: 60px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; background: #f8fafc; white-space: nowrap; font-size: 12.5px; }
tr:hover td { background: #f8fafc; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; color: #fff; white-space: nowrap; }
.muted { color: var(--muted); }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.filterbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filterbar input.search { max-width: 260px; }
.filterbar select { width: auto; min-width: 120px; }
.table-scroll { overflow-x: auto; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal.wide { max-width: 760px; }
.modal .m-head { padding: 15px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: #fff; z-index: 2; border-radius: 12px 12px 0 0; }
.modal .m-head h3 { font-size: 16px; color: var(--primary-dark); }
.modal .m-body { padding: 16px 20px; }
.modal .m-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: 0; background: #fff; border-radius: 0 0 12px 12px; }
.close-x { border: none; background: none; font-size: 20px; color: var(--muted); cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.modal .items-table { margin-top: 8px; }
.items-table input { padding: 5px 8px; font-size: 12.5px; }

/* ---------- 状态色 ---------- */
.st-draft { background: #94a3b8; }
.st-confirmed, .st-ordered, .st-running { background: var(--amber); }
.st-shipped, .st-received, .st-done { background: var(--green); }
.st-cancelled { background: #cbd5e1; }
.st-pending { background: #94a3b8; }
.st-unpaid { background: var(--red); }
.st-partial { background: var(--amber); }
.st-paid { background: var(--green); }

/* ---------- 移动端 ---------- */
@media (max-width: 900px) {
  .sidebar { width: 100%; height: auto; position: static; }
  .main { margin-left: 0; padding: 16px; }
  .layout { flex-direction: column; }
  .nav { display: flex; overflow-x: auto; padding: 0; }
  .nav-item { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
  .nav-item.active { border-bottom-color: #fff; }
  .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; }
}
