/* ==========================================================================
   UAEERF Declarations – components on top of the Live Results theme (site.css).
   Uses site.css tokens only; add-on status colours are defined below.
   ========================================================================== */
:root {
    --ok: #1f7a46; --ok-soft: #e1f3e8;
    --warn: #8a5a00; --warn-soft: #fbf1d9;
    --danger: #b42318; --danger-soft: #fde7e5;
    --info: #2f3237; --info-soft: #eef0f2;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ok: #5cc98a; --ok-soft: #173325; --warn: #e2c068; --warn-soft: #2e2919;
        --danger: #ff8a7a; --danger-soft: #3a1a17; --info: #d6d8dc; --info-soft: #2a2c30;
    }
}
:root[data-theme="dark"] {
    --ok: #5cc98a; --ok-soft: #173325; --warn: #e2c068; --warn-soft: #2e2919;
    --danger: #ff8a7a; --danger-soft: #3a1a17; --info: #d6d8dc; --info-soft: #2a2c30;
}

body { font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.small { font-size: .82rem; }

/* ---------- App bar additions ---------- */
/* Transparent logo (emblem + white "UAEERF") on the dark bar; a hairline light edge keeps the black ribbon visible. */
.brand__logo { height: 40px; width: auto; filter: drop-shadow(0 0 .6px rgba(255,255,255,.7)); }
.brand__text strong { display: none; } /* the logo already says UAEERF */
.brand__text { padding-inline-start: 10px; border-inline-start: 1px solid rgba(212,175,79,.45); }
.topnav a { white-space: nowrap; }
@media (min-width: 900px) and (max-width: 1199px) {
    .topnav a { padding: 8px 10px; }
    .topnav a[href^="mailto:"], .usermenu__name { display: none; }
}
.brand { flex: none; }
/* The logo already reads "UAEERF"; drop the text label when the full nav is shown. */
/* Subtitle only where there is room. */
@media (max-width: 560px) { .brand__text { display: none; } }
.appbar__tools { display: flex; align-items: center; gap: 4px; margin-inline-start: auto; }
@media (min-width: 900px) { .topnav + .appbar__tools { margin-inline-start: 6px; } } /* the nav is hidden on phones; keep tools right-aligned there */
.appbar__tools .theme-toggle { margin: 0; }
.appbar__btn, .usermenu summary {
    display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px;
    border-radius: 999px; color: #fff; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
    border: 1px solid rgba(212, 175, 79, .4); background: transparent;
}
.appbar__btn:hover, .usermenu summary:hover { background: rgba(255,255,255,.12); color: #fff; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary i { color: #f1d78a; font-size: 1.1rem; }
.usermenu__name { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu__panel {
    position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 220px; z-index: 60;
    background: var(--surface); color: var(--text); border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 6px;
}
.usermenu__who { padding: 8px 10px; font-weight: 700; border-bottom: 1px solid var(--line-soft); margin-bottom: 4px; }
.usermenu__item { width: 100%; display: flex; gap: 8px; align-items: center; padding: 10px; border: 0; background: none; color: inherit; font: inherit; border-radius: 8px; cursor: pointer; text-align: start; }
.usermenu__item:hover { background: var(--surface-2); }
@media (max-width: 899px) { .usermenu__name { display: none; } }

/* Announcement strip (vision18_logos.main) */
.strip { background: var(--gold-soft); border-bottom: 1px solid var(--line-soft); color: var(--text); font-size: .88rem; }
.strip__inner { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; min-height: 40px; padding-block: 8px; }
.strip i { color: var(--gold); }
.strip__date { color: var(--gold); font-weight: 600; }

/* ---------- Page head ---------- */
.page-head .facts { margin-top: 8px; }
.sponsor { display: block; flex: none; }
.sponsor img, img.sponsor { display: block; max-height: 96px; max-width: 220px; object-fit: contain; background: #fff; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 6px; }
@media (max-width: 899px) { .page-head { flex-direction: column-reverse; } .sponsor img, img.sponsor { max-height: 64px; } }

/* ---------- Buttons ---------- */
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line-soft); }
.btn--outline { color: var(--gold); border-color: var(--gold-bright); background: var(--surface); }
.btn--outline:hover { background: var(--gold-soft); color: var(--gold); }
.btn--block { width: 100%; }
.btn--lg { min-height: 50px; font-size: 1rem; }
a.btn--primary:hover { color: #f1d78a; }

/* ---------- Event cards ---------- */
.event { overflow: hidden; }
.event__main { display: flex; gap: 14px; padding: 14px; }
.event__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.event__name { font-weight: 700; font-size: 1.02rem; }
.event__actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 0 14px 14px; }
.event__actions .btn { min-width: 0; white-space: nowrap; }
@media (max-width: 400px) { .event__actions .btn { padding: 0 8px; gap: 6px; font-size: .86rem; } }
@media (min-width: 900px) {
    .eventlist { grid-template-columns: 1fr; }
    .event__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; padding: 0 14px 14px; padding-inline-start: 82px; }
    .event__actions .btn { min-width: 150px; }
}

/* ---------- Stats (declared per class) ---------- */
.stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin: 0 0 6px; }
.stat strong { color: var(--gold); font-variant-numeric: tabular-nums; }

/* ---------- Toolbar & search ---------- */
.toolbar .search { flex: 1 1 260px; max-width: 420px; margin-bottom: 0; }

/* ---------- Badges, tags ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--gold { background: var(--gold-soft); color: var(--gold); border: 1px solid var(--line-soft); }
.badge--muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-soft); font-size: .78rem; font-weight: 600; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius-sm); padding: 12px 16px; margin: 16px 0; border: 1px solid var(--line-soft); border-inline-start: 4px solid; }
.alert p { margin-top: 4px; }
.alert--warn { background: var(--warn-soft); border-inline-start-color: var(--gold-bright); }
.alert--warn strong { color: var(--warn); }
.alert--info { background: var(--info-soft); border-inline-start-color: var(--primary); }
.alert--danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

/* ---------- Tables (stack into cards on phones) ---------- */
.tablewrap { overflow-x: auto; margin-top: 10px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: start; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gold); background: var(--surface-2); padding: 12px 14px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:nth-child(even) td { background: var(--surface-2); }
.who { display: flex; flex-direction: column; gap: 2px; }
.who small { color: var(--gold); font-weight: 600; font-size: .76rem; }
.who strong i { color: var(--gold); }
.who--photo { flex-direction: row; align-items: center; gap: 10px; }
.who--photo img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--surface-2); border: 1px solid var(--line-soft); flex: none; }
.who--photo > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

@media (max-width: 760px) {
    .table--cards thead { display: none; }
    .table--cards, .table--cards tbody, .table--cards tr, .table--cards td { display: block; width: 100%; }
    .table--cards tr { padding: 6px 14px; border-bottom: 8px solid var(--bg); }
    .table--cards tbody tr:nth-child(even) td { background: none; }
    .table--cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); text-align: end; }
    .table--cards td:last-child { border-bottom: 0; }
    .table--cards td::before { content: attr(data-label); flex: none; max-width: 45%; text-align: start; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--gold); }
    .table--cards .who { align-items: flex-end; }
    .table--cards .who--photo { flex-direction: row-reverse; }
    .table--cards .who--photo > div { align-items: flex-end; }
    .table--cards .cell-actions { justify-content: flex-end; }
}

/* ---------- Documents ---------- */
.docs--page { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.doc { transition: border-color .12s; }
.doc span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.doc .bi-download { color: var(--gold); font-size: 1rem; }

/* ---------- Login ---------- */
.login { display: grid; gap: 20px; padding-top: 8px; }
.login__logo { display: block; width: min(320px, 80%); height: auto; background: #fff; border-radius: var(--radius); padding: 10px; border: 1px solid var(--line-soft); margin-bottom: 18px; }
.login__intro p { color: var(--muted); max-width: 54ch; margin-top: 10px; }
.login__card { padding: 22px; border-top: 3px solid var(--gold-bright); }
.login__card h2 { display: flex; align-items: center; gap: 8px; font-size: 1.15rem; font-weight: 800; margin-bottom: 14px; }
.login__card h2 i { color: var(--gold); }
.form { display: grid; gap: 14px; }
.loginwith { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.loginwith legend { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); margin-bottom: 6px; padding: 0; }
.loginwith label { position: relative; }
.loginwith input { position: absolute; inset: 0; opacity: 0; }
.loginwith span { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--surface-2); font-weight: 600; font-size: .9rem; cursor: pointer; }
.loginwith input:checked + span { background: linear-gradient(180deg, #3d4045, #26282c); color: #f1d78a; border-color: var(--gold-bright); box-shadow: inset 0 -2px 0 var(--gold-bright); }
.loginwith input:focus-visible + span { outline: 3px solid var(--gold-bright); outline-offset: 2px; }
.field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; }
.field__control { position: relative; display: flex; align-items: center; }
.field__control i { position: absolute; inset-inline-start: 14px; color: var(--gold); pointer-events: none; }
.field__control input { width: 100%; min-height: 46px; padding-inline: 40px 12px; border-radius: 12px; border: 1px solid var(--line-soft); background: var(--surface); color: var(--text); font: inherit; font-size: 16px; }
.field__control input:focus { outline: none; border-color: var(--line); box-shadow: 0 0 0 3px var(--primary-soft); }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.check input { accent-color: var(--gold-bright); width: 18px; height: 18px; }
@media (min-width: 900px) { .login { grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: start; padding-top: 24px; } }

/* ---------- Confirm dialog ---------- */
.dialog { border: 1px solid var(--line-soft); border-top: 3px solid var(--gold-bright); border-radius: var(--radius); padding: 0; width: min(440px, calc(100% - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.dialog::backdrop { background: rgba(10,10,12,.6); }
.dialog form { padding: 22px; }
.dialog__title { font-size: 1.12rem; font-weight: 800; margin-bottom: 8px; }
.dialog__text { color: var(--muted); }
.dialog__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.dialog__actions [value="cancel"] { margin-inline-start: auto; }

/* ---------- Loader ---------- */
.loader { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 60%, transparent); }
.loader span { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--gold-soft); border-top-color: var(--gold-bright); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }



/* ==========================================================================
   Declaration page – quiet list + bottom sheet (mobile-first)
   ========================================================================== */
.dl { max-width: 640px; }

.dl-summary { margin: 4px 0 18px; }
.dl-summary p { color: var(--muted); font-size: .92rem; margin-bottom: 8px; }
.dl-summary strong { color: var(--text); font-weight: 700; }
.dl-meter { height: 4px; border-radius: 4px; background: var(--border); overflow: hidden; }
.dl-meter span { display: block; height: 100%; border-radius: inherit; background: var(--gold-bright); transition: width .4s ease; }

.dl-section { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 22px 4px 8px; }

.dl-group { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.dl-group > li + li { border-top: 1px solid var(--border); }
.dl-row { width: 100%; display: flex; align-items: center; gap: 14px; min-height: 68px; padding: 12px 16px;
    background: none; border: 0; color: var(--text); font: inherit; text-align: start; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.dl-row:hover { background: var(--surface-2); }
.dl-row:active { background: var(--surface-2); }
.dl-row__mark { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
    background: var(--surface-2); color: var(--muted); font-weight: 700; font-size: .95rem; border: 1px solid var(--border); }
.dl-row.is-declared .dl-row__mark { background: var(--ok-soft); color: var(--ok); border-color: transparent; font-size: 1.1rem; }
.dl-row__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dl-row__text strong { font-weight: 600; font-size: 1rem; overflow-wrap: anywhere; }
.dl-row__text small { color: var(--muted); font-size: .84rem; }
.dl-row__text small.dl-ok { color: var(--ok); }
.dl-row__chev { color: var(--muted); opacity: .6; font-size: .9rem; }

/* Bottom sheet (phones) / centred panel (desktop) */
.dl-sheet { border: 0; padding: 0; background: var(--surface); color: var(--text);
    width: min(520px, calc(100% - 32px)); max-height: min(86vh, 760px); border-radius: 18px;
    box-shadow: 0 24px 64px rgba(0,0,0,.28); overflow: hidden; transition: transform .15s ease; }
.dl-sheet[open] { display: flex; flex-direction: column; }
.dl-sheet::backdrop { background: rgba(12,12,14,.45); }
.dl-sheet__grip { display: none; }
.dl-sheet__close { position: absolute; top: 12px; inset-inline-end: 12px; width: 36px; height: 36px; border-radius: 50%;
    border: 0; background: var(--surface-2); color: var(--muted); cursor: pointer; display: grid; place-items: center; z-index: 1; }
.dl-sheet__body { overflow-y: auto; padding: 22px 20px 20px; overscroll-behavior: contain; }
.dl-sheet__head { padding-inline-end: 44px; margin-bottom: 18px; }
.dl-sheet__head h2 { font-size: 1.25rem; font-weight: 700; }
.dl-sheet__head p { color: var(--muted); font-size: .88rem; margin-top: 4px; }
.dl-sheet__label { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }

.dl-options { display: grid; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.dl-opt { position: relative; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 12px 14px; background: var(--surface); }
.dl-opt + .dl-opt { border-top: 1px solid var(--border); }
.dl-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.dl-opt__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dl-opt__text strong { font-weight: 600; font-size: .98rem; }
.dl-opt__text small { color: var(--muted); font-size: .82rem; }
.dl-opt__radio { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); transition: border-color .12s, box-shadow .12s; }
label.dl-opt { cursor: pointer; }
label.dl-opt:hover { background: var(--surface-2); }
.dl-opt:has(input:checked) { background: var(--surface-2); }
.dl-opt:has(input:checked) .dl-opt__radio { border-color: var(--gold-bright); box-shadow: inset 0 0 0 5px var(--gold-bright); }
.dl-opt:has(input:focus-visible) { outline: 2px solid var(--gold-bright); outline-offset: -2px; }
.dl-opt.is-declared i { color: var(--ok); font-size: 1.15rem; }
.dl-opt.is-declared small { color: var(--ok); }
.dl-opt.is-locked { background: var(--surface-2); }
.dl-opt.is-locked strong { color: var(--muted); font-weight: 500; }
.dl-opt.is-locked i { color: var(--muted); opacity: .7; }

.dl-qualify { display: flex; align-items: flex-start; gap: 12px; margin-top: 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; cursor: pointer; }
.dl-qualify input { flex: none; width: 20px; height: 20px; margin-top: 2px; accent-color: var(--gold-bright); }
.dl-qualify span { display: flex; flex-direction: column; gap: 2px; }
.dl-qualify strong { font-weight: 600; font-size: .95rem; }
.dl-qualify small { color: var(--muted); font-size: .82rem; }

.dl-error { margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: .88rem; }
.dl-submit { width: 100%; min-height: 52px; margin-top: 18px; font-size: 1rem; border-radius: 14px; }
.dl-submit:disabled { opacity: 1; background: var(--surface-2); color: var(--muted); border-color: var(--border); box-shadow: none; }
.dl-fine { margin-top: 12px; text-align: center; color: var(--muted); font-size: .8rem; }

@media (max-width: 640px) {
    .dl-sheet { width: 100%; max-width: 100%; max-height: 88vh; margin: auto 0 0; border-radius: 20px 20px 0 0; }
    .dl-sheet[open] { animation: dl-up .24s cubic-bezier(.2,.8,.2,1); }
    .dl-sheet__grip { display: block; flex: none; width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 10px auto 0; }
    .dl-sheet__close { top: 18px; }
    .dl-sheet__body { padding: 14px 18px calc(18px + env(safe-area-inset-bottom)); }
}
@keyframes dl-up { from { transform: translateY(100%); } }

/* Toast */
.dl-toast { position: fixed; inset-inline: 16px; bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom)); z-index: 70;
    margin: 0 auto; max-width: 420px; display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-radius: 14px;
    background: var(--text); color: var(--bg); font-weight: 500; font-size: .92rem; box-shadow: 0 10px 30px rgba(0,0,0,.2);
    opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.dl-toast i { color: #5cc98a; }
.dl-toast.is-in { opacity: 1; transform: none; }
@media (min-width: 900px) { .dl-toast { bottom: 24px; } }
@media (prefers-reduced-motion: reduce) { .dl-sheet[open] { animation: none; } .dl-toast, .dl-sheet { transition: none; } }

/* Declaration page on phones: compact header so the horse list is visible straight away */
@media (max-width: 640px) {
    .main:has(.dl) { padding-top: 8px; }
    .main:has(.dl) .page-head { margin-bottom: 4px; gap: 0; }
    .main:has(.dl) .page-head .sponsor, .main:has(.dl) .page-head .eyebrow { display: none; }
    .main:has(.dl) .page-head h1 { font-size: 1.2rem; }
    .main:has(.dl) .page-head .facts { margin-top: 6px; }
    .main:has(.dl) .page-head .facts > span { border: 0; background: none; padding: 0; margin-inline-end: 10px; }
    .strip { font-size: .8rem; }
    .strip__inner { min-height: 0; padding-block: 6px; gap: 2px 8px; }
}
