:root {
  --ink: #1e2a28;
  --muted: #687a74;
  --line: #d9e2dc;
  --paper: #fbfcf9;
  --cream: #f4f0e6;
  --green: #1e5c4a;
  --green-2: #2f7d63;
  --gold: #b8873b;
  --red: #a33b33;
  --blue: #2c5d86;
  --shadow: 0 12px 34px rgba(30, 50, 42, .09);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.65;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.3; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: 30px; letter-spacing: -.3px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.hidden, [hidden] { display: none !important; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 22px; }
.narrow { max-width: 760px; margin: 0 auto; }
.center { text-align: center; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 26px; } .mt-4 { margin-top: 40px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.flex { display: flex; gap: 12px; align-items: center; }
.between { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
.card.pad-sm { padding: 14px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 9px; padding: 8px 14px; font: inherit; font-size: 14px;
  cursor: pointer; transition: .16s ease; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: #a9c3b5; background: #f4faf6; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.danger { color: var(--red); border-color: #e4bbb6; background: #fff8f7; }
.btn.soft { background: #eef6f0; border-color: #d4e6da; color: var(--green); }
.btn.sm { padding: 5px 9px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; }
.input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
  font: inherit; font-size: 14px; color: var(--ink); background: #fff; outline: none;
}
.input:focus, select:focus, textarea:focus { border-color: #7eac96; box-shadow: 0 0 0 3px rgba(47,125,99,.10); }
input[type="file"].input { padding: 7px; }
label.field { display: block; margin-bottom: 12px; font-size: 13px; color: #3d4c47; }
label.field > span { display: block; margin-bottom: 5px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.error { color: var(--red); font-size: 13px; min-height: 20px; margin: 8px 0; }
.notice { border-radius: 10px; padding: 12px 14px; background: #f5f1e6; border: 1px solid #e3d7bc; color: #6e5528; font-size: 13px; }
.notice.blue { background: #eef4f9; border-color: #cdddea; color: #315b76; }
.notice.red { background: #fbf0ee; border-color: #ecd2cd; color: #843b33; }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #eef2ef; color: #4c6058; white-space: nowrap; }
.badge.ok { background: #e7f4eb; color: #246444; }
.badge.blue { background: #eaf2f9; color: #2d5e83; }
.badge.gold { background: #faf2df; color: #85601e; }
.badge.red { background: #fbeeeb; color: #8c3d35; }
.badge.gray { background: #eff1ef; color: #64736d; }

/* header */
.topbar { background: rgba(251,252,249,.94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; backdrop-filter: blur(10px); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; letter-spacing: .2px; }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 13px; font-weight: 700; letter-spacing: .4px; color: var(--green); }
.brand-mark span { color: var(--gold); font-size: 11px; margin-left: 5px; }
.brand small { color: var(--muted); font-weight: 400; font-size: 12px; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a, .nav button { color: #3f514a; font-size: 13px; padding: 7px 10px; border-radius: 7px; border: 0; background: transparent; cursor: pointer; }
.nav a:hover, .nav button:hover { background: #eef5f0; text-decoration: none; }
.nav .active { background: #e7f1eb; color: var(--green); font-weight: 700; }

/* hero */
.hero { position: relative; overflow: hidden; background: linear-gradient(120deg, #153f33, #255d4b 55%, #3b7961); color: #f7fbf7; }
.hero::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 78% 20%, rgba(255,255,255,.16), transparent 34%), repeating-linear-gradient(115deg, transparent 0 28px, rgba(255,255,255,.035) 28px 29px); pointer-events: none; }
.hero-inner { position: relative; z-index: 1; display: grid; grid-template-columns: 1.25fr .75fr; gap: 34px; padding: 64px 0 58px; align-items: center; }
.hero .eyebrow { color: #d9c48f; font-size: 11px; letter-spacing: 2.4px; font-weight: 700; margin-bottom: 10px; }
.hero h1 { font-size: 38px; letter-spacing: .5px; margin-bottom: 14px; }
.hero p.lead { color: #d8e7df; font-size: 15px; max-width: 620px; }
.hero-card { background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.25); border-radius: 16px; padding: 22px; backdrop-filter: blur(6px); }
.hero-card .label { color: #d7e6dd; font-size: 12px; }
.hero-card .big { font-size: 27px; font-weight: 700; color: #fff; margin: 3px 0 12px; }
.hero-card .line { border-top: 1px solid rgba(255,255,255,.18); padding-top: 12px; margin-top: 12px; color: #e5f0ea; font-size: 13px; }
.hero-points { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.pill { border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: #e7f1eb; }
.section { padding: 42px 0; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.section-head h2 { margin-bottom: 2px; }
.section-head p { margin: 0; }

/* steps */
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.step { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.step .n { color: var(--gold); font-weight: 800; font-size: 12px; letter-spacing: 1px; }
.step h3 { margin: 8px 0 4px; }
.step p { margin: 0; color: var(--muted); font-size: 13px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 30px 18px; background: radial-gradient(circle at 10% 0%, #e8f0e9, transparent 36%), radial-gradient(circle at 95% 100%, #f1e7d3, transparent 34%), var(--paper); }
.login-card { width: min(430px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 30px; }
.login-card h1 { font-size: 24px; margin: 18px 0 5px; }
.login-card .brand-mark { font-size: 14px; }
.login-card .foot-link { margin-top: 18px; }

/* admin layout */
.admin-shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: #143c31; color: #dcebe2; padding: 22px 14px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { color: #fff; padding: 0 8px 18px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 14px; display: block; }
.sidebar .brand small { color: #a9c7b8; display: block; margin-top: 3px; }
.sidebar nav { display: grid; gap: 3px; }
.sidebar a, .sidebar button { display: flex; width: 100%; text-align: left; border: 0; background: transparent; color: #cfe2d7; padding: 9px 10px; border-radius: 8px; font: inherit; font-size: 13px; cursor: pointer; }
.sidebar a:hover, .sidebar button:hover, .sidebar .active { background: rgba(255,255,255,.10); color: #fff; text-decoration: none; }
.sidebar .side-foot { position: absolute; bottom: 20px; left: 22px; right: 22px; font-size: 11px; color: #9eb9ab; }
.main { min-width: 0; padding: 24px 26px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; margin: 0 0 2px; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 9px 12px; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--green); border-bottom-color: var(--green); font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 25px; font-weight: 800; margin-top: 2px; }
.stat .v small { font-size: 12px; font-weight: 400; color: var(--muted); }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #edf1ee; vertical-align: top; }
th { background: #f5f8f5; color: #53665d; font-size: 12px; font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td .actions { display: flex; gap: 5px; flex-wrap: wrap; }
.empty { color: var(--muted); text-align: center; padding: 30px 14px; font-size: 13px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .input { width: auto; min-width: 170px; }
.progress { height: 7px; background: #edf1ee; border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--green-2); }
.side-list { display: grid; gap: 8px; }
.side-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
.side-item .between { align-items: flex-start; }
.mono { font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; }
.token { font-family: Consolas, monospace; font-size: 11px; background: #f2f5f2; border: 1px solid #dfe7e0; border-radius: 6px; padding: 4px 6px; word-break: break-all; }
.rank-list { display: grid; gap: 8px; }
.rank-row { display: grid; grid-template-columns: 48px 1fr auto auto; gap: 12px; align-items: center; padding: 11px 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.rank-row .rank { font-weight: 800; color: var(--gold); font-size: 16px; }
.rank-row .score { font-weight: 800; color: var(--green); }
.rank-row .name { font-weight: 700; }
.rank-row .meta { color: var(--muted); font-size: 12px; }
.rank-row.advanced { border-color: #c9e1d1; background: #fbfefb; }

/* student */
.notice-band { background: #f6f1e3; border-bottom: 1px solid #e7dbc0; color: #6d5525; font-size: 13px; text-align: center; padding: 7px 14px; }
.submit-wrap { max-width: 860px; margin: 0 auto; padding: 30px 18px 60px; }
.submit-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 26px; }
.submit-card h1 { font-size: 25px; }
.upload-box { border: 1.5px dashed #b9cec0; border-radius: 12px; background: #f7fbf8; padding: 22px; text-align: center; color: #587266; cursor: pointer; }
.upload-box:hover { border-color: var(--green); background: #f1f8f3; }
.upload-box strong { color: var(--green); }
.check-line { display: flex; gap: 9px; align-items: flex-start; font-size: 12px; color: #55665f; line-height: 1.7; }
.check-line input { margin-top: 4px; }
.success-box { text-align: center; padding: 24px 10px; }
.success-box .ok-mark { width: 58px; height: 58px; border-radius: 50%; background: #e7f4eb; color: #26734f; display: grid; place-items: center; margin: 0 auto 14px; font-size: 28px; }
.code { font-size: 22px; letter-spacing: 1px; font-weight: 800; color: var(--green); }
.status-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 7px 12px; font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

/* judge */
.judge-shell { max-width: 1320px; margin: 0 auto; padding: 20px; }
.judge-grid { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
.work-list { display: grid; gap: 7px; max-height: calc(100vh - 220px); overflow: auto; }
.work-item { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; font: inherit; }
.work-item:hover { border-color: #9fbca9; }
.work-item.active { border-color: var(--green); background: #f3faf5; }
.work-item .top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 700; }
.work-item .meta { color: var(--muted); font-size: 11px; margin-top: 2px; }
.work-item .done { color: var(--green); }
.viewer-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; min-height: 500px; overflow: hidden; }
.viewer-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); background: #f8faf8; }
.pdf-scroll { background: #e9eeea; max-height: calc(100vh - 360px); overflow: auto; padding: 14px; }
.pdf-scroll canvas { display: block; margin: 0 auto 12px; background: #fff; box-shadow: 0 3px 14px rgba(0,0,0,.12); max-width: 100%; height: auto; }
.score-box { border-top: 1px solid var(--line); padding: 14px 16px; background: #fff; }
.score-line { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.score-line .input { width: 130px; }
.range-hint { font-size: 12px; color: var(--muted); }

/* results */
.results-wrap { max-width: 1120px; margin: 0 auto; padding: 30px 18px 70px; }
.result-banner { background: linear-gradient(120deg, #173f34, #2b6a55); color: #fff; border-radius: 16px; padding: 28px; margin-bottom: 20px; }
.result-banner h1 { color: #fff; margin-bottom: 4px; }
.result-banner p { color: #d7e8de; margin: 0; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.work-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.work-card h3 { margin: 0 0 3px; }
.work-card .meta { color: var(--muted); font-size: 12px; }
.public-table { font-size: 13px; }

/* modal / toast */
.modal-mask { position: fixed; inset: 0; background: rgba(12,25,20,.52); z-index: 100; display: grid; place-items: center; padding: 18px; }
.modal { width: min(720px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: #fff; border-radius: 16px; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.modal.wide { width: min(1100px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 18px; border-top: 1px solid var(--line); }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: #1f3029; color: #fff; border-radius: 9px; padding: 9px 16px; font-size: 13px; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,.22); }
.loading { position: fixed; inset: 0; margin: auto; width: 100%; height: 26px; text-align: center; color: var(--muted); font-size: 13px; z-index: 50; background: transparent; pointer-events: none; }
.footer { color: var(--muted); font-size: 12px; padding: 24px 0 40px; text-align: center; }
.rule-list { padding-left: 18px; margin: 0; color: #4e6058; font-size: 13px; }
.rule-list li { margin-bottom: 4px; }

@media (max-width: 960px) {
  .hero-inner { grid-template-columns: 1fr; padding: 44px 0; }
  .hero h1 { font-size: 30px; }
  .steps { grid-template-columns: 1fr 1fr; }
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar .side-foot { position: static; margin-top: 18px; }
  .sidebar nav { grid-template-columns: repeat(3, 1fr); }
  .stats { grid-template-columns: 1fr 1fr; }
  .judge-grid { grid-template-columns: 1fr; }
  .work-list { max-height: 300px; }
  .gallery { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .container { padding: 0 14px; }
  .main { padding: 16px 12px 40px; }
  .form-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 26px; }
  .steps { grid-template-columns: 1fr; }
  .sidebar nav { grid-template-columns: 1fr 1fr; }
  .rank-row { grid-template-columns: 38px 1fr auto; }
  .rank-row .score { grid-column: 2 / -1; font-size: 13px; }
  .gallery { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 92px 1fr; }
  .topbar-inner { min-height: 56px; }
  .nav a { padding: 6px; }
}
