:root {
  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-text: #1c1e21;
  --color-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-primary: #2563eb;
  --color-income: #16a34a;
  --color-expenditure: #dc2626;
  --color-danger: #dc2626;
  --nav-height: 64px;
  --topbar-height: 56px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  padding-bottom: calc(var(--nav-height) + 16px);
}

.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 10;
}

.topbar h1 {
  font-size: 1.1rem;
  margin: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.settings-link {
  font-size: 1.3rem;
  text-decoration: none;
  line-height: 1;
}

.content {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  display: flex;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  z-index: 10;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--color-muted);
  font-size: 0.7rem;
}

.nav-item.active {
  color: var(--color-primary);
  font-weight: 600;
}

.nav-icon {
  font-size: 1.3rem;
}

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

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.stat-card .label {
  font-size: 0.8rem;
  color: var(--color-muted);
}

.stat-card .value {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 4px;
}

.stat-card.income .value { color: var(--color-income); }
.stat-card.expenditure .value { color: var(--color-expenditure); }
.stat-card.balance .value { color: var(--color-primary); }

form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

input, select, textarea {
  font-size: 1rem;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  min-height: 44px;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
}

textarea {
  min-height: 70px;
  resize: vertical;
}

.type-toggle {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

.type-toggle button {
  flex: 1;
  padding: 10px;
  border: none;
  background: var(--color-surface);
  min-height: 44px;
  font-size: 0.95rem;
  cursor: pointer;
}

.type-toggle button.active[data-type="income"] {
  background: var(--color-income);
  color: #fff;
}

.type-toggle button.active[data-type="expenditure"] {
  background: var(--color-expenditure);
  color: #fff;
}

button, .btn {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  background: var(--color-primary);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

button.secondary {
  background: var(--color-border);
  color: var(--color-text);
}

button.danger {
  background: var(--color-danger);
}

button.small {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

.list-item .main {
  flex: 1;
  min-width: 0;
}

.list-item .title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item .meta {
  font-size: 0.8rem;
  color: var(--color-muted);
}

.list-item .amount {
  font-weight: 700;
  white-space: nowrap;
}

.amount.income { color: var(--color-income); }
.amount.expenditure { color: var(--color-expenditure); }

.actions {
  display: flex;
  gap: 6px;
}

.month-divider {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 4px 6px;
}

.month-divider:first-child {
  padding-top: 0;
}

.empty-state {
  text-align: center;
  color: var(--color-muted);
  padding: 40px 16px;
}

.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: #1c1e21;
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 0.9rem;
  z-index: 20;
}

.toast.error {
  background: var(--color-danger);
}

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.filters select, .filters input {
  flex: 1;
  min-width: 100px;
}

.search-input {
  display: block;
  width: 100%;
  margin-bottom: 12px;
}
