/* SIGLAKAS - shared styles (on top of Bootstrap 5) */
:root {
    --brand: #0c2e68;
    --brand-dark: #061a3d;
    --brand-soft: #eff6ff;
    --brand-gradient: linear-gradient(135deg, #0c2e68 0%, #1e40af 100%);
    --gold: #f59e0b;
    --gold-dark: #d97706;
    --gold-soft: #fef3c7;
    --forest: #166534;
    --ink: #0f172a;
    --muted: #64748b;
    --bg: #f8fafc;
    --card: rgba(255, 255, 255, 0.94);
    --line: rgba(226, 232, 240, 0.9);
}

body {
    background: linear-gradient(135deg, rgba(244, 247, 252, 0.93) 0%, rgba(235, 241, 250, 0.95) 100%),
                url('../../images/login-bg.jpg') center center / cover no-repeat fixed;
    color: var(--ink);
    min-height: 100vh;
}
.page { max-width: 1180px; margin: 0 auto; padding: 20px 16px 52px; }
.page-wide { max-width: none; }
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -.2px; color: #0f172a; }
.page-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-title h2, .page-title h3 { margin: 0; font-weight: 800; }

/* ---------- top navigation ---------- */
.app-nav {
    background: linear-gradient(90deg, #071938 0%, #0c2e68 55%, #15428a 100%);
    box-shadow: 0 4px 20px rgba(7, 25, 56, 0.15);
    border-bottom: 3px solid #f59e0b;
    padding-top: 8px;
    padding-bottom: 8px;
}
.app-nav .navbar-brand { color: #fff; font-weight: 800; letter-spacing: .8px; font-size: 1.15rem; }
.app-nav .navbar-brand small {
    background: rgba(245, 158, 11, 0.22);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
    letter-spacing: 0;
    font-size: .72rem;
    margin-left: 6px;
}
.app-nav .nav-link {
    color: rgba(255, 255, 255, .88);
    font-weight: 500;
    padding: 7px 14px !important;
    border-radius: 8px;
    transition: all .2s ease;
}
.app-nav .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}
.app-nav .nav-link.active {
    color: #fbbf24 !important;
    background: rgba(245, 158, 11, 0.2);
    font-weight: 700;
}
.app-nav .user-chip {
    color: rgba(255, 255, 255, .8) !important;
    font-size: .85rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 5px 12px !important;
}
.app-nav .navbar-toggler { border-color: rgba(255, 255, 255, .4); }
.app-nav .navbar-toggler-icon { filter: invert(1); }

/* ---------- admin layout ---------- */
.admin-wrap { display: flex; min-height: 100vh; }
.admin-side {
    width: 240px;
    flex: 0 0 240px;
    background: linear-gradient(180deg, #071938 0%, #0c2e68 55%, #081733 100%);
    color: #fff;
    padding: 20px 14px;
    box-shadow: 4px 0 20px rgba(7, 25, 56, 0.16);
    position: relative;
    z-index: 10;
}
.admin-side .side-brand {
    font-weight: 800;
    letter-spacing: .8px;
    font-size: 1.22rem;
    padding: 4px 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    margin-bottom: 12px;
}
.admin-side .side-brand small {
    display: block;
    font-weight: 600;
    letter-spacing: .5px;
    font-size: .75rem;
    color: #f59e0b;
    margin-top: 2px;
    text-transform: uppercase;
}
.admin-side nav a {
    display: block;
    color: #cbd5e1;
    text-decoration: none;
    padding: 9px 12px;
    border-radius: 8px;
    margin-bottom: 3px;
    font-size: .92rem;
    font-weight: 500;
    transition: all .2s ease;
}
.admin-side nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    transform: translateX(3px);
}
.admin-side nav a.active {
    background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
    color: #071938;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
}
.admin-side nav a.logout {
    margin-top: 18px;
    color: #fca5a5;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 12px;
}
.admin-side nav a.logout:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fecaca;
}
.admin-main { flex: 1; min-width: 0; padding: 24px 24px 48px; }
@media (max-width: 991.98px) {
    .admin-wrap { flex-direction: column; }
    .admin-side { width: 100%; flex: none; padding: 12px; }
    .admin-side .side-brand { padding: 2px 6px 10px; margin-bottom: 8px; }
    .admin-side nav { display: flex; flex-wrap: wrap; gap: 4px; }
    .admin-side nav a { margin: 0; padding: 6px 10px; font-size: .85rem; background: rgba(255, 255, 255, 0.08); }
    .admin-side nav a.active { background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%); color: #071938; }
    .admin-side nav a.logout { margin-top: 0; border-top: none; padding-top: 6px; }
    .admin-main { padding: 16px 14px 40px; }
}

/* ---------- cards / panels ---------- */
.panel {
    background: var(--card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: 0 4px 20px -2px rgba(12, 46, 104, 0.07), 0 2px 6px -1px rgba(0, 0, 0, 0.03);
    transition: box-shadow .2s ease, transform .2s ease;
}
.panel > h5, .panel > .panel-title {
    font-weight: 700;
    color: #0c2e68;
    margin-bottom: 14px;
    letter-spacing: -.1px;
}
.stat {
    background: var(--card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px 18px;
    height: 100%;
    text-decoration: none;
    display: block;
    color: inherit;
    border-top: 4px solid var(--brand);
    box-shadow: 0 4px 16px rgba(12, 46, 104, 0.06);
    transition: all .2s ease;
}
.stat:hover {
    border-color: #2563eb;
    border-top-color: #f59e0b;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(12, 46, 104, 0.12);
}
.stat .num { font-size: 2.2rem; font-weight: 800; line-height: 1.1; color: #0c2e68; }
.stat .lbl { color: var(--muted); text-transform: uppercase; font-size: .75rem; font-weight: 700; letter-spacing: .6px; margin-top: 4px; }

/* ---------- units ---------- */
.unit-badge { display: inline-block; padding: 2px 8px; border-radius: 5px; font-weight: 600; font-size: .82rem; white-space: nowrap; border: 1px solid #ced4da; background: #f8f9fa; line-height: 1.5; }
select.unit-select option { background: #fff; color: #212529; }

/* ---------- matches ---------- */
.match-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.h2h { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; margin-top: 8px; text-align: center; }
.h2h-side { padding: 8px; border-radius: 8px; background: #f8f9fa; }
.h2h-side.winner { background: #e8f6ec; outline: 2px solid #2e9e4f; }
.h2h-score { font-size: 1.6rem; font-weight: 800; }
.h2h-vs { font-weight: 800; color: var(--muted); }
.mini-table td, .mini-table th { padding: .2rem .35rem; font-size: .88rem; vertical-align: middle; }
.standing-table tr.top1 td { background: #fff7d6; }
.standing-table tr.top2 td { background: #f1f3f5; }
.standing-table tr.top3 td { background: #fbefe6; }
.medal-img { height: 22px; vertical-align: middle; }
.medal { display: inline-block; min-width: 64px; text-align: center; font-weight: 700; font-size: .75rem; border-radius: 4px; padding: 1px 6px; }
.medal-gold { background: #ffe58a; }
.medal-silver { background: #e5e7eb; }
.medal-bronze { background: #f3c7a2; }

/* ---------- TM (phone-first) ---------- */
.tm-event { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.tm-event .event-name { font-size: 1.5rem; font-weight: 800; line-height: 1.2; margin: 6px 0; }
.tm-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tm-actions .btn { padding: 18px 8px; font-weight: 700; font-size: 1.05rem; border-radius: 12px; position: relative; }
.tm-actions .btn small { display: block; font-weight: 400; font-size: .75rem; opacity: .85; }
@media (min-width: 768px) { .tm-actions { grid-template-columns: repeat(4, 1fr); } }
.entry-table td { vertical-align: middle; }
.entry-table input, .entry-table select { min-width: 90px; }
.entry-table .col-num { width: 2.6rem; text-align: center; font-weight: 700; color: var(--muted); }
.entry-table .col-mark { width: 9rem; }
.entry-table .col-rem { width: 6rem; }
.entry-table .col-place { width: 4rem; text-align: center; font-weight: 800; }
.side-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #fff; }
.score-input { font-size: 1.8rem; font-weight: 800; text-align: center; height: 64px; }
.winner-box { text-align: center; padding: 10px; border-radius: 10px; background: #f8f9fa; font-weight: 700; }
.winner-box.has { background: #e8f6ec; color: #1e6b35; }
.form-label { font-weight: 600; font-size: .9rem; color: #1e293b; margin-bottom: 5px; }
.form-control, .form-select {
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.96);
    padding: 7px 12px;
    font-size: .93rem;
    transition: all .2s ease;
}
.form-control:focus, .form-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
    background-color: #fff;
}
.btn {
    font-weight: 600;
    border-radius: 8px;
    padding: 7px 16px;
    transition: all .18s ease;
}
.btn-primary {
    background: linear-gradient(135deg, #1d4ed8 0%, #0c2e68 100%);
    border: none;
    box-shadow: 0 2px 8px rgba(12, 46, 104, 0.22);
}
.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, #2563eb 0%, #0e3a82 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(12, 46, 104, 0.32);
}
.btn-success {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    border: none;
    box-shadow: 0 2px 8px rgba(22, 101, 52, 0.22);
}
.btn-success:hover, .btn-success:focus {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(22, 101, 52, 0.32);
}
.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.22);
}
.btn-warning:hover, .btn-warning:focus {
    background: linear-gradient(135deg, #fbbf24 0%, #b45309 100%);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(217, 119, 6, 0.32);
}
.btn-outline-success {
    border: 1.5px solid #16a34a;
    color: #16a34a;
    font-weight: 700;
}
.btn-outline-success:hover {
    background: #16a34a;
    color: #fff;
    transform: translateY(-1px);
}
.btn-outline-primary {
    border: 1.5px solid #2563eb;
    color: #2563eb;
    font-weight: 700;
}
.btn-outline-primary:hover {
    background: #2563eb;
    color: #fff;
    transform: translateY(-1px);
}
.table {
    --bs-table-bg: transparent;
}
.table thead th {
    background: rgba(241, 245, 249, 0.95);
    color: #334155;
    font-weight: 700;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 2px solid #cbd5e1;
}
.table-hover tbody tr:hover {
    background-color: rgba(239, 246, 255, 0.7) !important;
}

/* ---------- announcer ---------- */
.speak-bar { position: sticky; top: 0; z-index: 20; background: #111827; color: #fff; border-radius: 10px; padding: 8px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.speak-bar .dot { width: 10px; height: 10px; border-radius: 50%; background: #6b7280; display: inline-block; }
.speak-bar.on .dot { background: #22c55e; animation: pulse 1s infinite; }
.speak-bar input[type=range] { width: 140px; }
@keyframes pulse { 50% { opacity: .3; } }
.queue-section h5 { font-weight: 800; margin: 6px 0 8px; display: flex; align-items: center; gap: 8px; }
.queue-section h5 .count { font-size: .8rem; }
.q-item { background: #fff; border: 1px solid var(--line); border-left: 6px solid #adb5bd; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; display: flex; gap: 12px; align-items: flex-start; }
.q-item.call { border-left-color: #f59e0b; }
.q-item.result { border-left-color: #16a34a; }
.q-item.final { border-left-color: #dc2626; }
.q-item .q-body { flex: 1; min-width: 0; }
.q-item .q-title { font-size: .75rem; font-weight: 800; letter-spacing: .6px; color: var(--muted); }
.q-item .q-event { font-weight: 800; font-size: 1.05rem; }
.q-item .q-text { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.q-item .q-actions { display: flex; flex-direction: column; gap: 6px; }
.q-item .q-actions .btn { white-space: nowrap; }
.q-empty { color: var(--muted); font-size: .9rem; padding: 8px 2px 14px; }

/* ---------- public ---------- */
.hero {
    background: linear-gradient(135deg, #071938 0%, #0c2e68 55%, #1e40af 100%);
    color: #fff;
    border-radius: 16px;
    padding: 24px 22px;
    margin-bottom: 20px;
    box-shadow: 0 10px 28px rgba(12, 46, 104, 0.22);
    border-left: 5px solid #f59e0b;
}
.hero h2 { margin: 0; font-weight: 800; letter-spacing: .8px; }
.tally-table th { font-size: .8rem; }
.nav-pills .nav-link.active {
    background: linear-gradient(135deg, #1d4ed8 0%, #0c2e68 100%);
    box-shadow: 0 2px 8px rgba(12, 46, 104, 0.25);
}
.nav-pills .nav-link { color: var(--brand); font-weight: 600; border-radius: 8px; }
.winner-card {
    border: 2px solid #f59e0b;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-radius: 16px;
    padding: 24px 20px;
    margin-bottom: 16px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.18);
}
.winner-card .label { font-weight: 800; color: #b07a00; letter-spacing: 2px; font-size: .95rem; }
.winner-card .name { font-size: 2.5rem; font-weight: 800; line-height: 1.1; margin-top: 8px; color: #78350f; }
.winner-card .medals { display: flex; justify-content: center; gap: 28px; font-size: 1.6rem; font-weight: 700; margin-top: 12px; }
.winner-card .medals img { height: 38px; vertical-align: middle; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15)); }

/* ---------- login ---------- */
.login-bg { position: fixed; inset: 0; background: url('../../images/login-bg.jpg') center/cover no-repeat; filter: blur(6px); transform: scale(1.1); z-index: -2; }
.login-shade { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: -1; }
.login-card { width: 100%; max-width: 390px; background: rgba(255, 255, 255, .92); border-radius: 16px; padding: 26px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }

/* ---------- toasts ---------- */
.toast-box { position: fixed; right: 14px; bottom: 14px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 28px)); }
.app-toast { background: #1f2937; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); opacity: 0; transform: translateY(8px); transition: all .25s; font-size: .95rem; }
.app-toast.show { opacity: 1; transform: none; }
.app-toast-ok { background: #166534; }
.app-toast-err { background: #b91c1c; }
.app-toast-info { background: #1f2937; }

/* ---------- misc ---------- */
.chip { display: inline-block; background: #eef2ff; color: #3730a3; border-radius: 999px; padding: 1px 9px; font-size: .78rem; margin: 1px 2px; white-space: nowrap; }
.chip-muted { background: #f3f4f6; color: #4b5563; }
.assign-grid th, .assign-grid td { text-align: center; vertical-align: middle; }
.assign-grid td:first-child, .assign-grid th:first-child { text-align: left; }
.assign-grid .owner { display: block; font-size: .7rem; color: var(--muted); }
.table > :not(caption) > * > * { padding-top: .45rem; padding-bottom: .45rem; }

@media print {
    body { background: #fff; }
    .admin-main, .page { padding: 0; }
    .panel { border: none; box-shadow: none; padding: 0; }
    .unit-badge { border: none !important; background: none !important; color: #000 !important; padding: 0; }
}
.login-body .page { padding: 0; max-width: none; }
.q-item .mini-table { max-width: 680px; }
.mini-table td:nth-child(2) { width: 42%; }
@media (max-width: 575.98px) {
    .tally-table th, .tally-table td { padding: .35rem .25rem; font-size: .85rem; }
    .tally-table .medal-img { height: 18px; }
    .tally-table td.fs-5 { font-size: 1rem !important; }
}
/* Athlete rows become small cards on phones */
@media (max-width: 767.98px) {
    input, select, textarea, .form-control, .form-select {
        font-size: 16px !important; /* Prevents iOS Safari from auto-zooming when focusing inputs */
    }
    .entry-table thead { display: none; }
    .entry-table, .entry-table tbody { display: block; }
    .entry-table tr { display: grid; grid-template-columns: 1.6rem 1fr 1fr auto; gap: 6px 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
    .entry-table td { display: block; padding: 0 !important; border: 0 !important; width: auto !important; }
    .entry-table td.col-num { grid-column: 1; grid-row: 1; }
    .entry-table td.col-name { grid-column: 2 / span 2; grid-row: 1; }
    .entry-table td.col-del { grid-column: 4; grid-row: 1; }
    .entry-table td.col-dept { grid-column: 2; grid-row: 2; }
    .entry-table td.col-mark { grid-column: 3; grid-row: 2; }
    .entry-table td.col-rem { grid-column: 2; grid-row: 3; }
    .entry-table td.col-place { grid-column: 3; grid-row: 3; text-align: left !important; }
    .entry-table.no-mark td.col-dept { grid-column: 2 / span 2; }
    .entry-table tr:not(:has(.col-name)) td.col-dept { grid-column: 2 / span 2; grid-row: 1; }
    .entry-table tr:not(:has(.col-name)) td.col-mark { grid-column: 2; grid-row: 2; }
    .entry-table tr:not(:has(.col-name)) td.col-rem { grid-column: 3; grid-row: 2; }
    .entry-table tr:not(:has(.col-name)) td.col-place { grid-column: 2; grid-row: 3; }
    .entry-table input, .entry-table select { min-width: 0; }
    .page-title h3 { font-size: 1.35rem; }
}

/* iOS & Android touch optimizations */
button, .btn, a, input[type=button], input[type=submit] {
    touch-action: manipulation;
}
.table-responsive, .ev-hits {
    -webkit-overflow-scrolling: touch;
}
body {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.page, .admin-main {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
}
@media (max-width: 575.98px) {
    .q-item { flex-direction: column; }
    .q-item .q-actions { flex-direction: row; width: 100%; }
    .q-item .q-actions .btn { flex: 1; }
}
.q-item.standing, .q-item.tally { border-left-color: #2563eb; }
.q-item.edited { background: #fff5f5; }
.rules-box { background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 8px; padding: 6px 10px; font-size: .85rem; color: #334155; }
.side-box.winner { outline: 3px solid #2e9e4f; background: #f0fbf3; }
.place-row { border-bottom: 1px dashed var(--line); padding-bottom: 8px; }
.cat-title { font-size: .78rem; font-weight: 800; letter-spacing: .6px; color: var(--muted); margin: 14px 0 6px; text-transform: uppercase; }

/* ---------- master list / assignment grid ---------- */
.events-table td.cat-title, .assign-grid td.cat-title { background: #f8fafc; text-align: left; padding-top: 10px; }
.events-table .ev-child td { background: #fcfcfd; }
.events-table .js-toggle { font-size: .78rem; text-decoration: none; }
.q-item.overall { border-left-color: #e0a800; background: #fffbea; }
/* ---------- spectator search ---------- */
.ev-hits { background: #fff; color: var(--ink); border-radius: 10px; box-shadow: 0 10px 24px rgba(0, 0, 0, .25); max-height: 340px; overflow-y: auto; margin-top: 10px; }
.ev-hits a { display: block; padding: 9px 12px; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); font-weight: 600; font-size: .92rem; }
.ev-hits a:hover { background: var(--brand-soft); }
.ev-hits .badge { font-size: .65rem; vertical-align: middle; }
#catChips .btn.active { background: #fff; color: var(--brand); }
