/* build 11 */
:root {
  --red: #a4232b; --red-dark: #7d1a20; --gold: #d4a017;
  --ink: #1c1e22; --soft: #5a6069; --faint: #868c95;
  --line: #e3e0db; --bg: #faf9f7; --card: #fff;
  /* One stack everywhere. SF / Segoe UI / Roboto all have complete Vietnamese
     coverage, so diacritics never fall back to a different face. */
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--ui);
  display: flex; flex-direction: column; min-height: 100vh;
}
/* Luôn rộng 90% màn hình. */
.wrap { width: 90%; margin-inline: auto; }
/* Đoạn văn đứng riêng thì giới hạn độ dài dòng cho dễ đọc trên màn hình rộng. */
main.wrap > p { max-width: 78ch; }
main.wrap { flex: 1 0 auto; padding: 1.8rem 0 3rem; }
a { color: var(--red); }
h1, h2, h3 { font-family: var(--ui); font-weight: 700; letter-spacing: -.01em; line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem); }
h2 { font-size: 1.45rem; margin: 2.8rem 0 1.2rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .9rem; }
ul { margin: .4rem 0 0; padding-left: 1.1rem; color: var(--soft); }
li { margin-bottom: .3rem; }
.muted { color: var(--faint); }
.small { font-size: .85rem; }
.hint { font-weight: 400; color: var(--faint); font-size: .82rem; }
.nowrap { white-space: nowrap; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .88em; background: #ece8e1; padding: .1em .35em; border-radius: 4px; }

.topbar { background: var(--red); border-bottom: 3px solid var(--gold); }
.bar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; min-height: 60px; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.12rem; margin-right: auto; }
.brand span { color: var(--gold); }
.topbar nav { display: flex; align-items: center; gap: .2rem; flex-wrap: wrap; }
.topbar nav a, .topbar nav button {
  color: #fff; text-decoration: none; padding: .4rem .7rem; border-radius: 6px;
  font-size: .92rem; background: none; border: 0; cursor: pointer; font-family: inherit;
}
.topbar nav a:hover, .topbar nav button:hover { background: rgba(255,255,255,.15); }
.topbar nav a.cta { background: var(--gold); color: #3a2a00; font-weight: 600; }
.topbar form { margin: 0; }

.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(150deg, #8e1c24, #a4232b 60%, #7d1a20);
  color: #fff; padding: 3rem 1.8rem; border-radius: 10px; margin-bottom: 1rem;
  min-height: 300px; display: flex; align-items: center;
}
.hero h1 { color: #fff; }
.hero p { margin: 0; opacity: .94; max-width: 62ch; }
.hero-content { position: relative; z-index: 1; }

/* Trống đồng Đông Sơn — hai lớp SVG tĩnh xoay ngược chiều nhau.
   Dùng background-image nên trình duyệt lưu đệm, không phải sinh lại mỗi lần tải. */
.page-drum, .hero-drum { position: absolute; pointer-events: none; overflow: hidden; }
.page-drum { position: fixed; inset: 0; z-index: 0; }
.hero-drum { inset: 0; }
.topbar, main.wrap, .foot { position: relative; z-index: 1; }

.page-drum::before, .page-drum::after,
.hero-drum::before, .hero-drum::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  background-repeat: no-repeat; background-size: contain; background-position: center;
}
.page-drum::before, .hero-drum::before { background-image: url(drum-outer.svg); }
.page-drum::after,  .hero-drum::after  { background-image: url(drum-inner.svg); }

/* Nền cả trang: rất nhạt, chỉ là hoa văn chìm */
.page-drum::before, .page-drum::after {
  width: min(1040px, 170vw); height: min(1040px, 170vw);
  margin: calc(min(1040px, 170vw) / -2) 0 0 calc(min(1040px, 170vw) / -2);
  opacity: .05;
}
/* Trong khung đầu trang: đậm hơn, lệch sang phải */
.hero-drum::before, .hero-drum::after {
  width: 420px; height: 420px; margin: -210px 0 0 -210px;
  left: auto; right: -60px; opacity: .22;
  filter: brightness(0) saturate(100%) invert(78%) sepia(58%) saturate(560%) hue-rotate(1deg);
}

.page-drum::before, .hero-drum::before { animation: drum-turn 150s linear infinite; }
.page-drum::after,  .hero-drum::after  { animation: drum-turn 100s linear infinite reverse; }
@keyframes drum-turn { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .page-drum::before, .page-drum::after,
  .hero-drum::before, .hero-drum::after { animation: none; }
}
@media (max-width: 760px) {
  .hero { min-height: 260px; }
  .hero-drum::before, .hero-drum::after {
    width: 320px; height: 320px; margin: -160px 0 0 -160px; right: -110px; opacity: .18;
  }
}

/* Số cột cố định theo bề rộng màn hình: 6 thẻ luôn chia đều 3+3 (hoặc 2+2+2),
   không bao giờ rơi vào cảnh trên 4 dưới 2. */
.grid {
  display: grid; gap: 1.15rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;                 /* các thẻ cùng hàng cao bằng nhau */
}
@media (max-width: 1080px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px)  { .grid { grid-template-columns: 1fr; } }

/* Bài viết: 3 thẻ một hàng cho khớp nhịp với lưới thông tin */
.posts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1080px) { .posts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px)  { .posts { grid-template-columns: 1fr; } }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1.35rem 1.4rem; box-shadow: 0 1px 2px rgba(20,20,30,.04);
  display: flex; flex-direction: column;   /* để đẩy dòng nguồn xuống đáy */
}
.card p:last-child, .card ul:last-child { margin-bottom: 0; }

/* Tiêu đề thẻ có vạch vàng nhỏ phía trên cho đều nhau */
.grid .card > h3 {
  font-size: 1.02rem; margin: 0 0 .55rem; padding-top: .55rem;
  border-top: 3px solid var(--gold); display: inline-block; align-self: flex-start;
}
.grid .card > p { color: var(--soft); margin-bottom: .7rem; }
.grid .card > ul { margin-top: 0; }
.grid .card > ul li { margin-bottom: .38rem; }
.card.danger { border-color: #e6b9b9; }
.pass {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.2rem;
  background: #fff; border: 2px dashed var(--gold); padding: .5rem .8rem;
  border-radius: 6px; display: inline-block; user-select: all;
}
.fields { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.fields .wide2 { grid-column: 1 / -1; }
.two { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
/* Dòng nguồn chính thức ở cuối mỗi thẻ */
.src {
  margin: 1rem 0 0; padding-top: .65rem; border-top: 1px solid var(--line);
  font-size: .8rem; color: var(--faint);
  margin-top: auto;              /* dồn xuống đáy dù nội dung dài ngắn khác nhau */
}
.src a { color: var(--red); text-decoration: underline; text-underline-offset: 2px; }
.src a:hover { color: var(--red-dark); }

/* Liên kết nguồn ở cuối mỗi dòng thông tin */
.ln {
  font-size: .74rem; font-weight: 600; color: var(--faint);
  text-decoration: none; border-bottom: 1px dotted var(--faint);
  white-space: nowrap; margin-left: .15rem;
}
.ln:hover { color: var(--red); border-bottom-color: var(--red); }
.grid .card > ul li { margin-bottom: .5rem; line-height: 1.55; }
.note { border-left: 4px solid var(--gold); background: #fdf4e0; padding: .9rem 1.1rem; border-radius: 0 8px 8px 0; margin: 1.4rem 0; }
.note p { margin: 0; }
.narrow { max-width: 430px; margin-inline: auto; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

.ok, .bad { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .94rem; }
.ok { background: #e8f4ec; color: #1d6a3c; border: 1px solid #bfdfcc; }
.bad { background: #fbeaea; color: var(--red); border: 1px solid #eec6c6; }
.ok p:last-child, .bad p:last-child { margin-bottom: 0; }

label { display: block; font-size: .85rem; font-weight: 600; color: var(--soft); margin: .8rem 0 .25rem; }
input, select, textarea {
  font: inherit; font-size: .94rem; width: 100%; padding: .5rem .65rem;
  border: 1px solid #cfccc6; border-radius: 7px; background: #fff; color: var(--ink);
}
textarea { min-height: 4.5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(164,35,43,.3); border-color: var(--red); }

.btn { display: inline-block; margin-top: 1rem; padding: .55rem 1.1rem; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-size: .93rem; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: #f3f1ed; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.warn { background: #fff; border-color: #e6b9b9; color: var(--red); }
.btn.wide { width: 100%; }
.search { display: flex; gap: .5rem; margin: 1rem 0; flex-wrap: wrap; }
.search input { flex: 1 1 240px; }
.search .btn { margin-top: 0; }

.stats { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin: 1rem 0; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: .7rem .9rem; }
.stats strong { display: block; font-size: 1.5rem; font-weight: 700; }
.stats span { font-size: .78rem; color: var(--faint); }

.scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; min-width: 820px; }
th { background: #f5f3ef; text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--soft); padding: .6rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .6rem .8rem; border-bottom: 1px solid #f1efeb; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfaf7; }
.tag { background: #fbeaea; color: var(--red); border-radius: 999px; padding: .05rem .45rem; font-size: .72rem; font-weight: 700; }

dl { display: grid; grid-template-columns: minmax(130px, auto) 1fr; gap: .4rem .9rem; margin: 0 0 1rem; }
dt { font-size: .8rem; font-weight: 600; color: var(--faint); text-transform: uppercase; }
dd { margin: 0; }
@media (max-width: 520px) { dl { grid-template-columns: 1fr; gap: 0; } dd { margin-bottom: .6rem; } }

/* Chân trang: nền kem ấm, viền vàng phía trên — gọn nhẹ, không dùng nền đen. */
.foot {
  background: #fbfaf8;
  border-top: 1px solid var(--line);
  box-shadow: inset 0 3px 0 var(--red);
  margin-top: 3.5rem; padding: 2.4rem 0 1.6rem;
  flex-shrink: 0;
}
.foot-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 2rem 3rem; flex-wrap: wrap; padding-bottom: 1.6rem;
}
.foot-brand { max-width: 42ch; }
.foot-name { font-weight: 700; font-size: 1rem; color: var(--ink); margin: 0 0 .35rem; }
.foot-name span { color: var(--gold); margin-right: .15rem; }
.foot-desc { color: var(--soft); font-size: .9rem; margin: 0 0 .25rem; }
.foot-place { color: var(--faint); font-size: .83rem; margin: 0; }

.foot-nav { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.foot-nav a {
  color: var(--soft); text-decoration: none; font-size: .9rem;
  border-bottom: 1px solid transparent; padding-bottom: 1px;
}
.foot-nav a:hover { color: var(--red); border-bottom-color: var(--red); }

.foot-bar {
  border-top: 1px solid var(--line); padding-top: 1.1rem;
  display: flex; justify-content: space-between; gap: .5rem 2rem; flex-wrap: wrap;
}
.foot-bar p { margin: 0; color: var(--faint); font-size: .83rem; }

@media (max-width: 620px) {
  .foot { padding-top: 1.8rem; }
  .foot-nav { flex-direction: row; flex-wrap: wrap; gap: .5rem 1.2rem; }
  .foot-bar { flex-direction: column; }
}

/* ---------- màn hình nhỏ ---------- */
@media (max-width: 700px) {
  body { font-size: 15.5px; }
  .wrap { width: 92%; }
  main.wrap { padding: 1.2rem 0 2rem; }

  /* Thanh trên: tên trang một dòng, các mục xuống dòng dưới */
  .bar { min-height: 0; padding: .6rem 0; gap: .5rem; }
  .brand { font-size: 1rem; margin-right: 0; width: 100%; }
  .topbar nav { width: 100%; gap: .3rem; }
  .topbar nav a, .topbar nav button { padding: .35rem .6rem; font-size: .88rem; }

  .hero { padding: 1.8rem 1.2rem; min-height: 220px; }
  h2 { margin-top: 1.8rem; font-size: 1.25rem; }
  .card { padding: 1rem; }

  /* Bảng dài: cuộn ngang trong khung, không phá vỡ bố cục trang */
  table { min-width: 640px; font-size: .86rem; }
  .scroll { -webkit-overflow-scrolling: touch; }

  /* Nút bấm đủ lớn để chạm bằng ngón tay */
  .btn { padding: .6rem 1rem; }
  .search { flex-direction: column; align-items: stretch; }
  .search .btn { width: 100%; }
  .fields { grid-template-columns: 1fr; }
  .two, .grid { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .hero h1 { font-size: 1.4rem; }
  .pass { font-size: 1rem; word-break: break-all; }
}

/* ---------- trang sinh hoạt, đảng phí, thông báo ---------- */
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actions .btn { margin-top: 0; }
td.mid, th.mid { text-align: center; }
td.mid input[type=radio], td.mid input[type=checkbox] { width: auto; }
/* Giữ nguyên xuống dòng của biên bản và nội dung thông báo */
.prewrap { white-space: pre-wrap; }
input[type=month] { max-width: 220px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
article.card h3 { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }

/* ---------- nhịp trang: các dải nội dung ---------- */
.band { margin-bottom: 2.6rem; }
.band > .head { align-items: baseline; margin-bottom: 1rem; }
.band .more { font-size: .9rem; font-weight: 600; white-space: nowrap; }
.section-lede { color: var(--soft); max-width: 70ch; margin: -.3rem 0 1.3rem; }
.page-head { margin-bottom: 1.6rem; }
.page-head h1 { margin-bottom: .3rem; }

/* ---------- phần đầu trang ---------- */
.eyebrow {
  text-transform: uppercase; letter-spacing: .14em; font-size: .72rem;
  font-weight: 700; color: var(--gold); margin: 0 0 .5rem;
}
.hero .lede { font-size: 1.06rem; max-width: 60ch; }
.hero-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1.4rem 0 0; }
.btn.light { background: var(--gold); border-color: var(--gold); color: #3a2a00; margin-top: 0; }
.btn.light:hover { background: #e5b62a; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.55); color: #fff; margin-top: 0; }
.btn.ghost:hover { background: rgba(255,255,255,.14); }

/* ---------- thẻ bài viết ---------- */
.posts { display: grid; gap: 1.15rem; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.post-card {
  display: flex; flex-direction: column; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1.3rem 1.35rem; transition: border-color .15s, transform .15s, box-shadow .15s;
}
.post-card:hover {
  border-color: var(--red); transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(20,20,30,.07);
}
.post-card .meta { font-size: .78rem; color: var(--faint); display: flex; align-items: center; gap: .5rem; }
.post-card h3 { font-size: 1.08rem; margin: .55rem 0 .45rem; color: var(--ink); }
.post-card p { color: var(--soft); font-size: .93rem; margin-bottom: .9rem; }
.post-card .readmore { margin-top: auto; color: var(--red); font-weight: 600; font-size: .9rem; }
.chip {
  background: #f4ece9; color: var(--red); border-radius: 999px;
  padding: .1rem .55rem; font-size: .72rem; font-weight: 700;
}

.plain { list-style: none; padding: 0; }
.plain li { margin-bottom: .45rem; }

/* ---------- dải số khẩn cấp ---------- */
.emergency {
  background: linear-gradient(150deg, #8e1c24, #a4232b 70%); color: #fff;
  border-radius: 12px; padding: 1.8rem 1.6rem; margin-bottom: 2.6rem;
}
.emergency h2 { color: #fff; border: 0; margin: 0 0 1.1rem; font-size: 1.25rem; padding: 0; }
.emergency-grid { display: grid; gap: 1.2rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.emergency-grid strong { display: block; font-size: 1.5rem; color: var(--gold); line-height: 1.2; }
.emergency-grid span { font-size: .85rem; opacity: .92; }

@media (max-width: 700px) {
  .emergency { padding: 1.3rem 1.1rem; }
  .emergency-grid { gap: .9rem; }
  .band > .head { flex-direction: column; align-items: flex-start; gap: .3rem; }
}

/* ---------- trình soạn thảo bài viết ---------- */
.editor-bar {
  display: flex; gap: .25rem; align-items: center; flex-wrap: wrap;
  border: 1px solid #cfccc6; border-bottom: 0; border-radius: 7px 7px 0 0;
  background: #f6f4f0; padding: .35rem .4rem; margin-top: .25rem;
}
.editor-bar button {
  font: inherit; font-size: .88rem; min-width: 2rem; padding: .3rem .5rem;
  background: #fff; border: 1px solid var(--line); border-radius: 5px;
  cursor: pointer; color: var(--ink); line-height: 1.2;
}
.editor-bar button:hover { background: #efece7; border-color: #c9c5bd; }
.editor-bar .editor-spacer { flex: 1 1 auto; }
.editor-bar .editor-preview-btn { font-weight: 600; color: var(--red); }
.editor-bar + textarea { border-radius: 0 0 7px 7px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; }
.editor-hint { margin: .4rem 0 0; }
.editor-hint code { font-size: .8em; }
.editor-preview {
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 1rem 1.1rem; margin-top: .6rem;
}
.editor-preview > :first-child { margin-top: 0; }
.editor-preview > :last-child { margin-bottom: 0; }

/* ---------- nội dung đã dựng (bảng tin, sự kiện, bài viết) ---------- */
.article-body p { margin-bottom: 1.05rem; line-height: 1.75; }
.article-body h3 { margin: 1.8rem 0 .6rem; font-size: 1.12rem; }
.article-body ul, .article-body ol { margin: 0 0 1.05rem; padding-left: 1.3rem; color: var(--ink); }
.article-body li { margin-bottom: .4rem; }
.article-body blockquote {
  margin: 0 0 1.05rem; padding: .2rem 0 .2rem 1rem;
  border-left: 3px solid var(--gold); color: var(--soft);
}
.article-body a { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- ngày sinh dạng ba ô chọn ---------- */
.dob-row { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: .5rem; }
.dob-row select { width: 100%; }
@media (max-width: 420px) { .dob-row { grid-template-columns: 1fr; } }

/* ---------- thư viện ảnh sự kiện ---------- */
.gallery { display: grid; gap: 1.15rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1080px) { .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px)  { .gallery { grid-template-columns: 1fr; } }

.event-card {
  display: flex; flex-direction: column; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; transition: border-color .15s, transform .15s, box-shadow .15s;
}
.event-card:hover {
  border-color: var(--red); transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(20,20,30,.07);
}
.event-card .thumb {
  display: block; aspect-ratio: 4 / 3; background: #f1efea; overflow: hidden;
}
.event-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.event-card .thumb-empty {
  display: grid; place-items: center; height: 100%; font-size: 2.4rem; color: var(--gold);
}
.event-body { display: flex; flex-direction: column; gap: .25rem; padding: 1rem 1.1rem; }
.event-body .meta { font-size: .78rem; color: var(--faint); }
.event-body strong { font-size: 1.02rem; line-height: 1.35; }

/* Lưới ảnh trong một sự kiện */
.photos { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-bottom: 1.5rem; }
.photos .photo, .photos .photo-item { display: block; }
.photos img {
  /* height:auto là bắt buộc — nếu không, thuộc tính height="…" trong HTML sẽ
     ghi đè aspect-ratio và ảnh bị kéo dài theo kích thước gốc. */
  width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; display: block;
  border-radius: 10px; border: 1px solid var(--line); background: #f1efea;
}
.photos.admin .photo-item { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .5rem; }
.photos.admin img { border: 0; border-radius: 7px; }
.photos.admin .btn { margin-top: .5rem; width: 100%; padding: .35rem; font-size: .82rem; }
input[type=file] { font: inherit; font-size: .9rem; padding: .5rem; border: 1px dashed #cfccc6; border-radius: 7px; background: #fff; width: 100%; }

/* ---------- khoảng cách trong biểu mẫu ---------- */
/* Nhãn đầu tiên trong thẻ không cần đẩy xuống, các nhãn sau mới cần. */
.card > label:first-of-type,
.card > .fields > div > label:first-child { margin-top: 0; }
.card label + input,
.card label + select,
.card label + textarea { margin-bottom: .2rem; }
label .hint { margin-top: .15rem; line-height: 1.45; }
.card > .btn { margin-top: 1.3rem; }
.narrow .card { padding: 1.5rem 1.5rem 1.6rem; }
.narrow h1 { margin-bottom: .35rem; }
.narrow > .muted { margin-bottom: 1.3rem; line-height: 1.6; }
.narrow .card label { margin-top: 1.1rem; }
.narrow .card label:first-of-type { margin-top: 0; }
.narrow > .small { margin-top: 1.1rem; line-height: 1.7; }
.inline-form { display: inline; margin-left: .4rem; }
.link-btn {
  background: none; border: 0; padding: 0; font: inherit; font-size: .8rem;
  color: var(--red); text-decoration: underline; cursor: pointer; width: auto;
}

/* ---------- bảng tin nội bộ: dòng thời gian ---------- */
.filter { display: flex; gap: .6rem; margin: 0 0 1.4rem; flex-wrap: wrap; }
.filter input[type=search] { flex: 1 1 260px; }
.filter select { flex: 0 0 auto; width: auto; min-width: 150px; }
.filter .btn { margin-top: 0; }
@media (max-width: 560px) {
  .filter { flex-direction: column; }
  .filter select, .filter .btn { width: 100%; }
}

.timeline { position: relative; }
.tl-month { margin-bottom: 2.2rem; }
.tl-label {
  font-size: 1.05rem; margin: 0 0 1rem; padding: 0 0 .5rem;
  border-bottom: 1px solid var(--line); display: flex;
  align-items: baseline; gap: .6rem; flex-wrap: wrap;
}
.tl-count { font-size: .78rem; font-weight: 400; color: var(--faint); }

.tl-item { position: relative; padding: 0 0 1.3rem 1.9rem; }
/* Đường dọc nối các tin trong cùng tháng */
.tl-item::before {
  content: ""; position: absolute; left: 5px; top: .5rem; bottom: -.4rem;
  width: 2px; background: var(--line);
}
.tl-item:last-child::before { bottom: auto; height: 0; }
.tl-dot {
  position: absolute; left: 0; top: .45rem; width: 12px; height: 12px;
  border-radius: 50%; background: var(--gold); border: 2px solid var(--bg); z-index: 1;
}
.tl-body {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 1.1rem 1.2rem;
}
.tl-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
           font-size: .8rem; color: var(--faint); margin: 0 0 .45rem; }
.tl-body h3 { font-size: 1.05rem; margin: 0 0 .6rem; }
.tl-text { color: var(--soft); }
.tl-text p { margin-bottom: .75rem; }
.tl-text p:last-child { margin-bottom: 0; }
.tl-actions { margin: .9rem 0 0; font-size: .85rem; }

/* Danh sách tài liệu đính kèm */
.files { list-style: none; margin: .9rem 0 0; padding: 0; }
.files li {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .45rem .7rem; margin-bottom: .35rem;
  background: #faf8f4; border: 1px solid var(--line); border-radius: 7px; font-size: .9rem;
}
.files li::before { content: "⤓"; color: var(--red); font-weight: 700; }
.files a { font-weight: 600; }

/* ---------- ảnh đại diện ----------
   Chữ cái đầu nằm dưới, ảnh phủ lên trên; ảnh lỗi tự gỡ nên vẫn còn chữ cái. */
.avatar {
  position: relative; overflow: hidden;
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 34px; height: 34px; border-radius: 50%;
  background: #efe9df; border: 1px solid var(--line);
  color: var(--red); font-weight: 700; font-size: .95rem; line-height: 1;
}
.avatar > img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%; display: block;
}
.avatar-empty { color: var(--red); font-weight: 700; font-size: .95rem; }
.avatar-md { width: 72px; height: 72px; font-size: 1.6rem; }
.avatar-lg { width: 88px; height: 88px; font-size: 2rem; }
.avatar-xl { width: 96px; height: 96px; font-size: 2.2rem; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.avatar-cell { width: 46px; padding-right: 0; }

.profile-head { display: flex; align-items: center; gap: 1.1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.profile-head h1 { margin-bottom: .15rem; }
.profile-head p { margin: 0; }

.avatar-form { margin-bottom: 1rem; }
.avatar-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.avatar-row .grow { flex: 1 1 220px; }
.avatar-row label { margin-top: 0; }
.form-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.form-row .btn { margin-top: 1rem; }

/* ---------- trang Chi uỷ & Ban cố vấn ---------- */
.board {
  display: grid; gap: 1.15rem; margin-bottom: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
}
.person { gap: .9rem; border-top: 3px solid var(--line); }
.person-lead { border-top-color: var(--red); }
.person-advisor { border-top-color: var(--gold); }
.person-head { display: flex; align-items: center; gap: 1rem; }
.person-name { min-width: 0; }
.person-name h3 { margin: .1rem 0 .15rem; font-size: 1.12rem; }
.person-role {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--red);
}
.person-advisor .person-role { color: #8a6500; }
.person-title { margin: 0; color: var(--soft); font-size: .9rem; line-height: 1.45; }
.person-positions { margin: 0; padding-left: 1.05rem; font-size: .9rem; }
.person-positions li { margin-bottom: .2rem; }
.person-bio { margin: 0; color: var(--ink); font-size: .93rem; line-height: 1.6; }
.person-contact {
  margin-top: auto; padding-top: .8rem; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: .35rem; font-size: .9rem;
}
.person-contact a { text-decoration: none; overflow-wrap: anywhere; }
.person-contact a:hover { text-decoration: underline; }
.person-contact span { display: inline-block; width: 1.2em; color: var(--faint); }
.person-edit { align-self: flex-start; font-size: .82rem; color: var(--faint) !important; }
.board-heading { margin-top: 2.6rem; }
@media (max-width: 420px) {
  .person-head { gap: .8rem; }
}

.board-fields { border: 1px dashed var(--line); border-radius: 10px; padding: .4rem 1rem 1rem; margin: 1.2rem 0 0; }
.board-fields legend { font-weight: 700; padding: 0 .4rem; }
.board-fields > .hint { margin: .2rem 0 0; }
.board-self { margin-top: 1rem; }

/* ---------- trang Đảng viên: tìm kiếm và phân trang ---------- */
.member-search { display: flex; gap: .6rem; flex-wrap: wrap; align-items: stretch; margin-bottom: .6rem; }
.member-search input[type=search] { flex: 1 1 260px; margin: 0; font-size: 1rem; }
.member-search select { flex: 0 0 auto; width: auto; margin: 0; }
.member-search .btn { margin-top: 0; }
.results-count { margin: .4rem 0 1rem; }
#member-results { transition: opacity .15s; }
#member-results.loading { opacity: .5; }

.member-grid {
  display: grid; gap: .9rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
}
.member-card {
  display: flex; gap: .9rem; align-items: flex-start;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem 1.1rem; box-shadow: 0 1px 2px rgba(20,20,30,.04);
}
.member-info { min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.member-info h3 { margin: 0; font-size: 1rem; }
.member-info h3 a { color: var(--ink); text-decoration: none; }
.member-info h3 a:hover { color: var(--red); }
.member-role { margin: 0 0 .25rem; color: var(--soft); font-size: .85rem; line-height: 1.45; }
.member-line { font-size: .86rem; text-decoration: none; overflow-wrap: anywhere; }
.member-line:hover { text-decoration: underline; }
.member-line span { display: inline-block; width: 1.15em; color: var(--faint); }

.pager { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; justify-content: center; margin: 1.6rem 0 1rem; }
.pager a, .pager span {
  min-width: 2.3rem; padding: .4rem .7rem; border-radius: 7px; text-align: center;
  border: 1px solid var(--line); background: #fff; text-decoration: none; font-size: .9rem;
}
.pager a:hover { background: #f3f1ed; }
.pager .cur { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.pager .off { color: var(--faint); background: transparent; }
.pager .gap { border: 0; background: none; min-width: 0; padding: .4rem .2rem; }
@media (max-width: 420px) {
  .member-search select { flex: 1 1 auto; }
  .pager a[rel], .pager .off { flex: 1 1 40%; }
}

/* ---------- menu: mục đang mở ---------- */
.topbar nav a.on { background: rgba(255,255,255,.18); box-shadow: inset 0 -2px 0 var(--gold); }

/* ---------- thanh quản trị: màu tối riêng để không lẫn với menu đảng viên ---------- */
.adminbar { background: #262a31; border-bottom: 1px solid #000; position: relative; z-index: 1; }
.adminbar-in { display: flex; align-items: center; gap: .9rem; min-height: 44px; }
.adminbar-label {
  flex: 0 0 auto; color: var(--gold); font-size: .74rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
}
.adminbar-tabs {
  display: flex; gap: .15rem; overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; min-width: 0;
}
.adminbar-tabs::-webkit-scrollbar { display: none; }
.adminbar-tabs a {
  color: #d5d8de; text-decoration: none; font-size: .86rem; white-space: nowrap;
  padding: .35rem .65rem; border-radius: 6px;
}
.adminbar-tabs a:hover { background: rgba(255,255,255,.08); color: #fff; }
.adminbar-tabs a.on { background: var(--gold); color: #2b2000; font-weight: 700; }

/* ---------- xem tài liệu bảng tin ---------- */
.file-acts { margin-left: auto; display: inline-flex; gap: .4rem; }
.file-act {
  font-size: .8rem; font-weight: 600 !important; text-decoration: none;
  padding: .1rem .55rem; border: 1px solid var(--line); border-radius: 999px; background: #fff;
}
.file-act:hover { background: #fbeaea; }
.viewer-head { display: flex; gap: 1rem; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 1rem; }
.viewer-title { min-width: 0; }
.viewer-title h1 { font-size: 1.35rem; margin: .3rem 0 .1rem; overflow-wrap: anywhere; }
.viewer-title p { margin: 0; }
.viewer-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.viewer-actions .btn { margin-top: 0; }
.viewer-frame {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #525659;
  height: max(480px, calc(100vh - 240px));
}
.viewer-frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.viewer-note { margin-top: .6rem; }
.viewer-image { text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
.viewer-image img { max-width: 100%; height: auto; }
@media (max-width: 700px) {
  .viewer-frame { height: 70vh; }
  .viewer-actions { width: 100%; }
  .viewer-actions .btn { flex: 1 1 auto; text-align: center; }
}

/* ---------- hồ sơ đảng viên ---------- */
.member-link { color: var(--ink); text-decoration: none; }
.member-link:hover { color: var(--red); text-decoration: underline; }
.person-name h3 a { color: inherit; text-decoration: none; }
.person-name h3 a:hover { color: var(--red); text-decoration: underline; }
.profile-card { gap: 1.4rem; max-width: 880px; }
.profile-top { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.profile-name { flex: 1 1 220px; min-width: 0; }
.profile-name h1 { margin: .1rem 0 .2rem; font-size: clamp(1.4rem, 1.1rem + 1vw, 1.9rem); }
.profile-tools .btn { margin-top: 0; }
.profile-grid { display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.profile-grid h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin-bottom: .6rem; }
.profile-dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0; font-size: .95rem; }
.profile-dl dt { color: var(--faint); }
.profile-dl dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 420px) { .profile-dl { grid-template-columns: 1fr; gap: 0; } .profile-dl dd { margin-bottom: .5rem; } }

/* ---------- đăng nhập, quên mật khẩu, đặt mật khẩu ---------- */
.auth {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  max-width: 980px; margin: .6rem auto 1rem; background: var(--card);
  border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
  box-shadow: 0 24px 60px -28px rgba(90, 15, 22, .45), 0 2px 6px rgba(20, 20, 30, .04);
}
.auth-side {
  position: relative; overflow: hidden; color: #fff;
  background: linear-gradient(155deg, #8e1c24 0%, #a4232b 55%, #6f161c 100%);
  padding: 2.6rem 2.4rem; display: flex;
}
.auth-side .hero-drum::before, .auth-side .hero-drum::after {
  width: 460px; height: 460px; margin: 0; top: auto; bottom: -170px; left: auto; right: -170px; opacity: .2;
}
.auth-side-in { position: relative; z-index: 1; display: flex; flex-direction: column; gap: .2rem; }
.auth-brand { font-weight: 700; font-size: 1.02rem; margin: 0 0 2.2rem; }
.auth-brand span { color: var(--gold); }
.auth-side h2 {
  color: #fff; border: 0; padding: 0; margin: 0 0 .6rem;
  font-size: clamp(1.5rem, 1.1rem + 1.2vw, 2rem); line-height: 1.2;
}
.auth-lede { opacity: .9; margin: 0 0 1.4rem; max-width: 34ch; }
.auth-points { list-style: none; padding: 0; margin: 0 0 2rem; color: #fff; }
.auth-points li { position: relative; padding-left: 1.7rem; margin-bottom: .7rem; opacity: .95; }
.auth-points li::before {
  content: "✓"; position: absolute; left: 0; top: .05rem;
  width: 1.15rem; height: 1.15rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold); color: #3a2a00; font-size: .7rem; font-weight: 800;
}
.auth-help { margin: auto 0 0; font-size: .85rem; opacity: .85; }
.auth-help a { color: #ffe08a; }

.auth-main { padding: 2.8rem 2.6rem 2.4rem; display: flex; flex-direction: column; justify-content: center; }
.auth-main h1 { font-size: 1.75rem; margin-bottom: .4rem; }
.auth-main > .muted, .auth-state > .muted { line-height: 1.6; margin-bottom: 1.4rem; }
.auth-form label { margin: 1.1rem 0 .35rem; font-size: .86rem; color: var(--ink); }
.auth-form label:first-of-type { margin-top: 0; }
.auth-form input[type=email], .auth-form input[type=password], .auth-form input[type=text] {
  padding: .72rem .85rem; font-size: 1rem; border-radius: 9px; background: #fcfbf9;
}
.auth-form input:focus { background: #fff; outline: 3px solid rgba(164,35,43,.16); }
.auth-label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.auth-label-row label { margin-bottom: .35rem; }
.auth-label-row a { font-size: .84rem; font-weight: 600; text-decoration: none; margin-top: 1.1rem; }
.auth-label-row a:hover { text-decoration: underline; }
.pw-field { position: relative; }
.pw-field input { padding-right: 4.2rem !important; }
.pw-toggle {
  position: absolute; right: .4rem; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--soft); font: inherit; font-size: .82rem; font-weight: 600;
  padding: .35rem .55rem; border-radius: 6px; cursor: pointer;
}
.pw-toggle:hover { background: #f1ede6; color: var(--ink); }
.auth-submit { margin-top: 1.5rem !important; padding: .8rem 1rem; font-size: 1rem; border-radius: 9px; text-align: center; }
.auth-foot { margin: 1.4rem 0 0; padding-top: 1.1rem; border-top: 1px solid var(--line); line-height: 1.65; }
.auth-state { display: flex; flex-direction: column; }
.auth-icon {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.5rem; font-weight: 800; margin-bottom: 1rem;
}
.ok-icon { background: #e8f4ec; color: #1d6a3c; }
.bad-icon { background: #fbeaea; color: var(--red); }

@media (max-width: 780px) {
  .auth { grid-template-columns: 1fr; border-radius: 14px; margin-top: 0; }
  .auth-side { padding: 1.4rem 1.4rem 1.3rem; }
  .auth-brand { margin-bottom: .8rem; }
  .auth-side h2 { font-size: 1.3rem; margin-bottom: .2rem; }
  .auth-lede { margin: 0; font-size: .92rem; }
  .auth-points, .auth-help { display: none; }
  .auth-side .hero-drum::before, .auth-side .hero-drum::after { width: 260px; height: 260px; bottom: -110px; right: -90px; }
  .auth-main { padding: 1.6rem 1.3rem 1.6rem; }
  .auth-main h1 { font-size: 1.45rem; }
}

/* ---------- thẻ tài khoản trong hồ sơ ---------- */
.account-card form { margin: 0; }
.account-card form .btn { margin-top: .2rem; }
.account-alt { margin-top: 1.2rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.account-alt summary { cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--soft); }
.account-alt summary:hover { color: var(--red); }
.account-alt p { margin: .7rem 0 .4rem; }

/* ---------- trang đọc bài viết ---------- */
.reader { max-width: 1040px; margin: 0 auto; }
.crumbs { font-size: .85rem; color: var(--faint); display: flex; gap: .45rem; align-items: center; margin-bottom: 1.4rem; }
.crumbs a { color: var(--soft); text-decoration: none; font-weight: 600; }
.crumbs a:hover { color: var(--red); }

.article {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: clamp(1.4rem, 1rem + 2.5vw, 3.2rem) clamp(1.2rem, .6rem + 3.5vw, 4rem);
  box-shadow: 0 1px 2px rgba(20,20,30,.04);
}
.article-head { max-width: 720px; margin: 0 auto 2rem; padding-bottom: 1.6rem; border-bottom: 1px solid var(--line); }
.article-kicker {
  display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--red); padding-bottom: .35rem; border-bottom: 2px solid var(--gold); margin-bottom: 1rem;
}
.article-head h1 {
  font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.6rem); line-height: 1.18; letter-spacing: -.02em; margin: 0 0 .9rem;
}
.article-head .lede { font-size: clamp(1.05rem, 1rem + .3vw, 1.2rem); line-height: 1.6; color: var(--soft); margin: 0 0 1.2rem; }
.article-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .86rem; color: var(--faint); }
.copy-link {
  margin-left: auto; font: inherit; font-size: .8rem; font-weight: 600; color: var(--soft); cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: .3rem .8rem;
}
.copy-link:hover { border-color: var(--red); color: var(--red); }

.article-layout { max-width: 720px; margin: 0 auto; }
.article-layout.has-toc {
  max-width: none; display: grid; gap: 3rem; align-items: start;
  grid-template-columns: minmax(0, 210px) minmax(0, 720px); justify-content: center;
}
.toc { position: sticky; top: 1.2rem; font-size: .88rem; }
.toc-title { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin: .3rem 0 .7rem; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.toc li { margin: 0; }
.toc a {
  display: block; padding: .35rem 0 .35rem .9rem; margin-left: -2px; border-left: 2px solid transparent;
  color: var(--soft); text-decoration: none; line-height: 1.4;
}
.toc a:hover { color: var(--red); border-left-color: var(--red); }

.article .article-body { font-size: 1.06rem; color: #2a2d33; }
.article .article-body p { line-height: 1.8; margin-bottom: 1.2rem; }
.article .article-body > p:first-child::first-letter {
  float: left; font-size: 3.3em; line-height: .9; font-weight: 700; color: var(--red); margin: .08em .1em 0 0;
}
.article .article-body h3 {
  font-size: 1.3rem; letter-spacing: -.01em; margin: 2.4rem 0 .8rem; scroll-margin-top: 1rem;
  padding-top: 1.4rem; border-top: 1px solid var(--line);
}
.article .article-body h3:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.article .article-body ul { list-style: none; padding-left: 0; }
.article .article-body ul li { position: relative; padding-left: 1.4rem; line-height: 1.7; }
.article .article-body ul li::before {
  content: ""; position: absolute; left: .25rem; top: .72em; width: 6px; height: 6px; border-radius: 50%; background: var(--gold);
}
.article .article-body blockquote {
  background: #fbf6ea; border-left: 4px solid var(--gold); border-radius: 0 10px 10px 0;
  padding: 1rem 1.2rem; color: #5b4a1c; margin: 1.6rem 0;
}
.article .article-body a { color: var(--red); text-decoration-thickness: 1px; }
.article .article-body strong { color: var(--ink); }

.article-foot {
  max-width: 720px; margin: 2.6rem auto 0; padding-top: 1.4rem; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between;
}
.article-foot p { margin: 0; flex: 1 1 320px; }
.article-foot .btn { margin-top: 0; }
.related { max-width: 1040px; margin: 2.8rem auto 0; }
.related h2 { margin-top: 0; }

@media (max-width: 900px) {
  .article-layout.has-toc { display: block; }
  .toc { position: static; margin-bottom: 1.8rem; padding: 1rem 1.1rem; background: #faf8f4; border-radius: 10px; }
}
@media (max-width: 560px) {
  .article { border-radius: 12px; }
  .article .article-body { font-size: 1.02rem; }
  .copy-link { margin-left: 0; }
}
@media print {
  .topbar, .adminbar, .foot, .crumbs, .copy-link, .toc, .related, .article-foot .btn, .page-drum { display: none !important; }
  .article { border: 0; padding: 0; box-shadow: none; }
}

/* ---------- chọn kỳ đảng phí ---------- */
.period-nav { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .6rem 0 1.2rem; }
.period-nav .btn { margin-top: 0; }
.period-nav select { width: auto; margin: 0; }
.period-today { font-size: .88rem; font-weight: 600; margin-left: .3rem; }

/* ---------- thu chi (quản lý ngân sách) ---------- */
:root { --in: #1f7a4d; --in-soft: #e6f3ec; --out: #c0392b; --out-soft: #fbeaea; }
.pos { color: var(--in); }
.neg { color: var(--out); }
.fin-card .link-btn, .collect-tools .link-btn { font-size: .85rem; font-weight: 600; }

.fin-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.fin-head h1 { margin: 0; }
.fin-eyebrow { margin: 0 0 .2rem; font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.fin-head-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.fin-head-actions .btn { margin-top: 0; }
.fin-year select { width: auto; margin: 0; font-weight: 600; }

.fin-tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1.4rem; overflow-x: auto; }
.fin-tabs a {
  padding: .65rem 1rem; text-decoration: none; color: var(--soft); font-weight: 600; font-size: .93rem;
  border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.fin-tabs a:hover { color: var(--ink); }
.fin-tabs a.on { color: var(--red); border-bottom-color: var(--red); }

.kpis { display: grid; gap: 1rem; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 1.2rem; }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px)  { .kpis { grid-template-columns: 1fr; } }
.kpi {
  display: flex; flex-direction: column; gap: .3rem; padding: 1.15rem 1.25rem; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(20,20,30,.04);
  text-decoration: none; color: inherit; min-width: 0;
}
.kpi-label { font-size: .8rem; font-weight: 600; color: var(--soft); display: flex; align-items: center; gap: .4rem; }
.kpi-value { font-size: clamp(1.45rem, 1.1rem + 1vw, 1.85rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: .55em; font-weight: 600; color: var(--faint); margin-left: .15rem; }
.kpi-sub { font-size: .8rem; color: var(--faint); }
.kpi-balance { background: linear-gradient(140deg, #2a1416, #7d1a20 70%, #a4232b); border: 0; color: #fff; }
.kpi-balance .kpi-label, .kpi-balance .kpi-sub { color: rgba(255,255,255,.75); }
.kpi-balance .kpi-value { color: #ffe08a; }
.kpi-in { border-top: 3px solid var(--in); }
.kpi-out { border-top: 3px solid var(--out); }
.kpi-dues { border-top: 3px solid var(--gold); transition: box-shadow .15s, transform .15s; }
.kpi-dues:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(20,20,30,.08); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.in { background: var(--in); } .dot.out { background: var(--out); }
.meter { display: block; height: 8px; border-radius: 99px; background: #efe9df; overflow: hidden; margin: .25rem 0 .1rem; }
.meter > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--gold), #e8b923); transition: width .25s; }

.fin-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem 1.35rem; margin-bottom: 1.2rem; box-shadow: 0 1px 2px rgba(20,20,30,.04); }
.fin-card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .9rem; }
.fin-card-head h2 { margin: 0; padding: 0; border: 0; font-size: 1.05rem; }
.fin-grid { display: grid; gap: 1.2rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); align-items: start; }
.fin-grid .fin-card { margin-bottom: 0; }
.fin-note { margin: .4rem 0 0; }
.legend { display: flex; gap: 1rem; font-size: .82rem; color: var(--soft); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.legend i.in { background: var(--in); } .legend i.out { background: var(--out); }

.fin-chart { width: 100%; height: auto; display: block; }
.fin-chart .grid { stroke: #ece7df; stroke-width: 1; }
.fin-chart .grid.base { stroke: #cfc8bd; }
.fin-chart .ylab { font-size: 11px; fill: var(--faint); text-anchor: end; font-variant-numeric: tabular-nums; }
.fin-chart .xlab { font-size: 11px; fill: var(--faint); text-anchor: middle; }
.fin-chart .xlab.cur { fill: var(--red); font-weight: 700; }
.fin-chart .bar.in { fill: var(--in); } .fin-chart .bar.out { fill: var(--out); }
.fin-chart .bar:hover { opacity: .8; }
.fin-chart .now { fill: #fbf6ea; }

.cat-bars { list-style: none; margin: 0; padding: 0; }
.cat-bars li { display: grid; grid-template-columns: 1fr auto; gap: .25rem .8rem; margin-bottom: .85rem; }
.cat-name { font-size: .9rem; color: var(--ink); }
.cat-amt { font-size: .9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cat-amt small { font-weight: 500; color: var(--faint); margin-left: .3rem; }
.cat-track { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: #f3eee6; overflow: hidden; }
.cat-track > span { display: block; height: 100%; background: var(--out); opacity: .8; border-radius: 99px; }

.tx-list { list-style: none; margin: 0; padding: 0; }
.tx-list li { display: flex; align-items: center; gap: .8rem; padding: .65rem 0; border-bottom: 1px solid #f0ebe3; }
.tx-list li:last-child { border-bottom: 0; }
.tx-icon { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; }
.tx-icon.in { background: var(--in-soft); color: var(--in); }
.tx-icon.out { background: var(--out-soft); color: var(--out); }
.tx-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.tx-main strong { font-size: .92rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-main small { font-size: .78rem; color: var(--faint); }
.tx-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* sổ thu chi */
.tx-add summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; gap: .6rem; }
.tx-add summary::-webkit-details-marker { display: none; }
.tx-add .plus { width: 26px; height: 26px; border-radius: 8px; background: var(--red); color: #fff; display: grid; place-items: center; font-size: 1.1rem; }
.tx-add[open] summary { margin-bottom: 1rem; }
.tx-form .btn { margin-top: .4rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin: 0 0 .6rem; background: #f7f4ef; }
.seg label { margin: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: .45rem 1rem; border-radius: 8px; font-size: .9rem; font-weight: 600; color: var(--soft); }
.seg .seg-in input:checked + span { background: var(--in); color: #fff; }
.seg .seg-out input:checked + span { background: var(--out); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--gold); }
.tx-fields { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.tx-fields .wide { grid-column: 1 / -1; }
#cat[data-kind=thu] optgroup[data-for=chi], #cat[data-kind=chi] optgroup[data-for=thu] { display: none; }
.money-in { display: flex; align-items: stretch; }
.money-in span { display: grid; place-items: center; padding: 0 .7rem; background: #f3efe8; border: 1px solid #cfccc6; border-right: 0; border-radius: 7px 0 0 7px; color: var(--soft); font-weight: 600; }
.money-in input { border-radius: 0 7px 7px 0; font-variant-numeric: tabular-nums; }

.ledger-head { margin-bottom: 1rem; }
.ledger-head .btn { margin-top: 0; }
.chips { display: flex; gap: .35rem; }
.chips a { padding: .35rem .85rem; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--soft); font-size: .86rem; font-weight: 600; background: #fff; }
.chips a.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.ledger-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 1rem; }
.ledger-sum > div { background: #fcfbf9; padding: .7rem .9rem; display: flex; flex-direction: column; }
.ledger-sum span { font-size: .75rem; color: var(--faint); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.ledger-sum strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .ledger-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
table.ledger td, table.ledger th { vertical-align: middle; }
table.ledger .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.ledger .strong { font-weight: 700; }
table.ledger tr.auto td { background: #fbfaf6; }
table.ledger tr.opening td { color: var(--faint); font-style: italic; border-top: 2px solid var(--line); }
.cat-chip { display: inline-block; font-size: .72rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; margin-right: .35rem; white-space: nowrap; }
.cat-chip.in { background: var(--in-soft); color: var(--in); }
.cat-chip.out { background: var(--out-soft); color: var(--out); }

/* thu đảng phí */
.collect-sum { display: flex; gap: 2rem; flex-wrap: wrap; align-items: flex-end; }
.collect-stat { flex: 1 1 260px; display: flex; flex-direction: column; gap: .25rem; }
.collect-rate { flex: 0 1 260px; }
.collect-rate label { margin-top: 0; }
.collect-tools { display: flex; gap: 1rem; margin: 0 0 .6rem .2rem; }
.collect-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.collect-list label {
  display: flex; align-items: center; gap: .7rem; margin: 0; padding: .6rem .8rem; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); font-weight: 400;
  transition: border-color .12s, background .12s;
}
.collect-list label:hover { border-color: #d8cfc2; }
.collect-list input { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; accent-color: var(--in); }
.collect-list label:has(input:checked) { background: var(--in-soft); border-color: #b9dcc7; }
.collect-name { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; font-size: .92rem; font-weight: 600; }
.collect-name small { font-weight: 500; color: var(--faint); font-size: .76rem; }
.collect-state { color: var(--faint); }
.collect-list label:has(input:checked) .collect-state { color: var(--in); font-weight: 600; }
.collect-save { position: sticky; bottom: 0; padding: .8rem 0; background: linear-gradient(to top, var(--bg) 70%, transparent); margin-bottom: 1rem; }
.collect-save .btn { margin-top: 0; }
