:root {
  --bg: #0b0f14;
  --surface: #131a22;
  --surface-2: #1b2430;
  --border: #263140;
  --text: #e6edf3;
  --text-dim: #8b98a5;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --accent: #3b82f6;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.hidden {
  display: none !important;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

input {
  font: inherit;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}

/* ---- Login screen ---- */

#login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  gap: 16px;
}

#login-screen h1 {
  font-size: 1.3rem;
  margin: 0;
}

#login-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-form button {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

#login-error {
  color: var(--red);
  font-size: 0.9rem;
  min-height: 1.2em;
}

/* ---- App shell ---- */

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 12px 32px;
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 16px;
}

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

#logout-btn {
  background: transparent;
  color: var(--text-dim);
  padding: 6px 10px;
  font-size: 0.85rem;
}

nav.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

nav.tabs button {
  flex: 1;
  background: var(--surface);
  color: var(--text-dim);
  font-weight: 600;
}

nav.tabs button.active {
  background: var(--accent);
  color: #fff;
}

section.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---- Summary card ---- */

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.summary-stat .label {
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.summary-stat .value {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 2px;
}

/* ---- Cards ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

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

.side-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

.side-badge.buy {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
}

.side-badge.sell {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
}

.horizon-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.horizon-badge.short_term {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  border-color: transparent;
}

.horizon-badge.long_term {
  background: rgba(139, 152, 165, 0.15);
  color: var(--text-dim);
  border-color: transparent;
}

.card .meta {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 4px;
}

.amount-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.amount-row label {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.amount-field {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  gap: 2px;
}

.amount-dollar {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.amount-input {
  background: transparent;
  border: none;
  color: var(--text);
  width: 70px;
  padding: 2px 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.amount-input:disabled {
  opacity: 0.6;
}

.amount-input:focus {
  outline: none;
}

.card .quote {
  margin-top: 10px;
  font-style: italic;
  color: var(--text-dim);
  font-size: 0.88rem;
  border-left: 2px solid var(--border);
  padding-left: 10px;
}

.card .rationale {
  margin-top: 8px;
  font-size: 0.88rem;
}

.flags {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.flag {
  font-size: 0.8rem;
  color: var(--amber);
}

.status-line {
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-line.placed {
  color: var(--green);
}

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

.status-line.skipped {
  color: var(--text-dim);
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.card-actions button {
  flex: 1;
  font-weight: 600;
}

.btn-confirm {
  background: var(--green);
  color: #05130a;
}

.btn-confirm.force {
  background: var(--amber);
  color: #1a1200;
}

.btn-skip {
  background: var(--surface-2);
  color: var(--text-dim);
}

.btn-refresh {
  background: var(--surface-2);
  color: var(--text);
  width: 100%;
  margin-bottom: 4px;
}

.empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 32px 12px;
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 16px;
  max-width: 456px;
  margin: 0 auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.88rem;
  z-index: 100;
}

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

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
