:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1e21;
  --muted: #6b7280;
  --accent: #2563eb;
  --pos: #16a34a;
  --neg: #dc2626;
  --border: #e5e7eb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

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

/* --- login --- */

.login-box {
  margin-top: 20vh;
  text-align: center;
}

.login-box h1 { margin-bottom: 24px; }

.login-box input {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 0 auto 12px;
}

/* --- header --- */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

#me { font-weight: 600; }

/* --- balance --- */

.balance {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  margin-bottom: 16px;
}

#balance-amount {
  font-size: 40px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#balance-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* --- card / form --- */

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

.card h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

form label {
  display: block;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
}

.row {
  display: flex;
  gap: 10px;
}

.row > label { flex: 1; }

input, select, button {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  width: 100%;
  margin-top: 2px;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 600;
  width: auto;
}

button.secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  font-weight: 500;
  cursor: pointer;
  width: auto;
}

.link-btn.danger { color: var(--neg); }

/* --- podpowiadanie nazw --- */

.autocomplete { position: relative; }

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.suggestion {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--text);
  font-weight: 400;
  padding: 10px 12px;
  cursor: pointer;
}

.suggestion:hover, .suggestion.active { background: var(--bg); }

.error {
  color: var(--neg);
  font-size: 14px;
  margin: 8px 0 0;
}

/* --- filters --- */

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

.filters select, .filters input { width: auto; flex: 1; margin: 0; }

.filter-sum {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 8px;
}

/* --- entries --- */

#entries {
  list-style: none;
  padding: 0;
  margin: 0;
}

.entry {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
}

.entry-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.entry-name { font-weight: 600; }

.entry-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.entry-desc {
  font-size: 14px;
  margin-top: 2px;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.entry-actions {
  margin-left: auto;
  display: flex;
  gap: 12px;
}

.entry-actions .link-btn { font-size: 12px; }

.empty {
  text-align: center;
  color: var(--muted);
}
