* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
#root {
  min-height: 100vh;
  max-width: 100%;
  margin: 0 auto;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left,
.topbar-center,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-center {
  font-size: 14px;
  color: #94a3b8;
}
.quota-badge {
  background: #334155;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: #fff;
  transition: background 0.15s ease, color 0.15s ease;
}
.quota-badge:hover {
  background: #475569;
  color: #fff;
}
.quota-badge--low {
  background: #991b1b;
  color: #fff;
}
.quota-badge--low:hover {
  background: #b91c1c;
  color: #fff;
}
.badge {
  background: #dc2626;
  color: white;
  border-radius: 9999px;
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}
.unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dc2626;
  flex-shrink: 0;
}
.icon-btn {
  background: none;
  border: none;
  color: #e2e8f0;
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
  font-size: 2rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover {
  background: #334155;
}

/* Lists */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #334155;
  cursor: pointer;
  background: #1e293b;
  min-height: 56px;
}
.list-item:active {
  background: #334155;
}
.list-item-content {
  flex: 1;
  min-width: 0;
}
.list-item-title {
  font-weight: 500;
  color: #e2e8f0;
}
.list-item-meta {
  font-size: 14px;
  color: #94a3b8;
  margin-top: 2px;
}
.list-item-meta a {
  color: #60a5fa;
  text-decoration: none;
}

/* Webhook row: swipe left to reveal Delete */
.webhook-row-wrap {
  list-style: none;
  margin: 0;
  overflow: hidden;
  border-bottom: 1px solid #334155;
}
.webhook-row-slider {
  display: flex;
  width: 100%;
  transition: transform 0.15s ease-out;
  touch-action: pan-y;
}
.webhook-row-main {
  flex: 1;
  min-width: 100%;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.webhook-row-config {
  flex-shrink: 0;
  width: 72px;
  padding: 0 8px;
  border: none;
  border-radius: 0;
  background: #475569;
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.webhook-row-config:hover {
  background: #64748b;
}
.webhook-row-config:active {
  background: #334155;
}
.webhook-row-delete {
  flex-shrink: 0;
  width: 72px;
  padding: 0 8px;
  border: none;
  border-radius: 0;
  background: #dc2626;
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.webhook-row-delete:hover {
  background: #ef4444;
}
.webhook-row-delete:active {
  background: #b91c1c;
}

/* Webhook config panel */
.webhook-config-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.webhook-config-panel {
  background: #1e293b;
  border-radius: 12px;
  padding: 20px;
  max-width: 360px;
  width: 100%;
  border: 1px solid #334155;
}
.webhook-config-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.webhook-config-close:hover {
  color: #e2e8f0;
}

/* Screens */
.screen {
  padding-bottom: 24px;
}
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #334155;
}
.screen-header-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.screen-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}
.screen-description {
  font-size: 12px;
  color: #94a3b8;
  margin: 0;
  line-height: 1.3;
}
.back-btn {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #475569;
  background: #334155;
  color: #e2e8f0;
}
.back-btn:hover {
  background: #475569;
}

/* Forms */
.form {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 16px;
}
.input::placeholder {
  color: #64748b;
}
.btn {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: #3b82f6;
  color: white;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-secondary {
  background: #334155;
  color: #e2e8f0;
}
.btn-danger {
  background: #dc2626;
}
.link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: #3b82f6;
  cursor: pointer;
  text-decoration: underline;
}
.link:hover {
  color: #60a5fa;
}

/* Params help dialog */
.params-help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.params-help-dialog {
  position: relative;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 20px 40px 20px 20px;
  max-width: 100%;
  max-height: 90vh;
  overflow: auto;
}
.params-help-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: #334155;
  color: #e2e8f0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.params-help-close:hover {
  background: #475569;
}
.params-help-code {
  margin: 0;
  padding: 10px 12px;
  background: #0f172a;
  border-radius: 8px;
  font-size: 12px;
  font-family: ui-monospace, monospace;
  color: #e2e8f0;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* FAB */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #3b82f6;
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Login */
.login-screen {
  max-width: 400px;
  margin: 0 auto;
  padding: 24px 16px;
}
.login-screen h1 {
  font-size: 24px;
  margin-bottom: 8px;
}
.login-screen p {
  color: #94a3b8;
  margin-bottom: 24px;
}

/* Quota page (standalone /quota) */
body.quota-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px;
}
.quota-body .quota-page {
  max-width: 360px;
  width: 100%;
}
.quota-body .quota-back {
  margin-bottom: 32px;
}
.quota-body .quota-back p {
  margin: 0;
}
.quota-body .quota-intro h1 {
  font-size: 24px;
  margin: 0 0 8px;
}
.quota-body .quota-intro p {
  color: #94a3b8;
  margin: 0 0 16px;
  text-align: left;
}
.quota-body .quota-title {
  margin-top: 24px;
  font-size: 24px;
  margin-bottom: 8px;
}
.quota-body h2 {
  font-size: 16px;
  margin: 24px 0 12px;
  color: #94a3b8;
  font-weight: 600;
}
.quota-body h2.quota-buy-heading {
  margin-bottom: 4px;
}
.quota-body .quota-page > p {
  color: #94a3b8;
  margin: 0 0 16px;
  text-align: left;
}
.quota-body a {
  color: #3b82f6;
  text-decoration: none;
}
.quota-body a:hover {
  text-decoration: underline;
}
.quota-body .hidden {
  display: none;
}
.quota-body .quota-form-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.quota-body .quota-form-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 14px;
}
.quota-body .quota-form-row button {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: #334155;
  color: #e2e8f0;
  font-size: 14px;
  cursor: pointer;
}
.quota-body .quota-form-row button:hover {
  background: #475569;
}
.quota-body .quota-form-row button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.quota-body .quota-msg {
  font-size: 14px;
  margin-top: 8px;
}
.quota-body .quota-msg.success {
  color: #22c55e;
}
.quota-body .quota-msg.error {
  color: #f87171;
}
.quota-body .quota-buy-list {
  list-style: none;
  margin: 0 0 24px 0;
  padding: 0;
}
.quota-body .quota-buy-list li {
  padding: 12px 0;
  border-bottom: 1px solid #334155;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.quota-body .quota-buy-list li:last-child {
  border-bottom: none;
}
.quota-body .quota-buy-list .coming {
  font-size: 14px;
  color: #64748b;
}
.quota-body .quota-smallprint {
  font-size: 12px;
  color: #64748b;
  margin: 0;
}
