:root {
  --blue-900: #0b3a66;
  --blue-800: #0f4c81;
  --blue-700: #1464a8;
  --blue-600: #1c7ae0;
  --blue-500: #3b93f0;
  --blue-100: #e6f1fd;
  --blue-50: #f2f8ff;
  --ink: #15263b;
  --ink-soft: #55708c;
  --line: #dbe8f6;
  --bg: #f3f8fe;
  --card: #ffffff;
  --green: #12a37a;
  --amber: #d98a15;
  --red: #d94848;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 62, 105, 0.06), 0 4px 14px rgba(20, 62, 105, 0.05);
  --shadow-md: 0 12px 34px rgba(15, 76, 129, 0.14);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

.hidden { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- 登录 ---------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
}

.login-art {
  position: relative;
  overflow: hidden;
  padding: 56px 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
  background:
    radial-gradient(1100px 520px at -10% -10%, rgba(96, 190, 255, 0.55), transparent 60%),
    radial-gradient(760px 460px at 105% 110%, rgba(37, 211, 190, 0.32), transparent 60%),
    linear-gradient(150deg, var(--blue-900) 0%, var(--blue-700) 52%, var(--blue-600) 100%);
}

.login-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 30% 30%, #000 20%, transparent 78%);
}

.login-brand { position: relative; display: flex; align-items: center; gap: 16px; }

.login-brand h1 { margin: 0; font-size: 30px; letter-spacing: 1px; }
.login-brand p { margin: 4px 0 0; font-size: 12px; letter-spacing: 3px; opacity: 0.7; text-transform: uppercase; }

.brand-mark {
  width: 46px; height: 46px; flex: 0 0 46px;
  display: grid; place-items: center;
  border-radius: 13px;
  font-weight: 700; font-size: 20px;
  color: var(--blue-700);
  background: #fff;
  box-shadow: 0 8px 22px rgba(3, 30, 60, 0.28);
}

.login-points {
  position: relative;
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  gap: 14px;
  max-width: 470px;
}

.login-points li {
  padding: 16px 20px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(6px);
}

.login-points strong { display: block; font-size: 15px; margin-bottom: 5px; }
.login-points span { font-size: 13px; opacity: 0.78; line-height: 1.6; }

.login-panel { display: grid; place-items: center; padding: 40px; background: #fff; }

.login-card { width: 100%; max-width: 360px; }
.login-card h2 { margin: 0 0 6px; font-size: 26px; }
.login-sub { margin: 0 0 26px; color: var(--ink-soft); font-size: 13px; }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; margin-bottom: 7px; font-size: 13px; color: var(--ink-soft); font-weight: 600; }

.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdff;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue-500);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(59, 147, 240, 0.15);
}

.field textarea { resize: vertical; min-height: 74px; }

.form-error { min-height: 18px; margin: 0 0 10px; color: var(--red); font-size: 13px; }
.login-hint { margin: 18px 0 0; font-size: 12px; color: var(--ink-soft); line-height: 1.7; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  transition: transform 0.12s, background 0.16s, border-color 0.16s, box-shadow 0.16s, color 0.16s;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; letter-spacing: 2px; }

.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, var(--blue-500), var(--blue-600));
  box-shadow: 0 8px 20px rgba(28, 122, 224, 0.3);
}

.btn-primary:hover { background: linear-gradient(180deg, #4b9df5, #1973d4); }

.btn-ghost { background: #fff; border-color: var(--line); color: var(--blue-800); }
.btn-ghost:hover { border-color: var(--blue-500); color: var(--blue-600); background: var(--blue-50); }

.btn-soft { background: var(--blue-100); color: var(--blue-700); }
.btn-soft:hover { background: #d8eafc; }

.btn-danger { background: #fdecec; color: var(--red); }
.btn-danger:hover { background: #fbdcdc; }

.btn-mini { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

.btn-icon {
  width: 30px; height: 30px; padding: 0;
  border-radius: 8px; background: transparent; color: var(--ink-soft);
  border: 1px solid transparent;
}
.btn-icon:hover { background: var(--blue-50); color: var(--blue-600); border-color: var(--line); }

/* ---------- 布局 ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

.sidebar {
  display: flex; flex-direction: column;
  padding: 22px 16px;
  color: #dbeafe;
  background: linear-gradient(180deg, #0d3f6d 0%, #0f4c81 55%, #14609e 100%);
  position: sticky; top: 0; height: 100vh;
}

.side-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.side-brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.side-brand-text strong { color: #fff; font-size: 16px; letter-spacing: 1px; }
.side-brand-text span { font-size: 10px; letter-spacing: 2px; opacity: 0.55; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  border: none; background: transparent;
  color: rgba(230, 241, 253, 0.78);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: background 0.16s, color 0.16s;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.nav-item.active { background: #fff; color: var(--blue-700); font-weight: 700; box-shadow: 0 8px 18px rgba(2, 24, 48, 0.24); }
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 15px; }
.nav-item .nav-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--blue-600);
  color: #fff;
}
.nav-item.active .nav-badge { background: var(--blue-100); color: var(--blue-700); }

.side-foot { border-top: 1px solid rgba(255, 255, 255, 0.14); padding-top: 14px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 0 6px 12px; }
.side-user .avatar { background: rgba(255, 255, 255, 0.16); color: #fff; }
.side-user div { display: flex; flex-direction: column; line-height: 1.4; min-width: 0; }
.side-user strong { color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user span { font-size: 11px; opacity: 0.65; }

.side-logout {
  width: 100%; padding: 9px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(230, 241, 253, 0.85);
  cursor: pointer; font-size: 13px;
}
.side-logout:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 30px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}

.topbar h2 { margin: 0; font-size: 20px; }
.topbar p { margin: 3px 0 0; font-size: 12px; color: var(--ink-soft); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.clock { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.avatar {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--blue-100);
  color: var(--blue-700);
  font-weight: 700; font-size: 13px;
}

.content { padding: 26px 30px 40px; }

/* ---------- 通用卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { margin: 0; font-size: 15px; }
.card-head p { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }
.card-body { padding: 18px 20px; }

/* ---------- 看板 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }

.stat {
  position: relative;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; right: -30px; top: -30px;
  width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 147, 240, 0.16), transparent 70%);
}
.stat .stat-label { font-size: 12px; color: var(--ink-soft); }
.stat .stat-value { margin-top: 8px; font-size: 30px; font-weight: 700; letter-spacing: 1px; color: var(--blue-800); }
.stat .stat-unit { font-size: 12px; font-weight: 500; color: var(--ink-soft); margin-left: 4px; }
.stat.accent { background: linear-gradient(140deg, var(--blue-700), var(--blue-500)); border-color: transparent; }
.stat.accent .stat-label { color: rgba(255, 255, 255, 0.8); }
.stat.accent .stat-value, .stat.accent .stat-unit { color: #fff; }
.stat.accent::after { background: radial-gradient(circle, rgba(255, 255, 255, 0.28), transparent 70%); }

.dash-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

thead th {
  text-align: left;
  padding: 11px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--blue-50);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td { padding: 12px 14px; border-bottom: 1px solid #edf4fc; vertical-align: middle; }
tbody tr:hover { background: #f8fbff; }
tbody tr:last-child td { border-bottom: none; }

.code-cell { font-weight: 700; color: var(--blue-800); font-family: "SFMono-Regular", Consolas, monospace; }
.muted { color: var(--ink-soft); }
.small { font-size: 12px; }
.strong { font-weight: 600; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--blue-100);
  color: var(--blue-700);
}

.tag.green { background: #e3f7f0; color: var(--green); }
.tag.amber { background: #fdf1dd; color: var(--amber); }
.tag.red { background: #fdecec; color: var(--red); }
.tag.gray { background: #eef3f9; color: var(--ink-soft); }
.tag.in { background: #e3f7f0; color: var(--green); }
.tag.out { background: #ffecea; color: #dd5a3d; }

.empty {
  padding: 44px 18px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
}
.empty .empty-emoji { font-size: 30px; display: block; margin-bottom: 10px; opacity: 0.55; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

.search-box { position: relative; flex: 1; min-width: 200px; max-width: 380px; }
.search-box input {
  width: 100%;
  padding: 9px 13px 9px 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  outline: none;
}
.search-box input:focus { border-color: var(--blue-500); box-shadow: 0 0 0 4px rgba(59, 147, 240, 0.14); }
.search-box::before {
  content: "⌕";
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-soft); font-size: 16px;
}

.select {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  outline: none;
  cursor: pointer;
}
.select:focus { border-color: var(--blue-500); }

.spacer { flex: 1; }

/* ---------- 模具详情 ---------- */
.detail-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.detail-grid > * { min-width: 0; }
.detail-left { display: flex; flex-direction: column; gap: 0; min-width: 0; }

.log-list { display: grid; gap: 0; }
.log-item { display: flex; align-items: flex-start; gap: 10px; padding: 11px 16px; border-top: 1px solid #edf4fc; font-size: 13px; }
.log-item:first-child { border-top: none; }
.log-item .log-main { flex: 1; min-width: 0; }
.log-item .log-sub { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; }
.log-item .log-time { font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; }

.info-list { display: grid; gap: 12px; }
.info-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.info-row .k { color: var(--ink-soft); flex: 0 0 auto; }
.info-row .v { text-align: right; font-weight: 600; word-break: break-all; }

.group { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.group-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  background: var(--blue-50);
}
.group-head .code-cell { font-size: 14px; }
.group-head .spacer { flex: 1; }
.material-list { display: grid; gap: 0; }

.material-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid #edf4fc;
  font-size: 13px;
}
.material-row .code-cell { font-size: 13px; }
.material-row .spacer { flex: 1; }
.group-empty { padding: 12px 14px; font-size: 12.5px; color: var(--ink-soft); border-top: 1px dashed #e2eefa; }

/* ---------- 权限勾选 ---------- */
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.perm-group-title {
  grid-column: 1 / -1;
  font-size: 12px; font-weight: 700; color: var(--ink-soft);
  margin-top: 6px;
}
.perm-item { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.5; cursor: pointer; }
.perm-item input { margin: 1px 0 0; flex: 0 0 auto; width: 15px; height: 15px; accent-color: var(--blue-600); }
.perm-item span { min-width: 0; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(9, 38, 68, 0.42);
  backdrop-filter: blur(3px);
  animation: fade 0.16s ease;
}

.modal {
  width: 100%; max-width: 520px;
  max-height: 88vh; overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  animation: pop 0.18s ease;
}
.modal.wide { max-width: 720px; }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 14px;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 4px 22px 8px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px 20px;
  border-top: 1px solid var(--line);
  margin-top: 12px;
}

.close-x {
  width: 30px; height: 30px; border: none; border-radius: 8px;
  background: #f2f7fd; color: var(--ink-soft); cursor: pointer; font-size: 16px;
}
.close-x:hover { background: #e6f1fd; color: var(--blue-700); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---------- Toast ---------- */
.toast-root { position: fixed; right: 24px; bottom: 24px; z-index: 200; display: grid; gap: 10px; }
.toast {
  padding: 12px 18px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(15, 76, 129, 0.2);
  border-left: 4px solid var(--blue-600);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  animation: slide 0.2s ease;
  max-width: 340px;
}
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }
@keyframes slide { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------- 其他 ---------- */
.section-title { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 14px; }
.section-title h3 { margin: 0; font-size: 16px; }
.section-title span { font-size: 12px; color: var(--ink-soft); }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }

.alert {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--blue-50);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.7;
}

.notice-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: linear-gradient(100deg, #eef7ff, #f7fbff);
  border: 1px dashed #c7dffa;
  color: var(--blue-800);
  font-size: 13px;
  margin-bottom: 18px;
}

.pill-actions { display: flex; gap: 6px; justify-content: flex-end; }

@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid, .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-content: start; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center; gap: 10px;
    padding: 10px 12px;
    width: 100%; max-width: 100vw; min-width: 0; overflow: hidden;
  }
  .side-brand { padding: 0; flex: 0 0 auto; }
  .side-brand .brand-mark { width: 34px; height: 34px; flex-basis: 34px; font-size: 15px; border-radius: 10px; }
  .side-brand-text, .side-user div, .side-logout { display: none; }
  .nav {
    flex-direction: row; flex-wrap: nowrap; gap: 4px;
    flex: 1 1 auto; min-width: 0;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -ms-overflow-style: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { padding: 8px 11px; white-space: nowrap; flex: 0 0 auto; }
  .nav-item .nav-badge { display: none; }
  .side-foot { border: none; padding: 0; margin-left: 0; flex: 0 0 auto; }
  .side-user { padding: 0; }
  .content { padding: 16px; }
  .topbar { padding: 14px 16px; }
  .topbar-actions { gap: 8px; }
  .clock, #password-btn { display: none; }
  .perm-grid { grid-template-columns: 1fr; }
  .toolbar .search-box { max-width: none; flex: 1 1 100%; }
  .detail-grid { grid-template-columns: 1fr; }
  .stat-grid { gap: 12px; }
}
