:root {
  --bg0: #0b0d12;
  --bg1: #0f1117;
  --card: #151826;
  --card2: #1a1d29;
  --border: #2a2d3a;
  --green: #00c087;
  --red: #f6465d;
  --text: #eaecef;
  --muted: #98a2b3;
  --accent: #f0b90b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(240, 185, 11, 0.10), transparent 60%),
    radial-gradient(1000px 500px at 80% 0%, rgba(0, 192, 135, 0.08), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  color: var(--text);
  min-height: 100vh;
  padding: 20px;
}

a { color: inherit; }
.link-reset { text-decoration: none; }

.btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 8px 20px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  transition: transform 0.08s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 18px rgba(240, 185, 11, 0.18);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn.secondary { background: rgba(255, 255, 255, 0.06); color: var(--text); box-shadow: none; border: 1px solid var(--border); }
.btn:focus-visible { outline: 2px solid rgba(240, 185, 11, 0.55); outline-offset: 2px; }
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #3c4043;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 20px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  transition: box-shadow 0.2s ease, opacity 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}
.btn-google:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.35); opacity: 0.95; }
.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted, #888);
  font-size: 0.8rem;
  margin: 10px 0;
  width: 100%;
}
.login-divider::before, .login-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border, #333);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand .logo {
  width: 26px;
  height: 26px;
  display: block;
  filter: drop-shadow(0 8px 20px rgba(240, 185, 11, 0.18));
}
.header h1 {
  font-size: 1.55rem;
  letter-spacing: 0.2px;
  color: var(--text);
}
.header h1 strong { color: var(--accent); }

.header .actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.status { font-size: 0.8rem; color: var(--muted); }

.auto-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}
.auto-refresh input { accent-color: var(--accent); }

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.summary-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 70%), var(--card2);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}
.summary-card .label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.summary-card .value {
  font-size: 1.4rem;
  font-weight: 800;
}

.positions-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.position-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 65%), var(--card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: calc(var(--radius) + 2px);
  padding: 20px;
  transition: border-color 0.2s, transform 0.08s;
  box-shadow: var(--shadow);
}
.position-card:hover { border-color: rgba(240, 185, 11, 0.55); }

.position-card .top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.position-card .symbol { font-size: 1.15rem; font-weight: 800; }
.position-card .side {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.side.Buy { background: rgba(0, 192, 135, 0.12); color: var(--green); }
.side.Sell { background: rgba(246, 70, 93, 0.12); color: var(--red); }

.position-card .details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.detail-item .dl { font-size: 0.75rem; color: var(--muted); }
.detail-item .dv { font-size: 0.95rem; font-weight: 650; }

.pnl-positive { color: var(--green); }
.pnl-negative { color: var(--red); }

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.chart-header .chart-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.time-range-btns { display: flex; gap: 6px; }
.time-range-btns button {
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 6px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.time-range-btns button:hover { border-color: rgba(240, 185, 11, 0.55); color: var(--text); }
.time-range-btns button.active { background: var(--accent); color: #000; border-color: var(--accent); }

.chart-container { width: 100%; height: 280px; }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--muted);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state h2 { margin-bottom: 8px; color: var(--text); }

.error-banner {
  background: rgba(246, 70, 93, 0.1);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  display: none;
}
.warning-banner {
  background: rgba(240, 185, 11, 0.1);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  display: none;
}

/* Login */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 75%), var(--card2);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 38px;
  width: 100%;
  max-width: 390px;
  margin: 0 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.login-card .brandline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}
.login-card .brandline img { width: 30px; height: 30px; }
.login-card h1 { font-size: 1.35rem; color: var(--text); }
.login-card h1 strong { color: var(--accent); }
.login-card p { font-size: 0.88rem; color: var(--muted); margin-bottom: 22px; }
.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 14px;
}
.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus {
  border-color: rgba(240, 185, 11, 0.55);
  box-shadow: 0 0 0 4px rgba(240, 185, 11, 0.12);
}
.login-card button { width: 100%; padding: 12px; }
.error {
  background: rgba(246, 70, 93, 0.1);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 0.88rem;
}

@media (max-width: 768px) {
  .chart-container { height: 220px; }
  .header { gap: 8px; }
  .header h1 { font-size: 1.25rem; }
  .summary { grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
  .summary-card { padding: 12px 14px; }
  .summary-card .label { font-size: 0.7rem; }
  .summary-card .value { font-size: 1.15rem; }
  body { padding: 14px; }
}

@media (max-width: 500px) {
  body { padding: 10px; }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .header .actions { width: 100%; justify-content: space-between; }
  .btn { padding: 10px 16px; font-size: 0.85rem; border-radius: 12px; }
  .auto-refresh { font-size: 0.8rem; }
  .status { display: none; }

  .summary {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 16px;
  }
  .summary-card {
    padding: 12px 16px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .summary-card .label { font-size: 0.75rem; margin-bottom: 0; }
  .summary-card .value { font-size: 1.2rem; }

  .position-card { padding: 14px; border-radius: 14px; }
  .position-card .top-row { margin-bottom: 12px; }
  .position-card .symbol { font-size: 1.05rem; }

  .position-card .details {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }
  .detail-item .dl { font-size: 0.7rem; }
  .detail-item .dv { font-size: 0.85rem; }

  .chart-container { height: 200px; }
  .chart-header { flex-direction: column; align-items: flex-start; gap: 6px; }
  .time-range-btns { width: 100%; justify-content: space-between; }
  .time-range-btns button { flex: 1; padding: 8px 4px; font-size: 0.75rem; text-align: center; }
}

@media (max-width: 360px) {
  body { padding: 8px; }
  .summary-card .value { font-size: 1rem; }
  .position-card { padding: 10px; }
  .detail-item .dv { font-size: 0.8rem; }
  .chart-container { height: 170px; }
}
