:root {
  --tg-bg: var(--tg-theme-bg-color, #ffffff);
  --tg-text: var(--tg-theme-text-color, #1f1f1f);
  --tg-hint: var(--tg-theme-hint-color, #8e8e93);
  --tg-link: var(--tg-theme-link-color, #2481cc);
  --tg-button: var(--tg-theme-button-color, #2481cc);
  --tg-button-text: var(--tg-theme-button-text-color, #ffffff);
  --tg-secondary-bg: var(--tg-theme-secondary-bg-color, #f4f4f7);
  --tg-section-bg: var(--tg-theme-section-bg-color, #ffffff);
  --tg-divider: rgba(120, 120, 128, 0.16);
  --danger: #ff453a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--tg-secondary-bg);
  color: var(--tg-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.container {
  padding: 12px;
  padding-bottom: 100px;
  max-width: 640px;
  margin: 0 auto;
}

.topbar h1 {
  margin: 4px 4px 14px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.periods {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: var(--tg-section-bg);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.periods button {
  padding: 9px 4px;
  border: none;
  background: transparent;
  color: var(--tg-text);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.periods button.active {
  background: var(--tg-button);
  color: var(--tg-button-text);
  font-weight: 600;
}

.card {
  background: var(--tg-section-bg);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.summary {
  padding: 18px 18px 8px;
  margin-bottom: 6px;
  text-align: center;
}

.total-label {
  font-size: 13px;
  color: var(--tg-hint);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.total-amount {
  font-size: 38px;
  font-weight: 700;
  margin: 6px 0 2px;
  letter-spacing: -0.5px;
}

.total-count {
  font-size: 12px;
  color: var(--tg-hint);
  margin-bottom: 10px;
}

.chart-wrap {
  position: relative;
  height: 190px;
  margin-top: 8px;
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--tg-hint);
  margin: 18px 4px 8px;
  letter-spacing: 0.5px;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.list li {
  padding: 12px 16px;
  border-bottom: 1px solid var(--tg-divider);
}

.list li:last-child {
  border-bottom: none;
}

.cat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.cat-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-amount {
  font-weight: 600;
  white-space: nowrap;
}

.exp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.exp-left {
  min-width: 0;
  flex: 1;
}

.exp-desc {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exp-meta {
  font-size: 12px;
  color: var(--tg-hint);
  margin-top: 2px;
}

.exp-amount {
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
}

.empty {
  text-align: center;
  color: var(--tg-hint);
  padding: 24px;
  font-size: 14px;
}

.fab {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--tg-button);
  color: var(--tg-button-text);
  border: none;
  font-size: 30px;
  font-weight: 300;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 50;
  line-height: 1;
  padding: 0;
}

.fab:active { transform: scale(0.94); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fade 0.2s ease;
}

.modal.hidden { display: none; }

.modal-box {
  background: var(--tg-bg);
  border-radius: 20px 20px 0 0;
  padding: 22px 20px 28px;
  width: 100%;
  max-width: 640px;
  animation: slideUp 0.25s ease;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-box h3 {
  margin: 0 0 14px;
  font-size: 19px;
  font-weight: 700;
}

.modal-box label {
  display: block;
  margin: 10px 0 4px;
  font-size: 12px;
  color: var(--tg-hint);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 500;
}

.modal-box input,
.modal-box select {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--tg-divider);
  background: var(--tg-secondary-bg);
  color: var(--tg-text);
  font-size: 16px;
  font-family: inherit;
}

.modal-box input:focus,
.modal-box select:focus {
  outline: none;
  border-color: var(--tg-button);
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  align-items: center;
}

.modal-actions button {
  padding: 11px 14px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--tg-secondary-bg);
  color: var(--tg-text);
}

.btn-primary {
  background: var(--tg-button) !important;
  color: var(--tg-button-text) !important;
  flex: 1;
}

.btn-danger {
  background: transparent !important;
  color: var(--danger) !important;
  margin-right: auto;
}

.page.hidden {
  display: none !important;
}

/* Access Overlay styling */
#access-overlay {
  background: var(--tg-bg);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.access-box {
  background: var(--tg-section-bg);
  border-radius: 20px;
  padding: 30px 24px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
  animation: slideUp 0.3s ease;
}

.access-icon {
  font-size: 50px;
  margin-bottom: 16px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.access-box h2 {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 700;
}

.access-box p {
  font-size: 14px;
  color: var(--tg-hint);
  line-height: 1.5;
  margin: 0 0 24px;
}

/* Bottom Nav bar styling */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: max(60px, calc(60px + env(safe-area-inset-bottom)));
  background: var(--tg-section-bg);
  border-top: 1px solid var(--tg-divider);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 90;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03);
}

.bottom-nav.hidden {
  display: none !important;
}

.nav-item {
  flex: 1;
  height: 100%;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--tg-hint);
  cursor: pointer;
  gap: 3px;
  transition: color 0.15s;
}

.nav-item.active {
  color: var(--tg-button);
}

.nav-icon {
  font-size: 20px;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
}

/* Admin panel elements */
.user-card {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--tg-divider);
}

.user-card:last-child {
  border-bottom: none;
}

.user-info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.user-details {
  min-width: 0;
  flex: 1;
}

.user-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-id {
  font-size: 11px;
  color: var(--tg-hint);
  margin-top: 2px;
}

.user-stats {
  font-size: 12px;
  color: var(--tg-hint);
  margin-top: 4px;
}

.user-status-badge {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-pending {
  background: rgba(251, 99, 64, 0.12);
  color: #fb6340;
}

.badge-approved {
  background: rgba(45, 206, 137, 0.12);
  color: #2dce89;
}

.badge-rejected {
  background: rgba(245, 54, 92, 0.12);
  color: #f5365c;
}

.user-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-sm:active {
  opacity: 0.8;
}

.btn-sm-approve {
  background: var(--tg-button);
  color: var(--tg-button-text);
}

.btn-sm-reject {
  background: rgba(245, 54, 92, 0.1);
  color: var(--danger);
}

/* Categories Management Styles */
.cat-edit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.cat-edit-name {
  font-weight: 500;
  font-size: 15px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-edit-input {
  flex: 1;
  padding: 6px 10px;
  font-size: 15px;
  border: 1px solid var(--tg-button);
  border-radius: 6px;
  background: var(--tg-secondary-bg);
  color: var(--tg-text);
  outline: none;
}

.cat-edit-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  transition: transform 0.1s;
}

.btn-icon:active {
  transform: scale(0.85);
}

