/* 弘迪 · 物品借用管理系统 —— 高级感 UI */
:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #98a2b3;
  --line: #eceff4;
  --line-2: #e3e8ef;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: #eef0ff;
  --blue: #2563eb;
  --green: #12b76a;
  --green-soft: #e7f8ef;
  --amber: #f79009;
  --amber-soft: #fef4e6;
  --red: #f04438;
  --red-soft: #fdeceb;
  --gray: #667085;
  --gray-soft: #f2f4f7;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 12px 28px -12px rgba(16,24,40,.16);
  --shadow-lg: 0 24px 60px -18px rgba(16,24,40,.28);
  --ease: cubic-bezier(.4,0,.2,1);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }

/* ================= 登录 ================= */
.login {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 15% 0%, #312e81 0%, transparent 55%),
              radial-gradient(1000px 700px at 100% 100%, #4f46e5 0%, transparent 50%),
              linear-gradient(135deg, #1e1b4b 0%, #111827 100%);
  overflow: hidden;
}
.login-orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .5; }
.login-orb.o1 { width: 380px; height: 380px; background: #6366f1; top: -80px; right: 10%; animation: float 9s ease-in-out infinite; }
.login-orb.o2 { width: 320px; height: 320px; background: #a855f7; bottom: -80px; left: 8%; animation: float 11s ease-in-out infinite reverse; }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(24px)} }

.login-card {
  position: relative; z-index: 2; width: 372px; padding: 40px 34px 32px;
  background: rgba(255,255,255,.98); border-radius: 22px;
  box-shadow: var(--shadow-lg); text-align: center;
  animation: rise .5s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
.login-logo {
  width: 58px; height: 58px; margin: 0 auto 16px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 24px -8px rgba(79,70,229,.7);
}
.login-card h1 { margin: 0; font-size: 21px; letter-spacing: .5px; }
.login-sub { margin: 5px 0 26px; color: var(--ink-3); font-size: 13px; letter-spacing: 3px; }
.login-field { display: block; text-align: left; margin-bottom: 16px; }
.login-field span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 7px; font-weight: 600; }
.login-field input {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--line-2); border-radius: 12px;
  font-size: 15px; outline: none; transition: .2s; background: #fbfcfe;
}
.login-field input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 4px var(--brand-soft); }
.btn-block { width: 100%; padding: 13px; font-size: 15px; letter-spacing: 4px; margin-top: 6px; }
.login-err { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 12px; }
.login-foot { position: absolute; bottom: 26px; color: rgba(255,255,255,.5); font-size: 12px; letter-spacing: 1px; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  border-radius: 11px; padding: 10px 18px; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 8px 18px -8px rgba(79,70,229,.8); transition: .2s var(--ease);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 22px -8px rgba(79,70,229,.9); }
.btn-ghost { background: #fff; border: 1px solid var(--line-2); color: var(--ink-2); border-radius: 11px; padding: 10px 18px; font-size: 13.5px; font-weight: 600; }
.btn-ghost:hover { background: var(--gray-soft); }

/* ================= 布局 ================= */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 244px; flex-shrink: 0; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #141b2e 0%, #1c2540 100%);
  position: sticky; top: 0; height: 100vh; padding: 0 14px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 8px 20px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; color: #fff; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 18px -6px rgba(99,102,241,.9);
}
.brand-txt b { display: block; color: #fff; font-size: 15px; letter-spacing: .5px; }
.brand-txt small { color: #8b97b5; font-size: 11.5px; letter-spacing: 1.5px; }
#nav { flex: 1; display: flex; flex-direction: column; gap: 3px; padding-top: 6px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px; border-radius: 11px;
  color: #aab4cf; font-size: 13.8px; font-weight: 500; text-align: left; transition: .18s var(--ease);
}
.nav-item svg { width: 18px; height: 18px; stroke-width: 1.9; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
  color: #fff; font-weight: 600;
  background: linear-gradient(135deg, rgba(99,102,241,.95), rgba(124,58,237,.85));
  box-shadow: 0 10px 22px -10px rgba(99,102,241,1);
}
.nav-item .nav-badge { margin-left: auto; background: rgba(255,255,255,.16); color:#fff; font-size: 11px; padding: 1px 7px; border-radius: 10px; }

.side-user { position: relative; display: flex; align-items: center; gap: 10px; padding: 12px 10px; margin-top: 8px; border-top: 1px solid rgba(255,255,255,.08); }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg,#6366f1,#a855f7); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:700; font-size: 15px; }
.su-info { min-width: 0; }
.su-info b { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-info small { color: #8b97b5; font-size: 11px; }
.su-menu { margin-left: auto; color: #8b97b5; font-size: 18px; padding: 2px 8px; border-radius: 8px; }
.su-menu:hover { background: rgba(255,255,255,.08); color: #fff; }
.su-drop { position: absolute; bottom: 64px; left: 8px; right: 8px; background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 20; }
.su-drop button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 8px; font-size: 13px; color: var(--ink-2); }
.su-drop button:hover { background: var(--gray-soft); }
.su-drop button.danger { color: var(--red); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 74px; padding: 0 30px; background: rgba(255,255,255,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 8;
}
.topbar h2 { margin: 0; font-size: 19px; letter-spacing: .3px; }
.page-sub { margin: 3px 0 0; color: var(--ink-3); font-size: 12.5px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.view { padding: 26px 30px 44px; }

/* ================= 卡片 / KPI ================= */
.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi {
  background: var(--panel); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--line); display: flex; align-items: center; gap: 16px;
  transition: .22s var(--ease); animation: rise .4s var(--ease) both;
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #dfe4ee; }
.kpi-ico { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kpi-ico svg { width: 22px; height: 22px; stroke-width: 2; }
.kpi-val { font-size: 26px; font-weight: 800; letter-spacing: .5px; line-height: 1.1; }
.kpi-lbl { color: var(--ink-3); font-size: 12.5px; margin-top: 3px; }
.i-indigo { background: var(--brand-soft); color: var(--brand); }
.i-blue { background: #e8f0ff; color: var(--blue); }
.i-green { background: var(--green-soft); color: var(--green); }
.i-amber { background: var(--amber-soft); color: var(--amber); }
.i-red { background: var(--red-soft); color: var(--red); }
.i-gray { background: var(--gray-soft); color: var(--gray); }

.cols { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; }
@media (max-width: 980px) { .cols { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px 22px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-head h3 { margin: 0; font-size: 15px; }
.card-head .muted { color: var(--ink-3); font-size: 12px; }

/* 环形图 */
.donut-wrap { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }
.donut { width: 168px; height: 168px; border-radius: 50%; flex-shrink: 0; position: relative;
  background: conic-gradient(var(--gray-soft) 0 100%); }
.donut::after { content: ""; position: absolute; inset: 26px; background: #fff; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--line); }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 2; }
.donut-center b { font-size: 26px; font-weight: 800; }
.donut-center small { color: var(--ink-3); font-size: 11.5px; }
.legend { display: flex; flex-direction: column; gap: 10px; flex: 1; min-width: 150px; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }
.legend-row .lv { margin-left: auto; font-weight: 700; }
.legend-row .lp { color: var(--ink-3); font-size: 12px; width: 42px; text-align: right; }

/* 条形 */
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.bar-row .bl { width: 84px; color: var(--ink-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 9px; background: var(--gray-soft); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .6s var(--ease); }
.bar-row .bv { width: 30px; text-align: right; font-weight: 700; font-size: 12.5px; }

/* 动态列表 */
.feed { display: flex; flex-direction: column; gap: 4px; }
.feed-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; transition: .15s; }
.feed-item:hover { background: #f8fafc; }
.feed-ico { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.feed-ico svg { width: 16px; height: 16px; stroke-width: 2; }
.feed-item .fi-main { min-width: 0; flex: 1; }
.feed-item .fi-main b { font-size: 13px; font-weight: 600; }
.feed-item .fi-sub { color: var(--ink-3); font-size: 12px; margin-top: 1px; }
.empty { text-align: center; color: var(--ink-3); padding: 34px; font-size: 13px; }

/* ================= 工具栏 / 表格 ================= */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.search { position: relative; }
.search input {
  padding: 10px 14px 10px 38px; border: 1px solid var(--line-2); border-radius: 11px; min-width: 240px;
  outline: none; background: #fff; font-size: 13.5px; transition: .2s;
}
.search input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--ink-3); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 8px 14px; border-radius: 20px; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  background: #fff; border: 1px solid var(--line-2); transition: .18s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; box-shadow: 0 8px 16px -8px rgba(79,70,229,.9); }

.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 13px 16px; background: #fafbfd; color: var(--ink-3);
  font-weight: 600; font-size: 12px; letter-spacing: .4px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; }
.act { padding: 5px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; border: 1px solid var(--line-2); color: var(--ink-2); margin-right: 5px; background: #fff; transition:.15s; }
.act:hover { background: var(--gray-soft); }
.act.p { color: var(--brand); border-color: #d5d9ff; background: var(--brand-soft); }
.act.p:hover { background: #e3e6ff; }
.act.g { color: var(--green); border-color: #bff0d4; background: var(--green-soft); }
.act.a { color: var(--amber); border-color: #fbe3b8; background: var(--amber-soft); }
.act.d { color: var(--red); border-color: #fbd0cd; background: var(--red-soft); }
.muted { color: var(--ink-3); }
.strong { font-weight: 600; }
.prod b { font-weight: 600; }
.prod small { display:block; color: var(--ink-3); font-size: 11.5px; margin-top: 2px; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.p-idle { background: var(--green-soft); color: #0e9f5b; }
.p-borrowed { background: var(--brand-soft); color: var(--brand); }
.p-in_repair { background: var(--amber-soft); color: #d97a06; }
.p-scrapped { background: var(--red-soft); color: var(--red); }
.p-borrowing { background: #e8f0ff; color: var(--blue); }
.p-returned { background: var(--gray-soft); color: var(--gray); }
.p-damaged { background: var(--red-soft); color: var(--red); }
.p-pending { background: var(--amber-soft); color: #d97a06; }
.p-repairing { background: var(--amber-soft); color: #d97a06; }
.p-done { background: var(--green-soft); color: #0e9f5b; }
.role-tag { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 8px; }
.role-super { background: linear-gradient(135deg,#eef0ff,#f3e8ff); color: var(--brand); }
.role-admin { background: var(--gray-soft); color: var(--gray); }

/* ================= 模态框 ================= */
.modal { position: fixed; inset: 0; background: rgba(16,24,40,.5); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 18px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-box { background: #fff; width: 100%; max-width: 560px; border-radius: 18px; box-shadow: var(--shadow-lg); max-height: 92vh; display: flex; flex-direction: column; animation: rise .28s var(--ease); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 15.5px; }
.icon-btn { width: 30px; height: 30px; border-radius: 9px; color: var(--ink-3); font-size: 14px; }
.icon-btn:hover { background: var(--gray-soft); color: var(--ink); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 15px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.field .req { color: var(--red); }
.field input, .field select, .field textarea { padding: 10px 12px; border: 1.5px solid var(--line-2); border-radius: 10px; font-size: 14px; outline: none; background: #fbfcfe; transition: .18s; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 4px var(--brand-soft); }
.field textarea { resize: vertical; min-height: 66px; }
.field-hint { font-size: 11.5px; color: var(--ink-3); margin-top: -1px; }
.chip-static {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--brand-soft); color: var(--brand); border: 1px solid #dfe1ff;
}
.hint { font-size: 12px; color: var(--ink-3); }
.warn { background: var(--amber-soft); color: #b45309; padding: 12px 14px; border-radius: 11px; font-size: 13px; margin-bottom: 16px; border: 1px solid #fbe3b8; }

/* ================= Toast ================= */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: #101828; color: #fff; padding: 12px 22px; border-radius: 12px; font-size: 13.5px; z-index: 90; box-shadow: var(--shadow-lg); animation: rise .25s var(--ease); }
.toast.err { background: var(--red); }
.toast.ok { background: #0e9f5b; }

/* 空状态 */
.blank { text-align: center; padding: 60px 20px; color: var(--ink-3); }
.blank svg { width: 46px; height: 46px; stroke: var(--line-2); margin-bottom: 14px; }

@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .brand { padding: 8px; }
  #nav { flex-direction: row; overflow-x: auto; width: 100%; padding: 6px 0 0; }
  .nav-item { white-space: nowrap; padding: 9px 12px; }
  .side-user { width: 100%; margin-top: 6px; }
  .view { padding: 18px 16px 40px; }
  .topbar { padding: 0 16px; }
  .form-grid { grid-template-columns: 1fr; }
}
