:root {
  --bg: #0c0d10;
  --bg-2: #12141a;
  --line: rgba(244, 241, 234, 0.08);
  --text: #f6f3ec;
  --muted: #9c978e;
  --faint: #6f6b64;
  --gold: #c6a36a;
  --gold-dim: rgba(198, 163, 106, 0.16);
  --green: #9ec9ad;
  --green-dim: rgba(158, 201, 173, 0.14);
  --red: #e0b1aa;
  --red-dim: rgba(224, 177, 170, 0.14);
  --amber: #e2c48a;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  --serif: "Iowan Old Style", "Palatino Linotype", "Songti TC", serif;
  --sans: "Avenir Next", "PingFang TC", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: 0.01em;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.fine { color: var(--faint); font-size: 12px; margin: 14px 0 0; }
#login-hint:empty { display: none; }

.lang {
  display: flex;
  gap: 4px;
  width: fit-content;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(12, 13, 16, 0.55);
}
.lang button {
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.lang button.on { background: var(--text); color: #16140f; }
.login { position: relative; }
.login > .lang { position: absolute; top: 22px; right: 28px; }
.side .lang { margin: 12px 8px 8px; }

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  background:
    linear-gradient(90deg, rgba(8, 8, 10, 0.78) 0%, rgba(8, 8, 10, 0.28) 46%, rgba(8, 8, 10, 0.62) 100%),
    url("/login-stage.jpg") center / cover no-repeat;
}
.pw { position: relative; display: block; }
.pw input { padding-right: 44px; }
.pw-eye {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
.pw-eye:hover { color: var(--text); }
.pw-eye svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.turnstile { min-height: 68px; margin: 4px 0 8px; width: 100%; }
.login-copy { padding: 12vh 10vw 8vh; align-self: end; }
.login-copy h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 76px;
  line-height: 0.96;
  letter-spacing: -0.03em;
}
.lede { max-width: 420px; color: var(--muted); font-size: 16px; line-height: 1.7; }
.login-card {
  margin: auto 10vw auto 0;
  width: min(420px, 86%);
  padding: 36px 32px 28px;
  background: rgba(18, 20, 26, 0.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.login-card label { display: block; margin: 16px 0; color: var(--muted); font-size: 12px; }
.login-card input {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  background: #0c0d10;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.login-card input:focus { border-color: rgba(198, 163, 106, 0.7); }
.login-card input.invalid { border-color: var(--red); }
.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: transparent;
}
.btn.solid { width: 100%; background: var(--text); color: #16140f; font-weight: 600; }
.btn.solid:hover { background: #fff; }
.btn.solid:disabled { opacity: 0.72; cursor: progress; }
.btn.ghost {
  border: 1px solid var(--line);
  color: var(--text);
  background: transparent;
}
.btn.ghost:hover { border-color: rgba(244, 241, 234, 0.28); }
.btn.gold { background: var(--gold); color: #1a140c; font-weight: 650; }
.text-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.text-btn:hover { color: var(--text); }

.app { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 232px 1fr; }
.side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 18px;
  border-right: 1px solid var(--line);
  background: #101116;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 22px; }
.brand strong { display: block; font-family: var(--serif); font-size: 22px; font-weight: 500; }
.brand em { color: var(--muted); font-style: normal; font-size: 12px; }
.mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid rgba(198, 163, 106, 0.5);
  border-radius: 10px;
  color: var(--gold);
  font-family: var(--serif);
}
#nav { display: flex; flex-direction: column; gap: 4px; }
.nav-btn {
  text-align: left;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}
.nav-btn.active, .nav-btn:hover { background: #1a1d25; color: var(--text); }
.nav-btn.active { box-shadow: inset 2px 0 0 var(--gold); }
.side-out { margin-top: auto; text-align: left; padding: 8px; }

main { min-width: 0; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 28px 36px 8px;
}
.top h2 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 34px; letter-spacing: -0.02em; }
.who { color: var(--muted); text-align: right; font-size: 13px; }
.who strong { display: block; color: var(--text); font-weight: 600; }
.acting {
  margin: 8px 36px 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--gold-dim);
  color: #f3e6cf;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.view { padding: 18px 36px 40px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat, .panel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.stat { padding: 16px 18px 14px; }
.stat b { display: block; margin-top: 8px; font-family: var(--serif); font-size: 32px; font-weight: 500; }
.stat span, .panel h3, .hint { color: var(--muted); }
.panel { padding: 18px 18px 8px; }
.panel h3 { margin: 0 0 12px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; }
.rule { height: 1px; background: var(--line); margin: 14px 0; }

.work { display: grid; grid-template-columns: minmax(0, 1.45fr) 320px; gap: 16px; align-items: start; }
.field { margin: 0 0 14px; }
.field span, .label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
input[type="text"], input[type="url"], textarea, select {
  width: 100%;
  padding: 11px 12px;
  background: #0c0d10;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: rgba(198, 163, 106, 0.7); }

.seg { display: flex; padding: 3px; background: #0c0d10; border-radius: 12px; border: 1px solid var(--line); }
.seg button {
  flex: 1;
  border: 0;
  border-radius: 9px;
  padding: 8px 0;
  background: transparent;
  color: var(--muted);
}
.seg button.on { background: var(--gold); color: #1a140c; font-weight: 650; }

.msgs { display: flex; flex-direction: column; gap: 6px; }
.msg {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: #0c0d10;
}
.msg input { accent-color: var(--gold); }
.acc-list { display: flex; flex-direction: column; }
.acc {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px 2px;
  border-top: 1px solid var(--line);
  background: transparent;
  text-align: left;
}
.acc:first-child { border-top: 0; }
.acc.on .dot { background: var(--gold); box-shadow: 0 0 0 4px var(--gold-dim); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #3a3d46; }
.pill {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
}
.pill.ok { color: var(--green); background: var(--green-dim); }
.pill.wait { color: var(--amber); background: rgba(226, 196, 138, 0.12); }
.pill.off { color: var(--red); background: var(--red-dim); }

.summary { position: sticky; top: 18px; padding: 18px; }
.summary h3 { margin-top: 0; }
.summary dl { margin: 0; }
.summary div { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; }
.summary .btn { width: 100%; margin-top: 10px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0c0d10;
}
.stepper b { min-width: 24px; text-align: center; font-family: var(--serif); font-size: 22px; font-weight: 500; }

.rows { width: 100%; border-collapse: collapse; }
.rows th { text-align: left; color: var(--faint); font-weight: 500; font-size: 12px; padding: 0 8px 10px; }
.rows td { padding: 12px 8px; border-top: 1px solid var(--line); }
.merchant {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.merchant:first-child { border-top: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.machine {
  padding: 14px;
  border-radius: 14px;
  background: #0c0d10;
  border: 1px solid var(--line);
  min-height: 118px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.machine .model { font-size: 15px; }
.machine .addr { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.machine .pill { align-self: flex-start; margin-top: auto; }

.login.is-leaving { animation: leave-login 0.7s ease forwards; }
.app.is-entering { animation: app-in 0.45s ease; }
.gate, .ask {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate { background: rgba(8, 8, 10, 0.55); backdrop-filter: blur(10px); }
.gate-card { text-align: center; }
.gate-card .mark { margin: 0 auto 18px; }
.gate-card p { margin: 0; color: var(--text); letter-spacing: 0.14em; }
.gate-bar {
  display: block;
  width: 132px;
  height: 2px;
  margin: 18px auto 0;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(244, 241, 234, 0.14);
}
.gate-bar::after {
  content: "";
  display: block;
  width: 42%;
  height: 100%;
  background: var(--gold);
  animation: gate-slide 0.9s ease-in-out infinite;
}
.ask { background: rgba(8, 8, 10, 0.62); }
.ask-card {
  width: min(380px, 100%);
  padding: 28px 24px 22px;
  background: #16181f;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.ask-card h3 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 28px;
}
.ask-card p { margin: 0; color: var(--muted); line-height: 1.6; }
.ask-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.ask-actions .btn { width: auto; min-width: 88px; }

@keyframes leave-login {
  to { opacity: 0; transform: scale(0.985); }
}
@keyframes app-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes gate-slide {
  from { transform: translateX(-130%); }
  to { transform: translateX(280%); }
}
@media (prefers-reduced-motion: reduce) {
  .login.is-leaving, .app.is-entering, .gate-bar::after { animation: none; }
}

@media (max-width: 980px) {
  .login, .app, .work, .grid, .stats { grid-template-columns: 1fr; }
  .login-copy { padding: 88px 24px 0; }
  .login-copy h1 { font-size: 52px; }
  .login-card { margin: 24px auto 40px; width: min(420px, calc(100% - 40px)); }
  .side { position: relative; height: auto; }
  .summary { position: static; }
  .top, .view { padding-left: 20px; padding-right: 20px; }
  .acting { margin-left: 20px; margin-right: 20px; }
}

@media (max-width: 760px) {
  .login {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: 100dvh;
    padding: calc(60px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom));
  }
  .login > .lang { top: calc(12px + env(safe-area-inset-top)); right: 16px; }
  .login-copy { align-self: stretch; width: 100%; padding: 0; }
  .login-copy h1 { font-size: 36px; }
  .lede { max-width: none; font-size: 15px; line-height: 1.55; }
  .login-card { width: 100%; margin: 28px 0 0; padding: 22px 18px 18px; }
  .app { display: flex; flex-direction: column; min-height: 100dvh; }
  .side {
    position: sticky;
    top: 0;
    z-index: 5;
    height: auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "brand lang out" "nav nav nav";
    align-items: center;
    gap: 8px 10px;
    padding: 10px 12px 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand { grid-area: brand; padding: 0; }
  .brand em { display: none; }
  #nav { grid-area: nav; flex-direction: row; min-width: 0; overflow-x: auto; }
  .nav-btn { white-space: nowrap; padding: 8px 10px; }
  .lang button { padding: 6px 8px; white-space: nowrap; flex: none; }
  .side .lang { grid-area: lang; justify-self: end; width: max-content; margin: 0; flex-wrap: nowrap; }
  .side-out { grid-area: out; margin: 0; white-space: nowrap; }
  .top { padding: 16px 16px 4px; gap: 12px; }
  .top h2 { font-size: 26px; }
  .view { padding: 12px 16px 28px; }
  .acting { margin: 8px 16px 0; flex-wrap: wrap; gap: 8px; }
  .stat b { font-size: 26px; }
  .grid { grid-template-columns: 1fr 1fr; }
  .seg { flex-wrap: wrap; }
  .seg button { flex: 1 1 30%; }
  .merchant { align-items: flex-start; gap: 12px; }
  .merchant .btn { flex: none; }
}
