/* ==========================================================================
   TÙNG LÂM — token + thành phần dùng chung cho trang chùa và khu quản trị.
   --brand được in từ cấu hình chùa (cai_dat.mau_chinh) → đổi màu không sửa CSS.
   ========================================================================== */
:root {
  --brand: #8a4b1f;
  --brand-ink: color-mix(in srgb, var(--brand) 78%, #000);
  --brand-soft: color-mix(in srgb, var(--brand) 9%, #fff);
  --brand-line: color-mix(in srgb, var(--brand) 22%, #fff);
  --gold: #a87a2e;
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #2a211a;
  --muted: #62574c;
  --line: #e6ddd1;
  --ok: #2f6b3a;
  --ok-bg: #e9f4ea;
  --warn: #8a5a00;
  --warn-bg: #fdf3dc;
  --err: #a52a1f;
  --err-bg: #fbe9e7;
  --info: #1f5a80;
  --info-bg: #e6f1f8;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(42, 33, 26, .06), 0 4px 16px rgba(42, 33, 26, .06);
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Noto Serif', Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.6; color: var(--ink); background: var(--bg); }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--brand-ink); }
a:hover { color: var(--brand); }
h1, h2, h3, h4 { line-height: 1.3; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, #fff); outline-offset: 2px; border-radius: 3px; }

.skip { position: absolute; left: -9999px; top: 0; background: var(--ink); color: #fff; padding: 8px 14px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

.demo-bar { background: #3a2e24; color: #f6e9d6; font-size: .8125rem; text-align: center; padding: 6px 16px; }
.demo-bar__btn { margin-left: 8px; background: transparent; color: #f6e9d6; border: 1px solid rgba(246,233,214,.5); border-radius: 4px;
  padding: 2px 10px; font: inherit; cursor: pointer; min-height: 28px; }
.demo-bar__btn:hover { background: rgba(246,233,214,.12); }

/* ── Brand ──────────────────────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand__logo { width: 44px; height: 44px; border-radius: 50%; flex: none; object-fit: cover; }
.brand__txt { display: flex; flex-direction: column; min-width: 0; }
.brand__name { font-weight: 700; font-size: 1.0625rem; line-height: 1.25; }
.brand__sub { font-size: .8125rem; color: var(--muted); line-height: 1.3; }

/* ── Nút ────────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 18px;
  border-radius: var(--radius-sm); border: 1px solid var(--brand); background: var(--brand); color: #fff;
  font: 600 .9375rem/1.2 var(--font); text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
.btn--ghost { background: transparent; color: var(--brand-ink); border-color: var(--brand-line); }
.btn--ghost:hover { background: var(--brand-soft); color: var(--brand-ink); border-color: var(--brand); }
.btn--danger { background: transparent; color: var(--err); border-color: #e9c3be; }
.btn--danger:hover { background: var(--err-bg); color: var(--err); border-color: var(--err); }
.btn--sm { min-height: 36px; padding: 6px 12px; font-size: .875rem; }
.btn--block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form { display: inline; }

/* ── Form ───────────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 16px 20px; }
@media (min-width: 720px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: .9375rem; }
.field input, .field select, .field textarea, .input {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #cfc3b4; border-radius: var(--radius-sm);
  background: #fff; font: 400 1rem/1.4 var(--font); color: var(--ink); }
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field--error input, .field--error select, .field--error textarea { border-color: var(--err); }
.field__err { color: var(--err); font-size: .875rem; margin: 0; }
.field__hint { color: var(--muted); font-size: .8125rem; margin: 0; }
.field--check label { font-weight: 500; display: flex; gap: 10px; align-items: center; min-height: 32px; cursor: pointer; }
.field--check input { width: 20px; height: 20px; accent-color: var(--brand); }
.req { color: var(--err); }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.hp { position: absolute; left: -9999px; }

/* ── Thông báo ──────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin: 16px 0; border: 1px solid transparent; }
.alert--ok { background: var(--ok-bg); color: var(--ok); border-color: #c8e2cb; }
.alert--err { background: var(--err-bg); color: var(--err); border-color: #f1c9c3; }
.alert--info { background: var(--info-bg); color: var(--info); border-color: #c5dcea; }
.alert--warn { background: var(--warn-bg); color: var(--warn); border-color: #f0dcae; }

/* ── Badge ──────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8125rem; font-weight: 600;
  background: #efe9e1; color: #4a3f35; white-space: nowrap; }
.badge--brand { background: var(--brand-soft); color: var(--brand-ink); }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--err { background: var(--err-bg); color: var(--err); }
.badge--info { background: var(--info-bg); color: var(--info); }

/* ── Thẻ + bảng ─────────────────────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 20px; }
.card__h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 14px; }
.card__h h2, .card__h h3 { margin: 0; font-size: 1.125rem; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .8125rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; }
.table tbody tr:hover { background: #fcfaf7; }
.table a { font-weight: 600; text-decoration: none; }
.table a:hover { text-decoration: underline; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: .9375rem; }
.dl dd { margin: 0; font-weight: 500; }

@media print {
  .demo-bar, .qt-side, .qt-top, .s-header, .s-footer, .no-print, .nav-toggle { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; padding: 0; }
}
