:root {
  --green: #07c160;
  --green-dark: #06a552;
  --green-soft: #e8f8ef;
  --ink: #1a1d21;
  --ink-2: #4d5560;
  --ink-3: #8a929e;
  --line: #e9ecf0;
  --bg: #f5f6f8;
  --white: #ffffff;
  --red: #e54545;
  --red-soft: #fdecec;
  --amber: #d98600;
  --amber-soft: #fff6e5;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 26, 33, 0.04), 0 8px 24px rgba(20, 26, 33, 0.05);
}

* { box-sizing: border-box; }

/* hidden 属性必须能压住 .login-wrap / .layout 上的 display，否则隐藏不生效 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
button { font-family: inherit; cursor: pointer; }
code {
  background: #f1f3f6;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--ink-2);
}

/* ---------------- 登录 ---------------- */

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% 0%, #e6f9ee 0%, rgba(230, 249, 238, 0) 60%),
    radial-gradient(700px 500px at 100% 100%, #eef2ff 0%, rgba(238, 242, 255, 0) 55%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border-radius: 20px;
  padding: 34px 30px 26px;
  box-shadow: 0 2px 4px rgba(20, 26, 33, 0.03), 0 24px 60px rgba(20, 26, 33, 0.09);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.login-brand h1 { font-size: 19px; letter-spacing: 0.3px; }
.login-brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-3); }

.logo-mark {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: linear-gradient(140deg, #22d47a, var(--green));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 19px;
  font-weight: 600;
  flex: none;
  box-shadow: 0 6px 14px rgba(7, 193, 96, 0.28);
}

.logo-mark.sm {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 14px;
  box-shadow: none;
}

.field {
  display: block;
  margin-bottom: 15px;
}

.field > span {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 13px;
  font-size: 14px;
  color: var(--ink);
  background: #fbfcfd;
  transition: border-color 0.16s, background 0.16s, box-shadow 0.16s;
}

.field input:focus {
  outline: none;
  border-color: var(--green);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.11);
}

.login-hint {
  margin: 14px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
}

/* ---------------- 按钮 ---------------- */

.btn {
  height: 36px;
  padding: 0 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.16s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 2px 8px rgba(7, 193, 96, 0.22);
}
.btn-primary:hover { background: var(--green-dark); }

.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink-2);
}
.btn-ghost:hover { border-color: #d3d9e0; color: var(--ink); }

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

.btn-block { width: 100%; height: 44px; font-size: 15px; margin-top: 6px; }

.btn-sm {
  height: 30px;
  padding: 0 11px;
  font-size: 12.5px;
  border-radius: 7px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: 12.5px;
  padding: 0;
}
.link-btn:hover { color: var(--red); }

/* ---------------- 布局 ---------------- */

.layout {
  display: flex;
  min-height: 100%;
}

.sidebar {
  width: 208px;
  flex: none;
  background: var(--white);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 6px 18px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

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

.nav-item {
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: #f6f8fa; color: var(--ink); }

.nav-item.active {
  background: var(--green-soft);
  color: var(--green-dark);
  font-weight: 500;
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--ink-3);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 26px 30px 60px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-head h2 { font-size: 20px; letter-spacing: 0.2px; }

/* ---------------- 统计卡 ---------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 17px 18px 15px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 3px;
  border: 1px solid rgba(233, 236, 240, 0.7);
}

.stat-label { font-size: 12.5px; color: var(--ink-3); }

.stat-value {
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.stat-sub { font-size: 12px; color: var(--ink-3); }

.stat-card.warn .stat-value { color: var(--amber); }

/* ---------------- 面板 ---------------- */

.panel {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(233, 236, 240, 0.7);
  margin-bottom: 16px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-head h3, .panel-title { font-size: 14.5px; margin-bottom: 12px; }
.panel-head h3 { margin-bottom: 0; }

.muted { color: var(--ink-3); font-size: 12.5px; }

.low-stock { display: flex; flex-direction: column; gap: 8px; }

.low-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 13px;
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
}

.low-item b { color: var(--amber); font-weight: 600; }

.empty {
  padding: 26px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}

/* ---------------- 表格 ---------------- */

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.table th {
  text-align: left;
  font-weight: 500;
  color: var(--ink-3);
  font-size: 12.5px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 12px;
  border-bottom: 1px solid #f2f4f7;
  color: var(--ink-2);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table tbody tr:hover { background: #fbfcfd; }
.table tbody tr:last-child td { border-bottom: none; }

.table .t-title { color: var(--ink); font-weight: 500; }
.table .t-mono {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
}

.cell-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- 标签 ---------------- */

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}

.tag-green { background: var(--green-soft); color: var(--green-dark); }
.tag-gray { background: #f1f3f6; color: var(--ink-3); }
.tag-amber { background: var(--amber-soft); color: var(--amber); }
.tag-red { background: var(--red-soft); color: var(--red); }

/* ---------------- 筛选行 ---------------- */

.filter-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--ink-3);
}

.inline-field.grow { flex: 1; min-width: 200px; }
.inline-field.grow input { flex: 1; }

.inline-field select,
.inline-field input {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
  font-family: inherit;
}

.inline-field select { min-width: 130px; }
.inline-field select:focus,
.inline-field input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.1);
}

/* ---------------- 分页 ---------------- */

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--ink-3);
}

/* ---------------- 设置页 ---------------- */

.kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px 16px;
  font-size: 13px;
}

.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; color: var(--ink); word-break: break-all; }

.notice {
  margin-top: 16px;
  padding: 11px 14px;
  background: var(--amber-soft);
  color: #8a5a00;
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.65;
}

.steps {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 2;
}

/* ---------------- 弹窗 ---------------- */

.modal-root { position: fixed; inset: 0; z-index: 60; }

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(20, 26, 33, 0.42);
  backdrop-filter: blur(2px);
}

.modal {
  position: relative;
  z-index: 1;
  width: calc(100% - 40px);
  max-width: 520px;
  margin: 6vh auto;
  background: #fff;
  border-radius: 16px;
  padding: 24px 26px 22px;
  box-shadow: 0 30px 70px rgba(20, 26, 33, 0.22);
  max-height: 84vh;
  overflow-y: auto;
}

.modal.wide { max-width: 720px; }

.modal h3 {
  font-size: 16.5px;
  margin-bottom: 4px;
}

.modal-sub {
  margin: 0 0 18px;
  font-size: 12.5px;
  color: var(--ink-3);
}

.modal .field textarea {
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.7;
  resize: vertical;
  background: #fbfcfd;
}

.modal .field textarea:focus {
  outline: none;
  border-color: var(--green);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.11);
}

.modal .field input,
.modal .field select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 13.5px;
  background: #fbfcfd;
  font-family: inherit;
}

.modal .field input:focus,
.modal .field select:focus {
  outline: none;
  border-color: var(--green);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.11);
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.hint-text {
  font-size: 12px;
  color: var(--ink-3);
  margin: 5px 0 0;
  line-height: 1.6;
}

.secret-box {
  background: #f7f9fb;
  border: 1px dashed #d8dee6;
  border-radius: 10px;
  padding: 13px 15px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  word-break: break-all;
  line-height: 1.8;
  color: var(--ink);
}

.detail-list {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 9px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}

.detail-list dt { color: var(--ink-3); }
.detail-list dd { margin: 0; word-break: break-all; }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 38px;
  transform: translateX(-50%);
  background: rgba(26, 29, 33, 0.92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 90;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  max-width: 80vw;
  text-align: center;
}

.toast.error { background: rgba(196, 44, 44, 0.95); }

/* ---------------- 响应式 ---------------- */

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

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    padding: 10px 14px;
    overflow-x: auto;
  }
  .brand { padding: 0 12px 0 0; }
  .nav { flex-direction: row; }
  .sidebar-foot { margin: 0 0 0 auto; border: none; padding: 0; }
  .main { padding: 18px 16px 40px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-value { font-size: 22px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
}
