:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --primary: #0b6e4f;
  --primary-dark: #08513a;
  --border: #dde1e7;
  --danger: #b42318;
  --warn-bg: #fff7e6;
  --ok-bg: #e7f6ee;
  --err-bg: #fdecea;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }

.topbar { background: var(--primary); color: #fff; padding: 0.6rem 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.topbar a, .topbar .link-button { color: #fff; text-decoration: none; }
.brand { font-weight: 700; font-size: 1.15rem; }
.business-name { opacity: 0.85; font-size: 0.9rem; }
.nav { display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem; align-items: center; margin-left: auto; }
.nav a:hover, .link-button:hover { text-decoration: underline; }
.nav-primary { background: #fff; color: var(--primary) !important; padding: 0.25rem 0.7rem; border-radius: 6px; font-weight: 600; }
.inline-form { display: inline; margin: 0; }
.link-button { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

.container { max-width: 64rem; margin: 0 auto; padding: 1rem; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.25rem; margin-bottom: 1rem; }
.narrow { max-width: 30rem; margin-left: auto; margin-right: auto; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.button { display: inline-block; background: var(--primary); color: #fff; border: 0; border-radius: 8px; padding: 0.6rem 1.1rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.button:hover { background: var(--primary-dark); }
.button:disabled { opacity: 0.6; cursor: wait; }
.button-secondary { background: #e8ecef; color: var(--text); }
.button-secondary:hover { background: #d9dee3; }
.button-large { font-size: 1.1rem; padding: 0.8rem 1.4rem; }

form > div { margin-bottom: 0.9rem; }
label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
label.checkbox { display: inline-flex; gap: 0.35rem; align-items: center; font-weight: normal; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=date], input[type=email], input:not([type]), select, textarea {
  width: 100%; padding: 0.55rem 0.65rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.helptext { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }
.errorlist { color: var(--danger); margin: 0.25rem 0; padding-left: 1.1rem; }

.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; margin-bottom: 1rem; }
.filters > * { margin-bottom: 0; }
.filters input[type=search] { flex: 1 1 14rem; width: auto; }
.filters label { font-weight: normal; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.55rem 0.7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: #f0f2f5; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.02em; color: var(--muted); }
.num { text-align: right; white-space: nowrap; }
.actions a { margin-right: 0.6rem; white-space: nowrap; }
tr.inactive td { color: var(--muted); }
.low { color: var(--danger); font-weight: 700; }
.neg { color: var(--danger); }
.pos { color: var(--primary); }
.badge { font-size: 0.75rem; background: #eee; border-radius: 4px; padding: 0 0.35rem; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.message { padding: 0.7rem 1rem; border-radius: 8px; margin-bottom: 0.5rem; background: var(--ok-bg); }
.message-error { background: var(--err-bg); color: var(--danger); margin-bottom: 1rem; }
.notice { background: var(--warn-bg); border-left: 4px solid #e0a100; padding: 0.6rem 0.8rem; border-radius: 4px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; }
.stat-label { color: var(--muted); font-size: 0.9rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 0.35rem 0; border-bottom: 1px solid var(--border); }
.plain-list li:last-child { border-bottom: 0; }
.summary { margin: 0 0 0.75rem; }
.pagination { display: flex; gap: 1rem; justify-content: center; align-items: center; margin: 1rem 0; }

.filter-box { margin-bottom: 0.75rem; }
.sale-table input.qty { width: 5.5rem; text-align: right; }
.checkout { max-width: 30rem; }
.checkout input { font-size: 1.2rem; margin-bottom: 0.5rem; }

.receipt { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem; max-width: 26rem; margin: 0 auto 1rem; }
.receipt h1 { text-align: center; }
.receipt table th { background: none; }
.receipt tfoot th, .receipt tfoot td { border-bottom: 0; }

@media (max-width: 600px) {
  .container { padding: 0.75rem; }
  .nav { margin-left: 0; width: 100%; }
  th, td { padding: 0.45rem 0.5rem; }
  .actions a { display: inline-block; margin: 0.15rem 0.5rem 0.15rem 0; }
}

@media print {
  body { background: #fff; }
  .no-print, .topbar, .messages { display: none !important; }
  .container { padding: 0; }
  .receipt { border: 0; max-width: none; }
}
