:root {
  --bg: #0b0f14;
  --surface: #121820;
  --surface2: #1a2230;
  --border: #2a3544;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --yes: #22c55e;
  --yes-dim: #166534;
  --no: #ef4444;
  --no-dim: #991b1b;
  --accent: #3b82f6;
  --radius: 12px;
  --font: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

.hidden { display: none !important; }

/* Auth */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(ellipse at top, #1a2744 0%, var(--bg) 55%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
}

.auth-tagline {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  background: var(--bg);
  padding: 0.25rem;
  border-radius: 10px;
}

.auth-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.55rem;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--surface2);
  color: var(--text);
}

.auth-form { margin-bottom: 0.5rem; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.25rem 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  background: white;
  color: #1f2937;
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.google-btn:hover {
  background: #f3f4f6;
}

.auth-foot {
  margin-top: 1.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

.btn.ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

.btn.danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--no);
  color: var(--no);
  margin-top: 0.75rem;
}

.btn.danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.admin-panel {
  margin-top: 2rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.admin-panel h3 {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--muted);
}

.admin-panel .muted {
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 15, 20, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.logo {
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon { color: var(--accent); flex-shrink: 0; }

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.logo-title {
  font-weight: 700;
  font-size: 1.25rem;
}

.logo-sub {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.auth-logo {
  justify-content: center;
  margin-bottom: 0.5rem;
}

.nav { display: flex; gap: 0.5rem; flex: 1; }

.nav-link {
  color: var(--muted);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.9rem;
}

.nav-link:hover, .nav-link.active { color: var(--text); background: var(--surface2); }

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.balance-pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 1rem;
  font-size: 0.85rem;
}

.balance-pill .label {
  color: var(--muted);
  margin-right: 0.5rem;
}

.user-name { color: var(--muted); font-size: 0.85rem; }

/* Buttons */
.btn {
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }

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

.btn.yes { background: var(--yes); color: #052e16; }
.btn.no { background: var(--no); color: white; }
.btn.full { width: 100%; margin-top: 0.5rem; }

/* Main */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.view { display: none; }
.view.active { display: block; }

.hero {
  margin-bottom: 2rem;
}

.hero h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}

.hero h1 em {
  font-style: normal;
  background: linear-gradient(135deg, var(--yes), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p { color: var(--muted); max-width: 520px; }

/* Toolbar */
.toolbar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search {
  flex: 1;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.search:focus { outline: 2px solid var(--accent); outline-offset: 0; }

.filters { display: flex; gap: 0.35rem; }

.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
}

.filter-btn.active, .filter-btn:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--accent);
}

/* Market cards */
.markets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

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

.market-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.badge {
  background: var(--surface2);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.status {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status.open { color: var(--yes); }
.status.resolved { color: var(--muted); }

.market-card h3 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 1rem;
  min-height: 2.8em;
}

.prob-bar {
  height: 6px;
  background: var(--no-dim);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.prob-bar.lg { height: 10px; margin: 1rem 0; }

.yes-seg {
  height: 100%;
  background: linear-gradient(90deg, var(--yes-dim), var(--yes));
  border-radius: 999px;
  transition: width 0.3s;
}

.prices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.price-btn {
  border: none;
  border-radius: 8px;
  padding: 0.6rem;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.price-btn.yes { background: rgba(34, 197, 94, 0.15); color: var(--yes); }
.price-btn.no { background: rgba(239, 68, 68, 0.15); color: var(--no); }
.price-btn strong { font-size: 1.1rem; }

.card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: var(--muted);
}

/* Market detail */
.back-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.back-btn:hover { color: var(--text); }

.resolved-banner {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  text-align: center;
  font-weight: 600;
  display: none;
}

.market-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 800px) {
  .market-layout { grid-template-columns: 1fr; }
}

.market-main h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0.5rem 0;
  letter-spacing: -0.02em;
}

.desc { color: var(--muted); margin-bottom: 1rem; }

.prob-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.prob-labels .yes { color: var(--yes); }
.prob-labels .no { color: var(--no); }

.stats-row {
  display: flex;
  gap: 2rem;
  margin: 1.5rem 0;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat span:last-child { font-size: 1.25rem; font-weight: 700; }

.trades-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1.5rem;
}

.trades-box h3 { font-size: 0.9rem; margin-bottom: 0.75rem; color: var(--muted); }

.trades-box ul { list-style: none; font-size: 0.85rem; }

.trades-box li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.trades-box li:last-child { border: none; }
.trades-box .yes { color: var(--yes); font-weight: 600; }
.trades-box .no { color: var(--no); font-weight: 600; }

/* Trade panel */
.trade-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: sticky;
  top: 80px;
}

.trade-panel h3 { margin-bottom: 1rem; font-size: 1rem; }

.side-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.side-btn {
  border: 2px solid var(--border);
  background: transparent;
  border-radius: 8px;
  padding: 0.75rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  font-size: 1rem;
}

.side-btn.yes { color: var(--yes); }
.side-btn.no { color: var(--no); }
.side-btn.yes.active { background: rgba(34, 197, 94, 0.2); border-color: var(--yes); }
.side-btn.no.active { background: rgba(239, 68, 68, 0.2); border-color: var(--no); }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.field span { font-size: 0.8rem; color: var(--muted); }

.field input, .field textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

.field input:focus, .field textarea:focus {
  outline: 2px solid var(--accent);
}

.quick-amounts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.quick-amounts button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 0.4rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
}

.quick-amounts button:hover { color: var(--text); border-color: var(--accent); }

.trade-btn {
  width: 100%;
  background: var(--accent);
  color: white;
  padding: 0.85rem;
  font-size: 1rem;
}

.hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.75rem;
  line-height: 1.4;
}

.resolve-panel {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  flex-direction: column;
  gap: 0.5rem;
}

.resolve-panel h4 { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.5rem; }

.resolve-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }

/* Portfolio */
.portfolio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.balance-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  text-align: right;
}

.balance-card span { display: block; font-size: 0.8rem; color: var(--muted); }
.balance-card strong { font-size: 1.75rem; }

.positions-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.positions-table th,
.positions-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  font-size: 0.875rem;
}

.positions-table th {
  background: var(--surface2);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.positions-table tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
.positions-table tr.clickable { cursor: pointer; }
.positions-table tr.clickable:hover td { background: var(--surface2); }

.side-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.side-tag.yes { background: rgba(34, 197, 94, 0.2); color: var(--yes); }
.side-tag.no { background: rgba(239, 68, 68, 0.2); color: var(--no); }

.muted { color: var(--muted); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.open { display: flex; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-card h2 { margin-bottom: 0.35rem; }
.modal-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.25rem; }

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 300;
  max-width: 90vw;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success { border-color: var(--yes); }
.toast.error { border-color: var(--no); }

@media (max-width: 640px) {
  .header-inner { flex-wrap: wrap; gap: 0.75rem; }
  .nav { order: 3; width: 100%; }
  .user-name { display: none; }
}
