:root {
  --ink: #17252d;
  --muted: #687982;
  --line: #dde5e7;
  --bg: #f3f6f7;
  --card: #fff;
  --green: #118263;
  --green-dark: #0a7358;
  --red: #c4443c;
  --amber: #b86809;
  --shadow: 0 10px 30px rgba(23, 37, 45, 0.06);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--green); }

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.user-pill {
  height: 40px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
  background: #e7f5ef;
  color: #10775b;
  font-weight: 600;
  font-size: 13px;
}
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(92vw, 400px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
  display: grid;
  gap: 14px;
}
.login-card label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.login-card input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  outline: none;
}
.login-card input:focus { border-color: var(--green); }
.login-card .btn.primary { width: 100%; }
.login-tip { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
}

.brand strong { display: block; font-size: 22px; }
.brand span { color: var(--muted); font-size: 13px; }

.btn {
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: #33434b;
  font-weight: 600;
  font-size: 14px;
}
.btn:hover { background: #f5f8f8; }
.btn.primary {
  background: var(--green);
  border-color: #087458;
  color: #fff;
}
.btn.primary:hover { background: var(--green-dark); }
.btn.danger {
  background: var(--red);
  border-color: #a83832;
  color: #fff;
}
.btn.danger:hover { filter: brightness(0.95); }
.btn.ghost { background: transparent; }
.btn.small { height: 34px; padding: 0 10px; font-size: 13px; }

.toolbar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
  flex: 1;
}

.stat, .hint, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.stat { padding: 16px 18px; }
.stat p { margin: 0; color: var(--muted); font-size: 12px; }
.stat strong { display: block; margin-top: 6px; font-size: 26px; }

.search { min-width: 240px; display: flex; }
.search input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  background: #fff;
  outline: none;
}
.search input:focus { border-color: var(--green); }

.hint {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  padding: 18px 20px;
  margin-bottom: 20px;
}
.hint strong { font-size: 14px; }
.hint p, .hint small { color: var(--muted); line-height: 1.6; margin: 6px 0 0; }
.base-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.base-row { display: flex; gap: 8px; }
.base-row input {
  flex: 1;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  outline: none;
}
.base-row input:focus { border-color: var(--green); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.card { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.card-head h3 { margin: 0; font-size: 16px; line-height: 1.4; }
.badge {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 4px 8px;
  background: #e7f5ef;
  color: #10775b;
}
.badge.off { background: #fdebe9; color: #b33b35; }

.qr-wrap {
  display: grid;
  place-items: center;
  background: #f8fbfb;
  border: 1px dashed #c9d6d8;
  border-radius: 14px;
  padding: 12px;
}
.qr-wrap img { width: 180px; height: 180px; }

.meta, .url {
  font-size: 13px;
  color: var(--muted);
  word-break: break-all;
  line-height: 1.5;
}
.url a { color: inherit; text-decoration: none; }
.url a:hover { color: var(--green); text-decoration: underline; }
.meta span { margin-right: 12px; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 20px;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed #c9d6d8;
  border-radius: 16px;
}
.empty h3 { color: var(--ink); margin: 0 0 8px; }

dialog {
  width: min(92vw, 460px);
  border: 0;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 24px 80px rgba(23, 37, 45, 0.18);
}
dialog::backdrop { background: rgba(18, 32, 38, 0.42); }
.links-box { display: grid; gap: 12px; }
.link-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: #f8fbfb;
}
.link-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.link-row-head strong { font-size: 13px; }
#addLinkBtn { width: 100%; }
dialog h2 { margin: 0 0 16px; font-size: 20px; }
dialog form { display: grid; gap: 12px; }
dialog label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
dialog input, dialog textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
dialog input:focus, dialog textarea:focus { border-color: var(--green); }
.switch-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.switch-row input { width: auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.form-error { color: var(--red); font-size: 13px; margin: 0; }

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #24363d;
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 20;
}
#toast.error { background: var(--red); }

.toolbar-side { display: grid; gap: 10px; min-width: 260px; }
.filters, .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: #44555c;
  font-size: 13px;
}
.chip:hover { border-color: var(--green); color: var(--green); }
.chip.active { background: var(--green); border-color: var(--green); color: #fff; }
.qr-wrap { cursor: pointer; }
.qr-wrap:hover { border-color: var(--green); }
.preview { display: grid; gap: 12px; justify-items: center; text-align: center; }
.preview img { width: min(72vw, 320px); height: auto; background: #fff; border-radius: 12px; }
.preview h3 { margin: 8px 0 0; font-size: 14px; justify-self: start; }
.preview-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.logs {
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.logs li { padding: 8px 12px; font-size: 13px; color: var(--muted); border-bottom: 1px solid #edf1f2; }
.logs li:last-child { border-bottom: 0; }
.empty .btn { margin-top: 12px; }

@media (max-width: 820px) {
  .toolbar, .hint, .toolbar-side { grid-template-columns: 1fr; display: grid; }
  .stats { grid-template-columns: 1fr; }
  .search { min-width: 0; }
  .topbar { align-items: flex-start; flex-direction: column; }
}

@media print {
  body * { visibility: hidden; }
  #previewDialog, #previewDialog * { visibility: visible; }
  #previewDialog { position: static; inset: auto; width: auto; box-shadow: none; border: 0; }
  .preview-actions, .logs, #previewDialog h3 { display: none !important; }
}
