:root {
  --navy: #0b2545;
  --navy-2: #123a63;
  --ink: #17263a;
  --muted: #66788c;
  --line: #dfe7ef;
  --soft: #f4f7fa;
  --cyan: #2c7a8c;
  --red: #bd3a32;
  --green: #1f7a5a;
  --font: "PingFang SC", "Source Han Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--soft); font-size: 14px; line-height: 1.7; }
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font-family: inherit; font-size: 14px; }
[hidden] { display: none !important; }

.brand-mark {
  width: 36px; height: 36px; border-radius: 4px; background: var(--navy); color: #fff;
  display: inline-grid; place-items: center; font-size: 13px; font-weight: 800; flex: 0 0 auto;
}
.brand-mark--img { background: none; border-radius: 0; object-fit: contain; }
.field-hint { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.eyebrow { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--cyan); font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 4px; cursor: pointer; border: 1px solid transparent;
  font-weight: 600; transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.btn--solid { background: var(--navy); color: #fff; }
.btn--solid:hover { background: var(--navy-2); }
.btn--line { background: #fff; border-color: var(--line); color: var(--ink); }
.btn--line:hover { border-color: var(--cyan); color: var(--cyan); }
.btn--sm { padding: 7px 13px; font-size: 13px; }
.btn--danger { background: #fff; border-color: #e8c9c6; color: var(--red); }
.btn--danger:hover { background: #fdf3f2; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: #46596e; margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px;
  background: #fff; color: var(--ink); outline: none; transition: border-color .18s ease;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--cyan); }
.field textarea { resize: vertical; min-height: 84px; line-height: 1.7; }
.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }
.form-msg { font-size: 13px; color: var(--red); min-height: 20px; }
.form-msg.is-ok { color: var(--green); }

/* 登录 */
.login-view { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; background: #fff; }
.login-card { width: min(100% - 80px, 420px); margin: auto; padding: 48px 0; }
.login-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; margin-bottom: 44px; }
.login-card h1 { font-size: 30px; letter-spacing: -.02em; }
.login-sub { color: var(--muted); margin: 10px 0 24px; font-size: 14px; }
/* 后端连不上时的醒目自检提示：说明原因与正确打开方式 */
.login-status {
  margin: 0 0 24px; padding: 12px 14px; border: 1px solid #f0c987; border-radius: 6px;
  background: #fff7e8; color: #8a5a12; font-size: 13px; line-height: 1.7;
}
.login-status[hidden] { display: none; }
.login-status.is-ok { background: #eef8f3; border-color: #bfe3cf; color: #1d6b47; }
.login-retry {
  display: block; margin-top: 10px; padding: 5px 12px; border: 1px solid currentColor;
  border-radius: 4px; background: transparent; color: inherit; font-size: 12px; cursor: pointer;
}
.login-retry:hover { background: rgba(0,0,0,.05); }
#loginForm .btn { width: 100%; }
.login-foot { margin-top: 26px; font-size: 13px; color: var(--cyan); }
.login-side {
  background: var(--navy); color: #c7d9ea; padding: 64px; display: flex; align-items: center;
}
.login-side > div { max-width: 460px; }
.login-side .eyebrow { color: #8fd0de; }
.login-side h2 { color: #fff; font-size: 34px; line-height: 1.35; margin: 18px 0 16px; }
.login-side p { font-size: 15px; }
.login-side ul { margin: 32px 0 0; padding: 0; list-style: none; }
.login-side li { padding: 10px 0 10px 24px; border-bottom: 1px solid rgba(255,255,255,.1); position: relative; }
.login-side li::before { content: "—"; position: absolute; left: 0; color: #8fd0de; }

/* 主框架 */
.topbar {
  height: 64px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 0 28px; position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-left strong { font-size: 15px; }
.topbar-tag { font-size: 11px; color: var(--cyan); background: #e8f2f5; padding: 2px 8px; border-radius: 2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-user { font-size: 12px; color: var(--muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.admin-shell { display: grid; grid-template-columns: 230px 1fr; min-height: calc(100vh - 64px); }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 24px 16px; }
.sidebar-title { font-size: 11px; letter-spacing: .16em; color: var(--muted); margin: 0 12px 14px; }
#sectionNav { display: grid; gap: 3px; }
.nav-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 13px; border-radius: 4px; cursor: pointer; border: none;
  background: transparent; width: 100%; text-align: left; color: #40556b; font-size: 14px;
}
.nav-link:hover { background: var(--soft); }
.nav-link.is-active { background: var(--navy); color: #fff; font-weight: 600; }
.nav-link b { font-size: 11px; font-weight: 500; opacity: .6; }
.sidebar-note { margin: 28px 12px 0; padding: 14px; background: var(--soft); border-radius: 4px; font-size: 12px; color: var(--muted); line-height: 1.8; }

.workspace { padding: 36px 40px 80px; max-width: 1100px; width: 100%; }
.workspace-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 28px; }
.workspace-head h2 { font-size: 26px; margin: 8px 0 6px; }
.workspace-head p { color: var(--muted); font-size: 14px; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 24px; overflow: hidden; }
.panel-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; gap: 14px; }
.panel-head h3 { font-size: 16px; }
.panel-hint { font-size: 12px; color: var(--muted); }

.field-list { display: grid; }
.field-row { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.field-row:last-child { border-bottom: none; }
.field-row-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.field-row-head strong { font-size: 14px; }
.field-row-head code { font-size: 11px; color: #97a7b8; background: var(--soft); padding: 2px 7px; border-radius: 2px; }
.field-row .field { margin-bottom: 10px; }
.row-actions { display: flex; align-items: center; gap: 10px; }
.save-state { font-size: 12px; color: var(--green); }

.image-editor { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.image-preview {
  width: 180px; height: 120px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--soft) center/cover no-repeat; flex: 0 0 auto;
}
.image-controls { flex: 1; min-width: 220px; }
.image-controls .field { margin-bottom: 10px; }
.image-controls input[type="file"] { padding: 8px; }

.item-list { display: grid; }
.item-row { display: flex; gap: 18px; padding: 18px 22px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.item-row:last-child { border-bottom: none; }
.item-thumb { width: 92px; height: 68px; border-radius: 4px; background: var(--soft) center/cover no-repeat; flex: 0 0 auto; border: 1px solid var(--line); }
.item-main { flex: 1; min-width: 0; }
.item-main h4 { font-size: 15px; margin-bottom: 4px; }
.item-main p { font-size: 13px; color: var(--muted); white-space: pre-line; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 2px; background: var(--soft); color: #566b80; }
.chip--on { background: #e4f4ec; color: var(--green); }
.chip--off { background: #fdf0e5; color: #a46a1d; }
.item-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 230px; }
.empty-state { padding: 44px; text-align: center; color: var(--muted); background: #fff; border: 1px dashed var(--line); border-radius: 6px; }

/* 弹窗 */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal-mask { position: absolute; inset: 0; background: rgba(9, 27, 50, .55); }
.modal-box {
  position: relative; width: min(100%, 640px); max-height: min(88vh, 860px);
  background: #fff; border-radius: 8px; display: flex; flex-direction: column;
  box-shadow: 0 24px 70px rgba(9, 27, 50, .3);
}
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 17px; }
.modal-x { border: none; background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
#itemForm { display: flex; flex-direction: column; min-height: 0; }
.modal-body { padding: 22px 24px; overflow-y: auto; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-foot .form-msg { flex: 1; margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px);
  background: var(--navy); color: #fff; padding: 12px 22px; border-radius: 4px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .22s ease, transform .22s ease; z-index: 90;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--red); }

@media (max-width: 980px) {
  .login-view { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); padding: 16px; }
  #sectionNav { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .sidebar-note { margin: 14px 0 0; }
  .workspace { padding: 26px 20px 60px; }
  .topbar { padding: 0 16px; }
  .topbar-user { display: none; }
  .item-row { flex-wrap: wrap; }
  .item-actions { max-width: none; }
}
@media (max-width: 560px) {
  .topbar-right .btn { padding: 6px 10px; font-size: 12px; }
  .workspace-head { flex-direction: column; }
  .image-preview { width: 100%; height: 160px; }
}
