:root {
  --primary: #00E863;
  --on-primary: #00210D;
  --secondary: #FFC94A;
  --on-secondary: #231A00;
  --tertiary: #E5484D;
  --background: #050807;
  --on-background: #EAF2EC;
  --surface: #0E1511;
  --on-surface: #EAF2EC;
  --surface-variant: #15211A;
  --outline: #25352C;
  --error: #E5484D;

  --vip-green: #1B8A4B;
  --grace-orange: #B86E00;
  --grace-icon: #FFA726;
  --expiring-red: #FF5252;
  --sell-red: #D64550;
  --journal-green: #2E9E5B;
  --journal-gray: #8A8F98;
  --bubble-mine: #14532D;
  --bubble-other: #1F2937;
  --pdf-icon: #E57373;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;

  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--background);
  color: var(--on-background);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overscroll-behavior-y: none;
}

body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.screen {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

.screen.no-tabbar { padding-bottom: 16px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px calc(14px + env(safe-area-inset-top));
  padding-top: calc(14px + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--outline);
}
.topbar h1 { font-size: 18px; font-weight: 800; margin: 0; flex: 1; }
.topbar .icon-btn { font-size: 20px; background: none; border: none; color: var(--on-surface); padding: 4px; }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--outline);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tabbar button {
  flex: 1;
  background: none;
  border: none;
  color: var(--on-surface);
  opacity: .55;
  padding: 10px 4px 8px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.tabbar button.active { opacity: 1; color: var(--primary); }
.tabbar .tab-icon { font-size: 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  width: 100%;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-secondary { background: var(--secondary); color: var(--on-secondary); }
.btn-outline { background: transparent; border: 1px solid var(--outline); color: var(--on-surface); }
.btn-danger { background: var(--tertiary); color: #fff; }
.btn[disabled] { opacity: .5; }
.btn-text { background: none; border: none; color: var(--primary); font-weight: 700; padding: 8px; }

input, textarea, select {
  width: 100%;
  background: var(--surface-variant);
  border: 1px solid var(--outline);
  color: var(--on-surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  margin-bottom: 12px;
}
input::placeholder, textarea::placeholder { color: #8a9187; }

.title-hero {
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 6px;
  text-align: center;
  color: var(--primary);
}

.badge {
  display: inline-block;
  border-radius: 100px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
}
.badge-vip { background: var(--secondary); color: var(--on-secondary); }
.badge-admin { background: var(--secondary); color: var(--on-secondary); }
.badge-free { background: var(--surface-variant); color: var(--on-surface); }
.badge-socio { background: var(--vip-green); color: #EAF2EC; }

.lock-overlay {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--secondary);
  font-weight: 700;
  padding: 10px 0;
}

.bubble {
  max-width: 78%;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.35;
  word-wrap: break-word;
}
.bubble.mine {
  background: var(--bubble-mine);
  border-radius: var(--radius-md) 4px var(--radius-md) var(--radius-md);
  margin-left: auto;
}
.bubble.other {
  background: var(--bubble-other);
  border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
}
.bubble img { max-width: 100%; border-radius: 10px; display: block; margin-top: 4px; }
.bubble .author { font-size: 11px; opacity: .6; margin-bottom: 2px; }

.row { display: flex; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.muted { opacity: .65; font-size: 13px; }
.center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }

.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--outline);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end;
  z-index: 50;
}
.modal-sheet {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 85vh;
  overflow-y: auto;
}

.thumb {
  width: 92px; height: 92px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.day-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
}
.day-cell.profit { background: var(--journal-green); }
.day-cell.loss { background: var(--sell-red); }
.day-cell.flat { background: var(--journal-gray); }
.day-cell.empty { background: var(--surface-variant); opacity: .4; }

.install-banner {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
}
.install-banner button { background: none; border: none; color: var(--on-surface); opacity: .6; font-size: 16px; }

.toast {
  position: fixed;
  bottom: calc(96px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-variant);
  border: 1px solid var(--outline);
  padding: 10px 16px;
  border-radius: 100px;
  font-size: 13px;
  z-index: 70;
}
