:root {
  --ink: #1c2421;
  --muted: #5c6b66;
  --paper: #f4f1ea;
  --card: #fffcf7;
  --line: #d8d2c6;
  --accent: #1f6b4a;
  --accent-dark: #154c35;
  --danger: #9b2c2c;
  --warn: #8a6d1f;
  --shadow: 0 12px 32px rgba(28, 36, 33, 0.08);
  --font: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --sans: "Source Sans 3", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}

a { color: var(--accent-dark); }

.app-header {
  background: var(--ink);
  color: #f4f1ea;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font);
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: inherit;
  text-decoration: none;
}

.brand small {
  display: block;
  font-family: var(--sans);
  font-size: 0.72rem;
  opacity: 0.7;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

nav a {
  color: #d8d2c6;
  text-decoration: none;
  margin-right: 1rem;
  font-size: 0.95rem;
}

nav a.active, nav a:hover { color: #fff; }

.user-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.user-meta button {
  background: transparent;
  border: 1px solid #8a948f;
  color: #f4f1ea;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
}

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

h1, h2, h3 { font-family: var(--font); font-weight: 600; margin: 0 0 0.6rem; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.muted { color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.stat .label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stat .value {
  font-family: var(--font);
  font-size: 1.7rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.actions { white-space: nowrap; }

input, select, textarea, button, .btn {
  font: inherit;
}

input, select, textarea {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
}

label { display: block; font-size: 0.85rem; margin: 0.55rem 0 0.2rem; color: var(--muted); }

.row-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.6rem; }

button, .btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 0.5rem 0.85rem;
  text-decoration: none;
  cursor: pointer;
}

.btn.secondary, button.secondary {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--accent);
}

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

.btn.small, button.small { padding: 0.25rem 0.5rem; font-size: 0.85rem; }

.inline-form { display: inline; }

.flash {
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}
.flash.success { background: #e4f3ea; color: #154c35; }
.flash.error { background: #f8e4e4; color: var(--danger); }
.flash.info { background: #efe7d2; color: var(--warn); }

.filters { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: end; }
.filters > * { min-width: 140px; }
.filters button { height: 2.4rem; }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.ok { background: #e4f3ea; color: #154c35; border-color: #b7dcc6; }
.badge.warn { background: #efe7d2; color: #6a5318; border-color: #e0d3a8; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.login-card h1 { margin-bottom: 0.2rem; }
.login-card button { width: 100%; margin-top: 1rem; }

.diff-pos { color: var(--danger); }
.diff-neg { color: var(--accent-dark); }
.diff-zero { color: var(--muted); }

.invoice-sheet {
  max-width: 720px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  padding: 2.2rem;
}

.invoice-sheet h1 { font-size: 1.6rem; }
.invoice-meta { display: flex; justify-content: space-between; gap: 1rem; margin: 1.2rem 0 1.6rem; }
.totals-row { font-size: 1.15rem; font-family: var(--font); }

.checkbox-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 1rem; }
.checkbox-row input { width: auto; }

.pay-block { margin-top: 1.6rem; }
.pay-block h2 { font-size: 1.15rem; }
.pay-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 0.8rem;
}
.pay-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem 1rem;
}
.pay-card h3 { font-size: 1rem; margin-bottom: 0.4rem; }
.pay-card code { font-size: 0.85rem; word-break: break-all; }
.girocode { display: block; margin: 0.6rem 0; image-rendering: pixelated; }

@media print {
  .app-header, .no-print, .flash { display: none !important; }
  body, html { background: #fff; }
  main { max-width: none; padding: 0; }
  .invoice-sheet { border: 0; box-shadow: none; }
}
