:root {
  --color-primary: #2f6bff;
  --color-primary-dark: #1f52d6;
  --color-danger: #e0483d;
  --color-text: #1c2430;
  --color-text-secondary: #5b6675;
  --color-text-muted: #97a1b0;
  --color-border: #e4e8ef;
  --color-bg: #f4f6fb;
  --color-surface: #ffffff;
  --color-self: #f0f7ff;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 1px 3px rgba(20, 30, 50, 0.06), 0 4px 16px rgba(20, 30, 50, 0.05);
  --font-stack: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* 让 HTML `hidden` 属性优先于组件自身的 display 声明，
   否则 .auth / .modal 等 display:flex 会盖掉 hidden，导致登录页与弹窗一直显示。 */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-stack);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  font-size: 15px;
}

/* Header */
.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header__inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand__logo {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-primary); color: #fff;
  border-radius: var(--radius-md);
  font-size: 20px; font-weight: 700;
}
.brand__name { font-size: 17px; font-weight: 700; }
.brand__sub { font-size: 12px; color: var(--color-text-muted); }
.user-bar { display: flex; align-items: center; gap: 12px; }
.user-bar__name { font-size: 14px; color: var(--color-text-secondary); max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Layout */
.container { max-width: 960px; margin: 0 auto; padding: 24px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  width: auto; padding: 9px 18px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
  background: transparent; color: var(--color-text);
}
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-dark); }
.btn--ghost { border-color: var(--color-border); color: var(--color-text-secondary); background: #fff; }
.btn--ghost:hover { border-color: var(--color-text-muted); }
.btn--danger { color: var(--color-danger); border-color: transparent; background: transparent; }
.btn--danger:hover { background: #fdecea; }
.btn--block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Auth */
.auth { display: flex; justify-content: center; padding-top: 32px; }
.auth__card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  padding: 32px; width: 100%; max-width: 420px;
}
.auth__title { margin: 0 0 6px; font-size: 22px; }
.auth__desc { margin: 0 0 20px; color: var(--color-text-secondary); font-size: 14px; }
.auth__hint { margin-top: 18px; font-size: 12px; color: var(--color-text-muted); }
.auth__qr { margin-top: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.auth__qr img {
  width: 140px; height: 140px; display: block;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
}
.auth__qr-fallback {
  display: none; width: 140px; height: 140px;
  border: 1px dashed var(--color-border); border-radius: var(--radius-sm);
  align-items: center; justify-content: center; text-align: center;
  color: var(--color-text-muted); font-size: 13px; padding: 12px;
}
.auth__qr-caption { margin: 0; font-size: 12px; color: var(--color-text-muted); }

.tabs { display: flex; gap: 8px; margin-bottom: 20px; border-bottom: 1px solid var(--color-border); }
.tab {
  border: none; background: none; padding: 8px 4px; margin-bottom: -1px;
  font-size: 15px; color: var(--color-text-muted); cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab--active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; color: var(--color-text-secondary); }
.req { color: var(--color-danger); }
.input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; color: var(--color-text);
  background: #fff; transition: border-color 180ms ease;
}
.input:focus { outline: none; border-color: var(--color-primary); }
.textarea { resize: vertical; min-height: 72px; }
.checkbox { display: flex; align-items: flex-start; gap: 8px; font-size: 13px;
  color: var(--color-text-secondary); cursor: pointer; }
.checkbox input { margin-top: 3px; }
.form__error { margin: 0; color: var(--color-danger); font-size: 13px; }

/* Toolbar */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.search { display: flex; align-items: center; gap: 8px; flex: 1 1 320px; }
.search__input { flex: 1 1 auto; }

/* Card list */
.card-list { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 18px 20px;
  box-shadow: var(--shadow-card);
}
.card--self { background: var(--color-self); border-color: #cfe0ff; }
.card__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card__name { font-size: 16px; font-weight: 600; margin: 0; }
.card__badges { display: flex; gap: 6px; flex: none; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 500; }
.badge--self { background: var(--color-primary); color: #fff; }
.badge--other { background: #eef1f6; color: var(--color-text-muted); }
.card__meta { margin: 8px 0 0; font-size: 13px; color: var(--color-text-secondary);
  display: flex; flex-wrap: wrap; gap: 4px 18px; }
.card__meta b { font-weight: 500; color: var(--color-text-muted); }
.card__desc { margin: 10px 0 0; font-size: 13px; color: var(--color-text-secondary);
  white-space: pre-wrap; word-break: break-word; }
.card__actions { margin-top: 14px; display: flex; gap: 8px; justify-content: flex-end; }

/* Empty */
.empty { text-align: center; padding: 48px 24px; color: var(--color-text-muted); }
.empty__title { font-size: 16px; margin: 0 0 6px; color: var(--color-text-secondary); }
.empty__desc { margin: 0; font-size: 13px; }

/* Pager */
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 24px; }
.pager__info { font-size: 13px; color: var(--color-text-secondary); }

/* Mini-program entry */
.mp-entry {
  margin-top: 36px; padding: 24px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.mp-entry__title { margin: 0 0 6px; font-size: 16px; }
.mp-entry__desc { margin: 0; font-size: 13px; color: var(--color-text-secondary); max-width: 480px; }
.mp-entry__qr { flex: none; }
.mp-entry__qr img { border-radius: var(--radius-sm); border: 1px solid var(--color-border); display: block; }
.mp-entry__fallback {
  width: 160px; height: 160px; border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm); align-items: center; justify-content: center;
  text-align: center; color: var(--color-text-muted); font-size: 13px; padding: 12px;
}

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(20, 30, 50, 0.4); }
.modal__panel {
  position: relative; background: var(--color-surface); border-radius: var(--radius-lg);
  padding: 24px; width: 100%; max-width: 440px; margin: 16px;
  box-shadow: 0 12px 40px rgba(20, 30, 50, 0.2); max-height: 90vh; overflow-y: auto;
}
.modal__title { margin: 0 0 18px; font-size: 18px; }
.modal__actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

/* Toast */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: rgba(28, 36, 48, 0.94); color: #fff; padding: 10px 18px;
  border-radius: var(--radius-sm); font-size: 14px; z-index: 60; max-width: 88%;
}

@media (max-width: 768px) {
  .container { padding: 16px; }
  .app-header__inner { padding: 12px 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search { flex-basis: auto; }
  .createBtn, #createBtn { width: 100%; }
  .mp-entry { flex-direction: column; text-align: center; }
  .mp-entry__desc { max-width: none; }
}
