:root {
  --primary: #5b47f5;
  --primary-dark: #4634d1;
  --primary-light: #f1effe;
  --ink: #181b2e;
  --ink-soft: #565b76;
  --muted: #8a8fa8;
  --border: #e7e6f3;
  --surface: #ffffff;
  --bg: #f6f5fb;
  --danger: #d1453d;
  --danger-bg: #fdf0ef;
  --danger-border: #f6d4d1;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 9px;
  --shadow-card: 0 1px 2px rgba(24, 27, 46, 0.04), 0 10px 30px -12px rgba(24, 27, 46, 0.12);
  --shadow-pop: 0 20px 60px -15px rgba(91, 71, 245, 0.35);
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */
.dsh-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.dsh-brand {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.dsh-brand::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--primary), #9b8bff);
  display: inline-block;
}
.dsh-logout {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  transition: all 0.15s ease;
}
.dsh-logout:hover {
  background: var(--primary-light);
  border-color: #d8d4fb;
  color: var(--primary);
}

/* ---------- Auth pages ---------- */
.dsh-auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 550px at 15% -10%, #ece8ff 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #eef4ff 0%, transparent 55%),
    var(--bg);
}
.dsh-auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-pop);
  border: 1px solid rgba(255, 255, 255, 0.6);
}
.dsh-auth-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #8a76ff);
  display: inline-block;
  vertical-align: middle;
  box-shadow: 0 8px 20px -6px rgba(91, 71, 245, 0.55);
}
.dsh-auth-brand {
  display: inline-block;
  vertical-align: middle;
  margin-left: 10px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 24px;
}
.dsh-auth-card h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
  color: var(--ink);
}
.dsh-auth-card p.dsh-sub {
  margin: 0 0 28px;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.5;
}

/* ---------- Fields ---------- */
.dsh-field {
  margin-bottom: 16px;
}
.dsh-field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}
.dsh-field input,
.dsh-field textarea,
.dsh-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dsh-field input::placeholder,
.dsh-field textarea::placeholder {
  color: var(--muted);
}
.dsh-field input:focus,
.dsh-field textarea:focus,
.dsh-field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(91, 71, 245, 0.12);
}
.dsh-field textarea {
  resize: vertical;
  min-height: 78px;
  line-height: 1.5;
}
.dsh-field input[type="color"] {
  padding: 4px;
  height: 40px;
  cursor: pointer;
}
.dsh-field select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23565b76'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

/* ---------- Buttons ---------- */
.dsh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 2px rgba(24, 27, 46, 0.05);
}
.dsh-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 16px -6px rgba(91, 71, 245, 0.5);
}
.dsh-btn:active {
  transform: translateY(1px);
}
.dsh-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.dsh-btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1.5px solid #d8d4fb;
  box-shadow: none;
}
.dsh-btn-secondary:hover {
  background: var(--primary-light);
  box-shadow: none;
}
.dsh-topup-btn {
  background: linear-gradient(135deg, #12b76a, #0e9457);
}
.dsh-topup-btn:hover {
  background: linear-gradient(135deg, #0e9457, #0b7a48);
  box-shadow: 0 6px 16px -6px rgba(14, 148, 87, 0.5);
}
.dsh-btn-danger {
  background: var(--surface);
  color: var(--danger);
  border: 1.5px solid var(--danger-border);
  box-shadow: none;
}
.dsh-btn-danger:hover {
  background: var(--danger-bg);
  box-shadow: none;
}

.dsh-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.dsh-error.dsh-visible {
  display: block;
}

.dsh-auth-footer {
  margin-top: 22px;
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
}
.dsh-auth-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.dsh-auth-footer a:hover {
  text-decoration: underline;
}

/* ---------- App shell ---------- */
.dsh-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 36px 20px 60px;
}
.dsh-container-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.dsh-container-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.dsh-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.dsh-bot-card:hover {
  box-shadow: 0 1px 2px rgba(24, 27, 46, 0.04), 0 16px 36px -14px rgba(24, 27, 46, 0.16);
  transform: translateY(-1px);
}

.dsh-bot-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.dsh-bot-name {
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.005em;
}
.dsh-plan-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: 1px;
  background: var(--primary-light);
  color: var(--primary);
}
.dsh-plan-badge.dsh-plan-pro {
  background: #fff2e2;
  color: #ac6a06;
}
.dsh-swatch {
  width: 14px;
  height: 14px;
  border-radius: 5px;
  display: inline-block;
  margin-right: 9px;
  vertical-align: -2px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.dsh-usage {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: 8px 0 12px;
}
.dsh-usage-bar {
  height: 6px;
  border-radius: 4px;
  background: #edecf7;
  overflow: hidden;
  margin-top: 5px;
}
.dsh-usage-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), #8a76ff);
  transition: width 0.3s ease;
}
.dsh-crawl-bar {
  height: 6px;
  border-radius: 4px;
  background: #edecf7;
  overflow: hidden;
  margin-top: 8px;
  display: none;
}
.dsh-crawl-bar.dsh-visible {
  display: block;
}
.dsh-crawl-bar-fill {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--primary), #8a76ff);
  border-radius: 4px;
  animation: dsh-indeterminate 1.2s ease-in-out infinite;
}
@keyframes dsh-indeterminate {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}
.dsh-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.dsh-actions .dsh-btn {
  width: auto;
}

.dsh-snippet {
  background: #181b2e;
  color: #d3d6ea;
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.dsh-empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 0;
  font-size: 14px;
}

.dsh-hidden {
  display: none !important;
}

.dsh-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}
@media (max-width: 560px) {
  .dsh-form-grid {
    grid-template-columns: 1fr;
  }
}

.dsh-lang-switch {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--ink-soft);
  background: var(--surface);
  cursor: pointer;
  outline: none;
}
.dsh-lang-switch:focus {
  border-color: var(--primary);
}
.dsh-auth-lang {
  position: absolute;
  top: 20px;
  right: 20px;
}
.dsh-auth-page {
  position: relative;
}
