:root {
  --primary: #0f4c81;
  --primary-dark: #0b3a63;
  --accent: #f5a623;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1f2d3d;
  --muted: #6b7a90;
  --border: #e1e7ef;
  --success-bg: #e6f6ec; --success-fg: #1c7a43;
  --error-bg: #fdeaea;   --error-fg: #b3261e;
  --warn-bg: #fff6e5;    --warn-fg: #97631a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16,38,73,.08), 0 1px 2px rgba(16,38,73,.06);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--primary); color: #fff; padding: .6rem 1.2rem;
}
.topbar a { color: #fff; }
.brand a { font-weight: 700; font-size: 1.1rem; }
.edition-pill {
  background: rgba(255,255,255,.18); padding: .1rem .55rem; border-radius: 999px;
  font-size: .78rem; margin-left: .5rem;
}
.mainnav { display: flex; gap: .25rem; margin-left: auto; flex-wrap: wrap; align-items: center; }
.mainnav a {
  font-size: .875rem; font-weight: 500; letter-spacing: .01em;
  padding: .38rem .95rem; border-radius: 999px; opacity: .82;
  transition: background .18s ease, opacity .18s ease;
}
.mainnav a:hover { background: rgba(255,255,255,.14); opacity: 1; text-decoration: none; }
.mainnav a.active { background: rgba(255,255,255,.2); opacity: 1; font-weight: 600; }
.userbox {
  display: flex; align-items: center; gap: .65rem; font-size: .88rem;
  padding-left: .9rem; border-left: 1px solid rgba(255,255,255,.2);
}
.uname { opacity: .85; }
.nav-signout {
  font-size: .82rem; padding: .3rem .75rem; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.3); opacity: .85;
  transition: background .18s ease, opacity .18s ease;
}
.nav-signout:hover { background: rgba(255,255,255,.12); opacity: 1; text-decoration: none; }
.sync-status { color: #8ee6a8; font-size: 1.1rem; line-height: 1; }
.sync-status.pending { color: var(--accent); }

/* ---------- Layout ---------- */
.container { max-width: 1040px; margin: 1.5rem auto; padding: 0 1.2rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.5rem; margin: 0; }
.muted { color: var(--muted); }

/* ---------- Cards & grids ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

.stat { text-align: center; }
.stat .num { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat .lbl { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Forms ---------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .9rem; }
.field .req { color: var(--error-fg); }
input[type=text], input[type=email], input[type=tel], input[type=password],
input[type=number], input[type=date], select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid var(--border);
  border-radius: 8px; font: inherit; background: #fff;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
.row { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
.row.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 640px) { .row, .row.three { grid-template-columns: 1fr; } }
.help { color: var(--muted); font-size: .82rem; margin-top: .2rem; }

.btn {
  display: inline-block; background: var(--primary); color: #fff; border: 0;
  padding: .6rem 1.1rem; border-radius: 8px; font: inherit; font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn.small { padding: .35rem .7rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--border); }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr:hover td { background: #fafbfd; }

/* On narrow screens, let wide tables scroll sideways inside their card
   instead of overflowing the page (keeps all columns reachable). */
@media screen and (max-width: 720px) {
  .card table {
    display: block; width: 100%;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .card table th, .card table td { padding: .55rem .6rem; }
}
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge.group   { background: #e8f0fb; color: var(--primary); }
.badge.solo    { background: #eef7ee; color: #2f7d32; }
.badge.visitor { background: #fdf0e6; color: #b5651d; }
.badge.pending { background: var(--warn-bg); color: var(--warn-fg); }

/* ---------- Flash & banners ---------- */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-success { background: var(--success-bg); color: var(--success-fg); }
.flash-error   { background: var(--error-bg); color: var(--error-fg); }
.flash-warn    { background: var(--warn-bg); color: var(--warn-fg); }
.offline-banner { background: var(--warn-bg); color: var(--warn-fg); padding: .6rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }

/* ---------- Auth ---------- */
.auth-wrap { max-width: 380px; margin: 6vh auto; }
.auth-wrap .card { padding: 1.6rem; }
.auth-wrap h1 { margin-top: 0; }

/* ---------- Login page (centered, branded) ---------- */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.2rem 2rem 1.8rem;
  box-shadow: 0 24px 60px rgba(16, 38, 73, .18);
  animation: fadeInUp .5s cubic-bezier(.2,.7,.3,1) both;
}
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-logo {
  width: 66px; height: 66px; margin: 0 auto .9rem;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 1.05rem; letter-spacing: .04em;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--primary), #1466a8 70%, var(--accent));
  box-shadow: 0 10px 24px rgba(15, 76, 129, .35);
}
.login-card h1 { margin: 0; font-size: 1.55rem; letter-spacing: -.01em; }
.login-sub { margin: .25rem 0 0; color: var(--muted); font-size: .95rem; }
.login-form { margin-top: .5rem; }
.btn-block { width: 100%; padding: .7rem 1rem; font-size: 1rem; margin-top: .3rem; }
.login-foot {
  text-align: center; color: var(--muted);
  font-size: .78rem; letter-spacing: .04em; text-transform: uppercase;
  margin: 1.4rem 0 0; padding-top: 1rem; border-top: 1px solid var(--border);
}
.demo-note {
  background: var(--warn-bg); color: var(--warn-fg);
  border: 1px solid #f0d9a8; border-radius: 10px;
  padding: .7rem .85rem; margin-bottom: 1rem; font-size: .85rem; line-height: 1.5;
}
.demo-note strong { display: block; margin-bottom: .15rem; }
.demo-note code {
  background: rgba(0,0,0,.06); padding: .05rem .35rem; border-radius: 5px;
  font-size: .85rem;
}

/* ---------- Register category picker ---------- */
.cat-picker { display: grid; gap: 1rem; grid-template-columns: repeat(3,1fr); }
@media (max-width: 720px){ .cat-picker { grid-template-columns: 1fr; } }
.cat-card { display: block; border: 2px solid var(--border); border-radius: var(--radius); padding: 1.1rem; cursor: pointer; background: #fff; }
.cat-card:hover { border-color: var(--primary); text-decoration: none; }
.cat-card h3 { margin: 0 0 .3rem; color: var(--primary); }
.cat-card p { margin: 0; color: var(--muted); font-size: .88rem; }

.reg-success { text-align:center; padding: 1.5rem; }
.reg-success .regno { font-size: 2rem; font-weight: 800; letter-spacing: .04em; color: var(--primary); margin: .4rem 0; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing:.04em; color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom:.3rem; margin: 1.4rem 0 .8rem; }
.inline-actions { display:flex; gap:.5rem; flex-wrap: wrap; }
.toolbar { display:flex; gap:.6rem; align-items:center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input[type=text]{ max-width: 320px; }

/* ---------- Returning-attendee lookup ---------- */
.lookup { position: relative; }
.lookup-results {
  position: absolute; z-index: 20; left: 0; right: 0; top: 100%;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); max-height: 300px; overflow-y: auto; margin-top: 2px;
}
.lookup-item { padding: .5rem .7rem; cursor: pointer; border-bottom: 1px solid var(--border); }
.lookup-item:last-child { border-bottom: 0; }
.lookup-item:hover, .lookup-item.active { background: #eef2f8; }
.lookup-item .li-name { font-weight: 600; }
.lookup-item .li-meta { font-size: .8rem; color: var(--muted); }
.lookup-empty { padding: .6rem .7rem; color: var(--muted); font-size: .88rem; }
.linked-pill { background: var(--success-bg); color: var(--success-fg); padding: .3rem .6rem; border-radius: 8px; display: inline-flex; gap: .5rem; align-items: center; }
.linked-pill button { background: none; border: 0; color: var(--success-fg); cursor: pointer; font-weight: 700; font-size: 1rem; line-height: 1; }

/* ---------- Searchable select (combobox) ---------- */
.ss { position: relative; }
.ss-input { width: 100%; padding: .55rem 2rem .55rem .65rem; }
.ss-caret { position: absolute; right: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: auto; cursor: pointer; font-size: .8rem; transition: transform .2s ease; }
.ss.open .ss-caret { transform: translateY(-50%) rotate(180deg); }
.ss-panel {
  position: absolute; z-index: 30; left: 0; right: 0; top: 100%;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16,38,73,.14); max-height: 280px; overflow-y: auto; margin-top: 4px;
  transform-origin: top center; animation: ssDrop .16s ease;
}
.ss-item { padding: .55rem .75rem; cursor: pointer; transition: background .12s ease; }
.ss-item + .ss-item { border-top: 1px solid var(--border); }
.ss-item:hover, .ss-item.active { background: #eef3fa; }
.ss-add { color: var(--primary); font-weight: 600; }
@keyframes ssDrop { from { opacity: 0; transform: translateY(-6px) scaleY(.96); } to { opacity: 1; transform: none; } }

/* =====================================================================
   Visual polish & animations
   ===================================================================== */
body {
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(15,76,129,.06), transparent 60%),
    radial-gradient(900px 400px at -10% 0%, rgba(245,166,35,.06), transparent 55%),
    var(--bg);
  min-height: 100vh;
}

/* Top bar with gradient + depth */
.topbar {
  background: linear-gradient(100deg, var(--primary-dark), var(--primary) 60%, #1466a8);
  box-shadow: 0 2px 12px rgba(11,58,99,.25);
  position: sticky; top: 0; z-index: 50;
}
.brand a { transition: opacity .2s ease; }
.brand a:hover { opacity: .85; }
.edition-pill { backdrop-filter: blur(2px); }

/* Active nav item: accent dot below the pill */
.mainnav a { position: relative; }
.mainnav a.active::after {
  content: ""; position: absolute; left: 50%; bottom: 2px;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent); transform: translateX(-50%);
}

/* Sync dot pulse when pending */
.sync-status.pending { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* Buttons: smooth hover lift + press */
.btn {
  transition: background .18s ease, transform .12s ease, box-shadow .18s ease;
  box-shadow: 0 1px 2px rgba(15,76,129,.18);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(15,76,129,.25); }
.btn:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(15,76,129,.18); }
.btn.ghost, .btn.secondary { box-shadow: none; }
.btn.ghost:hover, .btn.secondary:hover { box-shadow: 0 3px 10px rgba(16,38,73,.12); }

/* Inputs: smooth focus */
input[type=text], input[type=email], input[type=tel], input[type=password],
input[type=number], input[type=date], select, textarea {
  transition: border-color .18s ease, box-shadow .18s ease;
}
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 4px rgba(15,76,129,.12); }

/* Cards: entrance + hover lift on interactive ones */
.card { transition: transform .2s ease, box-shadow .2s ease; }
.card.stat:hover, .cat-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(16,38,73,.12); }
.cat-card { transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }

/* Table rows hover */
tbody tr { transition: background .12s ease; }

/* Stat numbers */
.stat .num { transition: color .2s ease; }

/* ---------- Entrance animations ---------- */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes flashIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.page-head { animation: fadeIn .35s ease both; }
.container > .card,
.container > form,
.container > .toolbar,
.grid > .card,
.cat-picker > .cat-card { animation: fadeInUp .45s cubic-bezier(.2,.7,.3,1) both; }

/* Stagger grid items */
.grid > .card:nth-child(1), .cat-picker > .cat-card:nth-child(1) { animation-delay: .03s; }
.grid > .card:nth-child(2), .cat-picker > .cat-card:nth-child(2) { animation-delay: .09s; }
.grid > .card:nth-child(3), .cat-picker > .cat-card:nth-child(3) { animation-delay: .15s; }
.grid > .card:nth-child(4) { animation-delay: .21s; }

.flash { animation: flashIn .3s ease both; }

/* Auth card pop */
.auth-wrap .card { animation: fadeInUp .5s cubic-bezier(.2,.7,.3,1) both; }

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