:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #68758b;
  --line: #dce3ee;
  --primary: #1473e6;
  --primary-dark: #0b5ec7;
  --accent: #0f9f7a;
  --danger: #c93b49;
  --warning: #b47b00;
  --shadow: 0 18px 45px rgba(30, 41, 59, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  min-height: 40px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 700;
  transition:
    background 0.15s ease,
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

button:hover {
  background: var(--primary-dark);
  box-shadow: 0 8px 20px rgba(20, 115, 230, 0.18);
}

button:active {
  transform: translateY(1px);
}

button.ghost {
  background: #eef4fb;
  color: var(--text);
}

button.ghost:hover {
  background: #ddeaf8;
}

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

button.secondary:hover {
  background: #0c8063;
}

button.danger {
  background: var(--danger);
}

button.small {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 115, 230, 0.12);
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 18px;
  background: #111827;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #1473e6, #14b89a);
  font-size: 28px;
  font-weight: 900;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
}

.brand p {
  margin-top: 3px;
  color: #aab6c7;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 22px;
}

.nav-item {
  justify-content: flex-start;
  width: 100%;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  box-shadow: none;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: none;
}

.account-box {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

#accountName {
  font-weight: 800;
}

#accountMeta {
  margin-top: 4px;
  color: #aab6c7;
  font-size: 12px;
  line-height: 1.5;
}

.main {
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h2,
.topbar p {
  margin: 0;
}

.topbar h2 {
  font-size: 28px;
  line-height: 1.1;
}

.topbar p {
  margin-top: 7px;
  color: var(--muted);
}

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

.top-actions select {
  width: 140px;
}

.auth-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.auth-panel.hidden {
  display: none;
}

.auth-card,
.panel,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 20px;
}

.auth-card h2,
.auth-card p {
  margin: 0;
}

.auth-card p {
  margin-top: 8px;
  color: var(--muted);
}

.muted-card {
  background: var(--panel-soft);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 16px;
}

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

.metric {
  padding: 18px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel h3,
.panel p {
  margin: 0;
}

.panel p {
  color: var(--muted);
  margin-top: 5px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.studio-grid,
.chat-layout,
.call-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 16px;
}

.form-grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.form-grid.compact {
  grid-template-columns: 1fr 180px auto;
  align-items: end;
}

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

.result-box {
  min-height: 180px;
  max-height: 430px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #d7e0ee;
  padding: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.feed {
  display: grid;
  gap: 12px;
}

.feed.wide {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.video-card,
.product-card,
.ledger-item,
.chat-bubble {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.video-card {
  padding: 14px;
}

.video-card h4,
.video-card p {
  margin: 0;
}

.video-card p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #eef4fb;
  padding: 0 8px;
  color: #38506c;
  font-weight: 700;
}

.product-list {
  display: grid;
  gap: 10px;
}

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

.product-card {
  overflow: hidden;
}

.product-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #e7edf5;
}

.product-body {
  display: grid;
  gap: 9px;
  padding: 14px;
}

.price-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.price-row strong {
  font-size: 22px;
}

.product-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.call-stage {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-height: 520px;
  border-radius: 8px;
  background: #0b1220;
  overflow: hidden;
  padding: 10px;
}

.call-stage video {
  width: 100%;
  height: 100%;
  min-height: 480px;
  border-radius: 8px;
  background: #111827;
  object-fit: cover;
}

.caption-layer {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.84);
  color: #fff;
  padding: 12px 14px;
  text-align: center;
  font-weight: 800;
}

.call-tools {
  display: grid;
  align-content: start;
  gap: 12px;
}

.log {
  height: 150px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.chat-messages {
  height: 430px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.chat-bubble {
  padding: 10px 12px;
}

.chat-bubble strong {
  display: block;
  margin-bottom: 5px;
}

.chat-bubble small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

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

.wallet-card {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 18px;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
}

.wallet-card span {
  color: #aab6c7;
}

.wallet-card strong {
  font-size: 32px;
}

.ledger {
  display: grid;
  gap: 10px;
}

.ledger-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
}

.ledger-item span {
  color: var(--muted);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox input {
  width: auto;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: none;
  max-width: min(420px, calc(100vw - 44px));
  border-radius: 8px;
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.toast.show {
  display: block;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .metrics,
  .product-grid,
  .feed.wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .studio-grid,
  .chat-layout,
  .call-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .main {
    padding: 18px;
  }

  .topbar,
  .auth-panel,
  .two-col,
  .metrics,
  .product-grid,
  .feed.wide,
  .form-grid.compact {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .call-stage {
    grid-template-columns: 1fr;
  }

  .call-stage video {
    min-height: 240px;
  }
}
