:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --panel: #151b23;
  --border: #263140;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #3fb950;
  --danger: #f85149;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding: 1rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  padding-bottom: max(3rem, env(safe-area-inset-bottom));
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

h1 {
  font-size: 1.25rem;
  margin: 0;
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 2.3rem;
  height: 2.3rem;
  font-size: 1.3rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#status {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

button {
  background: var(--accent);
  color: #04240c;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-weight: 600;
  font-size: 0.95rem;
}

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

button.danger {
  background: var(--danger);
  color: #2a0a08;
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

label {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

input, select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.5rem;
  font-size: 1rem;
}

.rule {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin-bottom: 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.rule .info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.rule .symbol-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.rule .symbol {
  font-weight: 700;
  font-size: 1.05rem;
}

.rule .price {
  font-size: 0.95rem;
  color: var(--text);
}

.rule .change {
  font-size: 0.85rem;
  font-weight: 600;
}

.rule .change.up { color: var(--accent); }
.rule .change.down { color: var(--danger); }
.rule .change.flat { color: var(--muted); }

.rule .desc {
  color: var(--muted);
  font-size: 0.85rem;
}

.rule .armed {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(63, 185, 80, 0.15);
  color: var(--accent);
  white-space: nowrap;
}

.rule .disarmed {
  background: rgba(139, 152, 165, 0.15);
  color: var(--muted);
}

.rule-delete {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 1.8rem;
  height: 1.8rem;
  min-width: 1.8rem;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal-overlay:not([hidden]) {
  display: flex;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  width: 100%;
  max-width: 360px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.modal-header h2 {
  font-size: 1.05rem;
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1rem;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}
