:root {
    --color-bg: #f7f8fa;
    --color-surface: #ffffff;
    --color-border: #e5e7eb;
    --color-text: #111827;
    --color-muted: #6b7280;
    --color-primary: #d61f26;
    --color-primary-dark: #b71a20;
    --color-accent: #f5c518;
    --color-success: #16a34a;
    --color-danger: #dc2626;
    --radius-lg: 14px;
    --radius-md: 10px;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-hover: 0 8px 20px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    margin: 0;
    line-height: 1.5;
}

.page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

.page-narrow { max-width: 640px; }

h1 { font-size: 28px; font-weight: 700; margin: 0 0 8px; }
h2 { font-size: 20px; font-weight: 700; margin: 32px 0 14px; }
h3 { font-size: 16px; font-weight: 700; margin: 0 0 4px; }
p.subtitle { color: var(--color-muted); margin: 0 0 24px; font-size: 15px; }

/* ---------- Nav ---------- */
.topnav {
    background: #111827;
    padding: 14px 28px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.topnav a {
    color: #d1d5db;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}
.topnav a:hover { color: #fff; }
.topnav .brand {
    color: #fff;
    font-weight: 700;
    font-size: 17px;
    margin-right: 8px;
}
.topnav .spacer { flex: 1; }
.topnav .nav-logout-btn {
    background: none;
    border: none;
    color: #d1d5db;
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    padding: 0;
}
.topnav .nav-logout-btn:hover { color: #fff; }

/* ---------- Cards ---------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-card);
    margin-bottom: 14px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
    margin-top: 20px;
}

.tile {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.15s ease;
}
.tile:hover { transform: translateY(-2px); }

.tile-image {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #e0e7ff, #f3e8ff);
    display: block;
    box-shadow: var(--shadow-card);
}
.tile:hover .tile-image { box-shadow: var(--shadow-hover); }

.tile-title {
    font-weight: 600;
    font-size: 16px;
    margin: 12px 0 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tile-meta {
    color: var(--color-muted);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.tile-desc {
    color: var(--color-muted);
    font-size: 13px;
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tag {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.9; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-secondary { background: #eef0f3; color: var(--color-text); }
.btn-success { background: var(--color-success); color: #fff; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ---------- Forms ---------- */
input[type=text], input[type=email], input[type=number], input[type=date],
input[type=file], textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--color-text);
}
label { font-size: 13px; font-weight: 600; color: var(--color-text); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-md); margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-info { background: #eff6ff; color: #1e40af; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; background: var(--color-surface); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-card); }
th { background: #f3f4f6; text-align: left; padding: 10px 14px; font-size: 13px; }
td { padding: 10px 14px; border-top: 1px solid var(--color-border); font-size: 14px; vertical-align: top; }

/* ---------- Misc ---------- */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-top: 32px; }
.muted { color: var(--color-muted); }
.rank-input { width: 70px; text-align: center; }


/* ================================================================
   ADDITIONS: shared site-wide nav bar + site-wide dark mode
   Append this whole block to the end of your existing style.css.
   Nothing above this comment should be touched.
   ================================================================ */

/* ---------- Site-wide dark mode ----------
   Overrides the SAME variable names your existing card/table/button
   styles already use, so switching to dark mode re-colors everything
   sitewide automatically -- no per-page changes needed. */
body.dark-mode {
    --color-bg: #0a0a0a;
    --color-surface: #1a1a1a;
    --color-border: #333333;
    --color-text: #f3f4f6;
    --color-muted: #9ca3af;
}
body.dark-mode table {
    background: var(--color-surface);
}
body.dark-mode th {
    background: #222222;
    color: var(--color-text);
}

/* ---------- Shared nav bar ---------- */
.site-nav {
    background: #0a0a2a;
    color: #fff;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    gap: 32px;
}
.site-nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 900;
    font-size: 18px;
    letter-spacing: 1px;
    text-decoration: none;
    color: #fff;
}
.site-nav-brand img {\n    display: block;\n    width: 42px;\n    height: 42px;\n    max-width: 42px;\n    max-height: 42px;\n    object-fit: contain;\n    flex: 0 0 42px;\n}

.site-nav-links {
    display: flex;
    gap: 28px;
    flex: 1;
}
.site-nav-links a {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    position: relative;
    padding: 4px 2px;
    transition: color 0.2s ease;
}
.site-nav-links a::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -4px;
    width: 0;
    height: 3px;
    background: #f5c518;
    transition: all 0.25s ease;
    transform: translateX(-50%);
}
.site-nav-links a:hover { color: #f5c518; }
.site-nav-links a:hover::after { width: 100%; }

.site-nav-right {
    display: flex;
    align-items: center;
    gap: 14px;
}
.theme-toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 17px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-logout-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    padding: 0;
}
.nav-logout-btn:hover { color: #f5c518; }


/* Mobile and touch usability */
.mobile-nav-toggle { display:none; }
.site-nav { min-width:0; flex-wrap:wrap; }
.site-nav-links { min-width:0; }
input[type=search] { min-width:0; max-width:100%; }
button, .btn, select, input, textarea { touch-action:manipulation; }
button, .btn, .theme-toggle-btn, .nav-logout-btn { min-height:42px; }
img, video, iframe { max-width:100%; }
@media (max-width:760px) {
 .site-nav { padding:10px 14px; gap:10px; }
 .site-nav-brand img { width:34px; height:34px; }
 .mobile-nav-toggle { display:inline-flex; align-items:center; justify-content:center; min-height:42px; padding:8px 12px; border:1px solid rgba(255,255,255,.24); border-radius:9px; background:rgba(255,255,255,.08); color:#fff; font:inherit; font-weight:600; }
 .site-nav-links { display:none; order:5; flex:0 0 100%; width:100%; flex-direction:column; align-items:stretch; gap:0; padding-top:6px; }
 .site-nav-links.is-open { display:flex; }
 .site-nav-links a { display:block; width:100%; padding:12px 10px; border-top:1px solid rgba(255,255,255,.12); font-size:15px; }
 .site-nav-right { margin-left:auto; display:flex; align-items:center; gap:6px; }
 .site-nav-right form { display:flex; }
 .page { padding:24px 16px 56px; }
 h1 { font-size:clamp(24px,6vw,30px); overflow-wrap:anywhere; }
 .card-grid { grid-template-columns:minmax(0,1fr); gap:18px; }
 .section-header { align-items:flex-start; flex-direction:column; gap:12px; }
 table { display:block; overflow-x:auto; -webkit-overflow-scrolling:touch; }
 .card { padding:16px; }
 .search-field { width:100%; max-width:100%; }
}
@media (max-width:520px) {
 .site-nav-right { gap:4px; }
 .site-nav-right .nav-logout-btn { font-size:12px; padding:7px; }
 .db-body { width:calc(100% - 24px); }
 .db-hello { font-size:clamp(25px,8vw,34px); }
 .db-panel { padding:14px; }
 .category-bar-labels { grid-template-columns:repeat(2,minmax(0,1fr)); }
 .category-bar-labels span { white-space:normal; overflow-wrap:anywhere; }
 input, select, textarea { font-size:16px; }
 .admin-user-row { flex-direction:column !important; align-items:stretch !important; gap:14px; }
 .admin-user-row > div { min-width:0; overflow-wrap:anywhere; }
 .admin-user-row > div:last-child { flex-direction:column; }
 .admin-user-row form { max-width:100%; flex-wrap:wrap; }
 .admin-user-row button, .admin-user-row select { min-height:42px; }
 .admin-competition-item { flex-direction:column !important; align-items:stretch !important; gap:14px; }
 .admin-competition-item > div:last-child { flex-wrap:wrap; }
}
