:root{
  --red:#8a1c1c; --red-dark:#6d1414; --gold:#d8b24a; --gold-soft:#f0dca4;
  --gold-grad:linear-gradient(135deg,#ecca64,#c89a2c);
  --ink:#2b2320; --muted:#7a6f68; --bg:#fbf7f0; --card:#ffffff;
  --line:#e7ddca; --shadow:0 6px 22px rgba(80,40,20,.10);
  --radius:14px; --maxw:1100px;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  font-family:"Be Vietnam Pro",system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  color:var(--ink); background:var(--bg);
  background-image:radial-gradient(circle at 20% 0%, #fff 0, transparent 55%);
  line-height:1.6;
  min-height:100vh; display:flex; flex-direction:column;
}
.site-header{flex-shrink:0}
.main-content{flex:1 0 auto; display:flex; flex-direction:column}
.site-footer{flex-shrink:0}
a{color:var(--red); text-decoration:none}
a:hover{text-decoration:underline}
.container{max-width:var(--maxw); margin:0 auto; padding:0 18px}
.main-content{padding:28px 18px 60px}

/* Header */
.site-header{background:linear-gradient(180deg,var(--red),var(--red-dark)); color:#fff; box-shadow:var(--shadow)}
.header-inner{display:flex; align-items:center; justify-content:space-between; gap:18px; padding:16px clamp(18px,3vw,40px); flex-wrap:wrap}
.brand-title{display:flex; flex-direction:column; line-height:1.15; color:#fff; text-decoration:none}
.brand-title:hover{text-decoration:none; opacity:.95}
.brand-eyebrow{font-size:11px; letter-spacing:2.5px; text-transform:uppercase; color:var(--gold-soft); font-weight:600}
.brand-name{font-size:22px; font-weight:700; color:#fff}
.brand{display:flex; align-items:center; gap:12px; color:#fff}
.brand:hover{text-decoration:none}
.brand-mark{display:inline-grid; place-items:center; width:42px; height:42px; border:2px solid var(--gold);
  border-radius:10px; color:var(--gold-soft); font-size:22px; font-weight:700; background:rgba(0,0,0,.12)}
.brand-text{font-weight:700; font-size:18px; letter-spacing:.3px}
.main-nav{display:flex; align-items:center; gap:18px; flex-wrap:wrap}
.main-nav a.nav-link{color:#fbe7c7; font-weight:500; position:relative; padding:9px 16px; border-radius:10px; transition:.15s}
.main-nav a.nav-link:hover{color:#fff; text-decoration:none; background:rgba(255,255,255,.10)}
.main-nav a.nav-link.active{color:#fff; font-weight:700; background:rgba(255,255,255,.08)}
.main-nav a.nav-link.active::after{content:''; position:absolute; left:16px; right:16px; bottom:3px; height:3px;
  background:var(--gold); border-radius:2px}
.branch-pill{background:var(--gold); color:#4a2f00; padding:4px 12px; border-radius:999px; font-weight:600; font-size:13px}
.btn-ghost{color:#fff; border:1px solid rgba(255,255,255,.55); padding:10px 20px; border-radius:10px; font-weight:600; transition:.15s}
.btn-ghost:hover{background:rgba(255,255,255,.14); border-color:#fff; text-decoration:none}

/* Flash */
.flash{margin:14px 0 0; padding:12px 16px; border-radius:10px; font-weight:500}
.flash-success{background:#e7f5ea; color:#1b6b34; border:1px solid #b6e0c1}
.flash-error{background:#fdeaea; color:#a52121; border:1px solid #f3c0c0}
.flash-info{background:#eef3fb; color:#2a4d80; border:1px solid #c4d6f0}

/* Buttons */
.btn{display:inline-block; background:var(--red); color:#fff; padding:10px 18px; border-radius:10px;
  font-weight:600; border:0; cursor:pointer; font-size:15px}
.btn:hover{background:var(--red-dark); text-decoration:none}
.btn-gold{background:var(--gold); color:#3d2800}
.btn-gold:hover{background:#b9921f}
.btn-sm{padding:6px 12px; font-size:13px; border-radius:8px}
.btn-outline{background:transparent; border:1px solid var(--red); color:var(--red)}
.btn-danger{background:#b3261e}
.btn-danger:hover{background:#8f1d17}

/* Cards */
.card{background:var(--card); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow)}
.card-pad{padding:22px}
.grid{display:grid; gap:18px}
.grid-2{grid-template-columns:repeat(2,1fr)}
.grid-3{grid-template-columns:repeat(3,1fr)}
.grid-4{grid-template-columns:repeat(4,1fr)}
@media(max-width:820px){.grid-2,.grid-3,.grid-4{grid-template-columns:1fr}}

/* Landing chọn họ */
.choose-wrap{flex:1 1 auto; min-height:0; display:flex; align-items:center; justify-content:center; text-align:center; padding:24px 0}
.choose-title{font-size:34px; font-weight:700; margin:0 0 6px}
.choose-sub{color:var(--muted); margin:0 0 34px}
.choose-cards{display:grid; grid-template-columns:1fr 1fr; gap:24px; max-width:680px; width:100%}
@media(max-width:620px){.choose-cards{grid-template-columns:1fr}}
.choose-card{display:block; color:inherit; text-decoration:none; background:var(--card); border:2px solid var(--line); border-radius:18px; padding:36px 22px;
  cursor:pointer; transition:.18s; box-shadow:var(--shadow)}
.choose-card:hover{border-color:var(--gold); transform:translateY(-4px); text-decoration:none}
.choose-card .glyph{font-size:54px; color:var(--red); margin-bottom:10px}
.choose-card h2{margin:6px 0 4px; font-size:24px}
.choose-card p{color:var(--muted); margin:0}
.choose-card button{margin-top:16px}

/* Section heading */
.page-head{display:flex; align-items:center; justify-content:space-between; gap:14px; margin-bottom:22px; flex-wrap:wrap}
.page-head h1{margin:0; font-size:26px}
.section-deco{height:3px; width:80px; background:linear-gradient(90deg,var(--gold),transparent); border-radius:2px; margin:6px 0 0}

/* Cây gia phả */
.tree{--lh:22px}
.tree ul{padding-left:0; margin:0; position:relative; display:flex; gap:24px; justify-content:flex-start}
.tree li{list-style:none; position:relative; padding:18px 10px 0; text-align:center}
.tree li::before, .tree li::after{content:''; position:absolute; top:0; height:18px; border-top:2px solid var(--gold)}
.tree li::before{left:0; width:50%; border-left:2px solid var(--gold)}
.tree li::after{right:0; width:50%}
.tree li:only-child::after,.tree li:only-child::before{display:none}
.tree li:only-child{padding-top:18px}
.tree li:first-child::before{border:0}
.tree li:last-child::after{border:0}
.tree li:last-child::before{border-right:2px solid var(--gold); border-radius:0 6px 0 0}
.tree li:first-child::after{border-radius:6px 0 0 0}
.tree>li::before,.tree>li::after{display:none}
.tree ul ul::before{content:''; position:absolute; top:-18px; left:50%; height:18px; border-left:2px solid var(--gold)}
.node{display:inline-flex; flex-direction:column; align-items:center; gap:6px; background:var(--card);
  border:1px solid var(--line); border-radius:12px; padding:10px 14px; box-shadow:var(--shadow); min-width:130px}
.node:hover{border-color:var(--gold); text-decoration:none}
.node .avatar{width:54px; height:54px; border-radius:50%; object-fit:cover; border:2px solid var(--gold-soft); background:#eee}
.node .nm{font-weight:600; color:var(--ink); font-size:14px}
.node .yr{font-size:12px; color:var(--muted)}
.node .spouse{font-size:12px; color:var(--red)}
.tree-scroll{overflow-x:auto; padding:10px 4px 24px}

/* Member detail */
.member-hero{display:flex; gap:26px; align-items:flex-start; flex-wrap:wrap}
.member-hero .avatar-lg{width:140px; height:140px; border-radius:16px; object-fit:cover; border:3px solid var(--gold-soft); background:#eee}
.member-hero h1{margin:0 0 8px}
.member-hero .badge{margin-bottom:4px}
/* Avatar mặc định (icon người) */
.avatar-default{display:grid; place-items:center; background:linear-gradient(160deg,#f4eee2,#e6dcc6); color:#b3a489}
.avatar-default svg{width:58%; height:58%}
.meta-list{list-style:none; padding:0; margin:10px 0}
.meta-list li{padding:5px 0; border-bottom:1px dashed var(--line)}
.meta-list b{color:var(--muted); font-weight:500; display:inline-block; min-width:130px}
.gio-badge{display:inline-block; background:#fff4e0; border:1px solid var(--gold); color:#7a5200; padding:8px 14px; border-radius:10px; font-weight:600}

/* Tables (admin) */
.table{width:100%; border-collapse:collapse; background:var(--card); border-radius:12px; overflow:hidden; box-shadow:var(--shadow)}
.table th,.table td{padding:11px 14px; text-align:left; border-bottom:1px solid var(--line); font-size:14px}
.table th{background:#f4ead3; color:#5b4a1e; font-weight:600}
.table tr:last-child td{border-bottom:0}
.table .actions{display:flex; gap:8px; flex-wrap:wrap}

/* Forms */
.form-grid{display:grid; gap:16px; max-width:760px}
.form-row{display:grid; gap:6px}
.form-row label{font-weight:600; font-size:14px}
.form-row input[type=text],.form-row input[type=number],.form-row input[type=email],
.form-row input[type=password],.form-row input[type=date],.form-row select,.form-row textarea{
  padding:10px 12px; border:1px solid var(--line); border-radius:10px; font:inherit; background:#fff; width:100%}
.form-row textarea{min-height:120px; resize:vertical}
.form-inline{display:flex; gap:12px; flex-wrap:wrap; align-items:end}
.hint{color:var(--muted); font-size:13px}
.two-col{display:grid; grid-template-columns:1fr 1fr; gap:16px}
@media(max-width:620px){.two-col{grid-template-columns:1fr}}

/* Login */
.login-wrap{max-width:400px; margin:6vh auto}

/* Văn khấn */
.prayer-content{white-space:pre-wrap; background:var(--card); border:1px solid var(--line); border-radius:12px; padding:22px; box-shadow:var(--shadow)}
.list-card{display:block; background:var(--card); border:1px solid var(--line); border-radius:12px; padding:18px; box-shadow:var(--shadow)}
.list-card:hover{border-color:var(--gold); text-decoration:none}
.list-card h3{margin:0 0 6px; color:var(--ink)}

/* Album gallery */
.gallery{display:grid; grid-template-columns:repeat(4,1fr); gap:12px}
@media(max-width:820px){.gallery{grid-template-columns:repeat(2,1fr)}}
.gallery a{display:block; aspect-ratio:1/1; overflow:hidden; border-radius:10px; border:1px solid var(--line)}
.gallery img{width:100%; height:100%; object-fit:cover; transition:.2s}
.gallery img:hover{transform:scale(1.05)}
.album-card .cover{aspect-ratio:4/3; object-fit:cover; width:100%; border-radius:12px 12px 0 0; background:#eee}

/* Lightbox */
.lb-overlay{position:fixed; inset:0; background:rgba(0,0,0,.9); display:none; align-items:center; justify-content:center; z-index:1000}
.lb-overlay.open{display:flex}
.lb-overlay img{max-width:92vw; max-height:86vh; border-radius:8px}
.lb-close,.lb-prev,.lb-next{position:absolute; color:#fff; background:rgba(255,255,255,.12); border:0; cursor:pointer;
  font-size:26px; width:48px; height:48px; border-radius:50%}
.lb-close{top:18px; right:18px}
.lb-prev{left:18px; top:50%; transform:translateY(-50%)}
.lb-next{right:18px; top:50%; transform:translateY(-50%)}
.lb-cap{position:absolute; bottom:18px; left:0; right:0; text-align:center; color:#fff}

/* Footer */
.site-footer{background:var(--red-dark); color:#f0d9b0; margin-top:0; padding:22px 0; text-align:center; font-size:14px}

/* Misc */
.empty{color:var(--muted); text-align:center; padding:40px; background:var(--card); border:1px dashed var(--line); border-radius:12px}
.badge{display:inline-block; padding:2px 9px; border-radius:999px; font-size:12px; font-weight:600}
.badge-nguyen{background:#e7eefc; color:#2a4d80}
.badge-pham{background:#fbeee7; color:#9a4a1d}
.badge-chung{background:#eee; color:#555}
.upcoming{display:flex; gap:12px; align-items:center; padding:12px 14px; border-left:4px solid var(--gold); background:#fffaf0; border-radius:8px; margin-bottom:10px}
.upcoming .d{font-weight:700; color:var(--red)}
.toolbar{display:flex; gap:10px; flex-wrap:wrap; margin-bottom:18px}

/* ===== Lịch giỗ (thiết kế phân cấp rõ) ===== */
.gio-wrap{margin-top:8px}
.gio-month{display:flex; align-items:center; gap:14px; margin:30px 0 14px}
.gio-month:first-child{margin-top:6px}
.gio-month-label{font-size:14px; font-weight:700; letter-spacing:.5px; text-transform:uppercase;
  color:var(--red); background:#fff; border:1px solid var(--gold-soft); padding:6px 14px; border-radius:999px; white-space:nowrap}
.gio-month-line{flex:1; height:2px; background:linear-gradient(90deg,var(--gold-soft),transparent)}

.gio-item{display:flex; align-items:stretch; gap:4px; background:var(--card); border:1px solid var(--line);
  border-radius:18px; overflow:hidden; margin-bottom:16px;
  box-shadow:0 4px 16px rgba(80,40,20,.08); transition:.16s; color:inherit}
.gio-item:hover{transform:translateY(-2px); border-color:var(--gold); text-decoration:none; box-shadow:0 10px 28px rgba(80,40,20,.15)}

/* Khối ngày dương — bo góc riêng, tách khỏi thân */
.gio-date{flex:0 0 88px; display:flex; flex-direction:column; align-items:center; justify-content:center;
  padding:16px 10px; margin:10px 0 10px 10px; border-radius:14px;
  color:#fff; background:linear-gradient(160deg,#9a2222,#6d1414); box-shadow:0 3px 10px rgba(109,20,20,.25)}
.gio-item.u-soon .gio-date{background:linear-gradient(160deg,#e6c25a,#c2962c); box-shadow:0 3px 10px rgba(190,150,40,.3)}
.gio-item.u-far .gio-date{background:linear-gradient(160deg,#9a8f80,#6f655a); box-shadow:0 3px 10px rgba(80,70,60,.2)}
.gio-date .dd{font-size:30px; font-weight:800; line-height:1}
.gio-date .my{font-size:12px; font-weight:600; opacity:.92; margin-top:5px; text-transform:uppercase; letter-spacing:.5px}

/* Thân */
.gio-body{flex:1; padding:16px 20px; display:flex; flex-direction:column; justify-content:center; gap:7px; min-width:0}
.gio-name{font-size:19px; font-weight:700; color:var(--ink); line-height:1.3}
.gio-lunar{font-size:14px; color:var(--muted)}
.gio-note{font-size:12.5px; color:#9a8f86; font-style:italic}
.tag-event{display:inline-block; vertical-align:middle; margin-left:8px; font-size:11px; font-weight:700;
  text-transform:uppercase; letter-spacing:.4px; background:#eef0f2; color:#5b6470; padding:3px 9px; border-radius:999px}

/* Đếm ngược */
.gio-side{display:flex; align-items:center; padding:0 20px 0 8px}
.gio-countdown{font-size:12.5px; font-weight:700; padding:7px 14px; border-radius:999px; white-space:nowrap}
.gio-countdown.u-urgent{background:#fdeaea; color:#c5221f}
.gio-countdown.u-soon{background:#fff4e0; color:#9a6a00}
.gio-countdown.u-far{background:#eef0f2; color:#667}

.gio-pending{margin-top:24px; border-color:var(--gold); background:#fffdf6}
.gio-pending h3{margin-top:0; color:#9a6a00}

/* Mobile: ngày + tên 1 hàng, đếm ngược xuống dòng có vạch ngăn rõ */
@media(max-width:560px){
  .gio-item{flex-wrap:wrap; gap:0}
  .gio-side{width:100%; padding:12px 20px; margin-top:2px; border-top:1px dashed var(--line)}
  .gio-side{justify-content:flex-start}
}

/* ============================================================
   TỐI ƯU MOBILE CHO NGƯỜI LỚN TUỔI
   Chữ to, nút lớn dễ chạm, tương phản rõ, 1 cột thoáng
   ============================================================ */
@media (max-width:768px){
  body{font-size:18px; line-height:1.75}
  .container{padding:0 16px}
  .main-content{padding:18px 16px 36px}

  /* --- Header mobile: title giữa, menu chip đều nhau --- */
  .header-inner{flex-direction:column; gap:16px; padding:16px 16px 18px}
  .brand-title{align-items:center; text-align:center}
  .brand-eyebrow{font-size:12px}
  .brand-name{font-size:24px}
  .main-nav{width:100%; display:grid; grid-template-columns:repeat(3,1fr); gap:10px}
  .main-nav a.nav-link{font-size:16px; font-weight:600; padding:12px 6px; text-align:center;
    background:rgba(255,255,255,.10); border-radius:12px; color:#fbe7c7}
  .main-nav a.nav-link:hover{background:rgba(255,255,255,.16)}
  .main-nav a.nav-link.active{background:var(--gold-grad); color:#4a2f00; box-shadow:0 3px 12px rgba(190,150,40,.4)}
  .main-nav a.nav-link.active::after{display:none}
  .main-nav .btn-ghost{grid-column:1 / -1; text-align:center; font-size:16px; padding:12px 18px;
    border-color:rgba(255,255,255,.5)}

  /* --- Tiêu đề lớn --- */
  .page-head h1{font-size:27px}
  .choose-title{font-size:30px}
  .choose-sub{font-size:18px}

  /* --- Thẻ chọn họ: 1 cột, lớn, dễ chạm --- */
  .choose-cards{grid-template-columns:1fr; gap:18px; max-width:460px}
  .choose-card{padding:30px 22px}
  .choose-card .glyph{font-size:62px}
  .choose-card h2{font-size:27px}
  .choose-card p{font-size:17px}

  /* --- Nút bấm: vùng chạm tối thiểu ~50px --- */
  .btn{font-size:18px; padding:14px 22px; min-height:52px}
  .btn-sm{font-size:16px; padding:11px 18px; min-height:46px}

  /* --- Lịch giỗ: số ngày & tên thật to --- */
  .gio-month-label{font-size:15px; padding:8px 16px}
  .gio-date{flex:0 0 84px; padding:15px 8px; margin:12px 0 12px 12px}
  .gio-date .dd{font-size:32px}
  .gio-date .my{font-size:14px}
  .gio-body{padding:16px 18px; gap:7px}
  .gio-name{font-size:22px}
  .gio-lunar{font-size:16px}
  .gio-note{font-size:14.5px}
  .gio-side{padding:13px 20px; border-top:1px dashed var(--line)}
  .gio-countdown{font-size:15px; padding:9px 16px}
  .tag-event{font-size:13px; padding:4px 11px}

  /* --- Chi tiết người --- */
  .member-hero{gap:16px}
  .member-hero h1{font-size:26px}
  .meta-list li{font-size:18px; padding:9px 0}
  .meta-list b{min-width:0; display:block; color:var(--muted); font-size:14px; margin-bottom:1px}
  .gio-badge{font-size:16px; padding:10px 16px}

  /* --- Văn khấn: dễ đọc --- */
  .prayer-content{font-size:19px; line-height:1.9; padding:20px}
  .list-card{padding:20px}
  .list-card h3{font-size:20px}

  /* --- Album --- */
  .gallery{grid-template-columns:repeat(2,1fr); gap:10px}

  /* --- Flash to rõ --- */
  .flash{font-size:17px; padding:14px 18px}
}

/* Màn hình rất nhỏ */
@media (max-width:400px){
  body{font-size:19px}
  .gio-date{flex-basis:74px}
  .gio-name{font-size:21px}
  .gallery{grid-template-columns:1fr}
}
