:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --danger: #f87171;
  --success: #34d399;
  --warn: #fbbf24;
  --radius: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.shell-loading {
  display: grid;
  place-items: center;
  min-height: 60vh;
  color: var(--muted);
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: linear-gradient(180deg, rgba(30,41,59,0.85), rgba(30,41,59,0.6));
  border-bottom: 1px solid var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.app-header h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.3px;
}

.app-header nav {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 13px;
}

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

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0 0 10px;
  font-size: 16px;
  color: var(--text);
}

/* Forms */
label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--surface-2);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  cursor: pointer;
  border: none;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  background: var(--accent);
  color: #0b1220;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

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

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #0b1220;
}

/* Auth */
.auth-card {
  max-width: 420px;
  margin: 40px auto;
}

.auth-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.auth-toggle button {
  flex: 1;
}

.auth-toggle button.active {
  outline: 2px solid var(--accent);
}

/* League cards */
.league-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.league-card {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: transform .08s ease, border-color .2s ease;
}

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

.league-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.league-meta {
  color: var(--muted);
  font-size: 12px;
}

/* Import wizard */
.wizard-steps {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.wizard-step {
  flex: 1;
  text-align: center;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--muted);
}

.wizard-step.active {
  background: var(--accent);
  color: #0b1220;
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.provider-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.provider-btn:hover {
  border-color: var(--accent);
}

.provider-btn.selected {
  outline: 2px solid var(--accent);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--surface-2);
}

th {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.4px;
}

tr:hover td {
  background: rgba(255,255,255,0.03);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--surface-2);
}

.tab {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

.tab.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

/* Messages */
.message {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
}

.message.error {
  background: rgba(248,113,113,0.12);
  color: var(--danger);
  border: 1px solid rgba(248,113,113,0.25);
}

.message.success {
  background: rgba(52,211,153,0.12);
  color: var(--success);
  border: 1px solid rgba(52,211,153,0.25);
}

/* Optimizer */
.lineup-slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--surface-2);
}

.lineup-slot .pos {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  min-width: 56px;
}

.lineup-slot .name {
  flex: 1;
  padding: 0 10px;
}

.lineup-slot .proj {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* Draft Help */
.draft-help-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.draft-help-results {
  margin-top: 18px;
}

.draft-help-results h4 {
  margin: 16px 0 8px;
  font-size: 14px;
  color: var(--accent);
}

.draft-pick-card {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.draft-pick-header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
}

.pick-label {
  font-weight: 600;
  color: var(--accent-2);
  min-width: 72px;
}

.pick-player {
  flex: 1;
  font-weight: 500;
}

.pick-adp {
  font-size: 12px;
}

.reason-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.reason-list.compact {
  padding-left: 14px;
  font-size: 12px;
}

.reason-list li {
  margin-bottom: 2px;
}

.draft-board-table {
  width: 100%;
  font-size: 13px;
}

.draft-board-table th,
.draft-board-table td {
  vertical-align: top;
  padding: 8px 6px;
}

.draft-board-table tr.stack-row {
  background: rgba(56, 189, 248, 0.08);
}

.tier-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  font-size: 11px;
  white-space: nowrap;
}

.draft-notes {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--surface-2);
}

.roster-block {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--surface-2);
}

.roster-block:last-child {
  border-bottom: none;
}

.roster-table {
  width: 100%;
  margin-top: 8px;
  font-size: 13px;
}

.roster-table th,
.roster-table td {
  padding: 4px 8px;
  text-align: left;
}

.my-roster-preview {
  margin-top: 16px;
  padding: 12px;
  background: var(--surface-1);
  border-radius: 8px;
}

.roster-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.roster-chip {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12px;
}

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

/* Misc */
.small { font-size: 12px; color: var(--muted); }

@media (max-width: 640px) {
  .shell { padding: 14px; }
  .app-header { flex-wrap: wrap; }
  .league-grid { grid-template-columns: 1fr; }
}
