:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.app-shell { display: flex; min-height: 100vh; max-width: 100%; }

.sidebar {
  width: 256px;
  background: var(--sidebar);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; padding: 0 6px; }
.brand-badge {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center;
  font-size: 15px; letter-spacing: 0.5px; flex-shrink: 0;
}
.brand-title { font-weight: 700; font-size: 15px; color: #fff; }
.brand-sub { font-size: 11px; color: #94a3b8; }

.nav-menu { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: none; color: #cbd5e1;
  padding: 11px 14px; border-radius: 9px; cursor: pointer;
  text-align: left; font-size: 14px; font-weight: 500; transition: 0.15s;
  text-decoration: none;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: #2563eb; color: #fff; }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.7; flex-shrink: 0; }

.sidebar-footer { margin-top: 20px; }
.plan-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px; padding: 12px;
}
.plan-tag { font-size: 11px; font-weight: 700; color: #60a5fa; text-transform: uppercase; letter-spacing: 0.3px; }
.plan-desc { font-size: 12px; color: #cbd5e1; margin: 6px 0 10px; line-height: 1.5; }
.sidebar-cta-row { margin-bottom: 6px; }
.full-btn { width: 100%; }
.link-btn {
  background: none; border: none; padding: 4px 0 0; color: #93c5fd;
  font-size: 12px; cursor: pointer; text-decoration: underline;
}
.link-btn:hover { color: #bfdbfe; }

.main-content {
  flex: 1;
  min-width: 0;
  padding: 24px 28px 32px;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.topbar-text { min-width: 0; flex: 1; }
.topbar h1 { margin: 0; font-size: 22px; font-weight: 700; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex-shrink: 0; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
  min-width: 0;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-header h2 { margin: 0; font-size: 16px; font-weight: 700; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  border-top: 3px solid #64748b; min-width: 0;
}
.kpi-card.accent-red { border-top-color: var(--danger); }
.kpi-card.accent-blue { border-top-color: var(--primary); }
.kpi-card.accent-green { border-top-color: var(--success); }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 30px; font-weight: 800; margin: 6px 0 4px; }
.kpi-meta { font-size: 12px; color: var(--muted); }

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

.promo-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap;
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
  border-color: #bfdbfe;
}
.promo-copy { flex: 1; min-width: 220px; }
.promo-eyebrow { font-size: 12px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.promo-banner h2 { margin: 0 0 6px; font-size: 17px; }
.promo-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.pricing-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.pricing-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.price-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.price-card.featured {
  border: 2px solid var(--primary);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.1);
}
.price-card.cn-featured {
  border: 2px solid var(--success);
  box-shadow: 0 8px 24px rgba(5, 150, 105, 0.1);
}
.price-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.price-name { font-size: 16px; font-weight: 700; }
.price-amount { font-size: 30px; font-weight: 800; color: var(--text); margin: 4px 0 2px; }
.price-cycle { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.price-features { list-style: none; padding: 0; margin: 0 0 18px; flex: 1; display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: #334155; }
.price-features li::before { content: "✓ "; color: var(--success); font-weight: 700; }

.quota-inline-note {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #334155;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  margin-bottom: 12px;
}

.compliance-notice-card {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
  font-size: 13px;
}
.compliance-notice-card .muted { color: #9a3412; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px; padding: 8px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; transition: 0.15s;
  max-width: 100%;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: #f8fafc; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-danger { background: #fee2e2; color: var(--danger); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.pill-ok { background: #dcfce7; color: #166534; }
.pill-warn { background: #fef3c7; color: #92400e; }
.pill-danger { background: #fee2e2; color: #991b1b; }
.pill-info { background: #dbeafe; color: #1e40af; }
.pill-neutral { background: #e2e8f0; color: #334155; }

.tag {
  display: inline-block; padding: 2px 7px; border-radius: 6px;
  font-size: 11px; font-weight: 600; background: #f1f5f9; color: #334155;
  margin: 2px 4px 2px 0;
}
.tag-red { background: #fee2e2; color: #991b1b; }
.tag-orange { background: #ffedd5; color: #9a3412; }
.tag-blue { background: #dbeafe; color: #1e40af; }

.inline-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.checkbox-label { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; }
.quick-actions, .action-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.layout-label { margin-left: 12px; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.filter-bar input { flex: 1; min-width: 180px; }

.form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; min-width: 0; }
.form-row label { font-size: 12px; font-weight: 600; color: #334155; }
input[type="text"], input[type="email"], input[type="file"], select, textarea {
  border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 10px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--text);
  max-width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: var(--primary); }
.upload-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.upload-row input[type="file"] { flex: 1; min-width: 0; }

.section-divider { border-top: 1px dashed var(--border); margin-top: 14px; padding-top: 14px; }
.sub-heading { margin: 0 0 10px; font-size: 14px; color: #1e293b; }

.table-wrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  padding: 10px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top;
}
.data-table th { background: #f8fafc; font-weight: 700; color: #475569; white-space: nowrap; }
.data-table tr:hover td { background: #fafcff; }
.empty-cell { text-align: center !important; color: var(--muted); padding: 28px !important; }

.muted { color: var(--muted); font-size: 13px; }
.code-box {
  background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px;
  font-size: 12px; overflow-x: auto; max-height: 240px;
}
.hidden { display: none !important; }

.svg-stage {
  min-height: 300px; background: #f8fafc; border: 1px dashed #cbd5e1;
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  padding: 14px; overflow: auto; color: var(--muted);
}
.svg-stage svg { max-width: 100%; height: auto; box-shadow: 0 4px 16px rgba(15,23,42,0.12); background: #fff; }

.validation-panel { max-height: 440px; overflow-y: auto; }
.val-platform { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.val-platform-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; font-weight: 700; flex-wrap: wrap; }
.val-item { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-top: 1px solid #f1f5f9; font-size: 12px; }

.sub-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.wh-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px;
}

.app-footer {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.footer-disclaimer { color: #64748b; }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.footer-links a { color: var(--primary); text-decoration: none; font-weight: 600; }
.footer-links a:hover { text-decoration: underline; }

.toast-container { position: fixed; top: 18px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast {
  background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,0.2); max-width: 420px; word-break: break-word;
}
.toast.ok { background: #065f46; }
.toast.err { background: #991b1b; }

.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,0.55); }
.modal-box {
  position: relative; background: #fff; border-radius: 12px; width: min(760px, 100%);
  max-height: 88vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 18px 48px rgba(15,23,42,0.25);
}
.modal-box.modal-sm { width: min(540px, 100%); }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 16px 18px; overflow-y: auto; font-size: 13px; }

.lead-plan-banner {
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a;
  border-radius: 8px; padding: 10px 12px; font-weight: 700; margin-bottom: 10px;
}
.lead-success-box {
  background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46;
  border-radius: 8px; padding: 14px; margin-top: 12px; line-height: 1.6;
}
.footer-ecosystem {
  margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--border);
}

@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col, .grid-3, .pricing-grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; padding: 14px 14px; }
  .brand { margin-bottom: 12px; }
  .nav-menu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .nav-item { padding: 9px 10px; font-size: 13px; }
  .sidebar-footer { margin-top: 12px; }
  .main-content { padding: 14px 12px 24px; }
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 16px; }
  .topbar-text, .topbar-actions { width: 100%; }
  .card { padding: 14px 12px; }
  .topbar h1 { font-size: 19px; }
  .kpi-grid, .grid-2, .pricing-grid-2 { grid-template-columns: 1fr; }
  .layout-label { margin-left: 0; width: 100%; }
  .filter-bar input, .filter-bar select { width: 100%; min-width: 0; }
}
