:root {
  --bg: #0f1115;
  --bg-soft: #141821;
  --panel: #171b23;
  --panel-2: #1c212b;
  --border: #2a3140;
  --text: #e7eaf0;
  --muted: #8f98a8;
  --primary: #2f7cf6;
  --primary-soft: rgba(47, 124, 246, 0.15);
  --danger: #e5484d;
  --green: #22c55e;
  --orange: #f59e0b;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

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

code {
  background: #232936;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* ---------- login ---------- */
.login-page {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100vh;
}

.login-art {
  position: relative;
  padding: 36px 48px;
  background: radial-gradient(800px 600px at 30% 30%, #16233b 0%, #0d1016 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border);
}

.brand {
  position: absolute;
  top: 24px;
  left: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.brand.small {
  position: static;
  padding: 18px 18px 10px;
  font-size: 16px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, #7c5cff 0%, #2f7cf6 55%, #22d3ee 100%);
  box-shadow: 0 0 18px rgba(80, 110, 255, 0.5);
}

.art-orb {
  position: relative;
  width: 280px;
  height: 280px;
  display: grid;
  place-items: center;
}

.orb-core {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #7fb2ff, #2f7cf6 55%, #1a3f8f);
  box-shadow: 0 0 60px rgba(47, 124, 246, 0.55);
}

.orb-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(120, 160, 255, 0.35);
}

.orb-ring.r1 {
  inset: 40px;
  transform: rotateX(62deg);
}

.orb-ring.r2 {
  inset: 10px;
  transform: rotateX(62deg) rotateZ(40deg);
}

.orb-bar {
  position: absolute;
  width: 10px;
  border-radius: 6px;
  background: linear-gradient(180deg, #22d3ee, #2f7cf6);
  opacity: 0.85;
}

.orb-bar.b1 {
  height: 36px;
  left: 38px;
  bottom: 96px;
}

.orb-bar.b2 {
  height: 58px;
  left: 60px;
  bottom: 96px;
}

.orb-bar.b3 {
  height: 24px;
  left: 82px;
  bottom: 96px;
}

.login-art h1 {
  margin: 12px 0 4px;
  font-size: 26px;
}

.login-art p {
  margin: 0;
  color: var(--muted);
}

.login-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: #101319;
}

.login-form {
  width: 100%;
  max-width: 380px;
}

.login-form h2 {
  margin: 0 0 6px;
  font-size: 32px;
}

.wave {
  display: inline-block;
}

.field {
  display: block;
  margin-top: 18px;
}

.field input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0e1117;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.btn {
  height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s ease;
}

.btn:hover:not(:disabled) {
  border-color: #3c465a;
  background: #232a36;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: #4a8ef8;
}

.btn.danger {
  border-color: rgba(229, 72, 77, 0.6);
  color: #ff6b70;
  background: transparent;
}

.btn.block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.form-error {
  min-height: 18px;
  margin-top: 10px;
  color: #ff6b70;
  font-size: 13px;
}

.login-hint {
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* ---------- app shell ---------- */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 224px;
  background: #121620;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.menu {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #cfd6e3;
  text-decoration: none;
  font-size: 14px;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.menu-item.active {
  background: #1d2431;
  color: #fff;
  box-shadow: inset 0 0 0 1px #2c3547;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 18px;
  color: #5f6b7f;
  font-size: 11px;
  line-height: 1.6;
  border-top: 1px solid var(--border);
}

.shell {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: #131822;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.crumb {
  color: var(--muted);
  font-size: 13px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: #1e2531;
  color: var(--text);
}

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.pill.open {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.4);
  background: rgba(34, 197, 94, 0.08);
}

.pill.connecting {
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
}

.pill.closed {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.08);
}

.user-chip {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #2b3446;
  color: #cfe0ff;
  font-size: 12px;
  text-transform: uppercase;
}

main {
  padding: 20px 24px 40px;
}

.page-head h1 {
  margin: 0 0 4px;
  font-size: 18px;
}

.page-head p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.select {
  height: 38px;
  min-width: 240px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0e1219;
  color: var(--text);
  outline: none;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
}

.dot.open {
  background: var(--green);
}

.dot.closed {
  background: #8b93a1;
}

/* ---------- table ---------- */
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}

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

th {
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  color: #c3cbd9;
  background: #1a202b;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid #242b38;
  font-size: 13.5px;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

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

.empty {
  padding: 64px 0;
  text-align: center;
  color: #6f7a8d;
}

.link-btn {
  border: none;
  background: transparent;
  color: #ff6b70;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}

.kv {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(74, 222, 128, 0.1);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.badge.off {
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.3);
}

/* ---------- rooms ---------- */
.btn.ghost {
  background: transparent;
  border-style: dashed;
  color: var(--muted);
}

.btn.ghost:hover:not(:disabled) {
  color: var(--text);
}

.room-toolbar {
  margin-bottom: 12px;
}

.room-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.room-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.room-tab:hover {
  border-color: #3c465a;
  color: var(--text);
}

.room-tab.active {
  background: var(--primary-soft);
  border-color: rgba(47, 124, 246, 0.65);
  color: #cfe0ff;
}

.room-tab-name {
  font-size: 13.5px;
  font-weight: 600;
}

.room-tab-meta {
  font-size: 11.5px;
  opacity: 0.75;
}

.room-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 18px;
}

.room-head {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 16px;
  border-bottom: 1px solid #242b38;
}

.room-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
}

.room-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12.5px;
}

.room-stats {
  display: flex;
  gap: 10px;
}

.room-stats .stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
  padding: 8px 10px;
  border-radius: 9px;
  background: #121722;
  border: 1px solid #232b39;
}

.room-stats .stat b {
  font-size: 18px;
  line-height: 1.15;
}

.room-stats .stat i {
  font-style: normal;
  font-size: 11.5px;
  color: var(--muted);
}

.room-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
}

.seat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px;
}

.seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px 10px;
  border-radius: 10px;
  border: 1px solid #242b38;
  background: #121722;
  text-align: center;
}

.seat.ringing {
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.15) inset;
}

.seat.muted .seat-avatar {
  filter: grayscale(1);
  opacity: 0.65;
}

.seat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 17px;
  color: #dbe7ff;
  background: linear-gradient(135deg, #2f7cf6, #7c5cff);
}

.seat-name {
  max-width: 100%;
  font-weight: 600;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat-uid {
  color: var(--muted);
  font-size: 11.5px;
}

.seat-state {
  font-size: 11.5px;
  color: #86efac;
}

.seat-state.ring {
  color: var(--orange);
}

.seat-ops {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid #202734;
  width: 100%;
  justify-content: center;
}

.seat-ops .link-btn {
  color: #8f98a8;
}

.seat-ops .link-btn:hover:not(:disabled) {
  color: #cfe0ff;
}

.seat-ops .link-btn.danger-text {
  color: #ff6b70;
}

.link-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- modal / toast ---------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 50;
}

.modal {
  width: min(520px, calc(100vw - 40px));
  background: #161b25;
  border: 1px solid #2c3547;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.modal-head {
  padding: 16px 18px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 18px;
}

.modal-foot {
  padding: 12px 18px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

textarea,
.modal input[type='text'] {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0e1219;
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
  resize: vertical;
}

textarea:focus,
.modal input[type='text']:focus {
  border-color: var(--primary);
}

.hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.progress {
  height: 8px;
  background: #242b38;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}

.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2f7cf6, #22d3ee);
  transition: width 0.2s ease;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #6f7a8d;
}

.steps .done {
  color: #4ade80;
}

.steps .active {
  color: #7fb2ff;
  font-weight: 600;
}

.toast-root {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
}

.toast {
  padding: 10px 14px;
  border-radius: 8px;
  background: #1b2230;
  border: 1px solid #2c3547;
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: fade-in 0.15s ease;
  max-width: 320px;
}

.toast.error {
  border-color: rgba(229, 72, 77, 0.5);
  color: #ff9ba0;
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.5);
  color: #86efac;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 900px) {
  .login-page {
    grid-template-columns: 1fr;
  }
  .login-art {
    display: none;
  }
  .sidebar {
    width: 68px;
  }
  .brand.small span:last-child,
  .menu-item span,
  .sidebar-foot {
    display: none;
  }
  .menu-item {
    justify-content: center;
  }
}

/* ---------- invite job overview ---------- */
.job-overview {
  margin-bottom: 14px;
}
.job-overview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}
.job-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.job-card {
  flex: 1 1 220px;
  min-width: 210px;
  max-width: 360px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.job-card:hover {
  background: var(--panel-2);
  border-color: #3b465c;
}
.job-card.running {
  border-color: rgba(47, 124, 246, 0.65);
}
.job-card.done {
  border-color: rgba(34, 197, 94, 0.35);
}
.job-card.error {
  border-color: rgba(229, 72, 77, 0.6);
}
.job-card .job-device {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}
.job-card .job-sub {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-card .job-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}
.job-card .job-metrics b {
  color: var(--text);
  font-weight: 600;
}
.job-card .job-bar {
  height: 6px;
  margin-top: 10px;
  background: #0b0e13;
  border-radius: 4px;
  overflow: hidden;
}
.job-card .job-bar i {
  display: block;
  height: 100%;
  background: var(--primary);
  transition: width 0.25s;
}
.job-card.done .job-bar i {
  background: var(--green);
}
.job-card.error .job-bar i {
  background: var(--danger);
}
.job-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
}
.job-detail-head .job-title {
  font-weight: 600;
}
.job-detail-head .job-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.job-toggle {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.job-toggle:hover {
  color: var(--text);
  border-color: #3b465c;
}
