/* 掼友赛务 · 后台管理
   浅色内容区 + 深绿侧栏；纯 CSS，无外部依赖 */

:root {
  --brand: #0b6b53;
  --brand-2: #14a67b;
  --brand-soft: #e8f5ef;
  --green: #128a68;
  --gold: #b8822d;
  --gold-soft: #fbf1df;
  --danger: #c53b3b;
  --danger-soft: #fdecec;
  --warn: #9a6612;
  --warn-soft: #fdf6e6;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #fafcfb;
  --line: #e2eae6;
  --line-strong: #cfded7;
  --text: #17332a;
  --text-2: #3d5a4f;
  --muted: #6f8a7e;
  --muted-2: #97aca3;
  --sidebar: #071a13;
  --sidebar-2: #0d2a20;
  --radius: 14px;
  --shadow: 0 8px 26px rgba(16, 56, 42, .07);
  --shadow-lg: 0 24px 60px rgba(9, 33, 25, .2);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4, p { margin-top: 0; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 236px; z-index: 40;
  background: var(--sidebar); color: #e8f5ef;
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 24px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #16b586, #0b6b53); color: #fff;
  font-size: 17px; font-weight: 800; box-shadow: 0 6px 18px rgba(22,181,134,.3);
}
.sidebar-brand-text strong { display: block; font-size: 15.5px; letter-spacing: .5px; }
.sidebar-brand-text small { display: block; font-size: 11px; color: #7fa095; letter-spacing: 2px; }

.side-nav { flex: 1; overflow-y: auto; padding: 16px 12px 24px; }
.side-group-label { font-size: 10.5px; letter-spacing: 1.6px; color: #5e7d70; padding: 16px 10px 8px; font-weight: 700; }
.side-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 12px; margin-bottom: 3px; border: none; border-radius: 9px;
  background: transparent; color: #a9c1b6; font-size: 13.5px; text-align: left;
  transition: background .18s, color .18s;
}
.side-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-item.active { background: linear-gradient(100deg, rgba(47,214,160,.18), rgba(47,214,160,.07)); color: #7ff0c4; font-weight: 600; box-shadow: inset 2px 0 0 #2fd6a0; }
.side-ico { width: 18px; text-align: center; font-size: 15px; flex: none; opacity: .9; }
.side-badge { margin-left: auto; font-size: 10px; font-weight: 700; background: var(--danger); color: #fff; min-width: 18px; height: 18px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }

.sidebar-foot { padding: 16px 18px 20px; border-top: 1px solid rgba(255,255,255,.07); }
.demo-flag { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: #f0c46a; background: rgba(240,196,106,.1); border: 1px solid rgba(240,196,106,.24); border-radius: 8px; padding: 7px 10px; margin-bottom: 12px; }
.demo-dot { width: 6px; height: 6px; border-radius: 50%; background: #f0c46a; flex: none; }
.sidebar-foot-note { font-size: 11px; color: #5e7d70; line-height: 1.7; }

.main-area { margin-left: 236px; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  height: 68px; padding: 0 30px;
  background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.side-toggle { display: none; border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 36px; height: 36px; color: var(--text); }
.topbar-title { display: flex; flex-direction: column; min-width: 0; }
.topbar-title > span { font-size: 16px; font-weight: 700; line-height: 1.3; }
.topbar-title small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.api-pill {
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11px; color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 20px; padding: 5px 11px;
}
.api-pill::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--brand-2); margin-right: 7px; vertical-align: 1px; }
.api-pill.offline::before { background: var(--danger); }
.top-btn { border: 1px solid var(--line-strong); background: #fff; color: var(--text-2); border-radius: 9px; padding: 8px 13px; font-size: 12.5px; font-weight: 600; transition: background .18s, border-color .18s; }
.top-btn:hover { background: var(--brand-soft); border-color: var(--brand-2); color: var(--brand); }
.top-btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.top-btn-primary:hover { background: #095a46; color: #fff; }
.top-btn.on { background: var(--gold-soft); border-color: var(--gold); color: var(--warn); }

.view { flex: 1; padding: 28px 30px 60px; max-width: 1400px; width: 100%; }

/* ---------- Common ---------- */
.page-head { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin-bottom: 5px; font-weight: 700; }
.page-head p { color: var(--muted); font-size: 13px; margin: 0; }
.page-head-actions { margin-left: auto; display: flex; gap: 9px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 20px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.card-title { font-size: 15.5px; font-weight: 700; margin: 0; }
.card-sub { font-size: 12px; color: var(--muted); }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-note { font-size: 12px; color: var(--muted); margin-top: 12px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line-strong); background: #fff; color: var(--text-2); font-size: 13px; font-weight: 600; transition: background .18s, transform .18s, border-color .18s, box-shadow .18s; }
.btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--brand-2); color: var(--brand); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(11,107,83,.18); }
.btn-primary:hover:not(:disabled) { background: #095a46; color: #fff; border-color: #095a46; }
.btn-soft { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.btn-soft:hover:not(:disabled) { background: #d9efe5; color: var(--brand); }
.btn-danger { color: var(--danger); border-color: #f0cdcd; background: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); border-color: #e5adad; }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }

.field { margin-bottom: 16px; }
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.field-hint { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.input, .textarea, .select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 9px;
  background: #fff; color: var(--text); outline: none; transition: border-color .18s, box-shadow .18s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(20,166,123,.12); }
.textarea { resize: vertical; min-height: 108px; font-family: inherit; line-height: 1.6; }
.input-mono { font-family: ui-monospace, SFMono-Regular, Consolas, 'Courier New', monospace; letter-spacing: .3px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.inline-form { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.inline-form .input { flex: 1; min-width: 180px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge-gray { background: #f0f4f2; color: var(--muted); border-color: var(--line); }
.badge-green { background: var(--brand-soft); color: var(--green); border-color: #c6e8d8; }
.badge-gold { background: var(--gold-soft); color: var(--warn); border-color: #eddcba; }
.badge-red { background: var(--danger-soft); color: var(--danger); border-color: #f2cccc; }
.badge-blue { background: #eaf2fb; color: #2c6396; border-color: #cfe0f2; }

.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-card .label { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.stat-card .value { font-size: 25px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-card .foot { font-size: 11px; color: var(--muted-2); margin-top: 5px; }
.stat-card.accent .value { color: var(--brand); }
.stat-card.warn .value { color: var(--warn); }
.stat-card.danger .value { color: var(--danger); }

.info-row { display: flex; flex-wrap: wrap; gap: 10px 28px; padding: 4px 0; }
.info-item { min-width: 130px; }
.info-item .k { font-size: 11.5px; color: var(--muted); }
.info-item .v { font-size: 14px; font-weight: 600; margin-top: 2px; }
.code-text { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 1.2px; font-size: 15px; color: var(--brand); font-weight: 700; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
table.data th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 11.5px; text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--text-2); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #f8fbf9; }
table.data td.num { font-variant-numeric: tabular-nums; }
table.data .strong { color: var(--text); font-weight: 600; }
.rank-num { display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; border-radius: 7px; background: #f0f4f2; font-size: 11.5px; font-weight: 700; }
.rank-num.top1 { background: #fbf1df; color: var(--warn); }
.rank-num.top2 { background: #eef2f1; color: #5b7168; }
.rank-num.top3 { background: #f7ecd6; color: #9a6612; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty-mark { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px; background: var(--brand-soft); display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--brand); }
.empty h3 { font-size: 15px; color: var(--text-2); margin-bottom: 6px; }
.empty p { font-size: 12.5px; margin: 0; }

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--muted); font-size: 13px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line-strong); border-top-color: var(--brand-2); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.alert { padding: 12px 15px; border-radius: 10px; font-size: 12.5px; line-height: 1.65; margin-bottom: 18px; border: 1px solid transparent; }
.alert-info { background: #eef7f3; border-color: #cfe8dc; color: #2d6b54; }
.alert-warn { background: var(--warn-soft); border-color: #eddcba; color: var(--warn); }
.alert-danger { background: var(--danger-soft); border-color: #f2cccc; color: var(--danger); }

.divider { height: 1px; background: var(--line); margin: 20px 0; }

/* ---------- Workbench ---------- */
.wb-hero { background: linear-gradient(120deg, #0b6b53, #128a68); color: #fff; border-radius: var(--radius); padding: 28px 30px; margin-bottom: 22px; position: relative; overflow: hidden; }
.wb-hero::after { content: ''; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.12), transparent 70%); }
.wb-hero h1 { font-size: 22px; margin-bottom: 8px; }
.wb-hero p { font-size: 13px; color: rgba(255,255,255,.8); margin: 0; max-width: 620px; }
.wb-hero-meta { display: flex; gap: 18px; margin-top: 20px; flex-wrap: wrap; }
.wb-hero-meta span { font-size: 11.5px; background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.18); padding: 5px 11px; border-radius: 20px; }

.ledger-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.ledger-item { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; background: #fff; transition: border-color .18s, transform .18s, box-shadow .18s; cursor: pointer; }
.ledger-item:hover { border-color: var(--brand-2); transform: translateY(-2px); box-shadow: var(--shadow); }
.ledger-item.active { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.ledger-item h3 { font-size: 14.5px; margin-bottom: 8px; }
.ledger-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.ledger-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted-2); }
.ledger-del { border: none; background: transparent; color: var(--muted-2); font-size: 11px; padding: 2px 4px; }
.ledger-del:hover { color: var(--danger); }

/* ---------- Timer ---------- */
.timer-panel { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.timer-display { min-width: 190px; }
.timer-display .label { font-size: 11.5px; color: var(--muted); }
.timer-display .clock { font-size: 42px; font-weight: 800; line-height: 1.15; color: var(--brand); font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.timer-display .clock.finished { color: var(--danger); }
.timer-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Matches ---------- */
.match-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.match-card { border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; }
.match-card.disputed { border-color: #e8c4c4; }
.match-card.confirmed { border-color: #cde8da; }
.match-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.match-table-no { font-size: 12.5px; font-weight: 700; }
.match-body { padding: 16px; }
.match-team { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; }
.match-team .name { font-size: 13.5px; font-weight: 600; }
.match-team .players { font-size: 11px; color: var(--muted); }
.match-team.winner .name { color: var(--brand); }
.match-vs { text-align: center; font-size: 10.5px; color: var(--muted-2); letter-spacing: 2px; }
.match-subs { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 10px; font-size: 11.5px; color: var(--muted); display: grid; gap: 4px; }
.match-subs b { color: var(--text-2); font-weight: 600; }
.match-foot { padding: 12px 16px; border-top: 1px solid var(--line); background: #fcfdfc; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.match-foot .select { width: auto; flex: 1; min-width: 120px; padding: 6px 9px; font-size: 12px; }
.match-foot .btn { flex: none; }

/* ---------- QR ---------- */
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.qr-card { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 16px; text-align: center; }
.qr-card img { width: 132px; height: 132px; display: block; margin: 0 auto 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.qr-card .qr-title { font-size: 13px; font-weight: 700; }
.qr-card .qr-sub { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.qr-broken { width: 132px; height: 132px; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 6px; font-size: 11px; color: var(--muted); padding: 10px; }

/* ---------- Settings ---------- */
.preset-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.preset { font-size: 11.5px; padding: 6px 11px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; color: var(--text-2); }
.preset:hover { border-color: var(--brand-2); color: var(--brand); background: var(--brand-soft); }

/* ---------- Toast / Modal ---------- */
.toast-root { position: fixed; top: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { min-width: 220px; max-width: 380px; padding: 12px 16px; border-radius: 10px; background: #17332a; color: #fff; font-size: 13px; box-shadow: var(--shadow-lg); animation: toastIn .25s ease; }
.toast.success { background: #0b6b53; }
.toast.error { background: #a83232; }
.toast.warn { background: #8a6115; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

.modal-root { position: fixed; inset: 0; z-index: 90; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(6, 24, 18, .55); backdrop-filter: blur(3px); }
.modal-root.open { display: flex; }
.modal { background: #fff; border-radius: 16px; width: min(520px, 100%); max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: modalIn .2s ease; }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { padding: 20px 24px 0; }
.modal-head h3 { font-size: 16.5px; margin-bottom: 6px; }
.modal-head p { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.7; }
.modal-body { padding: 18px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 0 24px 22px; }

.copy-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; line-height: 1.9; word-break: break-all; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .main-area { margin-left: 0; }
  .side-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { padding: 0 18px; }
  .view { padding: 22px 18px 50px; }
  .grid-2 { grid-template-columns: 1fr; }
  .api-pill { display: none; }
}

@media (max-width: 640px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .card { padding: 18px 16px; }
  .topbar-title small { display: none; }
  .top-btn { padding: 7px 10px; font-size: 12px; }
  .field-row { grid-template-columns: 1fr; }
  .match-grid { grid-template-columns: 1fr; }
  .page-head-actions { width: 100%; }
  .timer-display .clock { font-size: 34px; }
  .wb-hero { padding: 22px 20px; }
}

@media print {
  .sidebar, .topbar, .page-head-actions, .card-head .right, .toast-root, .modal-root { display: none !important; }
  .main-area { margin-left: 0; }
  .view { padding: 0; max-width: none; }
  .card { box-shadow: none; border: none; padding: 0; margin: 0; }
  .qr-card { break-inside: avoid; border: 1px solid #ccc; }
  body { background: #fff; }
}
