/* ═══════════════════════════════════════════════════════════════
   坏了么 · Web
   移动优先，≥840px 切成左侧栏布局。浅色/深色跟随系统。
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #f1f2f5;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eceef2;
  --border: #e2e5ea;
  --border-strong: #d2d7de;
  --text: #16181d;
  --text-2: #565d69;
  --muted: #8b919c;

  --accent: #0a7cf5;
  --accent-ink: #ffffff;
  --accent-soft: #e8f2ff;

  --green: #1a9e4b;
  --green-soft: #e6f6ec;
  --orange: #c96a06;
  --orange-soft: #fdf1e0;
  --red: #d32c2c;
  --red-soft: #fdeaea;
  --gray: #7c828d;
  --gray-soft: #edeff2;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-2: 0 4px 12px rgba(16, 24, 40, .08), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-3: 0 24px 64px rgba(16, 24, 40, .18), 0 2px 8px rgba(16, 24, 40, .08);

  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --surface: #171a20;
    --surface-2: #1d212a;
    --surface-3: #242934;
    --border: #2a2f3a;
    --border-strong: #39404d;
    --text: #eef1f6;
    --text-2: #a9b1bf;
    --muted: #7c8595;

    --accent: #4da6ff;
    --accent-ink: #06121f;
    --accent-soft: #10263d;

    --green: #4ade80;
    --green-soft: #10291b;
    --orange: #fbbf24;
    --orange-soft: #2b2010;
    --red: #f87171;
    --red-soft: #2c1416;
    --gray: #9aa3b2;
    --gray-soft: #232833;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 4px 14px rgba(0, 0, 0, .45);
    --shadow-3: 0 24px 64px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

/* `hidden` 属性的默认样式（display:none）优先级最低，
   任何一条作者样式里的 `display: grid/flex` 都会把它盖掉。
   这里统一提权，否则 .auth-wrap 会一直压在应用上面。 */
[hidden] { display: none !important; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }

/* 图标统一线宽 */
.sidebar-nav svg, .tabbar svg, .topbar-back svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

/* ───────────────────────────── 登录 ───────────────────────────── */

.auth-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 28px 18px calc(28px + var(--safe-b));
  background:
    radial-gradient(900px 500px at 50% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 388px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 30px 26px 22px;
  box-shadow: var(--shadow-2);
}

.brand { text-align: center; margin-bottom: 22px; }
.brand-mark {
  width: 52px; height: 52px;
  margin: 0 auto 10px;
  color: var(--accent);
}
.brand h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: .5px;
}
.brand p {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-3);
  border-radius: 12px;
  margin-bottom: 20px;
}
.seg-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-2);
  padding: 8px 0;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  transition: background .16s, color .16s, box-shadow .16s;
}
.seg-btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: .2px;
}
.field > span em {
  font-style: normal;
  font-weight: 400;
  color: var(--muted);
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.field input::placeholder { color: var(--muted); }

/* 表单字段下面的一行说明 */
.field-hint {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 500;
  transition: transform .1s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); }

.btn-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--border)); }
/* 危险操作的实心按钮。文字用 --surface 而不是白色：
   深色模式下 --red 是浅红，白字对比度不够。 */
.btn-danger-solid {
  background: var(--red);
  border-color: transparent;
  color: var(--surface);
  font-weight: 600;
}
.btn-danger-solid:hover:not(:disabled) { filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 8px 10px; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }

.form-error {
  margin: 12px 0 0;
  padding: 9px 12px;
  background: var(--red-soft);
  color: var(--red);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.auth-foot {
  margin: 16px 0 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
}

/* ───────────────────────────── 主布局 ───────────────────────────── */

.app { min-height: 100%; }

.sidebar { display: none; }

.main-col {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(64px + var(--safe-b));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 12px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
}
.topbar.is-stuck { border-bottom-color: var(--border); }

.topbar h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.2px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-back {
  border: 0; background: transparent; padding: 2px; margin-left: -4px;
  color: var(--accent); border-radius: 8px;
}
.topbar-actions { display: flex; gap: 6px; align-items: center; }

.view { flex: 1; padding: 4px 16px 24px; }

/* 离线提示条。所有写操作都要求在线，这条横幅是给用户的解释 */
.offline-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--orange-soft);
  color: var(--orange);
  font-size: 12.5px;
  font-weight: 500;
  border-bottom: 1px solid color-mix(in srgb, var(--orange) 22%, transparent);
}
.offline-bar svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  padding: 6px 8px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 5px 0;
  font-size: 10.5px;
  font-weight: 500;
  border-radius: 10px;
  transition: color .15s;
}
.tab-btn.is-active { color: var(--accent); }

@media (min-width: 840px) {
  .app { display: flex; }
  .main-col { flex: 1; min-width: 0; padding-bottom: 0; }
  .tabbar { display: none; }

  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 224px;
    flex-shrink: 0;
    padding: 20px 12px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
    height: 100vh;
  }
  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 4px 10px 18px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: .3px;
  }
  .sidebar-brand svg { width: 26px; height: 26px; color: var(--accent); }
  .sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
  .nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    background: transparent;
    color: var(--text-2);
    padding: 9px 10px;
    border-radius: 9px;
    font-size: 14.5px;
    font-weight: 500;
    text-align: left;
    transition: background .14s, color .14s;
  }
  .nav-btn:hover { background: var(--surface-2); }
  .nav-btn.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

  .view { padding: 4px 28px 40px; max-width: 900px; }
  .topbar { padding: 18px 28px 12px; max-width: 900px; }
}

/* ───────────────────────────── 通用块 ───────────────────────────── */

.section { margin-bottom: 22px; }
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .7px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 2px 9px;
}
.section-title .count {
  background: var(--surface-3);
  color: var(--text-2);
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 11px;
  letter-spacing: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  width: 100%;
  text-align: left;
  border-left: 0; border-right: 0; border-top: 0;
  color: inherit;
  transition: background .12s;
}
.row:last-child { border-bottom: 0; }
button.row:hover { background: var(--surface-2); }
.row-main { flex: 1; min-width: 0; }
.row-title {
  font-weight: 550;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-chevron { color: var(--muted); flex-shrink: 0; }
.row-chevron svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.empty {
  text-align: center;
  padding: 46px 24px;
  color: var(--muted);
}
.empty svg {
  width: 44px; height: 44px;
  margin: 0 auto 12px;
  fill: none; stroke: currentColor; stroke-width: 1.4;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: .55;
}
.empty h3 { margin: 0 0 6px; font-size: 15px; color: var(--text-2); font-weight: 600; }
.empty p { margin: 0; font-size: 13px; line-height: 1.6; }
.empty .btn { margin-top: 16px; }

/* ───────────────────────────── 状态胶囊 ───────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2.5px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.pill-active     { background: var(--green-soft);  color: var(--green); }
.pill-approaching{ background: var(--orange-soft); color: var(--orange); }
.pill-expired    { background: var(--red-soft);    color: var(--red); }
.pill-handled    { background: var(--gray-soft);   color: var(--gray); }
.pill-accent     { background: var(--accent-soft); color: var(--accent); }

/* ───────────────────────────── 物品 ───────────────────────────── */

.scopebar {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 0 12px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.scopebar::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: all .15s;
}
.chip.is-active {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 600;
}

.searchbar { position: relative; margin-bottom: 12px; }
.searchbar input {
  width: 100%;
  padding: 9px 13px 9px 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.searchbar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}
.searchbar svg {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
}

.alertbar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 12px;
}
.alertbar.is-red    { background: var(--red-soft);    color: var(--red); }
.alertbar.is-orange { background: var(--orange-soft); color: var(--orange); }
.alertbar svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.item-row { align-items: flex-start; }
.item-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.item-dot.s-active      { background: var(--green); }
.item-dot.s-approaching { background: var(--orange); }
.item-dot.s-expired     { background: var(--red); }
.item-dot.s-handled     { background: var(--gray); }

.item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted);
}
.item-meta .dotsep { opacity: .5; }
.item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.item-days { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.item-days.is-overdue { color: var(--red); }

/* ───────────────────────────── 归档 ───────────────────────────── */

.archive-hint {
  margin: 0 2px 16px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
}

/* ───────────────────────────── 群组 ───────────────────────────── */

.group-code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  letter-spacing: 1.6px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 6px;
}

.member-row { align-items: center; }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.badge-admin {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--orange);
  background: var(--orange-soft);
  padding: 1px 6px;
  border-radius: 5px;
  letter-spacing: .3px;
}

/* ───────────────────────────── 我的 ───────────────────────────── */

.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 4px 20px;
}
.profile-avatar {
  width: 54px; height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #8b5cf6));
  color: #fff;
  font-size: 21px;
  font-weight: 700;
  flex-shrink: 0;
}
.profile-name { font-size: 18px; font-weight: 700; }
.profile-handle { font-size: 13px; color: var(--muted); margin-top: 1px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 12px;
  text-align: center;
}
.stat b { display: block; font-size: 21px; font-weight: 700; letter-spacing: -.5px; }
.stat span { font-size: 11.5px; color: var(--muted); }
.stat.is-red b { color: var(--red); }
.stat.is-orange b { color: var(--orange); }

/* ───────────────────────────── 模态 ───────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(12, 16, 22, .42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade .16s ease;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 24px; }
}

.modal {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-3);
  animation: slideUp .22s cubic-bezier(.22, 1, .36, 1);
  padding-bottom: var(--safe-b);
}
@media (min-width: 640px) {
  .modal { border-radius: 18px; padding-bottom: 0; }
}

@keyframes fade { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(22px); opacity: 0; } }

.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 16.5px; font-weight: 700; flex: 1; }
.modal-close {
  border: 0; background: var(--surface-3); color: var(--text-2);
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; padding: 0;
  font-size: 16px; line-height: 1;
}
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex;
  gap: 9px;
  padding: 12px 18px calc(14px + var(--safe-b));
  border-top: 1px solid var(--border);
}
.modal-foot .btn { flex: 1; }

/* 二次确认弹窗的正文 */
.confirm-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-2);
}

.detail-list { display: grid; gap: 0; }.detail-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.detail-item:last-child { border-bottom: 0; }
.detail-item dt { color: var(--muted); flex-shrink: 0; }
.detail-item dd { margin: 0; text-align: right; font-weight: 500; word-break: break-word; }

/* ───────────────────────────── Toast ───────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--safe-b));
  transform: translateX(-50%) translateY(10px);
  z-index: 200;
  padding: 10px 18px;
  border-radius: 22px;
  background: color-mix(in srgb, var(--text) 92%, transparent);
  color: var(--bg);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 840px) { .toast { bottom: 32px; } }

/* ───────────────────────────── 骨架屏 ───────────────────────────── */

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: 7px;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.skeleton-row { height: 58px; border-radius: var(--radius); margin-bottom: 9px; }
