:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --surface: #ffffff;
  --bg: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --info: #0284c7;
  --info-soft: #f0f9ff;
  --wechat: #07c160;
  --wechat-soft: #e8f7ef;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 4px 12px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

html {
  height: 100%;
}

#app {
  height: 100%;
}

code,
.code-inline {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 0.85em;
  background: #f1f5f9;
  color: #be185d;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.card-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-panel .card-header {
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  padding: 0.9rem 1.25rem;
}

.card-panel .card-footer {
  background: #fafbfc;
  border-top: 1px solid var(--border);
}

.page-title {
  font-weight: 700;
  font-size: 1.625rem;
  margin-bottom: 0.35rem;
  letter-spacing: -0.03em;
  color: var(--text);
}

.page-subtitle {
  color: var(--text-muted);
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.code-box {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 1rem;
  letter-spacing: 0.06em;
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  word-break: break-all;
}

/* Alerts */
.alert {
  border: none;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.alert-danger {
  background: var(--danger-soft);
  color: #991b1b;
}

.alert-success {
  background: var(--success-soft);
  color: #065f46;
}

.alert-info {
  background: var(--info-soft);
  color: #075985;
}

.alert-warning {
  background: var(--warning-soft);
  color: #92400e;
}

.alert-light {
  background: #f8fafc;
  color: var(--text);
}

.alert-secondary {
  background: #f1f5f9;
  color: #475569;
}

/* Loading */
.loading-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.loading-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: #f1f5f9; color: #475569; }

.form-switch-lg .form-check-input {
  width: 2.5em;
  height: 1.25em;
}

.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  background: #f8fafc;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.tag-chip button {
  border: none;
  background: transparent;
  color: inherit;
  padding: 0;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
}

.tag-chip button:hover {
  opacity: 1;
}

.tag-chip-readonly {
  padding-right: 10px;
}

.feature-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafbfc;
}

.feature-option {
  margin: 0;
}

.tag-input {
  border: none;
  background: transparent;
  outline: none;
  min-width: 120px;
  flex: 1;
}

.flag-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flag-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
}

/* Tables */
.table-modern,
.card-panel .table {
  margin: 0;
}

.table-modern thead th,
.card-panel .table thead th {
  background: #f8fafc;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}

.table-modern td,
.table-modern th,
.card-panel .table td,
.card-panel .table th {
  vertical-align: middle;
  padding: 0.9rem 1.15rem;
}

.table-modern tbody tr,
.card-panel .table tbody tr {
  transition: background 0.12s;
}

.table-modern tbody tr:hover,
.card-panel .table tbody tr:hover {
  background: #fafbfc;
}

/* Buttons */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 500;
}

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

.btn-primary:hover,
.btn-primary:focus {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-hover);
}

.btn-secondary {
  background: #f8fafc;
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover,
.btn-secondary:focus {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: var(--text);
}

.btn-outline-secondary {
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
  background: var(--bg);
  border-color: #cbd5e1;
  color: var(--text);
}

.btn-outline-danger {
  color: var(--danger);
  border-color: #fca5a5;
}

.btn-outline-danger:hover,
.btn-outline-danger:focus {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover,
.btn-danger:focus {
  background: #b91c1c;
  border-color: #b91c1c;
}

.btn-link {
  color: var(--primary);
  text-decoration: none;
}

.btn-link:hover,
.btn-link:focus {
  color: var(--primary-hover);
}

.text-warning {
  color: var(--warning) !important;
}

.text-success {
  color: var(--success) !important;
}

.spinner-border {
  width: 1rem;
  height: 1rem;
  border: 2px solid #e2e8f0;
  border-right-color: transparent;
  color: var(--primary);
}

.spinner-border-sm {
  width: 0.875rem;
  height: 0.875rem;
  border-width: 2px;
}

.btn-sm {
  border-radius: 8px;
}

.text-muted {
  color: var(--text-muted) !important;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.form-select-compact {
  max-width: 280px;
}

.loading-spinner-sm {
  width: 0.9rem;
  height: 0.9rem;
  border-width: 2px;
}

.form-control,
.form-select {
  border-radius: var(--radius-sm);
  border-color: var(--border);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

/* Auth */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}

.auth-brand {
  text-align: left;
  margin-bottom: 1.25rem;
}

.auth-brand-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

.auth-brand h1 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  letter-spacing: normal;
}

.auth-brand p {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.875rem;
}

.auth-card .store-auth-tabs {
  margin-bottom: 1rem;
}

.auth-card .store-auth-tabs,
.auth-card .btn-group.w-100 {
  display: flex;
  gap: 0.35rem;
  padding: 0.25rem;
  background: #e2e8f0;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.auth-card .btn-group.w-100 > .btn {
  flex: 1;
  border-radius: 6px !important;
  border: none;
  box-shadow: none;
}

.auth-card .btn-group.w-100 > .btn-outline-secondary {
  background: transparent;
  color: var(--text-muted);
}

.auth-card .btn-group.w-100 > .btn-primary {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.auth-card .btn-group.w-100 > .btn-primary:hover,
.auth-card .btn-group.w-100 > .btn-primary:focus {
  background: var(--surface);
  color: var(--primary-hover);
}

/* App layout — user / agent / admin */
.app-shell {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

.app-heading {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.app-page-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.app-section-head {
  align-items: flex-end;
  padding: 0.25rem 0 1rem;
  margin-bottom: 1rem;
}

.app-section-head .app-heading {
  font-size: 1.125rem;
  margin-bottom: 0;
}

.app-detail-head {
  background: var(--surface);
  padding: 1.25rem 1.25rem 0;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.app-detail-head.card-panel {
  padding-bottom: 0;
}

.app-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin-top: 0.65rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.app-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.app-page-head .app-heading {
  font-size: 1.25rem;
  margin-bottom: 0;
}

.app-manage-overview {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.app-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem 1.25rem;
}

.app-info-item {
  min-width: 0;
}

.app-info-item-full {
  grid-column: 1 / -1;
}

.app-info-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.app-info-value {
  font-size: 0.875rem;
  color: var(--text);
  word-break: break-word;
}

.app-info-value-block {
  white-space: pre-wrap;
  line-height: 1.5;
}

.app-credential-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.app-credential-item {
  min-width: 0;
}

.app-credential-value {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.app-credential-value code,
.app-key-code {
  font-size: 0.8125rem;
  word-break: break-all;
}

.app-secret-code {
  font-size: 0.75rem;
  word-break: break-all;
}

.app-list-name {
  font-weight: 600;
  color: var(--text);
}

.app-list-meta {
  margin-top: 0.15rem;
  font-size: 0.8125rem;
}

.app-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  max-width: 14rem;
}

.app-tag-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  line-height: 1.2;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  white-space: nowrap;
}

.app-list-table td {
  vertical-align: middle;
}

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

.app-detail-bar {
  align-items: flex-start;
  gap: 1.25rem;
  margin-bottom: 1.15rem;
}

.app-detail-title {
  min-width: 0;
  flex: 1;
}

.app-detail-bar .app-heading {
  font-size: 1.25rem;
  line-height: 1.35;
  margin: 0.5rem 0 0.4rem;
}

.app-detail-subtitle {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.app-detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.app-page-bar .app-heading {
  margin-bottom: 0;
}

.app-metrics {
  display: flex;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.app-metrics > div {
  flex: 1;
  min-width: 5rem;
  padding: 0.75rem 1rem;
  border-right: 1px solid var(--border);
}

.app-metrics > div:last-child {
  border-right: none;
}

.app-metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.app-metric-value {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.app-section-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: 0.5rem 1rem 0.35rem;
}

.app-filter .card-body {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.app-table-scroll {
  overflow-x: hidden;
}

.app-shell .card-panel:has(> .table),
.app-shell .card-panel:has(> .card-header + .table),
.portal-shell .card-panel:has(> .table),
.portal-shell .card-panel:has(> .card-header + .table) {
  overflow-x: hidden;
}

.app-shell .table-responsive,
.portal-shell .table-responsive {
  overflow-x: hidden;
}

.app-table-scroll .table {
  margin-bottom: 0;
  font-size: 0.9375rem;
}

.app-shell .card-panel .table,
.portal-shell .card-panel .table {
  width: 100%;
  min-width: 0;
  table-layout: auto;
}

.app-empty,
.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.empty-state {
  padding: 2.75rem 1rem;
}

.empty-state i {
  font-size: 2.25rem;
  display: block;
  margin-bottom: 0.85rem;
  opacity: 0.45;
}

.empty-state-title {
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.app-empty {
  white-space: normal;
}

.app-shell .card-panel,
.portal-shell .card-panel {
  margin-bottom: 0.75rem;
}

.app-shell .card-panel .card-header,
.app-shell .card-panel .card-footer,
.portal-shell .card-panel .card-header,
.portal-shell .card-panel .card-footer {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.app-shell .card-panel .table thead th,
.portal-shell .card-panel .table thead th {
  white-space: nowrap;
  line-height: 1.45;
}

.app-shell .card-panel .table tbody td,
.portal-shell .card-panel .table tbody td {
  vertical-align: middle;
  line-height: 1.55;
  white-space: normal;
  word-break: break-word;
}

.app-shell .card-panel .table tbody td code,
.portal-shell .card-panel .table tbody td code {
  font-size: 0.875em;
  white-space: nowrap;
}

.app-shell .card-panel .table tbody tr:last-child td,
.portal-shell .card-panel .table tbody tr:last-child td {
  border-bottom: none;
}

.app-shell .alert,
.portal-shell .alert {
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

@media (max-width: 575.98px) {
  .app-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-metrics > div {
    flex: none;
    min-width: 0;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  .app-metrics > div:nth-child(2n) {
    border-right: none;
  }

  .app-metrics > div:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    border-right: none;
  }

  .app-metrics > div:nth-last-child(-n+2) {
    border-bottom: none;
  }
}

.app-plugin-list {
  display: flex;
  flex-direction: column;
}

.app-plugin-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.app-plugin-item:last-child {
  border-bottom: none;
}

.app-plugin-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  flex-shrink: 0;
  line-height: 1;
}

.app-plugin-icon-payment {
  background: var(--wechat-soft);
  color: var(--wechat);
}

.app-plugin-icon-notify {
  background: var(--info-soft);
  color: var(--info);
}

.app-plugin-body {
  flex: 1;
  min-width: 0;
}

.app-plugin-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.app-plugin-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text);
}

.app-plugin-id code {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: transparent;
  padding: 0;
}

.app-plugin-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0.35rem 0 0;
  line-height: 1.55;
}

.app-plugin-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  opacity: 0.85;
}

.app-plugin-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  padding-top: 0.15rem;
}

.app-plugin-tag {
  display: inline-block;
  font-size: 0.6875rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  line-height: 1.4;
}

.app-plugin-tag-prod {
  color: var(--success);
  border-color: #a7f3d0;
  background: var(--success-soft);
}

.app-plugin-events {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.app-plugin-events-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-right: 0.15rem;
  opacity: 0.85;
}

.app-plugin-event {
  display: inline-block;
  font-size: 0.6875rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--info);
  border: 1px solid var(--border);
  line-height: 1.4;
}

.app-plugin-config-block {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

@media (max-width: 575.98px) {
  .app-plugin-item {
    flex-wrap: wrap;
  }

  .app-plugin-actions {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding-top: 0;
  }
}

.app-shell .app-filter,
.portal-shell .app-filter {
  box-shadow: none;
}

.app-shell .page-subtitle,
.portal-shell .page-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: -0.35rem 0 0.75rem;
}

.app-back-link {
  display: inline-block;
  font-size: 0.8125rem;
  color: var(--primary);
  text-decoration: none;
  margin-bottom: 0.15rem;
  line-height: 1.5;
}

.app-back-link:hover {
  color: var(--primary-hover);
}

.app-detail-head .app-tabs {
  margin: 0 -1.25rem;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.app-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.app-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.9rem 1.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  margin-bottom: -1px;
  transition: color 0.12s;
}

.app-tab:hover {
  color: var(--text);
}

.app-tab.active {
  color: var(--primary);
  font-weight: 600;
  border-bottom-color: var(--primary);
}

.app-tab-count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}

.app-tab.active .app-tab-count {
  color: var(--primary);
  background: var(--primary-soft);
}

.app-plugin-modal-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.75rem;
}

.app-plugin-switches {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.app-plugin-switches-primary {
  padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--border);
}

.app-plugin-switch.form-check.form-switch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 1.75rem;
  padding-left: 0;
  margin-bottom: 0;
}

.app-plugin-switch .form-check-input {
  width: 2.25em;
  height: 1.125em;
  margin-left: 0;
  margin-top: 0;
  float: none;
  flex-shrink: 0;
}

.app-plugin-switch.form-switch-lg .form-check-input {
  width: 2.5em;
  height: 1.25em;
}

.app-plugin-switch .form-check-label {
  padding-left: 0;
  margin-bottom: 0;
  line-height: 1.45;
  cursor: pointer;
}

.app-plugin-config-block .app-plugin-switches {
  margin-bottom: 1rem;
}

.app-plugin-config-block .app-plugin-switches:last-child {
  margin-bottom: 0;
}

/* Store */
.store-trust-line {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.store-trust-line .bi {
  color: var(--success);
}

.store-user-chip {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.store-announcement {
  display: flex;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--info-soft);
  color: #075985;
  font-size: 0.875rem;
}

.store-announcement .bi {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.store-announcement p {
  margin-top: 0.15rem;
  opacity: 0.9;
}

.store-meta-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafbfc;
}

.store-meta-panel summary {
  cursor: pointer;
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  user-select: none;
}

.store-meta-body {
  padding: 0 1rem 0.85rem;
}

.store-auth-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.25rem;
  background: #e2e8f0;
  border-radius: var(--radius-sm);
}

.store-auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}

.store-auth-tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.store-app-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  font: inherit;
  color: inherit;
}

.store-app-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.store-app-card-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.store-app-card-arrow {
  color: #cbd5e1;
  flex-shrink: 0;
}

.sku-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  font: inherit;
  color: inherit;
  text-align: left;
}

.sku-card:hover {
  border-color: #94a3b8;
  box-shadow: var(--shadow-sm);
}

.sku-card.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 1px var(--primary);
}

.sku-card-body {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}

.sku-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.sku-card-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.sku-card-check {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  border: 2px solid #cbd5e1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: transparent;
  background: #fff;
  transition: all 0.15s;
  flex-shrink: 0;
}

.sku-card.selected .sku-card-check {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.sku-card-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}

.sku-card-desc {
  margin-bottom: 0.35rem;
  line-height: 1.45;
}

.sku-card-type {
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.sku-card-features {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.sku-price {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  line-height: 1.35rem;
}

.store-checkout-amount {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: 0.15rem;
}

.store-buy-btn {
  min-width: 9rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.store-section-subtitle {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.store-pay-method-grid {
  display: grid;
  gap: 0.65rem;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.store-pay-method {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  width: 100%;
  min-width: 0;
  min-height: 5.25rem;
  padding: 0.75rem 0.5rem 1.35rem;
  border: 2px solid var(--border);
  border-radius: 0.75rem;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  font: inherit;
  color: inherit;
  text-align: center;
}

.store-pay-methods {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafbfc;
}

.portal-shell .store-pay-method-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 480px) {
  .portal-shell .store-pay-method-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .portal-shell .store-pay-method-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.portal-shell .store-pay-method {
  min-height: 4.75rem;
  padding: 0.75rem 0.5rem 0.85rem;
}

.store-checkout-panel {
  margin-top: 1rem;
}

.store-checkout-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
  background: var(--primary-soft);
  border: 1px solid #dbeafe;
}

.store-checkout-summary {
  flex: 1 1 12rem;
  min-width: 0;
}

.store-pay-method:hover {
  border-color: #cbd5e1;
}

.store-pay-method.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.store-pay-method-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  background: #f1f5f9;
  font-size: 1.1rem;
}

.store-pay-wechat .store-pay-method-icon {
  color: var(--wechat);
  background: var(--wechat-soft);
}

.store-pay-alipay .store-pay-method-icon {
  color: #1677ff;
  background: #eff6ff;
}

.store-pay-stripe .store-pay-method-icon {
  color: #635bff;
  background: #eef2ff;
}

.store-pay-manual .store-pay-method-icon {
  color: #64748b;
  background: #f1f5f9;
}

.store-pay-mock .store-pay-method-icon {
  color: var(--warning);
  background: var(--warning-soft);
}

.store-pay-method-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.store-pay-method-check {
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  color: var(--primary);
  font-size: 0.85rem;
}

.store-pay-method.disabled,
.store-pay-method:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.store-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0.5rem 0;
  max-width: 100%;
  overflow-x: auto;
}

.store-step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.store-step.active {
  color: var(--primary);
  font-weight: 600;
}

.store-step.done {
  color: var(--success);
}

.store-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  border: 2px solid #cbd5e1;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.store-step.active .store-step-num {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.store-step.done .store-step-num {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}

.store-step-line {
  flex: 1;
  min-width: 1.5rem;
  max-width: 3rem;
  height: 2px;
  background: #e2e8f0;
  margin: 0 0.35rem;
}

.store-step-line.done {
  background: var(--success);
}

.store-step-label {
  white-space: nowrap;
}

@media (max-width: 576px) {
  .store-step-label {
    display: none;
  }
}

.store-payment-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-bottom: 1.15rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.store-payment-provider {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.store-payment-icon-wrap {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 12px;
  background: var(--primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.store-payment-method-name {
  font-weight: 600;
  font-size: 1.05rem;
}

.store-payment-amount {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.store-payment-amount strong {
  color: var(--primary);
  font-size: 1.05rem;
}

.store-order-id {
  text-align: right;
  font-size: 0.8rem;
}

.store-order-id code {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.78rem;
  word-break: break-all;
  color: var(--text);
}

.store-status-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-sm);
  background: var(--info-soft);
  color: #075985;
  font-size: 0.875rem;
}

.store-polling-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}

.store-polling-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: var(--primary);
  animation: store-pulse 1.2s ease-in-out infinite;
}

@keyframes store-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1); }
}

.store-payment-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.store-qr-block {
  width: 100%;
  max-width: 300px;
  text-align: center;
}

.store-qr-label {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.store-qr-frame {
  padding: 0.75rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: inline-block;
}

.store-qr-img {
  display: block;
  max-width: 240px;
  width: 100%;
  height: auto;
  margin: 0 auto;
  border: none;
  background: transparent;
  padding: 0;
}

.store-qr-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  line-height: 1.45;
}

.store-pay-link-block {
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.store-pay-btn {
  min-width: 12rem;
}

.store-manual-block {
  width: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 1.5rem 0;
}

.store-payment-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem;
  padding-top: 1.15rem;
  margin-top: 1.15rem;
  border-top: 1px solid var(--border);
}

.store-pay-wechat .store-payment-icon-wrap {
  background: var(--wechat-soft);
  color: var(--wechat);
}

.store-pay-alipay .store-payment-icon-wrap {
  background: #e8f2ff;
  color: #1677ff;
}

.store-pay-stripe .store-payment-icon-wrap {
  background: var(--primary-soft);
  color: var(--primary);
}

.store-pay-manual .store-payment-icon-wrap {
  background: #f1f5f9;
  color: #64748b;
}

.store-pay-mock .store-payment-icon-wrap {
  background: var(--warning-soft);
  color: var(--warning);
}

.store-payment-provider .bi-wechat {
  color: var(--wechat);
}

.store-payment-provider .bi-wallet2 {
  color: #1677ff;
}

.store-payment-provider .bi-credit-card {
  color: var(--primary);
}

.store-manual-icon {
  font-size: 2.5rem;
  color: #94a3b8;
}

.store-success-card .store-success-panel-inner {
  text-align: center;
  padding: 1.5rem 0.25rem;
}

.store-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  line-height: 1.45;
}

.store-alert .bi {
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.store-success-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
}

.store-success-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 1.5rem;
}

.store-success-icon {
  font-size: 3.5rem;
  color: var(--success);
  line-height: 1;
  margin-bottom: 0.85rem;
}

.store-code-display {
  font-size: 1.05rem;
}

.store-success-hint {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 1.25rem 0 0;
  text-align: left;
}

.store-success-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem;
  margin-top: 1.5rem;
}

.store-card-code-box,
.store-license-box {
  text-align: left;
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  max-width: 28rem;
  margin: 0 auto;
}

.store-license-box {
  margin-top: 1rem;
}

@media (max-width: 576px) {
  .portal-shell .portal-main {
    padding-bottom: 1.5rem;
  }

  .portal-shell .store-checkout-panel {
    position: sticky;
    bottom: 0;
    z-index: 20;
    margin-left: -0.25rem;
    margin-right: -0.25rem;
    padding-bottom: 0.25rem;
    background: var(--surface);
  }

  .store-checkout-bar {
    flex-direction: column;
    align-items: stretch;
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
  }

  .store-buy-btn {
    width: 100%;
  }

  .store-payment-header {
    flex-direction: column;
  }

  .store-order-id {
    text-align: left;
    width: 100%;
  }

  .store-polling-badge {
    margin-left: 0;
  }
}

/* Pagination */
.pagination-bar,
.card-footer.app-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.15rem;
  background: #fafbfc;
  border-top: 1px solid var(--border);
}

.app-pagination,
.pagination-bar.app-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.app-pagination .btn-secondary,
.pagination-bar .btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-muted);
}

.app-pagination .btn-secondary:hover:not(:disabled),
.pagination-bar .btn-secondary:hover:not(:disabled) {
  background: var(--bg);
  border-color: #cbd5e1;
  color: var(--text);
}

/* Toast */
.app-toast-stack {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
  width: min(420px, calc(100vw - 2rem));
}

.app-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  color: var(--text);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  border-left: 3px solid var(--text-muted);
}

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

.app-toast-hide {
  opacity: 0;
  transform: translateY(-10px);
}

.app-toast-success {
  border-left-color: var(--success);
}

.app-toast-error {
  border-left-color: var(--danger);
}

.app-toast-text {
  flex: 1;
  line-height: 1.45;
  word-break: break-word;
}

.app-toast-close {
  flex-shrink: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0;
  margin: -0.1rem 0 0;
  cursor: pointer;
}

.app-toast-close:hover {
  color: var(--text);
}

/* Modal */
.app-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1050;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.app-modal {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.app-modal-lg {
  max-width: 720px;
}

.app-modal-plugin {
  max-width: 800px;
}

.app-modal-sm {
  max-width: 400px;
}

.app-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}

.app-modal-header h5 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.app-modal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1.25rem;
}

.app-scroll-hidden {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.app-scroll-hidden::-webkit-scrollbar {
  display: none;
}

.app-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}

.btn-icon-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem;
  cursor: pointer;
  border-radius: 6px;
}

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

body.modal-open {
  overflow: hidden;
}

/* Landing */
.landing-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  background: var(--bg);
}

.landing-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin: 0 auto 1.25rem;
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  max-width: 920px;
  width: 100%;
  margin-top: 2rem;
}

.landing-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.landing-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  color: inherit;
}

.landing-card i {
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 0.65rem;
  display: block;
}

.landing-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
}

.landing-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (max-width: 575.98px) {
  .landing-page {
    justify-content: flex-start;
    padding: 2rem 1rem 2.5rem;
  }

  .landing-grid {
    grid-template-columns: 1fr;
    margin-top: 1.5rem;
  }

  .landing-page .page-title {
    font-size: 1.375rem;
  }
}

.min-w-0 {
  min-width: 0;
}

/* Agent portal — sidebar layout */
.agent-shell {
  display: flex;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.agent-sidebar {
  width: 15rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.agent-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
}

.agent-sidebar-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 1.15rem;
  flex-shrink: 0;
}

.agent-sidebar-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.2;
}

.agent-sidebar-user {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.agent-quota-panel {
  margin: 0.85rem 0.75rem 0;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: var(--primary-soft);
  border: 1px solid #dbeafe;
}

.agent-quota-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.agent-quota-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}

.agent-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.85rem 0.65rem;
}

.agent-nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}

.agent-nav-link i {
  font-size: 1rem;
  width: 1.15rem;
  text-align: center;
}

.agent-nav-link:hover {
  background: rgba(15, 23, 42, 0.04);
  color: var(--text);
}

.agent-nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.agent-sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}

.agent-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.agent-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.agent-page-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.agent-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.agent-main {
  flex: 1;
  padding: 1rem 1.5rem 2rem;
  overflow-x: hidden;
}

.agent-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.agent-stat-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
  font: inherit;
  color: inherit;
}

.agent-stat-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow);
}

.agent-stat-card-primary {
  background: var(--primary-soft);
  border-color: #bfdbfe;
}

.agent-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.agent-stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.agent-status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.agent-status-tab {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}

.agent-status-tab:hover {
  border-color: #cbd5e1;
  color: var(--text);
}

.agent-status-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.agent-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
}

.agent-filter-row .form-control,
.agent-filter-row .form-select {
  min-width: 10rem;
}

.agent-panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 991.98px) {
  .app-shell.portal-shell,
  .portal-shell,
  .agent-shell {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .portal-sidebar,
  .agent-sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .portal-sidebar-nav,
  .agent-sidebar-nav {
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
    padding-bottom: 0.35rem;
  }

  .portal-nav-link,
  .agent-nav-link {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .portal-sidebar-footer,
  .agent-sidebar-footer {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .portal-content,
  .agent-content {
    overflow: visible;
    min-height: auto;
  }

  .portal-main,
  .agent-main {
    overflow-y: visible;
    min-height: auto;
  }

  .agent-panel-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 575.98px) {
  .agent-main {
    padding: 0.75rem 1rem 1.5rem;
  }

  .agent-topbar {
    padding: 0.85rem 1rem;
  }

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

/* Shared portal shell (admin / user / store — aliases agent layout) */
.app-shell.portal-shell,
.portal-shell,
.agent-shell {
  display: flex;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.portal-sidebar,
.agent-sidebar {
  width: 15rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.portal-sidebar-brand,
.agent-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.portal-sidebar-icon,
.agent-sidebar-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 1.15rem;
  flex-shrink: 0;
}

.portal-sidebar-title,
.agent-sidebar-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.2;
}

.portal-sidebar-meta,
.agent-sidebar-user {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.portal-highlight-panel,
.agent-quota-panel {
  margin: 0.85rem 0.75rem 0;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: var(--primary-soft);
  border: 1px solid #dbeafe;
  flex-shrink: 0;
}

.portal-highlight-label,
.agent-quota-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.portal-highlight-value,
.agent-quota-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}

.portal-sidebar-nav,
.agent-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.85rem 0.65rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.portal-nav-link,
.agent-nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}

.portal-nav-link i,
.agent-nav-link i {
  font-size: 1rem;
  width: 1.15rem;
  text-align: center;
}

.portal-nav-link:hover,
.agent-nav-link:hover {
  background: rgba(15, 23, 42, 0.04);
  color: var(--text);
}

.portal-nav-link.active,
.agent-nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.portal-sidebar-footer,
.agent-sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}

.portal-content,
.agent-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.portal-topbar,
.agent-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.portal-page-title,
.agent-page-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.portal-topbar-actions,
.agent-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.portal-main,
.agent-main {
  flex: 1;
  min-height: 0;
  padding: 1rem 1.5rem 2rem;
  overflow-x: hidden;
  overflow-y: auto;
}

.portal-shell .card-panel > .card-body:not([class*='p-']):not(.store-payment-panel-inner):not(.store-success-panel-inner) {
  padding: 1.25rem;
}

.portal-shell .card-panel > .card-body.py-3 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.portal-shell .store-checkout-panel {
  margin-top: 0.5rem;
}

.portal-shell .store-payment-panel-inner {
  padding: 1.25rem 1.5rem;
}

.portal-shell .store-success-panel-inner {
  padding: 1.5rem 1.25rem 1.75rem;
}

.store-success-card {
  overflow: visible;
}

@media (max-width: 575.98px) {
  .portal-main,
  .agent-main {
    padding: 0.75rem 1rem 1.5rem;
  }

  .portal-topbar,
  .agent-topbar {
    padding: 0.85rem 1rem;
  }
}
