:root {
  --bg: #090b10;
  --panel: rgba(21, 24, 32, .88);
  --panel-strong: #151820;
  --line: #2b303e;
  --line-soft: #202531;
  --text: #f3f5fb;
  --muted: #949bad;
  --accent: #8067f7;
  --accent-2: #a891ff;
  --success: #55d7a4;
  --danger: #ff7894;
  --shadow: 0 24px 80px rgba(0, 0, 0, .34);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(102, 77, 229, .11), transparent 34rem),
    linear-gradient(180deg, #090b10 0%, #0c0f15 100%);
  font: 14px/1.55 "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; letter-spacing: .02em; }
.ambient { position: fixed; z-index: -1; border-radius: 999px; filter: blur(80px); opacity: .16; }
.ambient-one { width: 28rem; height: 28rem; background: #6c4df5; top: -16rem; left: -10rem; }
.ambient-two { width: 22rem; height: 22rem; background: #274b91; right: -12rem; top: 38%; }
.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 56px; }
.panel { border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.eyebrow { margin: 0 0 7px; color: var(--accent-2); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
.muted { color: var(--muted); }

.login-layout { min-height: calc(100vh - 80px); display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: clamp(32px, 8vw, 110px); }
.login-intro h1 { margin: 6px 0 16px; max-width: 620px; font-size: clamp(40px, 7vw, 72px); line-height: 1.03; letter-spacing: -.045em; }
.intro-copy { max-width: 520px; color: #adb3c2; font-size: 17px; }
.brand-mark { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 24px; border: 1px solid rgba(255,255,255,.28); border-radius: 18px; background: linear-gradient(145deg, #fff, #9aa1af); box-shadow: inset 0 1px #fff, 0 12px 35px rgba(0,0,0,.4); color: #11151d; font-size: 34px; font-weight: 900; }
.brand-mark.small { width: 39px; height: 39px; margin: 0; border-radius: 12px; font-size: 23px; }
.security-note { display: inline-flex; align-items: center; gap: 9px; margin-top: 20px; padding: 9px 13px; border: 1px solid #294c42; border-radius: 999px; background: rgba(46,112,89,.14); color: #a5ddc8; font-size: 12px; }
.security-note span { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 12px var(--success); }
.login-card { padding: clamp(24px, 5vw, 38px); }
.login-card h2, .section-heading h2 { margin: 0; font-size: 22px; }
.login-card .muted { margin: 7px 0 25px; }

.field { display: block; margin: 16px 0; }
.field > span, .term-picker legend { display: block; margin-bottom: 7px; color: #cfd3dd; font-size: 12px; font-weight: 700; }
.field input { width: 100%; height: 46px; border: 1px solid #343a49; border-radius: 12px; outline: 0; padding: 0 13px; background: #0c0f15; color: var(--text); transition: .18s ease; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(128,103,247,.15); }
.field input::placeholder { color: #5f6675; }
.button { min-height: 42px; border: 1px solid transparent; border-radius: 12px; padding: 0 17px; color: #fff; cursor: pointer; font-weight: 800; transition: transform .15s ease, border-color .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .52; cursor: wait; transform: none; }
.button.primary { background: linear-gradient(135deg, #7055ed, #8c70ff); box-shadow: 0 10px 24px rgba(105,77,235,.24); }
.button.secondary { border-color: #464c5c; background: #272c38; }
.button.ghost { border-color: var(--line); background: rgba(18,21,28,.7); color: #d6d9e2; }
.button.compact { min-height: 36px; padding: 0 12px; }
.button.wide { width: 100%; margin-top: 8px; }
.form-message { min-height: 22px; margin: 12px 0 0; color: var(--danger); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--line-soft); }
.brand-inline, .account-area { display: flex; align-items: center; gap: 12px; }
.brand-inline span, .account-area span { display: block; color: var(--muted); font-size: 10px; letter-spacing: .1em; }
.account-area { text-align: right; }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding: 42px 2px 24px; }
.hero h1 { margin: 0; font-size: clamp(32px, 5vw, 52px); letter-spacing: -.035em; }
.hero .muted { margin: 8px 0 0; }
.alert { margin-bottom: 18px; border: 1px solid; border-radius: 14px; padding: 13px 15px; }
.alert.danger { border-color: #6b3342; background: rgba(112,40,59,.22); color: #ffc0cf; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card { position: relative; overflow: hidden; min-height: 142px; border: 1px solid var(--line); border-radius: 19px; padding: 20px; background: linear-gradient(145deg, rgba(27,31,41,.92), rgba(17,20,27,.92)); }
.stat-card.accent::after { content: ""; position: absolute; width: 100px; height: 100px; right: -35px; bottom: -45px; border-radius: 50%; background: var(--accent); filter: blur(25px); opacity: .22; }
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card strong { display: block; margin: 8px 0 2px; font-size: 36px; line-height: 1; }
.stat-card small { font-size: 11px; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(320px, .95fr); gap: 18px; align-items: start; }
.issue-panel, .operator-panel, .records-panel, .agent-admin { padding: 22px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.safe-badge { border: 1px solid #355a4d; border-radius: 999px; padding: 6px 10px; background: #19322b; color: #a9e4cf; font-size: 11px; }
.term-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 13px; padding: 0; border: 0; }
.term-picker legend { grid-column: 1 / -1; }
.term-picker label { position: relative; cursor: pointer; }
.term-picker input { position: absolute; opacity: 0; pointer-events: none; }
.term-picker label span { display: block; min-height: 82px; border: 1px solid #343a49; border-radius: 14px; padding: 14px; background: #0f1218; transition: .17s ease; }
.term-picker label b, .term-picker label small { display: block; }
.term-picker label small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.term-picker input:checked + span { border-color: var(--accent); background: rgba(105,80,230,.16); box-shadow: inset 0 0 0 1px rgba(128,103,247,.25); }
.microcopy { margin: 11px 0 0; color: #747b8c; font-size: 10px; text-align: center; }
.result-box { margin-top: 16px; border: 1px solid #365f51; border-radius: 14px; padding: 14px; background: rgba(36,94,74,.18); color: #c0eadb; }
.result-box.error { border-color: #713647; background: rgba(112,40,59,.2); color: #ffc1d0; }
.result-box strong, .result-box span { display: block; }
.result-box .button { display: inline-flex; align-items: center; margin-top: 11px; text-decoration: none; }
.operator-list { display: grid; gap: 10px; }
.operator-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; border: 1px solid var(--line-soft); border-radius: 14px; padding: 13px; background: #10131a; }
.operator-row .name span { display: block; color: var(--muted); font-size: 10px; }
.operator-counts { display: flex; gap: 14px; text-align: right; }
.operator-counts span { color: var(--muted); font-size: 10px; }
.operator-counts b { display: block; color: var(--text); font-size: 17px; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--success); }
.status-dot.off { background: #697080; }

.records-panel, .agent-admin { margin-top: 18px; }
.records-heading .muted { margin: 0; font-size: 11px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 12px; border-bottom: 1px solid var(--line); color: #747b8b; font-size: 10px; letter-spacing: .08em; text-align: left; white-space: nowrap; }
td { padding: 14px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td small { display: block; color: var(--muted); }
.term-tag { display: inline-block; border: 1px solid #3b4252; border-radius: 999px; padding: 4px 8px; font-size: 10px; white-space: nowrap; }
.term-tag.trial { border-color: #5b4db1; background: #28204f; color: #c7bbff; }
.download-link { color: #bbaeff; font-weight: 700; text-decoration: none; white-space: nowrap; }
.empty-state { padding: 35px; color: var(--muted); text-align: center; }
.agent-form { display: grid; grid-template-columns: 1fr 1fr 1.5fr auto; align-items: end; gap: 12px; }
.agent-form .field { margin: 0; }
.agent-form .button { margin-bottom: 0; }
.toast { position: fixed; z-index: 20; right: 20px; bottom: 20px; max-width: min(380px, calc(100% - 40px)); border: 1px solid #405948; border-radius: 13px; padding: 12px 15px; background: #17221d; box-shadow: var(--shadow); color: #c8e9dc; }

@media (max-width: 820px) {
  .shell { width: min(100% - 22px, 680px); padding-top: 12px; }
  .login-layout { grid-template-columns: 1fr; gap: 24px; padding: 42px 0; }
  .login-intro h1 { font-size: 43px; }
  .intro-copy { font-size: 14px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat-card { min-height: 112px; padding: 15px; }
  .stat-card strong { font-size: 29px; }
  .stat-card small { display: none; }
  .agent-form { grid-template-columns: 1fr 1fr; }
  .agent-form .field:nth-child(3) { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .topbar { align-items: flex-start; }
  .brand-inline div:last-child span { display: none; }
  .account-area div { display: none; }
  .hero { align-items: flex-start; padding-top: 30px; }
  .hero .button { min-height: 38px; padding: 0 12px; }
  .stats-grid { margin-bottom: 12px; }
  .stat-card span { font-size: 11px; }
  .issue-panel, .operator-panel, .records-panel, .agent-admin { padding: 17px; border-radius: 18px; }
  .term-picker { grid-template-columns: 1fr; }
  .term-picker label span { min-height: 70px; }
  .records-heading { align-items: flex-start; }
  .records-heading .muted { max-width: 130px; text-align: right; }
  .table-wrap { overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody { display: grid; gap: 11px; }
  tbody tr { border: 1px solid var(--line-soft); border-radius: 14px; padding: 13px; background: #10131a; }
  td { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0; border: 0; text-align: right; word-break: break-all; }
  td::before { content: attr(data-label); flex: 0 0 auto; color: #71798a; font-size: 10px; }
  td:first-child { padding-top: 0; }
  td:last-child { justify-content: flex-end; padding-top: 10px; }
  td:last-child::before { display: none; }
  .agent-form { grid-template-columns: 1fr; }
  .agent-form .field:nth-child(3) { grid-column: auto; }
}
