:root {
  --bg: #f7f4ec;
  --paper: #fffdf8;
  --ink: #1f2d24;
  --ink-soft: #4b5a4f;
  --primary: #2f5233;
  --primary-dark: #203a24;
  --sage: #dbe6d3;
  --accent: #d9a62e;
  --accent-dark: #b3860f;
  --alert: #b8433a;
  --line: #d8d2c4;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: "Space Grotesk", "Inter", system-ui, sans-serif;
  color: var(--primary-dark);
  margin: 0 0 .4em;
  letter-spacing: -0.01em;
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }

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

.mono, .qty, .price, .total-value {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.topbar {
  background: var(--primary-dark);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar .brand {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }

.topbar nav a {
  color: #e8f0e5;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: .92rem;
  transition: background .15s ease;
}

.topbar nav a:hover, .topbar nav a.active {
  background: rgba(255,255,255,.14);
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 18px 60px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.muted { color: var(--ink-soft); font-size: .92rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.stat {
  background: var(--sage);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat .label { font-size: .82rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-family: "Space Grotesk", sans-serif; font-size: 1.6rem; font-weight: 700; color: var(--primary-dark); }

label {
  display: block;
  font-size: .88rem;
  color: var(--ink-soft);
  margin: 12px 0 4px;
}

input[type=text], input[type=number], input[type=password], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .96rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}

input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--primary); vertical-align: middle; }

button, .btn {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: .94rem;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  display: inline-block;
  transition: background .15s ease, transform .1s ease;
}

button:hover, .btn:hover { background: var(--primary-dark); }
button:active, .btn:active { transform: translateY(1px); }

.btn-accent { background: var(--accent); color: #34260a; }
.btn-accent:hover { background: var(--accent-dark); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--primary-dark);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--sage); }

.btn-small { padding: 5px 12px; font-size: .82rem; }

.btn-danger { background: var(--alert); }
.btn-danger:hover { background: #8f332c; }

/* ---------- receipt (signature element) ---------- */
.receipt {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}

.receipt::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: repeating-linear-gradient(90deg, var(--bg) 0 8px, transparent 8px 16px);
}

.receipt-head {
  text-align: center;
  padding: 22px 20px 14px;
  border-bottom: 1px dashed var(--line);
}

.receipt-head .store {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--primary-dark);
}

.receipt-category {
  padding: 14px 20px 4px;
  font-family: "Space Grotesk", sans-serif;
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent-dark);
  border-top: 1px dashed var(--line);
}

.receipt-category:first-of-type { border-top: none; }

.receipt-group {
  padding: 10px 20px 4px;
}

.receipt-group .group-name { font-weight: 600; font-size: .95rem; margin-bottom: 4px; }

.receipt-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: .92rem;
  border-bottom: 1px dotted var(--line);
}

.receipt-item:last-child { border-bottom: none; }

.receipt-item .item-name.excluded { color: var(--ink-soft); font-style: italic; }
.receipt-item .qty { text-align: right; color: var(--ink-soft); font-size: .88rem; }
.receipt-item .price { text-align: right; min-width: 90px; }

.status-ok { color: var(--primary); font-size: .82rem; }
.status-warn { color: var(--alert); font-weight: 600; font-size: .82rem; }

.receipt-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 16px 20px;
  border-top: 2px solid var(--ink);
  margin-top: 6px;
}

.receipt-total .label {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.receipt-total .total-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  background: var(--sage);
  color: var(--primary-dark);
}

.tag-warn { background: #f6ded9; color: var(--alert); }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { font-family: "Space Grotesk", sans-serif; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px 16px;
}

.checkbox-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.checkbox-row label { margin: 0; font-size: .92rem; color: var(--ink); }

.category-block { margin-bottom: 18px; }
.category-block h4 {
  font-family: "Space Grotesk", sans-serif;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent-dark);
  border-bottom: 1px dashed var(--line);
  padding-bottom: 4px;
  margin-bottom: 8px;
}

.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 140px; }

.footer-note {
  text-align: center;
  color: var(--ink-soft);
  font-size: .8rem;
  margin-top: 30px;
}

@media (max-width: 560px) {
  .receipt-item { grid-template-columns: 1fr auto; grid-template-rows: auto auto; }
  .receipt-item .qty { grid-column: 1 / 2; text-align: left; }
  .receipt-item .price { grid-column: 2 / 3; grid-row: 1 / 3; }
}
