:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --muted-surface: #eef3f8;
  --line: #dbe4ee;
  --text: #17202a;
  --muted: #66768a;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #059669;
  --red: #ef4444;
  --amber: #d97706;
  --red-soft: #fee2e2;
  --green-soft: #dcfce7;
  --amber-soft: #fef3c7;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { max-width: 100%; overflow-x: hidden; }
body { margin: 0; min-height: 100vh; max-width: 100%; overflow-x: hidden; color: var(--text); background: var(--bg); }
img { max-width: 100%; height: auto; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
.hidden-control { display: none !important; }

.shell { display: grid; grid-template-columns: 76px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #17202a; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 20px 12px; }
.brand { width: 44px; height: 44px; border-radius: 8px; border: 1px solid rgba(255,255,255,.28); display: grid; place-items: center; font-weight: 900; font-size: 13px; background: #243241; }
.nav { width: 44px; height: 44px; border: 0; border-radius: 8px; color: #b8c4d2; background: transparent; font-weight: 900; font-size: 18px; }
.nav.active, .nav:hover { color: #fff; background: var(--blue); }

.main { padding: 28px; display: grid; gap: 20px; }
.shell, .main, .topbar, .login-band, .locked-content, .dashboard-grid, .panel, .activity-band, .support-band { min-width: 0; max-width: 100%; }
.topbar, .login-band, .panel, .activity-band, .support-band { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.topbar { padding: 20px 24px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; }
h1, h2 { margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 18px; }

.chips { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.chip, .state-pill { display: inline-flex; align-items: center; min-height: 30px; border-radius: 8px; padding: 0 10px; background: var(--muted-surface); color: #334155; font-weight: 900; font-size: 13px; white-space: nowrap; }
.chip.ok, .state-pill.ok { color: var(--green); background: var(--green-soft); }
.chip.danger, .state-pill.error { color: var(--red); background: var(--red-soft); }
.state-pill.waiting { color: var(--amber); background: var(--amber-soft); }
.state-pill.idle { color: #475569; background: var(--muted-surface); }

.login-band { padding: 22px 12px 22px 24px; display: grid; grid-template-columns: minmax(360px, 1fr) minmax(380px, 560px); gap: 20px; align-items: end; }
.gate-copy { display: none; }
.login-copy p { margin: 10px 0 0; color: #4b5c72; line-height: 1.8; }
.login-copy ol { margin: 14px 0 0; padding-left: 24px; color: #4b5c72; line-height: 1.9; }
.login-copy li { margin: 4px 0; }
.login-form { display: grid; gap: 12px; }
.login-row { display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 10px; }
label { color: var(--muted); font-size: 13px; font-weight: 900; }
input, select { width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; outline: none; background: #fff; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
button { height: 46px; border: 0; border-radius: 8px; color: #fff; background: var(--blue); font-weight: 900; padding: 0 14px; }
button:hover { background: var(--blue-dark); }
.secondary { color: var(--blue); background: #e8f0ff; }
.secondary:hover { background: #dbe8ff; }
.danger-button, .ban-button { color: var(--red); background: var(--red-soft); }
.danger-button:hover, .ban-button:hover { background: #fecaca; }
.profile-box { display: none; }

.locked-content { display: none; gap: 20px; }
.locked-content.unlocked { display: grid; }

body.locked-mode .shell { display: block; min-height: 100vh; }
body.locked-mode .sidebar,
body.locked-mode .topbar,
body.locked-mode .login-copy,
body.locked-mode #lockedContent,
body.locked-mode #logoutButton { display: none; }
body.locked-mode .main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
body.locked-mode .login-band {
  width: min(520px, 100%);
  padding: 34px;
  grid-template-columns: 1fr;
  gap: 22px;
  align-items: stretch;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .12);
}
body.locked-mode .gate-copy {
  display: grid;
  gap: 10px;
  text-align: center;
}
body.locked-mode .gate-copy h1 { font-size: 32px; }
body.locked-mode .gate-copy p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}
body.locked-mode .login-form { gap: 14px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(300px, .95fr) minmax(360px, 1.1fr) minmax(300px, .95fr); gap: 18px; }
.panel { padding: 20px; min-height: 360px; display: grid; gap: 18px; align-content: start; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.session-heading { align-items: center; }
.session-hint { flex: 1 1 360px; max-width: 560px; margin: 0; color: var(--red); font-size: clamp(16px, 1.35vw, 23px); font-weight: 900; line-height: 1.25; }

.fixed-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field-tile { min-height: 78px; border: 1px solid #e2e8f0; border-radius: 8px; background: var(--muted-surface); padding: 12px; }
.field-tile span, .field-tile label, .phone-display span, .code-box span, .fixed-wait-box span { display: block; color: var(--muted); font-size: 12px; font-weight: 900; }
.field-tile strong { display: block; margin-top: 12px; font-size: 20px; word-break: break-word; }
.route-field { display: grid; gap: 10px; }
.route-field select { font-weight: 900; }
.fixed-wait-box { height: 58px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; background: #fff; }
.fixed-wait-box strong { display: block; margin-top: 6px; font-size: 20px; }
.primary-button { width: 100%; }

.phone-display, .code-box { border: 1px solid var(--line); border-radius: 8px; background: linear-gradient(180deg, #fff, #f8fafc); padding: 18px; }
.phone-display strong { display: block; font-size: clamp(32px, 4vw, 44px); line-height: 1.1; word-break: break-all; }
.phone-copy-row { margin-top: 10px; display: grid; grid-template-columns: minmax(0, 1fr) 72px; gap: 12px; align-items: center; }
.ban-button { width: 100%; margin-top: 12px; }
.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0; }
.meta div { background: var(--muted-surface); border-radius: 8px; padding: 12px; }
.meta dt { color: var(--muted); font-size: 12px; font-weight: 900; }
.meta dd { margin: 8px 0 0; font-weight: 900; word-break: break-all; }
.progress-track { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.progress-bar { width: 0; height: 100%; background: var(--blue); transition: width .25s ease; }

.code-box { min-height: 186px; display: grid; align-content: center; text-align: center; }
.code-box strong { display: block; margin-top: 14px; color: var(--green); font-size: clamp(44px, 6vw, 68px); line-height: 1; word-break: break-all; }
.code-box .secondary { justify-self: end; min-width: 96px; margin-top: 18px; }

.activity-band { padding: 20px 24px; }
.log-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.log-list { list-style: none; display: grid; gap: 8px; max-height: 240px; overflow: auto; margin: 14px 0 0; padding: 0; }
.log-list li { display: flex; justify-content: space-between; gap: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fbfdff; padding: 10px 12px; color: #334155; line-height: 1.5; }
.log-list time { color: var(--muted); white-space: nowrap; font-size: 12px; }
.support-band { padding: 32px 24px; display: grid; grid-template-columns: minmax(420px, 560px) minmax(260px, 320px); gap: 56px; align-items: center; justify-content: center; text-align: center; }
.support-copy h2 { font-size: 28px; }
.support-copy p:not(.eyebrow) { margin: 16px 0 0; color: #4b5c72; line-height: 1.8; font-size: 18px; font-weight: 700; white-space: nowrap; }
.support-qr { width: min(300px, 30vw); max-width: 100%; justify-self: center; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 10px; }
.toast { position: fixed; top: 22px; left: 50%; z-index: 50; transform: translate(-50%, -18px); opacity: 0; pointer-events: none; max-width: min(560px, calc(100vw - 32px)); padding: 14px 18px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 18px 48px rgba(15,23,42,.18); font-weight: 900; transition: opacity .18s ease, transform .18s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1180px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px), (pointer: coarse) and (max-width: 1180px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 14px; gap: 14px; }
  .topbar { align-items: flex-start; flex-direction: column; padding: 18px; }
  .chips { justify-content: flex-start; }
  .login-band { grid-template-columns: 1fr; }
  .login-copy ol { padding-left: 22px; line-height: 1.85; }
  .support-band { grid-template-columns: 1fr; }
  .support-qr { width: min(280px, 100%); }
  .login-row, .meta, .fixed-grid { grid-template-columns: 1fr; }
  body.locked-mode .login-row { grid-template-columns: 1fr; }
  body.locked-mode .login-band { padding: 26px 18px; }
  .panel, .activity-band, .support-band { padding: 18px; }
  .support-copy p:not(.eyebrow) { white-space: normal; }
  .phone-copy-row { grid-template-columns: 1fr; }
  .phone-display strong { font-size: clamp(28px, 10vw, 40px); }
  .code-box strong { font-size: clamp(42px, 13vw, 62px); }
  .session-heading { flex-wrap: wrap; align-items: flex-start; }
  .session-hint { flex-basis: 100%; order: 3; font-size: 17px; }
}
