:root {
  --background: 0 0% 100%;
  --foreground: 222 47% 11%;
  --card: 324 0% 94.9%;
  --card-foreground: 229 84% 5%;
  --primary: 198.5 100% 32.1%;
  --primary-foreground: 0 0% 100%;
  --muted: 213 27% 84%;
  --muted-foreground: 215 16% 47%;
  --accent: 175 44% 82%;
  --accent-foreground: 222 47% 11%;
  --border: 213 27% 84%;
  --input: 214.3 31.8% 91.4%;
  --ring: 198.5 100% 32.1%;
  --success: 142 76% 36%;
  --warning: 43 95% 48%;
  --destructive: 0 91% 71%;
  --radius: 0.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: 0 0% 0%;
    --foreground: 210 40% 98%;
    --card: 0 0% 9%;
    --card-foreground: 210 40% 98%;
    --primary: 201 95% 33.1%;
    --primary-foreground: 0 0% 0%;
    --muted: 217.2 32.6% 15.5%;
    --muted-foreground: 215 20.2% 65%;
    --accent: 175 84% 22%;
    --accent-foreground: 210 40% 98%;
    --border: 217.2 32.6% 20%;
    --input: 217.2 32.6% 17.5%;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.5;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.footer {
  padding: 1rem;
  text-align: center;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.card {
  width: 100%;
  max-width: 48rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
  overflow: hidden;
}

.card-wide { max-width: 56rem; }

.card-grid {
  display: grid;
  gap: 0;
}

@media (min-width: 768px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
}

.card-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 1.5rem;
}

@media (min-width: 768px) {
  .card-panel { padding: 2rem; }
}

.card-panel-left { text-align: center; }

.card-panel-right {
  border-top: 1px solid hsl(var(--border));
}

@media (min-width: 768px) {
  .card-panel-right {
    border-top: none;
    border-left: 1px solid hsl(var(--border));
  }
}

.logo {
  width: 12rem;
  height: 12rem;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
}

h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.lead {
  margin: 0;
  text-align: center;
  font-size: 1rem;
}

.text-muted {
  color: hsl(var(--muted-foreground));
}

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-center { text-align: center; }

.app-header {
  width: 100%;
  max-width: 56rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.app-header .logo-sm {
  width: 2.5rem;
  height: 2.5rem;
}

.user-bar {
  margin-left: auto;
  text-align: right;
}

.user-bar .credits {
  font-weight: 600;
  color: hsl(var(--primary));
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.5rem;
  padding: 0 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: hsl(var(--primary) / 0.9);
}

.btn-outline {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border-color: hsl(var(--input));
}

.btn-outline:hover:not(:disabled) {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.btn-destructive {
  background: hsl(var(--destructive));
  color: white;
}

.btn-destructive:hover:not(:disabled) {
  filter: brightness(0.95);
}

.btn-ghost {
  background: transparent;
  color: hsl(var(--muted-foreground));
  border: none;
  height: auto;
  padding: 0;
}

.btn-ghost:hover { color: hsl(var(--foreground)); }

.btn-block { width: 100%; }

.input,
.textarea,
.select {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--input));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: 2px solid hsl(var(--ring) / 0.35);
  outline-offset: 1px;
}

.label {
  display: block;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.35rem;
}

.field { margin-bottom: 1rem; }

.row { display: flex; gap: 0.5rem; }

.otp-box {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.otp-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: hsl(var(--primary));
}

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid hsl(var(--border));
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

.tab-btn.active {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--input));
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: hsl(var(--muted-foreground));
  margin: 0 0 0.75rem;
}

.market-list { display: flex; flex-direction: column; gap: 0.75rem; }

.market-card {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
  padding: 1rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.market-card:hover {
  border-color: hsl(var(--primary) / 0.45);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
}

.market-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 500;
}

.badge-pending { background: hsl(var(--warning) / 0.15); color: hsl(var(--warning)); }
.badge-active { background: hsl(var(--success) / 0.15); color: hsl(var(--success)); }
.badge-cancelled { background: hsl(var(--muted) / 0.35); color: hsl(var(--muted-foreground)); }
.badge-resolved { background: hsl(var(--primary) / 0.15); color: hsl(var(--primary)); }

.outcome-card {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
  padding: 0.75rem;
}

.outcome-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.stake-row {
  display: flex;
  gap: 0.5rem;
}

.error {
  color: hsl(var(--destructive));
  font-size: 0.875rem;
  margin-top: 0.75rem;
}

.hidden { display: none !important; }

.stack { display: flex; flex-direction: column; gap: 1.5rem; }

.grid-2 {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

.divider {
  border-top: 1px solid hsl(var(--border));
  margin-top: 1rem;
  padding-top: 1rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 1rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.875rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.back-link:hover { color: hsl(var(--foreground)); }
