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

:root {
  --bg: #1a1a1a;
  --surface: #2a2a2a;
  --text: #f0f0f0;
  --muted: #888;
  --orange: #f97316;
  --green: #22c55e;
  --red: #ef4444;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  user-select: none;
  -webkit-user-select: none;
}

/* Tabs */
.tabs {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid #333;
  z-index: 10;
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  flex: 1;
  padding: 10px 0 6px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  transition: color .2s;
}

.tab.active { color: var(--orange); }

.tab-icon {
  font-size: 22px;
  display: block;
  margin-bottom: 2px;
}

/* Pages */
.page { display: none; padding: 20px 16px 100px; }
.page.active { display: block; }

h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 24px;
}

/* Counter Page */
.counter-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding-top: 20px;
}

.count-display {
  font-size: 96px;
  font-weight: 800;
  color: var(--orange);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.goal-display {
  font-size: 24px;
  color: var(--muted);
  margin-top: -12px;
}

.progress-bar {
  width: 200px;
  height: 6px;
  background: #333;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--orange);
  border-radius: 3px;
  transition: width .3s;
}

.progress-fill.over { background: var(--red); }

.money-row {
  display: flex;
  gap: 32px;
}

.money-item {
  text-align: center;
}

.money-value {
  font-size: 20px;
  font-weight: 700;
}

.money-value.spent { color: var(--red); }
.money-value.saved { color: var(--green); }

.money-label {
  font-size: 12px;
  color: var(--muted);
}

/* Buttons */
.btn-row {
  display: flex;
  align-items: center;
  gap: 24px;
}

.btn-smoke {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--orange);
  border: none;
  color: #000;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(249,115,22,0.4);
  transition: transform .1s;
}

.btn-smoke:active { transform: scale(0.92); }

.btn-resist {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(34,197,94,0.15);
  border: 2px solid var(--green);
  color: var(--green);
  font-size: 28px;
  cursor: pointer;
  transition: transform .1s;
}

.btn-resist:active { transform: scale(0.92); }

.resist-count {
  color: var(--green);
  font-size: 15px;
}

.undo-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 16px;
  min-height: 36px;
}

/* Time chips */
.time-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}

.chip {
  font-size: 12px;
  padding: 4px 10px;
  background: var(--surface);
  border-radius: 12px;
  white-space: nowrap;
  color: var(--muted);
}

/* History */
.day-row {
  display: flex;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid #2a2a2a;
}

.day-date {
  flex: 1;
}

.day-date-main { font-weight: 600; }
.day-date-sub { font-size: 12px; color: var(--orange); }

.day-resisted {
  color: var(--green);
  font-size: 14px;
  margin-right: 12px;
}

.day-count {
  font-size: 24px;
  font-weight: 700;
  min-width: 32px;
  text-align: right;
}

/* Stats */
.stat-section {
  margin-bottom: 24px;
}

.stat-section h2 {
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.stat-row {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #2a2a2a;
}

.stat-label { flex: 1; }

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--orange);
}

.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }

/* Chart */
.chart-container {
  background: var(--surface);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 140px;
}

.bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.bar {
  width: 100%;
  min-height: 2px;
  background: var(--orange);
  border-radius: 3px 3px 0 0;
  transition: height .3s;
}

.bar.resist-bar {
  background: var(--green);
  border-radius: 0;
}

.bar-label {
  font-size: 9px;
  color: var(--muted);
  margin-top: 4px;
  text-align: center;
}

.goal-line {
  border-top: 1px dashed var(--red);
  opacity: 0.5;
  position: relative;
  margin-bottom: 8px;
}

.chart-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

/* Settings modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}

.modal-overlay.show { display: flex; }

.modal {
  background: var(--surface);
  width: 100%;
  max-width: 400px;
  border-radius: 16px 16px 0 0;
  padding: 24px 20px 40px;
}

.modal h2 {
  font-size: 20px;
  margin-bottom: 20px;
}

.modal input {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #444;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  margin-bottom: 12px;
}

.modal-btns {
  display: flex;
  gap: 12px;
}

.modal-btns button {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-size: 16px;
  cursor: pointer;
}

.btn-save { background: var(--orange); color: #000; font-weight: 600; }
.btn-cancel { background: #444; color: var(--text); }
.btn-danger { background: var(--red); color: #fff; font-size: 14px !important; }

/* Empty state */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  font-size: 15px;
}

/* Login */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.login-box {
  text-align: center;
  padding: 40px;
}

.login-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--orange);
  color: #000;
  font-size: 40px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.login-box h2 {
  margin-bottom: 24px;
  font-size: 24px;
}

.login-box input {
  width: 200px;
  padding: 14px;
  border-radius: 12px;
  border: 2px solid #444;
  background: var(--surface);
  color: var(--text);
  font-size: 24px;
  text-align: center;
  letter-spacing: 8px;
  display: block;
  margin: 0 auto 16px;
}

.login-box input:focus {
  outline: none;
  border-color: var(--orange);
}

.btn-login {
  width: 200px;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: var(--orange);
  color: #000;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
}

.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* Settings icon */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.header-row h1 { margin-bottom: 0; }

.settings-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  padding: 8px;
}
