/* 漆包线排产系统 Web 版 */
:root {
  --navy: #1f3a5f;
  --navy-dark: #16293f;
  --navy-light: #2c6b9e;
  --accent: #3498db;
  --green: #27ae60;
  --red: #e74c3c;
  --orange: #e67e22;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #dde3ea;
  --text: #22303f;
  --muted: #6b7a8d;
  --hover: #eaf2fa;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- 登录 ---------- */
#login-mask {
  position: fixed; inset: 0; z-index: 999;
  background: linear-gradient(135deg, #1f3a5f 0%, #2c6b9e 100%);
  display: flex; align-items: center; justify-content: center;
}
#login-mask.hidden { display: none; }
.login-box {
  background: #fff; border-radius: 10px; padding: 36px 40px;
  width: 380px; box-shadow: 0 12px 40px rgba(0,0,0,.28); text-align: center;
}
.login-box h1 { font-size: 22px; color: var(--navy); margin-bottom: 6px; }
.login-box p { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-box input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; margin-bottom: 14px; outline: none;
}
.login-box input:focus { border-color: var(--accent); }
.login-box button {
  width: 100%; padding: 11px; background: var(--navy); color: #fff;
  border: none; border-radius: 6px; font-size: 15px; cursor: pointer;
}
.login-box button:hover { background: var(--navy-light); }
.login-err { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ---------- 布局 ---------- */
#app.hidden { display: none; }
#app { display: flex; height: 100vh; }

.sidebar {
  width: 220px; background: var(--navy-dark); color: #cfd8e3;
  display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0;
}
.sidebar .brand {
  padding: 18px 16px; font-size: 16px; font-weight: bold; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.1); letter-spacing: 1px;
}
.nav-group { padding: 10px 0 4px; }
.nav-group-title {
  padding: 8px 18px; font-size: 12px; color: #7d8fa5;
  font-weight: bold; letter-spacing: 1px;
}
.nav-item {
  padding: 9px 18px 9px 24px; cursor: pointer; font-size: 14px;
  border-left: 3px solid transparent; white-space: nowrap;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active {
  background: rgba(52,152,219,.18); border-left-color: var(--accent); color: #fff;
}

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 54px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 18px; gap: 10px; flex-shrink: 0;
}
.topbar h2 { font-size: 17px; color: var(--navy); font-weight: 600; }
.topbar .spacer { flex: 1; }

.content { flex: 1; overflow: auto; padding: 16px 18px 40px; }

/* ---------- 按钮 ---------- */
.btn {
  padding: 7px 14px; border: 1px solid var(--border); background: #fff;
  border-radius: 5px; cursor: pointer; font-size: 13px; color: var(--text);
  white-space: nowrap;
}
.btn:hover { background: var(--hover); border-color: var(--accent); }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-light); border-color: var(--navy-light); }
.btn-green { background: var(--green); color: #fff; border-color: var(--green); }
.btn-green:hover { background: #2ecc71; border-color: #2ecc71; }
.btn-red { background: var(--red); color: #fff; border-color: var(--red); }
.btn-red:hover { opacity: .88; }
.btn-orange { background: var(--orange); color: #fff; border-color: var(--orange); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 工具栏 ---------- */
.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--panel); padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 6px; margin-bottom: 12px;
}
.toolbar label { font-size: 13px; color: var(--muted); }
.toolbar input[type=text], .toolbar input[type=date], .toolbar select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 5px;
  font-size: 13px; outline: none; background: #fff;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--accent); }
.toolbar .spacer { flex: 1; }

/* ---------- 表格 ---------- */
.table-wrap {
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  overflow: auto; max-height: calc(100vh - 210px);
}
table.grid { border-collapse: collapse; width: 100%; font-size: 13px; }
table.grid thead th {
  background: var(--navy); color: #fff; font-weight: 600;
  padding: 9px 10px; text-align: left; white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
table.grid tbody td {
  padding: 6px 10px; border-bottom: 1px solid #eef1f5; white-space: nowrap;
}
table.grid tbody tr:nth-child(even) { background: #fafbfc; }
table.grid tbody tr:hover { background: var(--hover); }
table.grid td.edit input {
  width: 100%; min-width: 80px; padding: 3px 6px; border: 1px solid transparent;
  border-radius: 3px; background: transparent; font-size: 13px; color: var(--text);
}
table.grid td.edit input:focus { border-color: var(--accent); background: #fff; outline: none; }
table.grid td.num { text-align: right; }
table.grid td.ops { white-space: nowrap; }
.mini-btn {
  padding: 3px 8px; font-size: 12px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--border); background: #fff; margin-right: 4px;
}
.mini-btn:hover { border-color: var(--accent); color: var(--navy-light); }
.mini-btn.danger { color: var(--red); }
.mini-btn.danger:hover { border-color: var(--red); }

.summary {
  margin-top: 10px; padding: 8px 12px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; color: var(--muted); font-weight: 600;
}

/* ---------- 统计卡片 ---------- */
.cards { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card {
  flex: 1; min-width: 130px; background: var(--panel);
  border: 1px solid var(--border); border-left: 4px solid var(--navy);
  border-radius: 6px; padding: 14px 16px;
}
.card .k { font-size: 13px; color: var(--muted); }
.card .v { font-size: 24px; font-weight: 700; color: var(--navy); margin-top: 4px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast-item {
  background: #22303f; color: #fff; padding: 10px 20px; border-radius: 5px;
  font-size: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.2);
}
.toast-item.ok { background: var(--green); }
.toast-item.err { background: var(--red); }

/* ---------- 模态 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 900;
  display: flex; align-items: center; justify-content: center;
}
.modal-mask.hidden { display: none; }
.modal {
  background: #fff; border-radius: 8px; padding: 22px 24px; min-width: 380px;
  max-width: 620px; max-height: 80vh; overflow: auto;
}
.modal h3 { font-size: 16px; color: var(--navy); margin-bottom: 14px; }
.modal .row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.modal .row input { padding: 6px 10px; border: 1px solid var(--border); border-radius: 5px; flex: 1; }
.modal-actions { margin-top: 16px; text-align: right; display: flex; gap: 8px; justify-content: flex-end; }
.hint { font-size: 12px; color: var(--muted); margin-bottom: 10px; line-height: 1.6; }

.empty { padding: 40px; text-align: center; color: var(--muted); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 12px; background: #eef1f5; color: var(--muted);
}
.badge.run { background: #fdeaea; color: var(--red); }
.badge.done { background: #e8f6ec; color: var(--green); }

.icp-foot {
  margin-top: 12px; font-size: 12px; color: #9aa3b0; text-align: center; line-height: 1.6;
}
.icp-foot a { color: #9aa3b0; text-decoration: none; }
.icp-foot a:hover { color: var(--navy); }
