/* 四川装修清单报价系统样式 */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: #f5f7fa;
  color: #2d3748;
  font-size: 14px;
  min-height: 100vh;
}

/* 登录守卫 */
.auth-check { display: none; }
.auth-check.show {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
.auth-check.show::after {
  content: '请先登录 admin';
  color: #fff;
  font-size: 18px;
  background: #e53e3e;
  padding: 20px 40px;
  border-radius: 8px;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.brand { font-size: 17px; font-weight: 700; color: #1a202c; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  padding: 8px 18px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: #4a5568;
  border-radius: 6px;
  font-weight: 500;
}
.tab:hover { background: #edf2f7; }
.tab.active { background: #667eea; color: #fff; }
.lib-count {
  font-size: 13px;
  color: #718096;
  background: #f7fafc;
  padding: 6px 12px;
  border-radius: 6px;
}
.admin-link {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid #1F4E78;
  color: #1F4E78;
  border-radius: 6px;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
}
.admin-link:hover { background: #1F4E78; color: #fff; }

.page { display: none; padding: 20px; max-width: 1280px; margin: 0 auto; }
.page.active { display: block; }

.layout { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.card {
  background: #fff;
  border-radius: 10px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; color: #2d3748; }

.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-bar input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 14px;
}
.search-bar input:focus { outline: none; border-color: #667eea; }

.btn {
  padding: 10px 16px;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #4a5568;
  transition: all 0.15s;
}
.btn:hover { background: #f7fafc; }
.btn.primary { background: #667eea; color: #fff; border-color: #667eea; }
.btn.primary:hover { background: #5568d3; }
.btn.ghost { background: transparent; }
.btn.danger { background: #e53e3e; color: #fff; border-color: #e53e3e; }
.btn.danger:hover { background: #c53030; }
.btn.small { padding: 6px 10px; font-size: 12px; }

.results { max-height: 600px; overflow-y: auto; }
.result-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
}
.result-item:hover { background: #fafbfc; }
.result-item .info { min-width: 0; }
.result-item .nm {
  font-weight: 600;
  color: #2d3748;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-item .sp {
  font-size: 12px;
  color: #a0aec0;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.result-item .pr {
  font-weight: 700;
  color: #c0392b;
  font-size: 14px;
}
.result-item .unit { color: #718096; font-size: 12px; margin-left: 4px; }
.result-item input[type="number"] {
  width: 70px;
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
}
.result-item input[type="number"]:focus { outline: none; border-color: #667eea; }

.cart-card { position: sticky; top: 20px; }
.cart-list { max-height: 500px; overflow-y: auto; margin-bottom: 12px; }
.cart-empty {
  padding: 30px 20px;
  text-align: center;
  color: #a0aec0;
  font-size: 13px;
  background: #fafbfc;
  border-radius: 6px;
}
.cart-item {
  padding: 10px 12px;
  background: #fafbfc;
  border-radius: 6px;
  margin-bottom: 8px;
}
.ci-top {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 4px;
}
.ci-amt { color: #c0392b; }
.ci-sp { font-size: 12px; color: #718096; margin-bottom: 6px; }
.ci-bot { display: flex; align-items: center; gap: 8px; }
.ci-bot input {
  width: 60px;
  padding: 4px 6px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 12px;
}
.ci-bot .del {
  background: transparent;
  border: none;
  color: #e53e3e;
  cursor: pointer;
  font-size: 12px;
  margin-left: auto;
}
.cart-foot { border-top: 1px solid #e2e8f0; padding-top: 12px; }
.total { font-size: 16px; font-weight: 700; margin-bottom: 10px; text-align: right; }
.total span { color: #c0392b; font-size: 18px; }
.cart-actions { display: flex; gap: 8px; }
.cart-actions .btn { flex: 1; }

.msg {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-top: 10px;
}
.msg.ok { background: #c6f6d5; color: #22543d; }
.msg.err { background: #fed7d7; color: #c53030; }

/* 清单库 */
.lib-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.lib-toolbar .hint { color: #718096; font-size: 12px; }
.drop {
  border: 2px dashed #cbd5e0;
  padding: 30px;
  text-align: center;
  border-radius: 8px;
  margin-bottom: 12px;
  background: #fafbfc;
  color: #718096;
  transition: all 0.2s;
}
.drop.drag { background: #e6f3ff; border-color: #667eea; color: #667eea; }
.drop .hint { font-size: 12px; margin-top: 6px; }

.table-wrap { max-height: 600px; overflow: auto; }
.lib-table { width: 100%; border-collapse: collapse; }
.lib-table th {
  background: #f7fafc;
  padding: 10px;
  text-align: left;
  font-weight: 600;
  color: #4a5568;
  font-size: 13px;
  position: sticky;
  top: 0;
  border-bottom: 2px solid #e2e8f0;
}
.lib-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}
.lib-table td[contenteditable] { cursor: text; }
.lib-table td[contenteditable]:focus {
  outline: 2px solid #667eea;
  background: #fafbfc;
}
.lib-table tr:hover { background: #fafbfc; }
.row-del {
  background: #e53e3e;
  color: #fff;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.row-del:hover { background: #c53030; }

.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: #2d3748;
  color: #fff;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 9999;
}
.toast.show { opacity: 1; }
/* ===== Admin Login Box ===== */
.login-box {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  text-align: center;
  min-width: 360px;
  z-index: 100;
}
.login-box h2 {
  color: #1F4E78;
  margin-bottom: 8px;
  font-size: 22px;
}
.login-box input {
  display: block;
  width: 100%;
  padding: 12px;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 15px;
  margin: 16px 0;
  box-sizing: border-box;
}
.login-box .btn {
  width: 100%;
  padding: 12px;
  background: #1F4E78;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.login-box .btn:hover { background: #2C5F8E; }
.login-box .err { color: #e53e3e; margin-top: 12px; min-height: 20px; font-size: 13px; }
.login-box .hint { color: #718096; font-size: 13px; margin-top: 12px; }
.login-box a { color: #1F4E78; }

/* ===== Drop Zone ===== */
.drop {
  border: 2px dashed #cbd5e0;
  border-radius: 8px;
  padding: 40px 20px;
  text-align: center;
  color: #4a5568;
  font-size: 15px;
  margin: 16px 0;
  transition: all 0.2s;
}
.drop.over { border-color: #1F4E78; background: #F2F6FB; }

/* ===== Row Del / Add Buttons ===== */
.row-del, .row-add {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid #cbd5e0;
  color: #4a5568;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.row-del:hover { background: #e53e3e; color: #fff; border-color: #e53e3e; }
.row-add:hover { background: #1F4E78; color: #fff; border-color: #1F4E78; }

/* ===== 购物车小计/管理费/税费/含税总价 ===== */
.cart-foot .total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
  color: #4a5568;
  border-bottom: 1px dashed #e2e8f0;
}
.cart-foot .total-row:last-of-type {
  border-bottom: none;
}
.cart-foot .total-label {
  flex: 1;
  color: #4a5568;
}
.cart-foot .total-value {
  font-weight: 600;
  color: #2d3748;
  font-variant-numeric: tabular-nums;
}
.cart-foot .total-row.total-final {
  margin-top: 8px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
  border-radius: 8px;
  border: 1px solid #F59E0B;
  border-bottom: 1px solid #F59E0B;
}
.cart-foot .total-row.total-final .total-label {
  font-weight: 700;
  font-size: 15px;
  color: #92400E;
}
.cart-foot .total-row.total-final .total-value {
  font-size: 18px;
  color: #C0392B;
  font-weight: 700;
}
