:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e2e4e9;
  --accent: #2563eb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --positive: #16a34a;
  --negative: #dc2626;
}

* { box-sizing: border-box; }

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

header.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

header.topbar a { color: var(--text); text-decoration: none; font-weight: 600; }
header.topbar nav a { margin-right: 1rem; font-weight: 500; color: var(--accent); }

main {
  max-width: 960px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

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

h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }

.amount-positive { color: var(--positive); font-weight: 600; }
.amount-negative { color: var(--negative); font-weight: 600; }

form.inline { display: inline; }

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.form-row label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--muted);
  gap: 0.25rem;
}

input, select, textarea {
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}

button {
  padding: 0.5rem 0.9rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}

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

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.summary-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.summary-tile .label { color: var(--muted); font-size: 0.85rem; }
.summary-tile .value { font-size: 1.5rem; font-weight: 700; margin-top: 0.25rem; }

.error-box {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.muted { color: var(--muted); font-size: 0.85rem; }

a.back-link { display: inline-block; margin-bottom: 1rem; color: var(--accent); text-decoration: none; }

.login-wrap {
  max-width: 380px;
  margin: 4rem auto;
}

.debtor-link { color: var(--accent); text-decoration: none; font-weight: 600; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  margin-left: 0.4rem;
}
