:root {
    --bg: #eef1f6;
    --card: #ffffff;
    --ink: #101828;
    --muted: #667085;
    --border: #e4e7ec;
    --brand-1: #1e2a78;
    --brand-2: #3b4fd8;
    --accent: #f59e0b;
    --ok: #12b76a;
    --err: #f04438;
    --gold: #f5b301;
    --silver: #98a2b3;
    --bronze: #cd7f32;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(16,24,40,.08), 0 8px 24px -12px rgba(16,24,40,.18);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background:
        radial-gradient(1200px 400px at 80% -10%, rgba(59,79,216,.12), transparent),
        var(--bg);
    color: var(--ink);
    min-height: 100vh;
}

/* ---------- layout ---------- */
.wrap { max-width: 680px; margin: 0 auto; padding: 0 16px 80px; }
.wrap.narrow { max-width: 400px; padding-top: 8vh; }
.wrap.wide { max-width: 1120px; }
.page { padding: 24px 16px 80px; }

/* ---------- hero / header ---------- */
.hero {
    background: linear-gradient(135deg, var(--brand-1), var(--brand-2) 70%, #5b6ef0);
    color: #fff;
    padding: 44px 16px 64px;
    border-radius: 0 0 28px 28px;
    text-align: center;
    box-shadow: var(--shadow);
    margin-bottom: -40px;
}
.hero .eyebrow {
    display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .12em;
    text-transform: uppercase; background: rgba(255,255,255,.16);
    padding: 5px 14px; border-radius: 99px; margin-bottom: 14px;
}
.hero h1 { margin: 0 0 6px; font-size: clamp(1.5rem, 5vw, 2.1rem); font-weight: 800; }
.hero p { margin: 0; opacity: .85; }
.hero .count {
    display: inline-flex; align-items: center; gap: 8px; margin-top: 18px;
    background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25);
    padding: 8px 16px; border-radius: 99px; font-size: .9rem; font-weight: 600;
}
.hero .count b { font-size: 1.15rem; }

/* ---------- cards ---------- */
.card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 26px; margin-bottom: 20px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-title { display: flex; align-items: center; gap: 12px; margin: 0 0 6px;
    font-size: 1.02rem; font-weight: 750; }
.card-title .step { flex: 0 0 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-2), #5b6ef0); color: #fff;
    display: grid; place-items: center; font-size: .85rem; font-weight: 800; }
.ranks legend { display: none; }

/* ---------- forms ---------- */
label { display: block; font-weight: 650; font-size: .92rem; margin: 16px 0 6px; }
input, select {
    width: 100%; padding: 13px 14px; font-size: 1rem; color: var(--ink);
    border: 1.5px solid var(--border); border-radius: 10px; background: #fff;
    transition: border-color .15s, box-shadow .15s; appearance: none;
}
input { appearance: auto; }
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' fill='none'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%23667085' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
    padding-right: 40px; cursor: pointer;
}
input:focus, select:focus {
    outline: none; border-color: var(--brand-2);
    box-shadow: 0 0 0 4px rgba(59,79,216,.14);
}
.hint { font-size: .8rem; color: var(--muted); margin-top: 5px; font-weight: 400; }

/* ranked picks */
.ranks { margin-top: 20px; display: grid; gap: 12px; }
.ranks legend { font-weight: 750; margin-bottom: 4px; }
.rank { display: flex; align-items: center; gap: 12px; }
.rank .medal {
    flex: 0 0 44px; height: 44px; border-radius: 12px; color: #fff;
    display: grid; place-items: center; font-weight: 800; font-size: 1rem;
}
.rank.r1 .medal { background: linear-gradient(160deg, #ffd24d, var(--gold)); color: #5b4300; }
.rank.r2 .medal { background: linear-gradient(160deg, #c8d0dd, var(--silver)); color: #37404f; }
.rank.r3 .medal { background: linear-gradient(160deg, #e8a66b, var(--bronze)); }
.rank select { flex: 1; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 15px; margin-top: 22px; font-size: 1.02rem; font-weight: 700;
    border: 0; border-radius: 12px; cursor: pointer; text-decoration: none;
    background: linear-gradient(135deg, var(--brand-2), #5b6ef0); color: #fff;
    box-shadow: 0 6px 16px -6px rgba(59,79,216,.55); transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 20px -6px rgba(59,79,216,.6); }
.btn:active { transform: translateY(0); }
.btn.small { width: auto; padding: 9px 18px; margin-top: 0; font-size: .88rem; }

/* ---------- messages ---------- */
.msg { padding: 12px 16px; border-radius: 10px; margin: 12px 0; font-size: .92rem;
    background: #eef4ff; border: 1px solid #d1e0ff; }
.msg.ok { background: #ecfdf3; border-color: #abefc6; color: #067647; }
.msg.err { background: #fef3f2; border-color: #fecdca; color: #b42318; }

.success { text-align: center; padding: 40px 26px; }
.success .tick {
    width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%;
    background: #ecfdf3; color: var(--ok); display: grid; place-items: center;
}
.success h2 { margin: 0 0 6px; }
.success p { color: var(--muted); margin: 0 0 10px; }

/* ---------- admin topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 10;
    background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
    color: #fff; box-shadow: var(--shadow);
}
.topbar .inner { max-width: 1120px; margin: 0 auto; padding: 14px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 1.15rem; font-weight: 800; letter-spacing: .01em; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
    color: #fff; text-decoration: none; font-size: .87rem; font-weight: 600;
    padding: 7px 13px; border-radius: 99px; opacity: .9; transition: background .15s;
}
.topbar nav a:hover, .topbar nav a.active { background: rgba(255,255,255,.18); opacity: 1; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px 18px; }
.stat .num { font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.stat .lbl { font-size: .8rem; color: var(--muted); font-weight: 600; margin-top: 2px; }

/* ---------- tables ---------- */
.tcard { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden; margin-bottom: 20px; }
.tcard .thead { padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.tcard .thead h2, .tcard .thead h3 { margin: 0; font-size: 1.05rem; }
.filter-input { width: 220px; max-width: 100%; padding: 9px 14px; font-size: .9rem;
    border-radius: 99px; }
.tcard .scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
    color: var(--muted); padding: 11px 16px; background: #f8fafc; border-bottom: 1px solid var(--border); }
td { padding: 12px 16px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8faff; }
td.num, th.num { text-align: center; }
.ac-name { font-weight: 650; }
.ac-name a { color: inherit; text-decoration: none; }
.ac-name a:hover { color: var(--brand-2); }
.pill { display: inline-block; min-width: 30px; text-align: center; padding: 3px 10px;
    border-radius: 99px; font-size: .8rem; font-weight: 700; background: #eef4ff; color: var(--brand-1); }
.pill.zero { background: #f2f4f7; color: var(--muted); }
.link-cell { font-family: ui-monospace, Consolas, monospace; font-size: .74rem;
    color: var(--muted); word-break: break-all; }
.copy-btn { border: 1px solid var(--border); background: #fff; border-radius: 8px;
    padding: 5px 10px; font-size: .75rem; font-weight: 650; cursor: pointer; color: var(--brand-1);
    white-space: nowrap; transition: background .15s; }
.copy-btn:hover { background: #eef4ff; }
.icon-btn { border: 1px solid var(--border); background: #fff; border-radius: 6px;
    width: 30px; height: 28px; cursor: pointer; color: var(--brand-1); font-size: .7rem; }
.icon-btn:hover:not(:disabled) { background: #eef4ff; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.inline-edit { display: flex; gap: 8px; align-items: center; }
.inline-edit input { padding: 8px 10px; font-size: .9rem; margin: 0; }
.drag-handle { cursor: grab; color: var(--muted); font-size: 1rem; padding: 4px 6px;
    display: inline-block; user-select: none; touch-action: none; }
.drag-handle:active { cursor: grabbing; }
tr.dragging td { opacity: .35; }
tr.drop-above td { box-shadow: inset 0 2px 0 var(--brand-2); }
tr.drop-below td { box-shadow: inset 0 -2px 0 var(--brand-2); }
button.link { background: none; border: 0; color: var(--err); cursor: pointer;
    padding: 0; font-size: .82rem; font-weight: 600; }

/* podium order in results */
.order b { font-weight: 700; }
.order .m1 { color: #a06c00; } .order .m2 { color: #667085; } .order .m3 { color: #9a5b21; }
.order .sep { color: #cfd4dc; padding: 0 6px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .8rem;
    background: #f2f4f7; padding: 8px 12px; border-radius: 8px; word-break: break-all; }

h2.sec { font-size: 1.15rem; margin: 26px 0 12px; }
h3.sec { font-size: 1rem; margin: 20px 0 10px; }

@media (max-width: 560px) {
    .card { padding: 20px 16px; }
    .topbar h1 { font-size: 1rem; }
    th, td { padding: 10px 10px; }
}
