:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --text: #17212b;
  --muted: #687580;
  --line: #dce3e8;
  --accent: #176b5b;
  --accent-hover: #125447;
  --blue: #235fa4;
  --success: #16734b;
  --warning: #9a650e;
  --danger: #b13a32;
  --sidebar: #152229;
  --shadow: 0 8px 24px rgba(25, 40, 55, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(420px, 1.2fr);
  background: var(--surface);
}

.auth-brand {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 38px;
  color: #ffffff;
  background:
    linear-gradient(rgba(21, 34, 41, 0.82), rgba(21, 34, 41, 0.96)),
    url("https://images.unsplash.com/photo-1451187580459-43490279c0fa?auto=format&fit=crop&w=1400&q=80") center/cover;
}

.auth-brand strong,
.auth-brand span {
  display: block;
}

.auth-brand strong {
  font-size: 24px;
}

.auth-brand span {
  margin-top: 4px;
  color: #c2d1d4;
  font-size: 13px;
}

.auth-panel {
  width: min(100% - 40px, 470px);
  align-self: center;
  justify-self: center;
}

.auth-heading {
  margin-bottom: 26px;
}

.auth-heading h1 {
  margin-bottom: 10px;
  font-size: 30px;
}

.auth-heading > p:last-child {
  color: var(--muted);
  line-height: 1.6;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  min-height: 44px;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.auth-tab.active {
  border-color: var(--accent);
  color: var(--accent);
}

.auth-form {
  display: none;
  gap: 15px;
}

.auth-form.active {
  display: grid;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.auth-form .primary-button {
  margin-top: 4px;
}

.auth-link {
  min-height: 34px;
  border: 0;
  padding: 0;
  color: var(--accent);
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.form-message {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface-soft);
}

.form-message span {
  color: var(--muted);
  font-size: 12px;
}

.captcha-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 124px;
  gap: 8px;
}

.captcha-code {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #23423c;
  background:
    repeating-linear-gradient(135deg, #f1f7f5 0, #f1f7f5 8px, #e2eeeb 8px, #e2eeeb 9px);
  font-family: Consolas, monospace;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 3px;
}

.demo-accounts {
  display: grid;
  gap: 5px;
  margin-top: 24px;
  padding: 14px;
  border-left: 3px solid var(--warning);
  color: var(--muted);
  background: #fff9eb;
  font-size: 12px;
}

.demo-accounts strong {
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 25px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

code {
  color: var(--blue);
  font-family: Consolas, monospace;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  color: #f4f8f6;
  background: var(--sidebar);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 24px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #ffffff;
  background: #2b8d78;
  font-size: 20px;
  font-weight: 800;
}

.brand strong,
.brand small,
.sidebar-status strong,
.sidebar-status small {
  display: block;
}

.brand strong {
  font-size: 18px;
}

.brand small,
.sidebar-status small {
  margin-top: 3px;
  color: #9fb0b6;
  font-size: 11px;
}

.nav-list {
  display: grid;
  gap: 5px;
}

.nav-item {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  color: #c8d3d6;
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: #26383f;
}

.nav-item.active {
  box-shadow: inset 3px 0 0 #4db69f;
}

.nav-icon {
  width: 20px;
  font-size: 18px;
  text-align: center;
}

.sidebar-status {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 10px;
  border-top: 1px solid #2e4149;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #55c79a;
  box-shadow: 0 0 0 4px rgba(85, 199, 154, 0.12);
}

.workspace {
  min-width: 0;
}

.topbar {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px clamp(18px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.session-user {
  display: grid;
  justify-items: end;
}

.session-user strong {
  font-size: 12px;
}

.session-user span {
  color: var(--muted);
  font-size: 10px;
}

.environment-tag,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.environment-tag {
  color: #71530b;
  background: #fff0bd;
}

.badge.success {
  color: var(--success);
  background: #e3f5ec;
}

.badge.warning {
  color: var(--warning);
  background: #fff0cf;
}

.badge.danger {
  color: var(--danger);
  background: #fde7e5;
}

.badge.neutral {
  color: #53636e;
  background: #edf1f3;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
  font-size: 20px;
}

main {
  padding: 24px clamp(18px, 3vw, 36px) 40px;
}

.view,
.ops-panel {
  display: none;
}

.view.active,
.ops-panel.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  min-height: 122px;
  display: grid;
  align-content: space-between;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  font-size: 28px;
}

.metric small {
  color: var(--muted);
}

.content-grid {
  display: grid;
  gap: 18px;
}

.content-grid.wide-left {
  grid-template-columns: minmax(0, 2fr) minmax(270px, 0.8fr);
}

.content-grid.equal {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.section-block {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.page-intro {
  margin-bottom: 18px;
  padding: 4px 2px;
}

.page-intro h2 {
  margin-bottom: 6px;
  font-size: 23px;
}

.page-intro > p:last-child {
  color: var(--muted);
  font-size: 13px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 17px;
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.sync-summary {
  color: var(--warning);
  font-size: 11px;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  font-size: 13px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.secondary-button,
.primary-button,
.text-button,
.danger-text-button {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 13px;
  font-weight: 700;
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface);
}

.primary-button {
  border: 1px solid var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-hover);
}

.text-button,
.danger-text-button {
  border: 0;
  background: transparent;
}

.text-button {
  color: var(--accent);
}

.danger-text-button {
  color: var(--danger);
}

.notice-list,
.order-list,
.location-list {
  display: grid;
  gap: 10px;
}

.notice {
  display: grid;
  grid-template-columns: 9px 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.notice:last-child {
  border-bottom: 0;
}

.notice-mark {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--warning);
}

.notice p,
.order-item p,
.account-strip p,
.field-hint,
.location-item span,
.checklist span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.order-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.order-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.account-strip {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding: 20px;
  border-left: 4px solid var(--accent);
  background: var(--surface);
}

.account-strip h2 {
  margin-bottom: 6px;
  font-size: 21px;
}

.compact-field,
.settings-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--text);
  background: #ffffff;
}

.compact-field {
  min-width: 230px;
}

.usage-numbers {
  margin: 24px 0 14px;
}

.usage-numbers strong,
.usage-numbers span {
  display: block;
}

.usage-numbers strong {
  font-size: 32px;
}

.usage-numbers span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 8px;
  background: #e9eef1;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.detail-row strong {
  color: var(--text);
}

.location-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.location-item strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
}

.client-tabs,
.segmented-control {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-soft);
}

.client-tabs {
  margin-bottom: 12px;
}

.client-tab,
.segment {
  min-height: 38px;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
}

.client-tab:last-child,
.segment:last-child {
  border-right: 0;
}

.client-tab.active,
.segment.active {
  color: #ffffff;
  background: var(--accent);
}

.subscription-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.subscription-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.qr-panel {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.qr-panel canvas {
  width: 220px;
  height: 220px;
  padding: 10px;
  background: #ffffff;
}

.qr-panel strong {
  display: block;
  margin-bottom: 6px;
}

.qr-panel p {
  max-width: 360px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.field-hint {
  margin-top: 9px;
}

.plan-grid,
.management-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

.plan-card,
.management-item {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.plan-card {
  display: grid;
  gap: 12px;
}

.plan-price {
  font-size: 25px;
  font-weight: 800;
}

.plan-price small,
.plan-card p,
.management-item p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.segmented-control {
  margin-bottom: 18px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto auto;
  gap: 10px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.inline-form#planForm {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.form-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.form-field-wide {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.inline-form#userForm {
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto auto;
}

.node-options {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.node-options legend {
  color: var(--muted);
  font-size: 11px;
}

.node-options label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}

.node-options input {
  width: 16px;
  min-height: 16px;
}

.management-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.small-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 10px;
  color: var(--text);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
}

.small-button.danger {
  border-color: #efc5c1;
  color: var(--danger);
}

.source-label {
  color: var(--muted);
  font-size: 11px;
}

.edit-user-form {
  margin-bottom: 18px;
  padding: 17px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: var(--surface-soft);
}

.edit-form-heading,
.edit-user-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.edit-form-heading {
  margin-bottom: 15px;
}

.edit-user-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.edit-user-footer {
  margin-top: 15px;
}

.edit-user-footer p {
  max-width: 720px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.sync-banner {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
  padding: 13px 15px;
  border-left: 4px solid var(--warning);
  background: #fff9eb;
}

.sync-banner strong {
  font-size: 13px;
}

.sync-banner span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.empty-state {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.hidden {
  display: none;
}

.management-item h3 {
  margin-bottom: 8px;
}

.management-item .badge {
  margin-top: 12px;
}

.integration-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.7fr);
  gap: 28px;
}

.settings-form {
  display: grid;
  gap: 13px;
}

.settings-form .primary-button {
  justify-self: start;
}

.architecture-flow {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
}

.architecture-flow div {
  width: min(100%, 280px);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: center;
  background: var(--surface-soft);
}

.architecture-flow strong,
.architecture-flow span {
  display: block;
}

.architecture-flow span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.architecture-flow b {
  color: var(--accent);
}

.checklist {
  display: grid;
  gap: 0;
  margin: 0;
  padding-left: 23px;
}

.checklist li {
  padding: 13px 8px;
  border-bottom: 1px solid var(--line);
}

.checklist li:last-child {
  border-bottom: 0;
}

.checklist strong {
  display: block;
  margin-bottom: 3px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 340px;
  padding: 12px 15px;
  border-radius: 6px;
  color: #ffffff;
  background: #22343c;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1050px) {
  .auth-shell {
    grid-template-columns: minmax(240px, 0.6fr) minmax(400px, 1fr);
  }

  .metric-grid,
  .plan-grid,
  .management-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid.wide-left,
  .integration-layout {
    grid-template-columns: 1fr;
  }

  .edit-user-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    min-height: 150px;
    padding: 24px;
  }

  .auth-panel {
    width: min(100% - 30px, 470px);
    padding: 34px 0;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 12px;
  }

  .brand {
    padding: 0 4px 12px;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .app-shell.user-session .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-item {
    height: 54px;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    padding: 4px;
    font-size: 11px;
  }

  .nav-item.active {
    box-shadow: inset 0 -3px 0 #4db69f;
  }

  .sidebar-status {
    display: none;
  }

  .topbar {
    height: auto;
    min-height: 72px;
    align-items: flex-start;
  }

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .session-user {
    width: 100%;
  }

  main {
    padding: 16px 12px 28px;
  }

  .metric-grid,
  .content-grid.equal,
  .plan-grid,
  .management-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric {
    min-height: 105px;
  }

  .metric strong {
    font-size: 23px;
  }

  .section-heading,
  .account-strip,
  .order-item,
  .edit-form-heading,
  .edit-user-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .heading-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .edit-user-grid {
    grid-template-columns: 1fr;
  }

  .compact-field {
    min-width: 0;
  }

  .detail-row {
    flex-direction: column;
  }

  .subscription-line,
  .inline-form,
  .inline-form#planForm,
  .inline-form#userForm {
    grid-template-columns: 1fr;
  }

  .subscription-actions,
  .qr-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .subscription-actions button {
    width: 100%;
  }

  .qr-panel canvas {
    width: min(220px, 100%);
    height: auto;
    align-self: center;
  }

  .form-field-wide {
    grid-column: auto;
  }

  .form-actions {
    align-items: stretch;
  }

  .client-tabs,
  .segmented-control {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .segmented-control {
    grid-template-columns: repeat(4, 1fr);
  }

  .client-tab,
  .segment {
    padding: 0 6px;
    font-size: 11px;
  }
}
