/* ========================================
   Hel1os Dashboard — Mobile-first Dark Theme
   ======================================== */

:root {
  --bg-primary: #07080d;
  --bg-card: #10121a;
  --bg-card-hover: #161924;
  --border: #1e2233;
  --accent: #00d4ff;
  --accent-dim: rgba(0, 212, 255, 0.12);
  --text-primary: #e8eaf0;
  --text-secondary: #8b91a8;
  --text-muted: #565c72;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ---- Login ---- */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  text-align: center;
  max-width: 340px;
  width: 100%;
}

.login-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--accent), #0070cc);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  color: #fff;
}

.login-card h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-card p {
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 15px;
}

.login-card input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 14px;
}

.login-card input:focus {
  border-color: var(--accent);
}

.login-card button {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent), #0070cc);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.login-card button:active {
  opacity: 0.85;
}

.error {
  color: var(--danger);
  font-size: 14px;
  margin-top: 12px;
}

/* ---- Header ---- */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: rgba(7, 8, 13, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent), #0070cc);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

#header-date {
  font-size: 13px;
  color: var(--text-secondary);
}

#header-time {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ---- Main ---- */
main {
  padding: 16px;
  padding-bottom: calc(var(--safe-bottom) + 72px);
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: background 0.2s;
}

.card:active {
  background: var(--bg-card-hover);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.card-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.card-body strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Icon backgrounds */
.icon-weather { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.icon-calendar { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }
.icon-email { background: rgba(167, 139, 250, 0.15); color: #a78bfa; }
.icon-health { background: rgba(248, 113, 113, 0.15); color: #f87171; }
.icon-system { background: rgba(52, 211, 153, 0.15); color: #34d399; }
.icon-budget { background: rgba(251, 146, 60, 0.15); color: #fb923c; }
.icon-news { background: rgba(0, 212, 255, 0.15); color: #00d4ff; }
.icon-finance { background: rgba(250, 204, 21, 0.15); color: #facc15; }
.icon-schedule { background: rgba(129, 140, 248, 0.15); color: #818cf8; }

/* ---- Stat row inside cards ---- */
.stat-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
}

.stat-pill .label {
  color: var(--text-muted);
  font-size: 11px;
}

/* ---- Status badges ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.badge-ok { background: rgba(52, 211, 153, 0.15); color: var(--success); }
.badge-warn { background: rgba(251, 191, 36, 0.15); color: var(--warning); }
.badge-danger { background: rgba(248, 113, 113, 0.15); color: var(--danger); }

/* ---- Veille / News list ---- */
.news-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.news-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.news-item .news-category {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  margin-bottom: 2px;
}

.news-item .news-title {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.4;
}

.news-item .news-source {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Greeting banner ---- */
.greeting-banner {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.08), rgba(0, 112, 204, 0.08));
  border: 1px solid rgba(0, 212, 255, 0.15);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  margin-bottom: 4px;
}

.greeting-banner h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.greeting-banner p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ---- Budget bars ---- */
.budget-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.budget-item:last-child { margin-bottom: 0; }

.budget-label {
  width: 80px;
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.budget-bar-bg {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
}

.budget-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.budget-value {
  width: 60px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- Loading ---- */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  gap: 16px;
  color: var(--text-secondary);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ---- Footer ---- */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px calc(var(--safe-bottom) + 10px);
  background: rgba(7, 8, 13, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

#refresh-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s;
}

#refresh-btn:active {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---- Finance grid ---- */
.finance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.finance-item {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  padding: 10px;
}

.finance-item .ticker {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.finance-item .price {
  font-size: 16px;
  font-weight: 700;
  margin: 2px 0;
  font-variant-numeric: tabular-nums;
}

.finance-item .change {
  font-size: 13px;
  font-weight: 600;
}

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