/* ============================================================
   工厂物料管理系统 — 主样式
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --bg:      #0f1117;
  --bg2:     #161b27;
  --bg3:     #1e2435;
  --card:    #1a2133;
  --border:  #2a3650;
  --accent:  #3b82f6;
  --accent2: #10b981;
  --accent3: #f59e0b;
  --accent4: #ef4444;
  --accent5: #8b5cf6;
  --text:    #e2e8f0;
  --text2:   #94a3b8;
  --text3:   #64748b;
  --sidebar-w: 220px;
  --topbar-h:  56px;
  --radius:  10px;
  --shadow:  0 4px 24px rgba(0,0,0,.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: 'Noto Sans SC', sans-serif; font-size: 14px; height: 100%; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── LAYOUT ── */
.app-wrap { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  transition: transform .25s;
  z-index: 50;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.logo-icon { font-size: 22px; }
.logo-text { font-size: 13px; font-weight: 700; color: var(--accent); letter-spacing: .3px; line-height: 1.3; }

.sidebar-nav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--text2); font-size: 13px; font-weight: 500;
  transition: all .15s;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.nav-item.active { background: rgba(59,130,246,.15); color: var(--accent); }
.nav-icon { font-size: 15px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-detail { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text3); }
.btn-logout {
  color: var(--text3); font-size: 18px; padding: 4px;
  border-radius: 6px; transition: color .15s;
  text-decoration: none; flex-shrink: 0;
}
.btn-logout:hover { color: var(--accent4); text-decoration: none; }

/* ── MAIN WRAP ── */
.main-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── TOPBAR ── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px; gap: 12px;
  flex-shrink: 0;
}
.menu-toggle {
  display: none; background: none; border: none;
  color: var(--text2); font-size: 20px; cursor: pointer; padding: 4px 8px;
}
.page-title { font-size: 15px; font-weight: 700; color: var(--text); flex: 1; }
.factory-badge {
  font-size: 12px; color: var(--accent2);
  background: rgba(16,185,129,.12);
  padding: 4px 10px; border-radius: 20px;
}

/* ── PAGE CONTENT ── */
.page-content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── CARDS ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 14px; font-weight: 700;
  color: var(--text); margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.card-title .dot {
  width: 6px; height: 6px;
  border-radius: 50%; background: var(--accent);
  flex-shrink: 0;
}

/* ── STATS GRID ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(150px,1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.stat-label { font-size: 11px; color: var(--text3); margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 700; font-family: 'JetBrains Mono',monospace; }
.stat-unit  { font-size: 12px; color: var(--text3); margin-left: 3px; font-family: inherit; }
.stat-card.blue   .stat-value { color: var(--accent); }
.stat-card.green  .stat-value { color: var(--accent2); }
.stat-card.yellow .stat-value { color: var(--accent3); }
.stat-card.red    .stat-value { color: var(--accent4); }
.stat-card.purple .stat-value { color: var(--accent5); }

/* ── FORMS ── */
.form-row { display: grid; grid-template-columns: repeat(auto-fill,minmax(200px,1fr)); gap: 14px; margin-bottom: 14px; }
.form-row.cols-2 { grid-template-columns: repeat(2,1fr); }
.form-row.cols-3 { grid-template-columns: repeat(3,1fr); }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1/-1; }
label { font-size: 12px; color: var(--text2); font-weight: 500; }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text);
  padding: 9px 11px; font-family: inherit; font-size: 13px;
  outline: none; transition: border-color .2s; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
select option { background: var(--bg2); }
input[type="file"] { padding: 6px; cursor: pointer; }
input[readonly] { color: var(--text2); cursor: default; }

/* ── BUTTONS ── */
.btn {
  padding: 8px 18px; border-radius: 6px; border: none;
  cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600;
  transition: all .15s; display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.15); }
.btn-success { background: var(--accent2); color: #fff; }
.btn-success:hover { filter: brightness(1.15); }
.btn-warning { background: var(--accent3); color: #000; }
.btn-warning:hover { filter: brightness(1.1); }
.btn-danger  { background: var(--accent4); color: #fff; }
.btn-danger:hover  { filter: brightness(1.15); }
.btn-ghost {
  background: transparent; border: 1px solid var(--border);
  color: var(--text2);
}
.btn-ghost:hover { border-color: var(--text2); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 7px; font-size: 11px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: var(--bg3); color: var(--text2); font-weight: 600;
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(59,130,246,.04); }
.mono { font-family: 'JetBrains Mono',monospace; }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── TAGS / BADGES ── */
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.tag-blue   { background: rgba(59,130,246,.15); color: var(--accent); }
.tag-green  { background: rgba(16,185,129,.15);  color: var(--accent2); }
.tag-yellow { background: rgba(245,158,11,.15);  color: var(--accent3); }
.tag-red    { background: rgba(239,68,68,.15);   color: var(--accent4); }
.tag-purple { background: rgba(139,92,246,.15);  color: var(--accent5); }
.tag-gray   { background: rgba(100,116,139,.15); color: var(--text2); }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent4); color: #fff; border-radius: 10px;
  min-width: 18px; height: 18px; font-size: 10px; font-weight: 700;
  padding: 0 5px; margin-left: 4px;
}
.badge-blue { background: var(--accent); }

/* ── STATUS DOTS ── */
.status-dot {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
}
.status-dot::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.status-pending    .status-dot::before { background: var(--text3); }
.status-in_transit .status-dot::before { background: var(--accent3); }
.status-received   .status-dot::before { background: var(--accent2); }
.status-partial    .status-dot::before { background: var(--accent5); }

/* ── EMPTY ── */
.empty { text-align: center; color: var(--text3); padding: 50px 20px; font-size: 13px; }
.empty-icon { font-size: 36px; margin-bottom: 10px; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--accent2); color: #fff;
  padding: 10px 18px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0;
  transform: translateY(8px); transition: all .25s;
  z-index: 999; pointer-events: none;
}
.toast.show   { opacity: 1; transform: translateY(0); }
.toast.error  { background: var(--accent4); }

/* ── MODAL ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 200;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 26px;
  width: 100%; max-width: 540px;
  max-height: 88vh; overflow-y: auto;
}
.modal-title  { font-size: 16px; font-weight: 700; margin-bottom: 18px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── ALERT ── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert-warn  { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); color: var(--accent3); }
.alert-error { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.3);  color: var(--accent4); }
.alert-info  { background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.3); color: var(--accent); }
.alert-ok    { background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3); color: var(--accent2); }

/* ── LOGISTICS TIMELINE ── */
.timeline { padding: 8px 0; }
.timeline-item {
  display: flex; gap: 12px; padding: 8px 0;
  border-left: 2px solid var(--border); margin-left: 6px; padding-left: 16px;
  position: relative;
}
.timeline-item::before {
  content: ''; position: absolute;
  left: -6px; top: 14px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--border);
}
.timeline-item.latest::before { background: var(--accent2); }
.timeline-time { font-size: 11px; color: var(--text3); white-space: nowrap; margin-top: 2px; font-family: 'JetBrains Mono',monospace; }
.timeline-body { flex: 1; }
.timeline-status { font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.timeline-note  { font-size: 12px; color: var(--text2); }

/* ── ATTACHMENTS ── */
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.attachment-item {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px;
  font-size: 12px; color: var(--text2);
}
.attachment-item a { color: var(--accent); }
.attachment-item .del-att { color: var(--accent4); cursor: pointer; font-size: 14px; margin-left: 4px; }

/* ── FILTERS ── */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters .form-group { margin: 0; min-width: 140px; }
.filters label { font-size: 11px; }

/* ── PAGINATION ── */
.pagination { display: flex; gap: 6px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.page-btn {
  padding: 5px 11px; border-radius: 6px; border: 1px solid var(--border);
  background: transparent; color: var(--text2); cursor: pointer; font-size: 13px; font-family: inherit;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-info { font-size: 12px; color: var(--text3); }

/* ── LOGIN PAGE ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { width: 380px; max-width: 96vw; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 36px 32px; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { font-size: 40px; display: block; margin-bottom: 8px; }
.login-logo h1 { font-size: 18px; font-weight: 700; color: var(--accent); }
.login-logo p  { font-size: 12px; color: var(--text3); margin-top: 4px; }
.login-card .form-group { margin-bottom: 14px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; font-size: 14px; }

/* ── MOBILE ── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100%;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .page-content { padding: 14px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .modal-box { padding: 18px; }
}
