:root {
  --ink: #17221c;
  --muted: #6c7770;
  --soft-muted: #95a098;
  --line: #e2e9e3;
  --paper: #ffffff;
  --canvas: #f4f7f4;
  --green: #1e795b;
  --green-deep: #15553f;
  --green-soft: #e7f2eb;
  --blue: #3d647a;
  --blue-soft: #eaf1f4;
  --amber: #a16d22;
  --amber-soft: #fff4df;
  --danger: #a94a45;
  --shadow: 0 16px 40px rgba(35, 54, 42, 0.08);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

.is-hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(240px, 1fr);
  background: #eef3ef;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px clamp(32px, 7vw, 96px);
  background: var(--paper);
}

.login-aside {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 80px clamp(32px, 8vw, 120px);
  background: #214b3d;
  color: #f4fbf6;
}

.login-aside p {
  max-width: 360px;
  margin: 12px 0 0;
  color: #c8ddd1;
  font-size: 18px;
  line-height: 1.6;
}

.aside-kicker,
.topbar-kicker,
.eyebrow {
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.login-aside .aside-kicker {
  color: #b7d9c6;
}

.aside-number {
  margin-top: 16px;
  color: #f4fbf6;
  font-size: clamp(72px, 11vw, 160px);
  font-weight: 300;
  line-height: 0.9;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--green-deep);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.login-panel .brand-mark {
  width: 46px;
  height: 46px;
  margin-bottom: 48px;
}

.login-panel h1,
.page-intro h1 {
  margin: 9px 0 0;
  color: var(--ink);
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.12;
}

.login-copy,
.intro-copy {
  max-width: 560px;
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-panel .stack-form {
  margin-top: 38px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

label small,
.toggle-row small {
  color: var(--soft-muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdfb;
  color: var(--ink);
  outline: 0;
  padding: 12px 13px;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.6;
}

input:focus,
textarea:focus {
  border-color: var(--green);
  background: var(--paper);
  box-shadow: 0 0 0 3px rgba(30, 121, 91, 0.12);
}

.primary-button,
.quiet-button,
.text-button,
.icon-button,
.avatar-button {
  border: 0;
  border-radius: 6px;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  background: var(--green);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--green-deep);
  transform: translateY(-1px);
}

.quiet-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.quiet-button:hover {
  border-color: #b6c9bc;
  background: #f7faf7;
}

.text-button {
  padding: 0;
  background: transparent;
  color: #b5c8bc;
  font-size: 12px;
}

.text-button:hover {
  color: #fff;
}

.icon-button,
.avatar-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  background: #f2f6f2;
  color: var(--ink);
  font-size: 19px;
}

.icon-button:hover,
.avatar-button:hover {
  background: var(--green-soft);
  color: var(--green-deep);
}

.icon-button.small {
  width: 30px;
  height: 30px;
  font-size: 16px;
}

.avatar-button {
  border-radius: 50%;
  background: var(--green-deep);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.button-icon {
  font-size: 16px;
  line-height: 1;
}

.full-width {
  width: 100%;
}

.form-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.form-success {
  color: var(--green);
  font-size: 12px;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 28px 16px 20px;
  background: #183c30;
  color: #eaf3ec;
}

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

.sidebar-brand .brand-mark {
  background: #e2f2e8;
  color: var(--green-deep);
}

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

.sidebar-brand strong {
  font-size: 14px;
}

.sidebar-brand span {
  margin-top: 4px;
  color: #9bb9a9;
  font-size: 10px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 58px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #a9c2b3;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
}

.nav-item:hover {
  background: rgba(231, 242, 235, 0.08);
  color: #fff;
}

.nav-item.is-active {
  background: #dceee3;
  color: var(--green-deep);
}

.nav-symbol {
  width: 18px;
  color: currentColor;
  font-size: 16px;
  text-align: center;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding: 18px 10px 0;
  border-top: 1px solid rgba(219, 240, 225, 0.15);
}

.connection-state {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #a9c2b3;
  font-size: 11px;
  white-space: nowrap;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #73c78d;
  box-shadow: 0 0 0 3px rgba(115, 199, 141, 0.13);
}

.status-dot.large {
  width: 10px;
  height: 10px;
}

.main-area {
  min-width: 0;
}

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 44px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
}

.topbar h2 {
  margin: 5px 0 0;
  font-size: 22px;
  font-weight: 650;
}

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

.callback-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
}

.content {
  width: min(1400px, 100%);
  margin: 0 auto;
  padding: 40px 44px 70px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.page-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}

.page-intro.compact-intro h1 {
  font-size: clamp(28px, 3.6vw, 42px);
}

.page-intro .primary-button {
  flex: 0 0 auto;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 40px;
}

.stat-block {
  min-height: 134px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

.stat-block.accent-stat {
  border-color: #c4dfce;
  background: var(--green-soft);
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
}

.stat-block strong {
  margin-top: 10px;
  color: var(--ink);
  font-size: 31px;
  font-weight: 650;
  line-height: 1;
}

.stat-note {
  margin-top: 10px;
  color: var(--soft-muted);
  font-size: 11px;
}

.accent-stat .stat-note {
  color: #5a8068;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 44px 0 14px;
}

.section-heading h3,
.panel-heading h3 {
  margin: 5px 0 0;
  font-size: 16px;
  font-weight: 700;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

.panel-table {
  min-width: 0;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 22px 16px;
}

.panel-heading p {
  margin: 8px 0 0;
  color: var(--soft-muted);
  font-size: 12px;
}

.count-pill,
.settings-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 24px;
  padding: 0 8px;
  border-radius: 12px;
  background: var(--green-soft);
  color: var(--green-deep);
  font-size: 11px;
  font-weight: 700;
}

.settings-badge {
  background: var(--amber-soft);
  color: var(--amber);
}

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

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

th,
td {
  padding: 14px 22px;
  border-top: 1px solid #edf1ed;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--soft-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  color: var(--muted);
  font-size: 12px;
}

td strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

td small {
  display: block;
  max-width: 250px;
  overflow: hidden;
  color: var(--soft-muted);
  font-size: 11px;
  text-overflow: ellipsis;
}

tbody tr:hover {
  background: #fbfdfb;
}

.scene-code {
  display: inline-block;
  padding: 5px 7px;
  border-radius: 4px;
  background: #f1f5f2;
  color: #496655;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 11px;
}

.status-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
  font-size: 11px;
  font-weight: 650;
}

.status-label.off {
  color: var(--soft-muted);
}

.status-label .status-dot {
  width: 6px;
  height: 6px;
  box-shadow: none;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.row-action {
  min-height: 29px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.row-action:hover {
  border-color: var(--line);
  background: #f7faf7;
  color: var(--green-deep);
}

.row-action.danger:hover {
  color: var(--danger);
}

.activity-panel {
  min-width: 0;
}

.activity-list {
  padding: 0 22px 12px;
}

.activity-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid #edf1ed;
}

.activity-symbol {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 13px;
}

.activity-item strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
}

.activity-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.activity-time {
  margin-top: 5px;
  color: var(--soft-muted);
  font-size: 10px;
}

.empty-state {
  padding: 30px 22px;
  color: var(--soft-muted);
  font-size: 12px;
  text-align: center;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 36px 0 14px;
}

.toolbar-copy {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-copy strong {
  font-size: 14px;
}

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

.full-panel {
  min-height: 260px;
}

.channel-table th,
.channel-table td {
  padding-left: 18px;
  padding-right: 18px;
}

.qr-cell {
  color: var(--soft-muted);
  font-size: 11px;
}

.qr-cell.ready {
  color: var(--green);
  font-weight: 650;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  align-items: start;
  gap: 14px;
  margin-top: 38px;
}

.settings-panel,
.callback-panel {
  padding: 22px;
}

.settings-panel .panel-heading,
.callback-panel .panel-heading {
  margin: -22px -22px 22px;
  padding: 22px;
  border-bottom: 1px solid #edf1ed;
}

.toggle-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 4px 0;
}

.toggle-row > span {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.toggle-row input {
  width: 38px;
  height: 22px;
  appearance: none;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #ccd7cf;
  cursor: pointer;
  transition: background 150ms ease;
}

.toggle-row input::before {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  margin: 2px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(23, 34, 28, 0.2);
  transition: transform 150ms ease;
}

.toggle-row input:checked {
  background: var(--green);
}

.toggle-row input:checked::before {
  transform: translateX(16px);
}

.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
}

.callback-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f7faf7;
}

.callback-box code {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: var(--green-deep);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 11px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.info-list {
  margin: 24px 0 0;
}

.info-list > div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 0;
  border-bottom: 1px solid #edf1ed;
  font-size: 12px;
}

.info-list dt {
  color: var(--muted);
}

.info-list dd {
  margin: 0;
  color: var(--ink);
  font-weight: 650;
}

.notice-box {
  display: flex;
  gap: 9px;
  margin-top: 20px;
  padding: 13px;
  border: 1px solid #f0dfbd;
  background: var(--amber-soft);
  color: #7f5c26;
  font-size: 11px;
  line-height: 1.6;
}

.notice-box p {
  margin: 0;
}

.notice-mark {
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  border: 1px solid #c99a52;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(17, 34, 25, 0.4);
}

.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
  padding: 26px;
  border-radius: 7px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.modal-heading h2 {
  margin: 5px 0 0;
  font-size: 23px;
  font-weight: 650;
}

.modal-actions {
  justify-content: flex-end;
}

.qr-modal {
  width: min(680px, 100%);
}

.qr-content {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  align-items: center;
  gap: 28px;
}

.qr-frame {
  display: grid;
  place-items: center;
  width: 240px;
  height: 240px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.qr-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-meta {
  min-width: 0;
}

.qr-meta strong,
.qr-meta span {
  display: block;
}

.qr-meta strong {
  font-size: 19px;
}

.qr-meta span {
  margin-top: 8px;
  color: var(--green);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
}

.qr-meta p {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.qr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.link-button {
  text-decoration: none;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 48px));
  padding: 12px 16px;
  border: 1px solid #b9d9c5;
  border-radius: 5px;
  background: #edf8f0;
  color: var(--green-deep);
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1050px) {
  .content,
  .topbar {
    padding-left: 28px;
    padding-right: 28px;
  }

  .workspace-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-aside {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    min-height: 0;
    padding: 14px 16px;
  }

  .sidebar-brand {
    padding: 0;
  }

  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    margin-top: 18px;
    padding-bottom: 2px;
  }

  .nav-item {
    width: auto;
    min-width: max-content;
  }

  .sidebar-footer {
    display: none;
  }

  .topbar {
    min-height: 76px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .callback-status {
    display: none;
  }

  .content {
    padding-top: 28px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 28px;
  }

  .page-intro {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .login-panel {
    padding: 42px 26px;
  }

  .topbar,
  .content {
    padding-left: 18px;
    padding-right: 18px;
  }

  .topbar h2 {
    font-size: 19px;
  }

  .topbar-actions {
    gap: 7px;
  }

  .page-intro h1,
  .page-intro.compact-intro h1 {
    font-size: 28px;
  }

  .stats-grid {
    gap: 9px;
  }

  .stat-block {
    min-height: 116px;
    padding: 15px;
  }

  .stat-block strong {
    font-size: 26px;
  }

  .panel-heading,
  th,
  td {
    padding-left: 15px;
    padding-right: 15px;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions .quiet-button {
    width: 100%;
  }

  .settings-panel,
  .callback-panel {
    padding: 17px;
  }

  .settings-panel .panel-heading,
  .callback-panel .panel-heading {
    margin: -17px -17px 17px;
    padding: 17px;
  }

  .qr-content {
    grid-template-columns: 1fr;
  }

  .qr-frame {
    width: min(240px, 100%);
    height: auto;
    aspect-ratio: 1;
    margin: 0 auto;
  }

  .qr-meta {
    text-align: center;
  }

  .qr-actions {
    justify-content: center;
  }
}
