:root {
  --ink: #0E1326;
  --surface: #1A2140;
  --surface-2: #232C52;
  --surface-3: #2C376A;
  --amber: #FF9F1C;
  --amber-soft: rgba(255, 159, 28, 0.16);
  --teal: #2EC4B6;
  --teal-soft: rgba(46, 196, 182, 0.16);
  --coral: #FF5A5F;
  --coral-soft: rgba(255, 90, 95, 0.16);
  --mint: #6FCF97;
  --mint-soft: rgba(111, 207, 151, 0.16);
  --text: #F4F6FB;
  --text-muted: #8A93B8;
  --text-faint: #5D6690;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --font-display: "Space Grotesk", "Inter", sans-serif;
  --font-body: "Inter", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 15% 0%, rgba(255, 159, 28, 0.10), transparent 45%),
    radial-gradient(circle at 90% 10%, rgba(46, 196, 182, 0.10), transparent 40%);
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 100px;
  min-height: 100vh;
}

/* ---------------- Topbar ---------------- */

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

.topbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 28px;
  filter: drop-shadow(0 2px 6px rgba(255, 159, 28, 0.4));
}

.topbar h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.icon-btn {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--text-muted);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s ease, transform 0.15s ease;
}
.icon-btn:hover { color: var(--amber); transform: rotate(20deg); }

/* ---------------- Gauge card ---------------- */

.gauge-card {
  background: linear-gradient(165deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-lg);
  padding: 20px 20px 22px;
  box-shadow: 0 20px 40px -20px rgba(0,0,0,0.6);
  margin-bottom: 16px;
}

.gauge-wrap {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.gauge-svg { width: 100%; display: block; }

.gauge-label {
  font-family: var(--font-display);
  font-size: 12px;
  fill: var(--text-faint);
  font-weight: 600;
}

#needle {
  transform-origin: 120px 130px;
  transition: transform 0.9s cubic-bezier(.34,1.56,.64,1);
}

#gaugeArc {
  transition: stroke-dasharray 0.9s ease;
}

.gauge-readout {
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.gauge-pct {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.gauge-caption {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.gauge-predict {
  text-align: center;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.predict-headline {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 2px;
}

.predict-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0;
}

.gauge-card.urgent .predict-headline { color: var(--coral); }

/* ---------------- Stats row ---------------- */

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid rgba(255,255,255,0.05);
}

.stat-card.teal { background: var(--teal-soft); }
.stat-card.amber { background: var(--amber-soft); }
.stat-card.mint { background: var(--mint-soft); }

.stat-value {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
}

.stat-card.teal .stat-value { color: var(--teal); }
.stat-card.amber .stat-value { color: var(--amber); }
.stat-card.mint .stat-value { color: var(--mint); }

.stat-label {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------------- Chart card ---------------- */

.chart-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-lg);
  padding: 16px 16px 8px;
  margin-bottom: 16px;
}

.chart-card h2 {
  font-family: var(--font-display);
  font-size: 15px;
  margin: 0 0 10px;
  font-weight: 600;
}

/* ---------------- History ---------------- */

.history-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.history h2 {
  font-family: var(--font-display);
  font-size: 16px;
  margin: 0;
  font-weight: 600;
}

.count-pill {
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 999px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.entry-card:hover { border-color: var(--amber); }

.entry-main { display: flex; flex-direction: column; gap: 2px; }

.entry-date {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
}

.entry-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.entry-side {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.entry-consumption {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--teal);
}

.entry-cost {
  font-size: 11.5px;
  color: var(--text-muted);
}

.entry-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  margin-left: 6px;
}

.empty-state {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-muted);
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: var(--radius-md);
}
.empty-state p { margin: 4px 0; }
.empty-sub { font-size: 12px; color: var(--text-faint); }

/* ---------------- FAB ---------------- */

.fab {
  position: fixed;
  bottom: 24px;
  right: 50%;
  transform: translateX(280px);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--amber), #FFC15E);
  color: #1A1200;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 12px 24px -8px rgba(255, 159, 28, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
  z-index: 20;
}
.fab:active { transform: translateX(280px) scale(0.94); }

@media (max-width: 620px) {
  .fab { right: 20px; transform: none; }
  .fab:active { transform: scale(0.94); }
}

/* ---------------- Sheets / modals ---------------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 20, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 30;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
  background: var(--surface);
  width: 100%;
  max-width: 560px;
  border-radius: 24px 24px 0 0;
  padding: 10px 20px 26px;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(.32,.72,0,1);
  max-height: 90vh;
  overflow-y: auto;
}
.sheet-backdrop.open .sheet { transform: translateY(0); }

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--surface-3);
  border-radius: 999px;
  margin: 6px auto 14px;
}

.sheet h2 {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 0 0 14px;
}

.sheet label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.sheet label .opt { color: var(--text-faint); font-weight: 400; }

.sheet input[type="text"],
.sheet input[type="number"],
.sheet input[type="date"] {
  background: var(--surface-2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  color: var(--text);
  font-size: 15px;
  font-family: var(--font-body);
}
.sheet input:focus {
  outline: none;
  border-color: var(--amber);
}

.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
}
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--amber); }

.form-warning {
  font-size: 12.5px;
  color: var(--coral);
  min-height: 16px;
  margin: 0 0 8px;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.btn {
  flex: 1;
  padding: 13px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
}

.btn.primary {
  background: linear-gradient(135deg, var(--amber), #FFC15E);
  color: #1A1200;
}

.btn.ghost {
  background: var(--surface-2);
  color: var(--text-muted);
}

.btn.ghost#deleteBtn {
  background: var(--coral-soft);
  color: var(--coral);
  flex: 0.7;
}

@media (min-width: 621px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 24px; transform: translateY(20px) scale(0.98); }
  .sheet-backdrop.open .sheet { transform: translateY(0) scale(1); }
}
