:root {
  --bg: #0f1220;
  --card: #1a1f33;
  --border: #2b3350;
  --text: #e6e9f5;
  --muted: #9aa3c0;
  --accent: #6c8bff;
  --green: #2ecc71;
  --red: #e74c3c;
  --orange: #f39c12;
  --gray: #7f8c9d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 900px;
  margin: 0 auto;
  padding: 18px 20px;
}

.topbar h1 { margin: 0; font-size: 1.4rem; }

#app-view section.card, #login-view, .login-card {
  max-width: 900px;
  margin: 0 auto 24px;
}

#login-view {
  max-width: 420px;
  margin-top: 10vh;
}

.login-card { display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0 0 4px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--muted); }

input[type="text"], input[type="password"], input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 1rem;
}

input:focus { outline: 2px solid var(--accent); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.checkbox { display: flex; gap: 18px; align-items: center; grid-column: 1 / -1; }
.checkbox label { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }

.form-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn.small { padding: 6px 10px; font-size: 0.8rem; }
.btn.danger { background: transparent; border: 1px solid var(--red); color: var(--red); }

.alerts-list { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

.alert-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.alert-info { flex: 1; min-width: 220px; }
.alert-info h3 { margin: 0 0 4px; font-size: 1.05rem; }
.alert-info .meta { color: var(--muted); font-size: 0.85rem; }

.status-pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}
.status-pill.AVAILABLE { background: rgba(46,204,113,.15); color: var(--green); }
.status-pill.SOLD_OUT  { background: rgba(231,76,60,.15); color: var(--red); }
.status-pill.UNKNOWN, .status-pill.ERROR { background: rgba(243,156,18,.15); color: var(--orange); }
.status-pill.PAUSED, .status-pill.OFF { background: rgba(127,140,157,.15); color: var(--gray); }

.badge { background: var(--accent); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: .8rem; }

.row-actions { display: flex; gap: 8px; }

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

.history { width: 100%; margin-top: 10px; }
.history details summary { cursor: pointer; color: var(--accent); font-size: .85rem; }
.history ul { margin: 8px 0 0; padding-left: 0; list-style: none; max-height: 180px; overflow: auto; }
.history li { display: flex; justify-content: space-between; font-size: .8rem; padding: 2px 0; border-bottom: 1px solid var(--border); }
.history .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }
.dot.AVAILABLE { background: var(--green); }
.dot.SOLD_OUT { background: var(--red); }
.dot.UNKNOWN, .dot.ERROR, .dot.none { background: var(--orange); }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
}
