:root {
  --bg: #f2f5fb;
  --panel: #ffffff;
  --ink: #141826;
  --muted: #78809a;
  --line: #e6eaf3;
  --brand: #4f6bff;
  --brand-2: #8b5cf6;
  --up: #16a34a;
  --down: #e11d48;
  --mid: #64748b;
  --shadow: 0 1px 2px rgba(20, 24, 38, .05), 0 12px 28px -18px rgba(20, 24, 38, .35);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.orb { position: fixed; border-radius: 50%; filter: blur(90px); opacity: .4; pointer-events: none; z-index: 0; }
.orb-a { width: 420px; height: 420px; top: -170px; left: -110px; background: #93a6ff; }
.orb-b { width: 460px; height: 460px; top: 260px; right: -190px; background: #d8b4fe; }

.app {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 20px 56px;
}

/* ---------------- topbar ---------------- */
.topbar {
  position: sticky;
  top: 12px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 13px 18px;
  background: rgba(255, 255, 255, .84);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

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

.logo {
  width: 46px; height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 21px;
  font-weight: 700;
  box-shadow: 0 8px 18px -8px rgba(79, 107, 255, .85);
}

.title-row { display: flex; align-items: center; gap: 9px; }
h1 { margin: 0; font-size: 20px; letter-spacing: -.3px; white-space: nowrap; }

.live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #15803d;
  background: #ecfdf3;
  border-radius: 99px;
  padding: 3px 8px;
  transition: color .2s, background .2s;
}
.live i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, .5);
  animation: pulse 2s infinite;
}
.live em { font-style: normal; }
.live.off { color: #9aa2b8; background: #f1f3f9; }
.live.off i { background: #b9c0d2; animation: none; box-shadow: none; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .45); }
  70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.sub { margin: 3px 0 0; font-size: 12px; color: var(--muted); }

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

.quota {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: #f5f7fd;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.quota-text { font-size: 12px; color: var(--muted); white-space: nowrap; }
.quota-text strong { font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
.quota-text em { font-style: normal; }

.dots { display: flex; gap: 4px; }
.dots i {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #dfe4f2;
  transition: background .2s, transform .2s;
}
.dots i.on { background: var(--brand); }
body.no-votes .quota { background: #fff7ed; border-color: #fed7aa; }
body.no-votes .quota-text strong { color: #c2410c; }

.btn {
  height: 40px;
  padding: 0 15px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: transform .12s, box-shadow .15s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 20px -12px rgba(79, 107, 255, .95);
}
.btn.primary:hover { box-shadow: 0 12px 24px -10px rgba(79, 107, 255, .95); }
.btn.ghost { background: #f5f7fd; }
.btn.ghost:hover { background: #eceffa; }

/* ---------------- controls ---------------- */
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0 14px;
}

.search {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 12px;
  background: rgba(255, 255, 255, .8);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  transition: border-color .15s, background .15s;
}
.search:focus-within { border-color: #b9c4ff; background: #fff; }
.search input {
  width: 130px;
  border: 0;
  background: transparent;
  outline: none;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
}
.search input::placeholder { color: #a2a9bd; }

.seg {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  background: rgba(255, 255, 255, .8);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.seg button {
  padding: 6px 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 2px 8px -4px rgba(20, 24, 38, .4); }

.meta { margin-left: auto; font-size: 12px; color: var(--muted); }

/* ---------------- cards ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  padding: 15px 16px 12px;
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  transition: transform .16s, box-shadow .16s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(20, 24, 38, .05), 0 20px 36px -22px rgba(20, 24, 38, .5);
}

.card.pop { animation: pop .45s ease-out; }
@keyframes pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.018); }
  100% { transform: scale(1); }
}

.card-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }

.avatar {
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 700;
}

.who { min-width: 0; }
.who h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.who p {
  margin: 3px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score { text-align: right; line-height: 1.1; }
.score strong {
  display: block;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.score span { font-size: 9.5px; color: var(--muted); letter-spacing: .2px; }
.score.pos strong { color: var(--up); }
.score.neg strong { color: var(--down); }
.score.zero strong { color: var(--mid); }
.score.none strong { color: #c3c9d8; }

.votes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 13px; }

.vote {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 4px 7px;
  border-radius: 12px;
  border: 1px solid transparent;
  font: inherit;
  cursor: pointer;
  user-select: none;
  transition: transform .1s, background .15s, border-color .15s, box-shadow .15s;
}
.vote b { font-size: 14.5px; font-weight: 700; }
.vote small { font-size: 10px; opacity: .62; font-variant-numeric: tabular-nums; }
.vote:active { transform: scale(.95); }

.vote.up { color: #15803d; background: #f0fdf4; border-color: #dcfce7; }
.vote.up:hover { background: #dcfce7; border-color: #bbf7d0; }
.vote.mid { color: #475569; background: #f8fafc; border-color: #e8edf4; }
.vote.mid:hover { background: #eef2f7; border-color: #dbe3ee; }
.vote.down { color: #be123c; background: #fff1f2; border-color: #ffe4e6; }
.vote.down:hover { background: #ffe4e6; border-color: #fecdd3; }

body.no-votes .vote { opacity: .6; }

.card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid #f1f4fa;
}

.comments-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}
.comments-btn b { font-weight: 700; color: #5a6178; }
.comments-btn:hover, .comments-btn.on { color: var(--brand); }
.comments-btn:hover b, .comments-btn.on b { color: var(--brand); }

.card-del {
  flex: none;
  padding: 4px 6px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  font-size: 11.5px;
  color: #b6bccd;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, color .15s, background .15s;
}
.card:hover .card-del { opacity: 1; }
.card-del:hover { color: var(--down); background: #fff1f2; }

/* ---------------- comments ---------------- */
.cpanel {
  margin-top: 8px;
  padding: 10px 12px;
  background: #f8fafd;
  border: 1px solid #eef2f8;
  border-radius: 12px;
  animation: slide .16s ease-out;
}
@keyframes slide {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.clist { max-height: 190px; overflow-y: auto; }
.cblank { margin: 4px 0 8px; font-size: 12px; color: #9aa2b8; }

.citem { padding: 7px 0; }
.citem + .citem { border-top: 1px dashed #e8edf5; }
.cmeta { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cmeta b { font-size: 12px; color: #4b5268; }
.cmeta time { font-size: 10.5px; color: #a6adc2; flex: none; }
.citem p { margin: 3px 0 0; font-size: 13px; line-height: 1.55; color: #3b4257; word-break: break-word; }

.cform {
  display: grid;
  grid-template-columns: 88px 1fr 50px;
  gap: 6px;
  margin-top: 9px;
}
.cform input {
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  outline: none;
  min-width: 0;
}
.cform input:focus { border-color: #b9c4ff; }
.cform .send {
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.cform .send:hover { background: #3f5bf0; }

/* ---------------- empty / misc ---------------- */
.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, .72);
  border: 1px dashed #d7dcec;
  border-radius: 18px;
}
.empty-emoji { font-size: 34px; margin-bottom: 8px; }
.empty strong { display: block; font-size: 16px; color: var(--ink); margin-bottom: 6px; }
.empty p { margin: 0 0 16px; font-size: 13px; }

.foot { margin-top: 26px; text-align: center; font-size: 11.5px; color: #9aa2b8; line-height: 1.7; }

.dlg {
  width: min(420px, 92vw);
  padding: 22px;
  border: 0;
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 30px 70px -24px rgba(15, 20, 40, .55);
}
.dlg::backdrop { background: rgba(17, 22, 44, .38); backdrop-filter: blur(3px); }
.dlg h2 { margin: 0 0 6px; font-size: 17px; }
.dlg .hint { margin: 0 0 14px; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.dlg input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f8fafe;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  outline: none;
}
.dlg input:focus { border-color: #b9c4ff; background: #fff; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 14px);
  padding: 10px 18px;
  background: rgba(20, 24, 38, .95);
  color: #fff;
  font-size: 13.5px;
  border-radius: 12px;
  box-shadow: 0 16px 32px -16px rgba(0, 0, 0, .6);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
  max-width: 84vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.loading { padding: 50px 0; text-align: center; color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  .app { padding: 12px 12px 44px; }
  .topbar { top: 6px; padding: 12px 14px; border-radius: 16px; }
  .side { width: 100%; justify-content: space-between; }
  .quota { flex: 1; justify-content: space-between; }
  .grid { grid-template-columns: 1fr; }
  h1 { font-size: 18px; }
  .card-del { opacity: 1; }
  .meta { margin-left: 0; width: 100%; }
  .search { flex: 1; }
  .search input { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition-duration: .001s !important; }
}

/* ================= v2: tabs / rank / admin ================= */
.tabs {
  display: inline-flex;
  gap: 4px;
  margin: 18px 0 0;
  padding: 4px;
  background: rgba(255, 255, 255, .72);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 13px;
  box-shadow: 0 1px 2px rgba(20, 24, 38, .05);
}
.tab {
  padding: 7px 20px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--ink); }
.tab.on { background: #fff; color: var(--ink); box-shadow: 0 2px 8px -4px rgba(20, 24, 38, .45); }

.admin-btn { display: inline-flex; align-items: center; gap: 6px; }
.admin-btn.is-admin { border-color: #c7d2fe; background: #eef2ff; color: #3f4ecb; }
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.rank-head { margin: 2px 0 14px; }
.rank-head h2 { margin: 0; font-size: 19px; letter-spacing: -.3px; }
.rank-head p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: end; margin-bottom: 16px; }
.p-item {
  position: relative;
  padding: 16px 10px 18px;
  text-align: center;
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.p-item.p1 {
  padding: 22px 10px 24px;
  background: linear-gradient(170deg, #fffbeb, #fff);
  border: 1px solid #fde68a;
  box-shadow: 0 14px 32px -20px rgba(180, 83, 9, .5);
}
.p-item.p2 { background: linear-gradient(170deg, #f8fafc, #fff); border: 1px solid #e2e8f0; }
.p-item.p3 { background: linear-gradient(170deg, #fff7ed, #fff); border: 1px solid #fed7aa; }
.p-crown { font-size: 19px; line-height: 1; margin-bottom: 7px; }
.p-avatar {
  width: 50px; height: 50px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  font-size: 19px;
  font-weight: 700;
}
.p-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-score { font-size: 26px; font-weight: 800; letter-spacing: -1px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.p-item.p1 .p-score { font-size: 31px; color: #b45309; }
.p-votes { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.panel { background: #fff; border-radius: 18px; padding: 16px 18px 14px; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.panel-head h3 { margin: 0; font-size: 15px; }

.rank-row {
  display: grid;
  grid-template-columns: 34px 34px minmax(70px, 1fr) 56px minmax(60px, 1.1fr) 58px;
  align-items: center;
  gap: 10px;
  padding: 9px 6px;
  border-radius: 10px;
}
.rank-row + .rank-row { border-top: 1px solid #f2f4fa; }
.rank-row:hover { background: #f8faff; }
.r-no { text-align: center; font-weight: 800; color: #a6adc2; font-variant-numeric: tabular-nums; }
.r-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-votes { font-size: 12px; color: var(--muted); text-align: right; }
.r-score { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.r-score.pos { color: var(--up); }
.r-score.neg { color: var(--down); }
.r-score.zero { color: var(--mid); }
.r-score.none { color: #c3c9d8; }
.rankbar { height: 8px; background: #eef1f8; border-radius: 99px; overflow: hidden; }
.rankbar i { display: block; height: 100%; border-radius: 99px; transition: width .3s; }
.rankbar i.pos { background: linear-gradient(90deg, #4ade80, #16a34a); }
.rankbar i.neg { background: linear-gradient(90deg, #fb7185, #e11d48); }
.rankbar i.zero { background: #cbd5e1; }

/* admin dialog */
.dlg.wide { width: min(620px, 94vw); max-height: 86vh; overflow-y: auto; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dlg-head h2 { margin: 0; }
.x {
  width: 30px; height: 30px;
  border: 0;
  border-radius: 9px;
  background: #f4f6fb;
  color: #8b93a9;
  font-size: 13px;
  cursor: pointer;
}
.x:hover { background: #eceff7; color: var(--ink); }

.admin-add { display: flex; gap: 8px; }
.admin-add input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafe;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  outline: none;
}
.admin-add input:focus { border-color: #b9c4ff; background: #fff; }

.admin-sec { margin-top: 16px; }
.admin-sec h3 { margin: 0 0 8px; font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.pill {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: #fff1f2;
  color: #e11d48;
  font-size: 11px;
  font-weight: 700;
}
.pill.gray { background: #f1f3f9; color: #78809a; }

.admin-list {
  padding: 2px 10px;
  background: #fbfcff;
  border: 1px solid #eef1f8;
  border-radius: 12px;
  max-height: 220px;
  overflow-y: auto;
}
.admin-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 2px; }
.admin-item + .admin-item { border-top: 1px solid #eef1f8; }
.ai-main { min-width: 0; }
.ai-main b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-main b span { display: block; margin-top: 2px; font-size: 11px; font-weight: 400; color: var(--muted); }
.ai-ops { display: flex; gap: 6px; flex: none; }
.btn.small.ok { background: #ecfdf3; color: #15803d; border-color: #d1fae5; }
.btn.small.ok:hover { background: #dcfce7; }
.btn.small.no { background: #fff1f2; color: #be123c; border-color: #ffe4e6; }
.btn.small.no:hover { background: #ffe4e6; }

@media (max-width: 760px) {
  .side { gap: 8px; }
  .side .btn { padding: 0 12px; font-size: 13px; }
  .podium { gap: 8px; }
  .p-item { padding: 12px 6px 14px; border-radius: 14px; }
  .p-item.p1 { padding: 16px 6px 18px; }
  .p-avatar { width: 42px; height: 42px; font-size: 17px; border-radius: 13px; }
  .p-name { font-size: 12.5px; }
  .p-score { font-size: 21px; }
  .p-item.p1 .p-score { font-size: 25px; }
  .rank-row { grid-template-columns: 28px 30px minmax(60px, 1fr) 48px 52px; gap: 8px; }
  .rank-row .rankbar { display: none; }
  .panel { padding: 14px; }
  .dlg.wide { max-height: 90vh; }
}

/* ================= weekly history ================= */
.range-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.range-row input[type="date"] {
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafe;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  outline: none;
}
.range-row input[type="date"]:focus { border-color: #b9c4ff; background: #fff; }
.range-sep { font-size: 12px; color: var(--muted); }
.range-hint { margin: 7px 0 9px; font-size: 11.5px; color: #9aa2b8; line-height: 1.5; }

.history { display: grid; gap: 10px; max-height: 420px; overflow-y: auto; padding-right: 2px; }
.week-card { background: #fbfcff; border: 1px solid #eef1f8; border-radius: 12px; overflow: hidden; }
.week-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 11px;
  background: #f5f7fd;
  border-bottom: 1px solid #eef1f8;
}
.week-head b { font-size: 12.5px; }
.week-head span { font-size: 11px; color: var(--muted); }
.week-head em { margin-left: auto; font-style: normal; font-size: 11px; color: var(--muted); }

.h-head, .h-row {
  display: grid;
  grid-template-columns: 40px 1fr 86px 52px;
  gap: 6px;
  align-items: center;
  padding: 5px 11px;
}
.h-head { font-size: 10.5px; color: #a2a9bd; border-bottom: 1px dashed #eef1f8; }
.h-head span:nth-child(3), .h-head span:nth-child(4) { text-align: right; }
.week-body { max-height: 200px; overflow-y: auto; }
.h-row { padding: 6px 11px; font-size: 12.5px; }
.h-row + .h-row { border-top: 1px solid #f4f6fb; }
.h-pos { text-align: center; font-weight: 700; color: #a6adc2; font-variant-numeric: tabular-nums; }
.h-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-week { text-align: right; font-size: 11.5px; color: var(--muted); }
.h-total { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.h-total.pos { color: var(--up); }
.h-total.neg { color: var(--down); }
.h-total.zero { color: var(--mid); }

/* ================= user auth ================= */
.auth-btn { white-space: nowrap; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 6px 0 5px;
  background: #fff;
  border: 1px solid #dfe5f4;
  border-radius: 11px;
  box-shadow: 0 1px 2px rgba(20, 24, 38, .05);
}
.u-avatar {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #eef2ff;
  color: #4f6bff;
  font-size: 13px;
  font-weight: 700;
}
.user-chip.is-admin-chip { border-color: #fed7aa; background: #fffbf5; }
.user-chip.is-admin-chip .u-avatar { background: #ffedd5; color: #c2410c; }
.u-name {
  max-width: 110px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.u-out {
  border: 1px solid #e3e8f4;
  border-radius: 8px;
  padding: 5px 9px;
  background: #f8fafd;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  white-space: nowrap;
  cursor: pointer;
}
.u-out:hover { background: #fff1f2; border-color: #fecdd3; color: #e11d48; }

.auth-tabs {
  display: flex;
  gap: 4px;
  margin: 12px 0 14px;
  padding: 4px;
  background: #f4f6fb;
  border-radius: 11px;
}
.auth-tabs button {
  flex: 1;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.auth-tabs button.on {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px -4px rgba(20, 24, 38, .4);
}

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; }
  .side { flex-wrap: wrap; justify-content: flex-end; }
  .quota { order: 3; }
  .u-name { max-width: 80px; }
}

/* ================= folders ================= */
.home-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 22px 0 16px;
}
.home-head h2 { margin: 0; font-size: 22px; letter-spacing: -.4px; }
.home-head p { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; max-width: 620px; }

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.folder-card {
  position: relative;
  padding: 16px 16px 14px;
  background: #fff;
  border: 1px solid #eef1f8;
  border-radius: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.folder-card:hover {
  transform: translateY(-2px);
  border-color: #c7d2fe;
  box-shadow: 0 16px 34px -22px rgba(20, 24, 38, .5);
}
.folder-card:active { transform: translateY(0); }
.fc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fc-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #eef2ff;
  font-size: 19px;
}
.fc-badge {
  padding: 3px 9px;
  border-radius: 999px;
  background: #f4f6fb;
  color: #78809a;
  font-size: 11px;
  font-weight: 600;
}
.folder-card h3 {
  margin: 11px 0 3px;
  font-size: 15.5px;
  letter-spacing: -.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.folder-card > p { margin: 0; font-size: 11.5px; color: #9aa2b8; }
.fc-quota {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #eef1f8;
  font-size: 12px;
  font-weight: 600;
  color: #3f4ecb;
}
.fc-quota.out { color: #b6bccd; }

.folder-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 20px 0 4px;
}
.back-btn { flex: none; }
.folder-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.folder-ico {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #eef2ff;
  font-size: 21px;
}
.folder-title h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.folder-title p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }
.folder-bar > .btn.primary { margin-left: auto; }

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 12px 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 14px;
  font-size: 13px;
  color: #92400e;
}

.pick {
  height: 34px;
  max-width: 180px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafe;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  outline: none;
  cursor: pointer;
}
.pick:focus { border-color: #b9c4ff; background: #fff; }

.del-name {
  border: 0;
  border-radius: 8px;
  padding: 4px 9px;
  background: transparent;
  font: inherit;
  font-size: 11.5px;
  color: #b6bccd;
  cursor: pointer;
}
.del-name:hover { background: #fff1f2; color: #e11d48; }

@media (max-width: 760px) {
  .home-head { align-items: stretch; margin: 16px 0 12px; }
  .home-head h2 { font-size: 19px; }
  .folder-grid { grid-template-columns: 1fr; }
  .folder-bar { gap: 9px; margin-top: 14px; }
  .folder-title { flex: 1; min-width: 0; }
  .folder-bar > .btn.primary { margin-left: 0; width: 100%; }
  .notice { font-size: 12.5px; }
  .admin-add { flex-wrap: wrap; }
  .admin-add input { flex-basis: 100%; order: 3; }
  .pick { max-width: none; flex: 1; }
}
