/* ============================================================
   KTMC Event Registration System
   Design language: Kwun Tong Maryknoll College website
   (deep navy #0f4d8a family + gold #ffa800, Gentium Book Plus
   serif headings, Noto Sans TC, warm off-white backgrounds)
   Breakpoints: ≤1024px tablet, ≤640px phone
   ============================================================ */
:root {
  --primary: #0f4d8a;         /* school navy */
  --primary-dark: #013d85;
  --navy-deep: #00266e;
  --navy-soft: #eaf1fa;
  --accent: #ffa800;          /* school gold */
  --accent-soft: #fdf3dd;
  --bg: #f6f4ef;              /* warm off-white */
  --card-bg: #ffffff;
  --text: #2b2b2b;
  --muted: #6d6d6d;
  --border: #e2ded6;
  --ok: #1e7a34;
  --warn: #9a6a00;
  --err: #c0392b;
  --danger: #c0392b;
  --serif: 'Gentium Book Plus', 'Noto Sans TC', Georgia, serif;
  --sans: 'Noto Sans TC', 'Segoe UI', 'Microsoft JhengHei', 'PingFang HK', Arial, sans-serif;
}

* { box-sizing: border-box; }
/* Desktop text size (Admin → Settings → Text size). Every rem-based size in
   this stylesheet scales with the root font size, so the whole page grows or
   shrinks in proportion instead of snapping to one size. Phones are excluded. */
html { font-size: calc(16px * var(--font-scale, 1)); -webkit-text-size-adjust: 100%; }
/* Tablets and phones have their OWN settings (Admin → Settings → Text size).
   Order matters: each narrower breakpoint must come after the wider one. */
@media (max-width: 1024px) {
  html { font-size: calc(16px * var(--font-scale-tablet, var(--font-scale, 1))); }
}
@media (max-width: 640px) {
  html { font-size: calc(16px * var(--font-scale-mobile, var(--font-scale-tablet, var(--font-scale, 1)))); }
}
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--text);
  background:
    radial-gradient(1200px 400px at 50% -100px, rgba(15, 77, 138, .06), transparent),
    var(--bg);
  line-height: 1.6;
}
a { color: var(--primary); }
img { max-width: 100%; height: auto; }
h1, h2, h3 { font-family: var(--serif); color: var(--navy-deep); letter-spacing: .2px; }
h1 { font-size: 1.8rem; margin: .5rem 0 1rem; }
h2 { font-size: 1.35rem; margin: 1.3rem 0 .6rem; }
h3 { font-size: 1.08rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.container { padding-top: 22px; padding-bottom: 70px; }

/* ---------------- Animations ---------------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes goldSlide { from { width: 0; } to { width: 88px; } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* ---------------- Header ---------------- */
.site-header {
  background: linear-gradient(135deg, var(--navy-deep) 0%, var(--primary-dark) 45%, var(--primary) 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(0, 38, 110, .28);
  border-bottom: 3px solid var(--accent);
}
.header-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  padding-top: 12px; padding-bottom: 12px; gap: 8px;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; display: flex; align-items: center; gap: 12px; line-height: 1.3; }
.brand-logo {
  height: 44px; width: auto; background: #fff; border-radius: 9px; padding: 3px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  transition: transform .35s ease;
}
.brand:hover .brand-logo { transform: scale(1.05); }
.brand-en { font-size: 1.08rem; font-family: var(--serif); letter-spacing: .4px; }
.brand-zh { font-size: .85rem; font-weight: 400; opacity: .9; }
.main-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.main-nav a {
  color: #fff; text-decoration: none; font-size: .95rem; opacity: .94;
  position: relative; padding: 4px 0; transition: opacity .2s ease;
}
.main-nav a::after {
  content: ''; position: absolute; left: 0; bottom: 0; height: 2px; width: 0;
  background: var(--accent); transition: width .28s ease;
}
.main-nav a:hover { opacity: 1; }
.main-nav a:hover::after { width: 100%; }
.linklike-light { color: #fff; }
/* Header Logout: a real button */
.main-nav .linklike-light {
  border: 1px solid rgba(255, 255, 255, .65);
  border-radius: 20px;
  padding: 5px 16px;
  text-decoration: none;
  font-size: .88rem;
  color: #fff;
  background: transparent;
  transition: all .25s ease;
}
.main-nav .linklike-light:hover { background: var(--accent); border-color: var(--accent); color: var(--navy-deep); text-decoration: none; }
.main-nav .linklike-light:hover::after { display: none; }
.lang-switch { display: inline-flex; align-items: center; gap: 4px; }
.lang-switch a, .lang-switch strong {
  padding: 5px 10px; display: inline-block; border-radius: 20px; color: #fff; font-size: .9rem;
}
.lang-switch a { background: rgba(255, 255, 255, .16); text-decoration: none; transition: background .25s ease; }
.lang-switch a:hover { background: rgba(255, 255, 255, .3); }
.lang-switch strong { background: #fff; color: var(--navy-deep); }

/* ---------------- Hero (home): full-bleed school photo banner ---------------- */
body.page-home main.container { padding-top: 0; }
.hero {
  position: relative;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-top: 0;
  border-radius: 0;
  overflow: hidden;
  min-height: 520px;
  display: flex;
  box-shadow: none;
}
.hero-photo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center 30%;
}
/* soft gradient fades at the two side edges, blending into the page background */
.hero-fade { position: absolute; top: 0; bottom: 0; width: 18%; z-index: 1; pointer-events: none; }
.hero-fade-left { left: 0; background: linear-gradient(to right, var(--bg) 0%, rgba(246, 244, 239, 0) 100%); }
.hero-fade-right { right: 0; background: linear-gradient(to left, var(--bg) 0%, rgba(246, 244, 239, 0) 100%); }
.hero-inner {
  position: relative; z-index: 2;
  width: 100%;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 22px 44px 46px;
  background: linear-gradient(180deg,
    rgba(0, 23, 61, .62) 0%,
    rgba(0, 38, 110, .12) 26%,
    rgba(0, 38, 110, .05) 52%,
    rgba(0, 23, 61, .92) 100%);
}
.hero-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.brand-logo.bare {
  background: transparent; padding: 0; box-shadow: none; border-radius: 0;
  height: 52px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .55));
}
.hero-content { max-width: 780px; }
.hero-kicker {
  font-size: .78rem; letter-spacing: 3.5px; text-transform: uppercase;
  color: #f0d9a8; font-weight: 500;
  animation: fadeUp .5s ease both;
}
.hero h1 {
  font-family: var(--serif); font-size: 2.6rem; margin: 10px 0 0;
  color: #fff; letter-spacing: .6px; line-height: 1.2; max-width: 680px;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .4);
  animation: fadeUp .6s .08s ease both;
}
.hero-zh { font-size: 1.25rem; margin: 8px 0 0; color: #f0d9a8; }
.hero .gold-line {
  width: 76px; height: 3px; background: var(--accent); margin: 16px 0 0;
  border-radius: 2px; animation: goldSlide .7s .25s ease both;
}
.hero-sub { color: #d9e6f5; margin-top: 12px; font-size: 1.05rem; animation: fadeUp .6s .3s ease both; }

/* Admin appearance preview */
.hero-preview { margin: 12px 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.hero-preview img { display: block; width: 100%; max-height: 220px; object-fit: cover; }

/* ---------------- Cards & layout ---------------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin: 18px 0;
  box-shadow: 0 2px 8px rgba(0, 38, 110, .05);
  animation: fadeUp .5s ease both;
  transition: box-shadow .3s ease, transform .3s ease;
}
.card:hover { box-shadow: 0 8px 22px rgba(0, 38, 110, .1); }
.card.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
/* Event cards: centred when there are only one or two; wraps into centred rows on small screens */
.event-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; margin-top: 12px; }
.event-card {
  flex: 1 1 320px; min-width: 280px;
  position: relative; overflow: hidden;
  animation: fadeUp .55s ease both;
}
.event-card:nth-child(2) { animation-delay: .08s; }
.event-card:nth-child(3) { animation-delay: .16s; }
.event-card:nth-child(4) { animation-delay: .24s; }
.event-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), #f1be48);
  transform: scaleX(0); transform-origin: left;
  transition: transform .4s ease;
}
.event-card:hover { transform: translateY(-4px); }
.event-card:hover::before { transform: scaleX(1); }
.event-card h2 { margin-top: 0; }
.row-between { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
/* Duplicate-event row at the bottom of the event form */
.dup-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }
.dup-form .help { margin: 0; max-width: 60ch; }
.inline-form { display: inline; }

/* ---------------- Forms ---------------- */
.stacked-form label { display: block; margin: 10px 0 4px; font-weight: 600; color: var(--navy-deep); }
.stacked-form label small, .help { color: var(--muted); font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 16px; }
.form-grid .span2 { grid-column: 1 / -1; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=datetime-local], input[type=tel],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #c9c2b6;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  margin-top: 3px;
  max-width: 100%;
  transition: border-color .2s ease, box-shadow .2s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 77, 138, .15);
}
textarea { resize: vertical; }
.req { color: var(--err); }
.checkbox-line { font-weight: 400 !important; display: flex; align-items: center; gap: 8px; }
.checkbox-line input { width: auto; }
.radio-group.inline { display: flex; flex-wrap: wrap; gap: 14px; margin: 6px 0; }
.radio-group.inline label.opt { font-weight: 400; }
.checkbox-group { margin: 6px 0; }
.checkbox-group label.opt { display: block; font-weight: 400; }
.mode-option {
  display: block; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; margin: 10px 0; font-weight: 400; cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
}
.mode-option:hover { border-color: var(--accent); background: #fffdf6; }
.mode-option input { margin-right: 8px; }
.password-field { margin-top: 14px; }
.form-foot { margin-top: 16px; font-size: .95rem; color: var(--muted); }
.or { text-align: center; color: var(--muted); }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ---------------- Buttons (school-style gradient sweep) ---------------- */
.btn {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 8px;
  text-decoration: none;
  font-size: .98rem;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.4;
  transition: all .3s ease;
}
.btn-primary {
  background: linear-gradient(to left, var(--primary-dark) 50%, var(--accent) 50%);
  background-size: 200% 100%; background-position: right bottom;
  color: #fff;
  box-shadow: 0 2px 6px rgba(1, 61, 133, .3);
}
.btn-primary:hover { background-position: left bottom; color: var(--navy-deep); box-shadow: 0 4px 12px rgba(255, 168, 0, .4); }
.btn-ghost { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-ghost:hover { background: var(--navy-soft); border-color: var(--navy-deep); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-danger-ghost { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-danger-ghost:hover { background: #fdf1f0; }
.linklike { background: none; border: none; color: var(--primary); cursor: pointer; font-size: .95rem; padding: 0; text-decoration: underline; font-family: inherit; }
.linklike.danger { color: var(--danger); }
.icon-btn { background: #fff; border: 1px solid #c9c2b6; border-radius: 6px; cursor: pointer; padding: 2px 10px; transition: all .2s ease; }
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn:disabled { opacity: .35; cursor: default; }
button[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------------- Tables ---------------- */
.slots-table, .info-table { width: 100%; border-collapse: collapse; margin: 12px 0; background: #fff; }
.slots-table th, .slots-table td {
  border: 1px solid var(--border); padding: 9px 12px; text-align: left;
  vertical-align: top; font-size: .95rem; word-break: break-word;
}
.slots-table th {
  background: linear-gradient(180deg, var(--navy-soft), #e2ecf8);
  color: var(--navy-deep); font-family: var(--serif); letter-spacing: .4px;
}
.slots-table tbody tr { transition: background .2s ease; }
.slots-table tbody tr:hover { background: #fbfaf6; }
.info-table th { width: 38%; border: 1px solid var(--border); padding: 8px 12px; text-align: left; background: var(--navy-soft); color: var(--navy-deep); }
.info-table td { border: 1px solid var(--border); padding: 8px 12px; word-break: break-word; }
.action-cell a, .action-cell .linklike { white-space: nowrap; }

/* ---------------- Badges & status ---------------- */
.badge-full { display: inline-block; background: var(--danger); color: #fff; padding: 2px 10px; border-radius: 20px; font-size: .85rem; margin-left: 6px; }
.badge-upcoming { display: inline-block; color: var(--navy-deep); font-weight: 600; }
.badge-closed { display: inline-block; background: #8d8d8d; color: #fff; padding: 2px 10px; border-radius: 20px; font-size: .85rem; }
.badge-cancelled { display: inline-block; background: #a09b93; color: #fff; padding: 2px 10px; border-radius: 20px; font-size: .85rem; margin-left: 6px; }
.badge-attended { display: inline-block; background: var(--ok); color: #fff; padding: 2px 10px; border-radius: 20px; font-size: .85rem; margin-left: 6px; }
.badge-status { display: inline-block; padding: 2px 12px; border-radius: 20px; font-size: .82rem; color: #fff; }
.status-draft { background: #8d8d8d; }
.status-published { background: var(--ok); }
.status-closed { background: #5a6b7d; }
.status-confirmed { background: var(--ok); }
/* Dashboard status column: the colour fills the whole cell instead of a pill */
.slots-table td.status-cell { color: #fff; font-weight: 600; text-align: center; vertical-align: middle; }
.status-cancelled { background: #a09b93; }
.status-admin { background: var(--primary); }
.status-staff { background: #4a6785; }

/* ---------------- Flash ---------------- */
.flash { padding: 12px 16px; border-radius: 10px; margin: 14px 0; border: 1px solid; border-left-width: 4px; animation: fadeUp .4s ease both; }
.flash-ok { background: #eaf6ec; border-color: #9fd0a6; color: #14531f; }
.flash-error { background: #fdecea; border-color: #f0b4ae; color: #7c1d16; }
.flash-info { background: var(--navy-soft); border-color: #b3cfe8; color: #1c4a75; }

/* ---------------- Slot list on home page ---------------- */
.slot-row { display: flex; flex-wrap: wrap; gap: 10px; padding: 9px 0; border-top: 1px dashed var(--border); }
.slot-row:first-child { border-top: none; }
.slot-date { min-width: 150px; color: var(--navy-deep); }
.slot-time { flex: 1; min-width: 160px; }
.slot-quota { min-width: 70px; text-align: center; font-weight: 700; color: var(--primary); }
.venue { margin: 4px 0; }
.quota-note { margin: 8px 0; }
.event-desc { margin: 10px 0; }

/* ---------------- Rich description (client pages + admin preview) ---------------- */
.event-desc > :first-child, .rich-surface > :first-child { margin-top: 0; }
.event-desc > :last-child, .rich-surface > :last-child { margin-bottom: 0; }
.event-desc p, .event-desc div, .rich-surface p, .rich-surface div { margin: .55em 0; }
.event-desc h2, .event-desc h3, .event-desc h4,
.rich-surface h2, .rich-surface h3, .rich-surface h4 {
  font-family: var(--serif); color: var(--navy-deep); line-height: 1.35; margin: 1.05em 0 .4em;
}
.event-desc h2, .rich-surface h2 { font-size: 1.18rem; }
.event-desc h3, .rich-surface h3 { font-size: 1.08rem; }
.event-desc h4, .rich-surface h4 { font-size: 1rem; }
.event-desc hr, .rich-surface hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.event-desc ul, .event-desc ol, .rich-surface ul, .rich-surface ol { margin: .5em 0; padding-left: 1.4em; }
.event-desc li, .rich-surface li { margin: .2em 0; }
.event-desc blockquote, .rich-surface blockquote {
  margin: .7em 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--accent); color: var(--muted);
}
.event-desc a, .rich-surface a { color: var(--primary); text-decoration: underline; }

/* ---------------- Rich-text editor (admin) ---------------- */
.field-block { margin-top: 4px; }
.field-label { display: block; margin: 10px 0 4px; font-weight: 600; color: var(--navy-deep); }
.field-block .help { margin-top: 5px; font-size: .82rem; font-weight: 400; }
.rich-editor {
  border: 1px solid #c9c2b6; border-radius: 8px; background: #fff;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.rich-editor:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 77, 138, .15); }
.rich-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px;
  padding: 5px 6px; background: #f2efe8; border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
}
.rich-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 7px;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--navy-deep); font: inherit; font-size: .9rem; line-height: 1; cursor: pointer;
}
.rich-btn:hover { background: #fff; border-color: var(--border); }
.rich-btn.on { background: var(--navy-soft); border-color: var(--primary); }
.rich-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.rich-btn svg { width: 17px; height: 17px; fill: currentColor; }
.rich-btn svg.stroke { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.rich-btn.rich-strong { font-weight: 700; }
.rich-btn.rich-em { font-style: italic; font-family: var(--serif); }
.rich-btn.rich-underline { text-decoration: underline; }
.rich-btn.rich-strike { text-decoration: line-through; }
.rich-sep { width: 1px; height: 20px; background: #d8d2c6; margin: 0 3px; }
.rich-toolbar select.rich-block {
  width: auto; margin: 0; padding: 3px 6px; height: 30px;
  font-size: .85rem; border-radius: 6px;
}
.rich-toolbar input[type=color].rich-colour {
  width: 30px; height: 30px; padding: 2px; margin: 0;
  border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer;
}
.rich-surface {
  min-height: 140px; padding: 10px 12px; outline: none;
  font-size: 1rem; line-height: 1.6; color: var(--text); overflow-wrap: anywhere;
}
.rich-surface:empty::before { content: attr(data-placeholder); color: #9a948a; }
.rich-source {
  width: 100%; min-height: 168px; margin: 0; padding: 10px 12px;
  border: none; border-radius: 0 0 8px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem; line-height: 1.5; resize: vertical;
}

/* ---------------- Email content editor ---------------- */
.mail-lang-tabs { display: flex; gap: 8px; margin: 4px 0 12px; }
.mail-placeholders { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 14px; }
.mail-placeholders code {
  background: var(--navy-soft); color: var(--navy-deep);
  border-radius: 5px; padding: 2px 6px; font-size: .78rem;
}
.mail-edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 24px; align-items: start; }
.mail-fields .field-block { margin-bottom: 6px; }
.mail-preview-col { position: sticky; top: 12px; }
.mail-preview-col h2 { margin-top: 0; }
.mail-preview-frame {
  width: 100%; height: 760px; border: 1px solid var(--border);
  border-radius: 10px; background: #f5f2ef;
}
@media (max-width: 1024px) {
  .mail-edit-grid { grid-template-columns: 1fr; }
  .mail-preview-col { position: static; }
  .mail-preview-frame { height: 520px; }
}

/* ---------------- Statistics ---------------- */
.stats-filters {
  display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end;
  padding: 16px 18px;
}
.stats-filters label {
  display: flex; flex-direction: column; gap: 4px; margin: 0;
  font-weight: 600; color: var(--navy-deep); min-width: 150px;
}
.stats-filters select { margin-top: 0; }
.stats-filter-actions { display: flex; gap: 8px; align-items: center; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 12px; margin: 16px 0 18px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 12px; padding: 12px 14px; }
.stat-card-label { font-size: .74rem; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stat-card-num { font-family: var(--serif); font-size: 1.9rem; line-height: 1.2; color: var(--navy-deep); font-weight: 700; }
.stat-card-sub { font-size: .78rem; color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.stat-chart-wide { grid-column: 1 / -1; }
.stat-chart-card h2 { margin-top: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.stat-chart-total { font-family: var(--sans); font-size: .78rem; font-weight: 400; color: var(--muted); }

.stat-bars { display: flex; flex-direction: column; gap: 7px; }
.stat-bar-row { display: grid; grid-template-columns: minmax(0, 30%) minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.stat-bar-label { font-size: .88rem; color: var(--text); line-height: 1.25; word-break: break-word; }
.stat-bar-label.is-blank { color: var(--muted); font-style: italic; }
.stat-bar-track { display: block; height: 16px; background: #eee9e0; border-radius: 8px; overflow: hidden; }
.stat-bar-fill { display: block; height: 100%; border-radius: 8px; min-width: 3px; transition: width .25s ease; }
.stat-bar-num { font-size: .9rem; font-weight: 700; color: var(--navy-deep); white-space: nowrap; }
.stat-bar-num em { font-style: normal; font-weight: 400; color: var(--muted); font-size: .8rem; }

.stat-trend { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 16px; border-bottom: 1px solid var(--border); }
.stat-trend-col { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.stat-trend-bar { width: 100%; max-width: 26px; background: var(--primary); border-radius: 3px 3px 0 0; }
.stat-trend-val { font-size: .68rem; color: var(--muted); }
.stat-trend-day { font-size: .62rem; color: var(--muted); height: 14px; white-space: nowrap; transform: rotate(0deg); }
.stat-footnote { margin-top: 12px; }
.stat-note { font-size: .78rem; margin: 10px 0 0; line-height: 1.5; }

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .stat-bar-row { grid-template-columns: minmax(0, 42%) minmax(0, 1fr) auto; gap: 6px; }
  .stat-card-num { font-size: 1.55rem; }
  .stats-filters { gap: 10px 12px; padding: 12px 14px; }
  .stats-filters label { min-width: 0; flex: 1 1 calc(50% - 6px); font-size: .92rem; }
  .stats-filters label select { font-size: .92rem; padding: 8px 10px; }
  .stats-filter-actions { flex: 1 1 100%; }
}

/* ---------------- Registration detail ---------------- */
.reg-detail-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 26px; }
.reg-detail-qr { text-align: center; }
.qr-img {
  width: 230px; height: 230px; max-width: 100%;
  border: 2px solid var(--accent); border-radius: 12px; padding: 8px; background: #fff;
  box-shadow: 0 4px 14px rgba(0, 38, 110, .12);
}
.regno-big {
  font-size: 1.15rem; letter-spacing: 1.5px; word-break: break-all;
  font-family: var(--serif); color: var(--navy-deep); background: var(--navy-soft);
  border-radius: 8px; padding: 6px 12px; display: inline-block;
}
.center { text-align: center; }
.muted { color: var(--muted); }
.reg-item {
  border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin: 14px 0;
  background: #fff; display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between;
  box-shadow: 0 2px 6px rgba(0, 38, 110, .05);
  transition: box-shadow .3s ease, transform .3s ease;
}
.reg-item:hover { box-shadow: 0 6px 18px rgba(0, 38, 110, .12); transform: translateY(-2px); }
.reg-main { flex: 2; min-width: 240px; }
.reg-actions { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

/* ---------------- Form blocks ---------------- */
.fblock { margin: 14px 0; animation: fadeUp .45s ease both; }
.fblock label { font-weight: 600; display: block; margin-bottom: 4px; color: var(--navy-deep); }
.block-heading { border-left: 5px solid var(--accent); padding-left: 12px; margin: 24px 0 8px; }
.block-notice {
  background: var(--accent-soft); border: 1px dashed #e2c069;
  padding: 12px 16px; border-radius: 8px; white-space: pre-line; color: #6b5410;
}
.existing-file { font-size: .9rem; color: var(--muted); margin: 4px 0; word-break: break-all; }
.privacy-note { font-size: .8rem; color: var(--muted); margin-top: 18px; }

/* ---------------- Scanner ---------------- */
.scan-layout { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; }
.camera-wrap {
  background: #101b2b; border-radius: 12px; min-height: 260px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  border: 3px solid var(--primary-dark);
}
.camera-wrap video { width: 100%; max-height: 420px; }
.scan-result { margin: 16px 0; padding: 16px; border-radius: 12px; border: 2px solid; word-break: break-word; animation: fadeUp .4s ease both; }
.scan-green { border-color: var(--ok); background: #eaf6ec; }
.scan-green h3 { color: #14531f; }
.scan-amber { border-color: var(--warn); background: #fdf6e3; }
.scan-red { border-color: var(--err); background: #fdecea; }
.scan-green, .scan-amber, .scan-red { font-weight: 700; }

/* Scan outcome popup: pinned to the top of the screen */
.scan-sheet {
  position: fixed; left: 0; right: 0; top: 0; z-index: 80;
  background: #fff; border-bottom: 5px solid var(--ok);
  border-radius: 0 0 18px 18px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 16px;
  box-shadow: 0 10px 34px rgba(0, 38, 110, .28);
  max-height: 62vh; overflow: auto;
  font-family: var(--sans);
}
.scan-sheet[hidden] { display: none !important; }
.scan-sheet[data-state=warn] { border-bottom-color: #d49a00; }
.scan-sheet[data-state=error] { border-bottom-color: var(--err); }
.scan-sheet-head { display: flex; align-items: center; gap: 10px; }
.scan-sheet-icon {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ok); color: #fff; font-size: 1.3rem; font-weight: 700; line-height: 1;
}
.scan-sheet[data-state=warn] .scan-sheet-icon { background: #d49a00; }
.scan-sheet[data-state=error] .scan-sheet-icon { background: var(--err); }
.scan-sheet-title { flex: 1 1 auto; font-family: var(--serif); font-size: 1.22rem; color: var(--navy-deep); }
.scan-sheet-close {
  flex: 0 0 auto; border: none; background: transparent; color: var(--muted);
  font-size: 1.6rem; line-height: 1; padding: 2px 6px; cursor: pointer;
}
.scan-sheet-rows { width: 100%; border-collapse: collapse; margin-top: 8px; }
.scan-sheet-rows th {
  text-align: left; width: 34%; padding: 5px 0; vertical-align: top;
  font-size: .74rem; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--muted);
}
.scan-sheet-rows td { padding: 5px 0; font-size: 1.06rem; font-weight: 700; color: var(--text); word-break: break-word; }
.scan-sheet-rows tr.scan-sheet-reg td { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .5px; }
.scan-sheet-rows tr.scan-sheet-time td { color: var(--primary); }
td.green { color: var(--ok); font-weight: 600; }
td.amber { color: var(--warn); font-weight: 600; }
td.red { color: var(--err); font-weight: 600; }

/* ---------------- Admin ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin: 14px 0; }
.stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 18px 16px; text-align: center;
  position: relative; overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 38, 110, .05);
  transition: transform .3s ease, box-shadow .3s ease;
  animation: fadeUp .5s ease both;
}
.stat-card:nth-child(2) { animation-delay: .07s; }
.stat-card:nth-child(3) { animation-delay: .14s; }
.stat-card:nth-child(4) { animation-delay: .21s; }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), #f1be48);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0, 38, 110, .14); }
.stat-num { font-size: 1.9rem; font-weight: 700; color: var(--navy-deep); font-family: var(--serif); }
.stat-label { color: var(--muted); font-size: .9rem; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; align-items: center; }
.filter-bar input[type=text] { flex: 1; min-width: 200px; width: auto; margin-top: 0; }
.filter-bar select { width: auto; margin-top: 0; }
.block-list { margin: 10px 0; }
.block-item {
  display: flex; gap: 12px; align-items: center; border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; margin: 8px 0; background: #fff; flex-wrap: wrap;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.block-item:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(0, 38, 110, .08); }
.block-main { flex: 1; min-width: 200px; }
.block-type { display: inline-block; background: var(--navy-soft); color: var(--navy-deep); border-radius: 20px; padding: 1px 10px; font-size: .78rem; margin-right: 8px; }
.block-edit { border: 1px dashed #c9c2b6; border-radius: 10px; padding: 12px; margin: -4px 0 10px 30px; background: #fbfaf7; }
.inline-edit { background: #fbfaf7; }
.notice-bar { background: var(--navy-soft); border: 1px solid #b3cfe8; border-radius: 10px; padding: 12px 16px; margin: 14px 0; color: #1c4a75; }
.danger-zone { border-color: #e5b6b1; background: #fffafa; }
.status-box { background: #f0f5ef; border: 1px solid #c5d9c8; border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
.error-box { background: #fdecea; padding: 10px; border-radius: 8px; white-space: pre-wrap; font-size: .85rem; }

/* ---------------- Dev mail ---------------- */
/* ---------------- Admin: people list ---------------- */
.people-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 6px 0 10px; }
.people-search { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.people-search input[type="search"] { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; min-width: 260px; }
.people-count { margin: 0; }
.table-scroll { overflow-x: auto; }
.people-table td { vertical-align: top; }
.people-table .nowrap { white-space: nowrap; }
.reg-lines { display: flex; flex-direction: column; gap: 4px; }
.reg-line { font-size: .92rem; line-height: 1.5; }
.reg-no { white-space: nowrap; font-weight: 600; }
.badge-confirmed { display: inline-block; background: var(--ok); color: #fff; padding: 1px 8px; border-radius: 20px; font-size: .78rem; }
.confirm-strip { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .88rem; }
.confirm-text { color: var(--danger); font-weight: 600; }
.btn-sm { padding: 5px 12px; font-size: .85rem; border-radius: 6px; }
.danger-zone { margin-top: 26px; border: 1px solid #e3b7b1; background: #fff9f8; }
.danger-zone h2 { margin-top: 0; color: var(--danger); }
.purge-form { max-width: 520px; }
.devmail-layout { display: grid; grid-template-columns: auto minmax(260px, 1fr); gap: 20px; }
.devmail-layout > * { min-width: 0; }
/* Mail log: columns size to their content; every value stays on one line inside its cell */
.devmail-list { overflow-x: auto; }
.devmail-list table { width: auto; }
.devmail-list th, .devmail-list td {
  padding: 8px 10px; font-size: .9rem;
  white-space: nowrap; word-break: normal; overflow-wrap: normal;
}
.mail-frame { width: 100%; height: 520px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

/* ---------------- Footer ---------------- */
.site-footer {
  margin-top: 50px; padding: 26px 0 30px;
  background: linear-gradient(135deg, var(--navy-deep), var(--primary-dark));
  border-top: 3px solid var(--accent);
  color: #cfdced; font-size: .88rem; text-align: center;
}
.site-footer p { margin: 4px 0; }

/* ---------------- Progress bar ---------------- */
.progress-bar { width: 120px; max-width: 100%; height: 12px; background: #e8e4dc; border-radius: 20px; overflow: hidden; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ok), #4cae6a, var(--ok));
  background-size: 200% 100%;
  animation: shimmer 2.2s linear infinite;
}

/* ================================================================
   RESPONSIVE — tablets (≤1024px)
   ================================================================ */
@media (max-width: 1024px) {
  .reg-detail-grid { grid-template-columns: 1fr; }
  .scan-layout { grid-template-columns: 1fr; }
  .devmail-layout { grid-template-columns: 1fr; }
  .camera-wrap video { max-height: 340px; }
}

/* ================================================================
   RESPONSIVE — phones (≤640px)
   ================================================================ */
@media (max-width: 640px) {
  .container { padding: 0 12px; }
  h1 { font-size: 1.45rem; }
  .hero { min-height: 460px; }
  .hero-inner { padding: 14px 16px 26px; }
  .hero h1 { font-size: 1.75rem; }
  .hero-kicker { letter-spacing: 2.5px; }
  .hero-fade { width: 12%; }
  .card { padding: 16px 14px; border-radius: 10px; }

  /* Header: brand row on top, nav + language switch wrap below */
  .header-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .brand { align-self: flex-start; }
  .main-nav { gap: 8px 14px; }
  .main-nav a { font-size: .9rem; }
  .lang-switch { margin-left: auto; }

  /* Buttons: full-width, 44px touch targets */
  .btn { min-height: 44px; display: flex; align-items: center; justify-content: center; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn { width: 100%; }
  .event-actions { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
  .event-actions .btn { width: 100%; }
  .reg-actions .btn { width: 100%; text-align: center; }
  .filter-bar input[type=text], .filter-bar select { width: 100%; flex: 1 1 100%; }

  /* Data tables scroll horizontally (finger-friendly) */
  .slots-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Detail (label/value) tables stack vertically */
  .info-table, .info-table tbody, .info-table tr, .info-table th, .info-table td {
    display: block; width: 100%; text-align: left;
  }
  .info-table th { border-bottom: none; }
  .info-table td { border-top: none; }

  /* Two-column stat cards */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-num { font-size: 1.5rem; }

  .slot-date { min-width: 0; flex: 1 1 100%; }
  .qr-img { width: 190px; height: 190px; }
  .block-edit { margin-left: 0; }
  .camera-wrap { min-height: 220px; }
  .mail-frame { height: 60vh; }
}

/* Reduced motion: respect users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ============================================================
   Activity log (admin) — who changed what, before -> after
   ============================================================ */
.log-intro { max-width: 78ch; margin-top: -4px; }
.log-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 8px; }
.log-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: #fff; color: var(--primary); text-decoration: none; font-size: .92rem;
}
.log-tab:hover { border-color: var(--primary); background: var(--navy-soft); }
.log-tab.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.log-tab-n { background: rgba(0,0,0,.08); border-radius: 999px; padding: 0 7px; font-size: .8rem; font-weight: 700; }
.log-tab.is-active .log-tab-n { background: rgba(255,255,255,.22); }
.log-tab-csv { margin-left: auto; }
.log-stats { margin: 4px 0 12px; font-size: .9rem; }
.log-alert { color: var(--err); }
.log-filter {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin: 0 0 12px;
}
.log-filter label { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; color: var(--muted); }
.log-filter input, .log-filter select {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: .9rem; background: #fff; color: var(--text);
}
.log-filter-q input { min-width: 240px; }
.log-count { font-size: .88rem; margin: 0 0 10px; }
.log-table td, .log-table th { vertical-align: top; }
.log-col-time { width: 150px; }
.log-type { display: inline-block; margin-left: 6px; font-size: .72rem; color: var(--muted); }
.log-entity { font-weight: 600; color: var(--navy-deep); }
.log-entity-name { display: block; font-size: .86rem; color: var(--text); }
.log-ip { font-size: .8rem; }
.log-ua { font-size: .76rem; max-width: 260px; overflow-wrap: anywhere; }
.log-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; overflow-wrap: anywhere; }
.log-action { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .8rem; font-weight: 600; background: var(--navy-soft); color: var(--primary); white-space: nowrap; }
.log-action-create { background: #e8f5ec; color: var(--ok); }
.log-action-update { background: var(--navy-soft); color: var(--primary); }
.log-action-delete, .log-action-purge { background: #fdecea; color: var(--err); }
.log-action-login, .log-action-logout { background: #eef0f4; color: #45536b; }
.log-action-login-failed { background: #fdecea; color: var(--err); }
.log-action-scan, .log-action-scan-undo, .log-action-scan-duplicate { background: var(--accent-soft); color: var(--warn); }
.log-diff > summary { cursor: pointer; list-style: none; }
.log-diff > summary::-webkit-details-marker { display: none; }
.log-diff > summary::before { content: '▸'; display: inline-block; margin-right: 6px; color: var(--muted); transition: transform .15s; }
.log-diff[open] > summary::before { transform: rotate(90deg); }
.log-diff-open { margin-left: 6px; font-size: .78rem; color: var(--primary); text-decoration: underline; }
.log-diff[open] .log-diff-open { display: none; }
.log-diff-table { width: 100%; border-collapse: collapse; margin-top: 8px; table-layout: fixed; }
.log-diff-table th, .log-diff-table td {
  border: 1px solid var(--border); padding: 6px 8px; text-align: left;
  vertical-align: top; font-size: .84rem; white-space: pre-wrap; overflow-wrap: anywhere;
}
.log-diff-table th { background: #f7f7f4; font-weight: 600; }
.log-diff-table .log-field { width: 22%; font-weight: 600; color: var(--navy-deep); }
.log-diff-table .log-before { width: 39%; background: #fdf4f3; }
.log-diff-table .log-after { width: 39%; background: #f2faf4; }
.log-diff-full { margin: 8px 0 0; }
.log-diff-full .log-before, .log-diff-full .log-after { font-size: .88rem; }
.log-pager { display: flex; align-items: center; gap: 12px; justify-content: center; margin: 16px 0 8px; }
.log-back { margin: 0 0 4px; }
.log-detail-card { margin-bottom: 16px; }
.log-info th { width: 190px; }
.log-raw { margin-top: 16px; }
.log-raw > summary { cursor: pointer; color: var(--primary); }
.log-raw-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin-top: 10px; }
.log-raw pre {
  background: #f7f7f4; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: .78rem; line-height: 1.45; max-height: 420px;
  overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
}
@media (max-width: 640px) {
  .log-filter { flex-direction: column; align-items: stretch; }
  .log-filter input, .log-filter select { width: 100%; }
  .log-filter-q input { min-width: 0; }
  .log-tab-csv { margin-left: 0; }
  .log-diff-table .log-field, .log-diff-table .log-before, .log-diff-table .log-after { width: auto; }
}

/* Public event page: the details-box toggle is the first row of the event form,
   shaded so it is never missed. */
.details-toggle {
  background: var(--navy-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 2px 0 10px;
  align-items: flex-start;
  line-height: 1.45;
}
.details-toggle input { margin-top: 3px; }
.details-toggle strong { color: var(--navy-deep); }

/* Visitors page: "Delete all" sits in the toolbar, with its own confirm strip */
.people-delete-all { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.people-delete-all .confirm-strip { margin: 0; }
.people-delete-all .confirm-text { font-size: .86rem; }
