:root {
  color-scheme: light;
  --bg: #f3f6fc;
  --panel: #ffffff;
  --panel-soft: #f8faff;
  --line: #dfe6f3;
  --line-soft: #edf1f7;
  --text: #172849;
  --muted: #71809c;
  --accent: #4d6fe8;
  --accent-soft: #e8eeff;
  --green: #40b581;
  --orange: #f0a044;
  --danger: #d36575;
  --shadow: 0 8px 26px rgba(48, 77, 139, .055);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 9% 0%, #fbfcff 0, var(--bg) 38%, #eef3fb 100%); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { border: 1px solid var(--line); border-radius: 11px; background: var(--panel); color: var(--text); cursor: pointer; transition: border-color .18s ease, box-shadow .18s ease, background .18s ease, transform .18s ease; }
button:hover { border-color: #aec0f2; box-shadow: 0 4px 14px rgba(65, 93, 170, .09); transform: translateY(-1px); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(77, 111, 232, .18); outline-offset: 1px; }

.admin-shell { width: min(1440px, calc(100% - 42px)); margin: 0 auto; padding: 30px 0 72px; }
.admin-login { width: min(430px, 100%); margin: 12vh auto 0; padding: 36px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255, 255, 255, .94); box-shadow: 0 24px 70px rgba(54, 75, 130, .14); }
.admin-login h1, .admin-header h1 { margin: 7px 0 10px; font-size: clamp(30px, 4vw, 43px); letter-spacing: -.04em; }
.admin-login p:not(.eyebrow) { color: var(--muted); font-size: 13px; line-height: 1.7; }
.eyebrow { margin: 0; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .2em; }
form { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); }
textarea { padding-top: 10px; }
form button { min-height: 42px; padding: 0 16px; border-color: var(--accent); background: var(--accent); color: #fff; }
form small, #admin-login-message { min-height: 18px; color: var(--muted); line-height: 1.5; }

.admin-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; padding: 3px 0 22px; border-bottom: 1px solid var(--line); }
.admin-account { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; font-weight: 600; }
.admin-account button { min-height: 38px; padding: 0 14px; }
.admin-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 15px 0 24px; }
.admin-nav button { min-height: 40px; padding: 0 17px; color: #647392; font-weight: 650; }
.admin-nav button.is-active { border-color: #91a6f2; background: var(--accent); color: #fff; box-shadow: 0 7px 16px rgba(77, 111, 232, .2); }
.admin-view { padding-top: 2px; }
.view-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.view-heading h2 { margin: 7px 0 0; font-size: 25px; letter-spacing: -.035em; }
.view-subtitle { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.heading-actions { display: flex; align-items: center; gap: 10px; }
.view-heading button, .toolbar-form button { min-height: 38px; padding: 0 14px; }
.data-badge { padding: 8px 11px; border: 1px solid #f1d39c; border-radius: 999px; background: #fff8e9; color: #b47717; font-size: 11px; font-weight: 700; }

.dashboard-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.kpi-card { position: relative; display: flex; min-height: 126px; gap: 13px; overflow: hidden; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, .93); box-shadow: var(--shadow); transition: transform .2s ease, box-shadow .2s ease; }
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(48, 77, 139, .1); }
.kpi-icon { display: grid; flex: 0 0 38px; place-items: center; width: 38px; height: 38px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); }
.kpi-icon.green { background: #e7f8ef; color: var(--green); }
.kpi-icon.orange { background: #fff2df; color: var(--orange); }
.kpi-icon svg { width: 21px; height: 21px; }
.kpi-content { min-width: 0; }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.kpi-value { margin-top: 7px; font-size: 28px; font-weight: 800; letter-spacing: -.04em; }
.kpi-footer { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--muted); font-size: 11px; }
.kpi-change { font-weight: 800; }
.kpi-change.positive { color: #249366; }
.kpi-change.negative { color: #bf7180; }
.kpi-sparkline { position: absolute; right: 12px; bottom: 12px; width: 108px; height: 40px; opacity: .95; }
.kpi-sparkline svg { width: 100%; height: 100%; overflow: visible; }
.kpi-sparkline path { fill: none; stroke: var(--accent); stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.2; }
.kpi-sparkline.green path { stroke: var(--green); }
.kpi-sparkline.orange path { stroke: var(--orange); }

.dashboard-grid { display: grid; gap: 14px; margin-bottom: 14px; }
.dashboard-grid-main { grid-template-columns: minmax(0, 1.62fr) minmax(330px, .88fr); }
.dashboard-grid-three { grid-template-columns: minmax(0, 1fr) minmax(0, 1.24fr) minmax(270px, .92fr); }
.dashboard-grid-bottom { grid-template-columns: minmax(0, 1.22fr) minmax(340px, .98fr); }
.dashboard-card { min-width: 0; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, .94); box-shadow: var(--shadow); }
.dashboard-grid-main .dashboard-card { min-height: 304px; }
.dashboard-grid-three .dashboard-card { min-height: 264px; }
.dashboard-grid-bottom .dashboard-card { min-height: 275px; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 20px 20px 0; }
.card-heading h3 { margin: 0; font-size: 15px; letter-spacing: -.015em; }
.card-heading p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.chart-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px 14px; color: var(--muted); font-size: 10px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.legend-dot.blue { background: var(--accent); }
.legend-dot.green { background: var(--green); }
.legend-dot.orange { background: var(--orange); }

.trend-chart { position: relative; height: 232px; padding: 18px 18px 12px; }
.trend-chart svg, .signup-chart svg { width: 100%; height: 100%; overflow: visible; }
.chart-grid-line { stroke: #e9eef7; stroke-width: 1; stroke-dasharray: 3 4; }
.chart-axis-label { fill: #8c9ab2; font-size: 10px; }
.trend-line { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.35; }
.trend-line.blue { stroke: var(--accent); }
.trend-line.green { stroke: var(--green); }
.trend-line.orange { stroke: var(--orange); }
.trend-point { stroke: #fff; stroke-width: 1.6; }
.trend-point.blue { fill: var(--accent); }
.trend-point.green { fill: var(--green); }
.trend-point.orange { fill: var(--orange); }

.composition-content { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; gap: 10px; min-height: 236px; padding: 12px 20px 20px; }
.donut { position: relative; width: 142px; height: 142px; margin: auto; border-radius: 50%; background: conic-gradient(var(--donut-stops)); }
.donut::after { position: absolute; inset: 28px; border-radius: 50%; background: #fff; content: ""; }
.donut-center { position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; text-align: center; }
.donut-center strong { font-size: 22px; letter-spacing: -.04em; }
.donut-center span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.composition-list { display: grid; gap: 14px; }
.composition-item { display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 8px; font-size: 11px; }
.composition-item i { width: 9px; height: 9px; border-radius: 50%; }
.composition-item span { color: var(--muted); }
.composition-item strong { font-size: 12px; }
.composition-item small { display: block; margin-top: 3px; color: #9aa6b9; font-size: 10px; }

.ranked-bars { display: grid; gap: 18px; padding: 22px 20px; }
.rank-bar-head { display: flex; justify-content: space-between; margin-bottom: 7px; color: var(--muted); font-size: 11px; }
.rank-bar-head strong { color: var(--text); font-size: 12px; }
.rank-bar-track { height: 12px; overflow: hidden; border-radius: 999px; background: #eef2f8; }
.rank-bar-fill { height: 100%; border-radius: inherit; }
.signup-chart { height: 208px; padding: 18px 18px 12px; }
.signup-bar { fill: var(--accent); opacity: .9; }
.signup-bar.login { fill: var(--green); }
.signup-bar-label { fill: #8795ad; font-size: 9px; }
.signup-value-label { fill: #6f7e99; font-size: 9px; font-weight: 700; }

.ticket-progress { display: grid; gap: 14px; padding: 22px 20px; }
.ticket-row { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; }
.ticket-row strong { color: var(--text); font-size: 11px; font-weight: 750; }
.ticket-track { height: 8px; overflow: hidden; border-radius: 999px; background: #eef2f8; }
.ticket-fill { height: 100%; min-width: 4px; border-radius: inherit; }
.ticket-total { display: flex; justify-content: space-between; padding-top: 4px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 11px; }
.ticket-total strong { color: var(--text); }

.activity-card { overflow: hidden; }
.link-button { padding: 0; border: 0; background: transparent; color: var(--accent); font-size: 11px; font-weight: 750; }
.link-button:hover { box-shadow: none; transform: none; }
.activity-table-wrap { overflow: auto; padding: 14px 20px 16px; }
.activity-table { width: 100%; min-width: 620px; border-collapse: collapse; }
.activity-table th, .activity-table td { padding: 10px 7px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; font-size: 11px; }
.activity-table th { color: #91a0b8; font-size: 10px; font-weight: 750; }
.activity-table td { color: #4e607f; }
.activity-table td:first-child { color: #8a98af; font-size: 10px; }
.activity-type { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-weight: 700; }
.activity-type i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.activity-type i.green { background: var(--green); }
.activity-type i.orange { background: var(--orange); }
.activity-type i.red { background: var(--danger); }
.activity-table tr:last-child td { border-bottom: 0; }

.heatmap { display: grid; grid-template-columns: 34px repeat(24, minmax(7px, 1fr)); grid-template-rows: repeat(7, 14px) 18px; align-items: center; gap: 4px; padding: 23px 20px 19px; }
.heatmap-day { color: #8291aa; font-size: 9px; }
.heat-cell { min-width: 0; height: 14px; border-radius: 3px; background: #edf2fb; }
.heat-cell.level-1 { background: #d6e1fb; }
.heat-cell.level-2 { background: #b6c9f6; }
.heat-cell.level-3 { background: #8faaf0; }
.heat-cell.level-4 { background: #6084e5; }
.heat-cell.level-5 { background: #3f66d7; }
.heat-hour { grid-row: 8; color: #8a98af; font-size: 9px; text-align: center; }
.heat-legend { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin: -5px 20px 17px; color: #8a98af; font-size: 9px; }
.heat-legend i { width: 10px; height: 10px; border-radius: 2px; background: #edf2fb; }
.heat-legend i:nth-of-type(2) { background: #b6c9f6; }
.heat-legend i:nth-of-type(3) { background: #6084e5; }
.heat-legend i:nth-of-type(4) { background: #3f66d7; }

.admin-note { margin-top: 16px; padding: 12px 14px; border: 1px solid #e1e7f4; border-radius: 11px; background: #f8faff; color: var(--muted); font-size: 11px; line-height: 1.6; }
.toolbar-form { display: flex; align-items: end; gap: 9px; margin-bottom: 15px; }
.toolbar-form input { flex: 1; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 13px; background: rgba(255, 255, 255, .86); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; font-size: 12px; }
th { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .04em; }
td button { min-height: 30px; padding: 0 9px; font-size: 11px; }
tr:last-child td { border-bottom: 0; }
.status-banned { color: var(--danger); }
.status-active { color: #17835e; }
.settings-form { grid-template-columns: 1fr 1fr 1.4fr auto; align-items: end; margin-bottom: 16px; }
.dialog-card { position: relative; width: min(700px, calc(100vw - 30px)); max-height: min(760px, calc(100vh - 30px)); overflow: auto; padding: 28px; border: 1px solid var(--line); border-radius: 17px; background: #fff; }
dialog { padding: 0; border: 0; background: transparent; }
dialog::backdrop { background: rgba(10, 20, 45, .35); }
.dialog-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%; font-size: 20px; }
.detail-heading { padding-right: 38px; }
.detail-heading h3 { margin: 0 0 6px; font-size: 20px; }
.detail-heading p { margin: 0 0 15px; color: var(--muted); font-size: 12px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.detail-grid div { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafbff; }
.detail-grid span, .detail-grid strong { display: block; }
.detail-grid span { color: var(--muted); font-size: 10px; }
.detail-grid strong { margin-top: 5px; font-size: 14px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.detail-actions button { min-height: 36px; padding: 0 11px; }
.detail-actions .danger { border-color: #efc3cb; color: var(--danger); }
.audit-list { display: grid; gap: 7px; }
.audit-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fafbff; font-size: 12px; }
.audit-list > div span, .audit-list > p { color: var(--muted); }
.audit-list > p { margin: 0; font-size: 12px; }
.admin-toast { position: fixed; left: 50%; bottom: 22px; z-index: 5; max-width: calc(100% - 30px); padding: 11px 16px; border-radius: 9px; background: #152443; color: #fff; font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: opacity .18s ease, transform .18s ease; }
.admin-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.is-hidden { display: none !important; }

@media (max-width: 1120px) {
  .dashboard-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid-main, .dashboard-grid-bottom { grid-template-columns: 1fr; }
  .dashboard-grid-three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid-three > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .admin-shell { width: min(100% - 22px, 1440px); padding-top: 18px; }
  .admin-header { align-items: flex-start; flex-direction: column; }
  .admin-account { width: 100%; justify-content: space-between; }
  .dashboard-heading { align-items: flex-start; flex-direction: column; }
  .heading-actions { width: 100%; justify-content: space-between; }
  .dashboard-grid-three { grid-template-columns: 1fr; }
  .dashboard-grid-three > :last-child { grid-column: auto; }
  .composition-content { grid-template-columns: 1fr; padding-top: 20px; }
  .composition-list { width: min(300px, 100%); margin: 0 auto; }
  .chart-legend { justify-content: flex-start; }
  .card-heading { flex-direction: column; }
  .activity-card .card-heading { flex-direction: row; align-items: center; }
  .toolbar-form { align-items: stretch; flex-direction: column; }
  .settings-form { grid-template-columns: 1fr; }
  .settings-form button { grid-column: auto; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 470px) {
  .dashboard-kpi-grid { grid-template-columns: 1fr; }
  .kpi-card { min-height: 116px; }
  .trend-chart { height: 210px; padding-inline: 9px; }
  .heatmap { column-gap: 2px; padding-inline: 10px; }
  .heatmap-day { font-size: 8px; }
  .heat-hour { font-size: 8px; }
}
