:root {
  --bg: #111315;
  --panel: #1b1f24;
  --panel-2: #232a32;
  --text: #e9edf3;
  --subtle: #97a2af;
  --border: #313b46;
  --primary: #329fff;
  --success: #2dbf6e;
  --warn: #ffb347;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

html.plugin-embed-mode,
html.plugin-embed-mode body {
  min-height: auto;
  height: 100%;
}

html.plugin-embed-mode .app-shell {
  min-height: auto;
  height: 100%;
  grid-template-columns: 200px 1fr;
}

html.plugin-embed-mode .nav-panel {
  padding: 12px;
}

html.plugin-embed-mode .content-panel {
  padding: 12px;
}

html.plugin-embed-mode .subscription-root {
  padding-bottom: 78px;
}

html.plugin-embed-mode .template-slots img {
  height: 74px;
}

.nav-panel {
  border-right: 1px solid var(--border);
  background: #171b20;
  padding: 14px;
}

.nav-panel h1 {
  margin: 0 0 14px 0;
  font-size: 18px;
}

.view-nav {
  display: grid;
  gap: 8px;
}

html.internal-mode .view-nav {
  grid-template-columns: 1fr;
}

.view-btn {
  text-align: left;
  border: 1px solid var(--border);
  background: #252c35;
  color: var(--text);
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
}

.view-btn.active {
  border-color: var(--primary);
  background: #273d51;
}

.content-panel {
  padding: 14px;
}

.view-page.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.internal-only {
  display: none !important;
}

html.internal-mode .internal-only {
  display: revert !important;
}

html.internal-mode .view-page.internal-only.hidden {
  display: none !important;
}

.page-header h2 {
  margin: 0;
  font-size: 22px;
}

.page-header p {
  margin: 6px 0 12px 0;
  color: var(--subtle);
  font-size: 13px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.card h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
}

.card p {
  margin: 0 0 10px 0;
  color: var(--subtle);
}

.trial-wrap {
  max-width: 760px;
  margin: 0 auto;
}

.trial-header {
  text-align: center;
  margin-bottom: 16px;
}

.trial-header h2 {
  margin: 0;
  font-size: 42px;
  font-weight: 700;
}

.trial-header p {
  margin: 8px 0 0 0;
  color: var(--subtle);
}

.trial-card {
  border: 1px solid #2a2f3a;
  background: #151821;
  border-radius: 8px;
  padding: 20px;
}

.input-shell {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #384054;
  border-radius: 8px;
  background: #0f1218;
  padding: 0 12px;
}

.input-shell input {
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  width: 100%;
  height: 46px;
}

.input-icon {
  color: #95a0b5;
  font-size: 14px;
}

.verify-row {
  display: grid;
  grid-template-columns: 1fr 132px;
  gap: 8px;
}

#apply-send-code-btn {
  height: 48px;
  border-color: #414757;
  background: #1e2430;
}

.trial-notice {
  margin: 10px 0 6px;
  color: var(--subtle);
  font-size: 12px;
}

.trial-notice summary {
  cursor: pointer;
  user-select: none;
}

.trial-notice p {
  margin-top: 8px;
  color: #a9b1c2;
}

.agree-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 14px;
  color: #c3ccdb;
  font-size: 13px;
}

.trial-start-btn {
  width: 100%;
  height: 48px;
  border-color: #3d4354;
  background: #2a2f3a;
  color: #8a93a4;
}

.trial-start-btn:not(:disabled) {
  border-color: #2f6fcb;
  background: #2e77da;
  color: #e7efff;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.muted-text {
  margin-top: 10px;
  color: var(--subtle);
  font-size: 12px;
}

.license-delivery {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.license-delivery h3 {
  margin: 0;
  font-size: 14px;
}

#license-api-status {
  margin-top: 8px;
}

.license-delivery-list {
  margin: 8px 0 0 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.license-delivery-list li {
  display: grid;
  grid-template-columns: 168px 1fr 140px 120px;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #1f2530;
  color: #c6d0df;
  font-size: 12px;
}

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

.inline-field {
  margin-bottom: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.field span {
  color: var(--subtle);
  font-size: 12px;
}

input[type="text"],
input[type="number"],
select {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  padding: 8px;
}

button {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #2c343d;
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.subscription-layout {
  display: grid;
  grid-template-columns: 260px minmax(620px, 1fr);
  gap: 10px;
}

html:not(.internal-mode) .subscription-layout {
  grid-template-columns: 1fr;
}

html:not(.internal-mode) .subscription-root {
  max-width: 960px;
}

.debug-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  height: fit-content;
  position: sticky;
  top: 14px;
}

.debug-panel h3 {
  margin: 0 0 10px 0;
  font-size: 16px;
}

.debug-actions {
  display: grid;
  gap: 8px;
}

.subscription-root {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px 12px 86px 12px;
  position: relative;
}

.subscription-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.subscription-header h2 {
  margin: 0;
  font-size: 20px;
}

.subscription-header p {
  margin: 6px 0 0 0;
  color: var(--subtle);
  font-size: 13px;
}

.status-tag {
  background: #3b4551;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.template-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.template-slots figure {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.template-slots img {
  width: 100%;
  height: 88px;
  display: block;
}

.plan-area,
.benefits-area,
.status-area {
  margin-bottom: 10px;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.section-title-row h3,
.benefits-area h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
}

#selected-plan-summary {
  color: var(--subtle);
  font-size: 12px;
}

.plan-selector {
  display: grid;
  gap: 8px;
}

.plan-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 10px;
  cursor: pointer;
}

.plan-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(50, 159, 255, 0.25) inset;
}

.plan-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.plan-name {
  font-size: 14px;
  font-weight: 600;
}

.plan-badge {
  border-radius: 999px;
  background: #2f475f;
  padding: 2px 8px;
  font-size: 11px;
}

.plan-price {
  margin-top: 6px;
  font-size: 13px;
}

.plan-origin {
  margin-left: 6px;
  color: var(--subtle);
  text-decoration: line-through;
}

#benefits-list {
  margin: 0;
  padding-left: 18px;
  color: var(--subtle);
  font-size: 13px;
}

#benefits-list li {
  margin-bottom: 4px;
}

.status-banner {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.status-banner p {
  margin: 0;
  font-size: 13px;
}

.status-banner.info {
  border-color: #3f5266;
}

.status-banner.success {
  border-color: #2f6b47;
}

.status-banner.warn {
  border-color: #7a5f2c;
}

.status-banner.error {
  border-color: #7a3636;
}

.checkout-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 1px solid var(--border);
  background: #191d22;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.checkout-main h3 {
  margin: 0 0 4px 0;
  font-size: 16px;
}

#checkout-final-price {
  margin: 0;
  color: var(--subtle);
  font-size: 13px;
}

.terms-check {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: var(--subtle);
  font-size: 12px;
}

.checkout-actions {
  display: flex;
  gap: 8px;
}

.primary-btn {
  border-color: #1b6eb8;
  background: #1f7bd0;
}

.orders-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 10px;
}

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

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 8px;
  font-size: 12px;
  text-align: left;
}

tbody tr {
  cursor: pointer;
}

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

tbody tr.active {
  background: rgba(50, 159, 255, 0.14);
}

#orders-events-tbody tr.active {
  background: rgba(50, 159, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(50, 159, 255, 0.24);
}

th {
  color: var(--subtle);
  font-weight: 500;
}

.order-detail {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.order-detail h3 {
  margin: 0 0 6px 0;
  font-size: 14px;
}

.order-detail p {
  margin: 4px 0;
  font-size: 12px;
}

.payment-events {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.payment-events h3 {
  margin: 0;
  font-size: 14px;
}

.feedback-card {
  max-width: 860px;
}

.feedback-meta-row {
  display: grid;
  grid-template-columns: 180px 120px 1fr;
  gap: 10px;
  align-items: end;
}

textarea {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  padding: 8px;
  resize: vertical;
  min-height: 140px;
  font-family: inherit;
}

.feedback-history {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.feedback-history h3 {
  margin: 0;
  font-size: 14px;
}

.feedback-history-list {
  margin: 8px 0 0 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.feedback-history-list li {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #1f2530;
  padding: 8px;
  font-size: 12px;
  color: #c6d0df;
}

.feedback-history-list li p {
  margin: 0;
  color: #c6d0df;
}

.feedback-history-list li p + p {
  margin-top: 4px;
}

.feedback-item-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.feedback-item-actions button {
  padding: 5px 8px;
  font-size: 12px;
}

.updates-card {
  max-width: 980px;
}

.updates-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.updates-kpi {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #1f2530;
  padding: 8px 10px;
  display: grid;
  gap: 4px;
}

.updates-kpi strong {
  font-size: 14px;
  color: #d8e2f2;
}

.updates-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 10px;
  margin-bottom: 8px;
}

.updates-list {
  margin: 8px 0 0 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.updates-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #1f2530;
  padding: 10px;
}

.updates-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.updates-item-title {
  margin: 0;
  font-size: 14px;
  color: #d8e2f2;
}

.updates-item-meta {
  margin: 2px 0 0 0;
  font-size: 12px;
  color: var(--subtle);
}

.updates-channel {
  border: 1px solid #3f5266;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  white-space: nowrap;
}

.updates-item ul {
  margin: 8px 0 0 18px;
  color: #c6d0df;
  font-size: 12px;
}

.updates-item li + li {
  margin-top: 4px;
}

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

  .overview-grid {
    grid-template-columns: 1fr 1fr;
  }

  .subscription-layout {
    grid-template-columns: 1fr;
  }

  .orders-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .trial-header h2 {
    font-size: 34px;
  }

  .verify-row {
    grid-template-columns: 1fr;
  }

  .license-delivery-list li {
    grid-template-columns: 1fr 1fr;
  }

  .feedback-meta-row {
    grid-template-columns: 1fr;
  }

  .updates-summary {
    grid-template-columns: 1fr;
  }

  .updates-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .debug-panel {
    position: relative;
    top: 0;
  }
}

@media (max-width: 680px) {
  .overview-grid {
    grid-template-columns: 1fr;
  }
}
