:root {
  /* Novel Construction brand palette */
  --ink: #221D17;
  --ink-soft: #3A332A;
  --paper: #EFE7D6;
  --paper-2: #F7F2E7;
  --brass: #B8863E;
  --brass-light: #D9B978;
  --brass-dark: #8C6529;
  --brick: #93432A;
  --stone: #6E665A;
  --stone-line: #DCD2B9;
  --hunter: #3D4A38;

  --card: var(--paper-2);
  --line: var(--stone-line);
  --radius: 3px;
  --pad: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);

  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

#app {
  max-width: 860px;
  margin: 0 auto;
  padding: 18px max(var(--pad), env(safe-area-inset-left)) calc(120px + var(--safe-b)) max(var(--pad), env(safe-area-inset-right));
}

h1 { font-family: var(--serif); font-weight: 500; font-size: 27px; line-height: 1.1; letter-spacing: -0.01em; margin: 0 0 4px; }
h2 { font-family: var(--mono); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--brass-dark); margin: 28px 0 12px; }
.cat-label { font-family: var(--serif); font-weight: 500; font-size: 16px; color: var(--ink-soft); margin: 6px 0 6px; }
p.sub { color: var(--stone); margin: 0 0 4px; font-size: 15px; }
.muted { color: var(--stone); }
.center { text-align: center; padding: 48px 0; }
a { color: var(--brass-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Header / brand wordmark ===== */
header {
  position: sticky; top: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: rgba(239, 231, 214, 0.92);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--stone-line);
  padding: 12px 0 12px; margin-bottom: 8px;
}
.wordmark { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); flex-shrink: 0; }
.wordmark:hover { text-decoration: none; }
.wordmark .mark {
  width: 38px; height: 38px; border: 1.5px solid var(--brass); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 15px; color: var(--brass-dark); flex-shrink: 0;
}
.wm-lines { display: flex; flex-direction: column; line-height: 1.15; }
.wm-eyebrow { font-family: var(--mono); font-size: 9.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--brass-dark); }
.wm-title { font-family: var(--serif); font-weight: 600; font-size: 18px; color: var(--ink); }
.wholine { font-family: var(--mono); font-size: 12px; color: var(--stone); letter-spacing: .04em; margin: 0 0 14px; }

nav.tabs {
  display: flex; gap: 5px; align-items: center; flex-wrap: wrap; justify-content: flex-end;
}
nav.tabs a {
  padding: 8px 12px; border-radius: var(--radius); color: var(--ink-soft); font-size: 14px; font-weight: 500;
  white-space: nowrap; border: 1px solid transparent;
}
nav.tabs a.active { background: var(--ink); color: var(--paper-2); }
nav.tabs a:hover { border-color: var(--brass); text-decoration: none; }
nav.tabs a.active:hover { background: var(--ink); }

/* On phones, stack the wordmark over a full-width wrapping tab row so nothing
   is ever clipped. */
@media (max-width: 640px) {
  header { flex-direction: column; align-items: stretch; gap: 12px; }
  nav.tabs { justify-content: flex-start; }
}

/* ===== Cards / grid ===== */
.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .grid.two { grid-template-columns: 1fr 1fr; } }
.card {
  background: var(--paper-2); border: 1px solid var(--ink); border-radius: var(--radius);
  padding: 20px 22px; display: flex; justify-content: space-between; align-items: center; gap: 14px;
  min-height: 74px; position: relative;
}
/* brass cornerstone dots — the brand plaque motif */
.card::before, .card::after { content: ""; position: absolute; top: 9px; width: 5px; height: 5px; border-radius: 50%; background: var(--brass); }
.card::before { left: 9px; } .card::after { right: 9px; }
.card.tap { cursor: pointer; }
.card.tap:active { background: #f1ead9; }
.card.tap:hover { border-color: var(--brass-dark); box-shadow: 0 2px 10px rgba(34,29,23,.08); text-decoration: none; }
.card .title { font-family: var(--serif); font-weight: 600; font-size: 19px; }
.card .meta { font-family: var(--mono); font-size: 12px; color: var(--stone); margin-top: 3px; }

.badge { font-family: var(--mono); border-radius: 20px; padding: 4px 11px; font-size: 11px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.badge.amber { background: #F1E2C2; color: var(--brass-dark); }
.badge.blue { background: var(--hunter); color: #E4EADF; }
.badge.green { background: #DCE6D5; color: var(--hunter); }
.badge.grey { background: var(--stone-line); color: var(--stone); }

/* ===== Lists ===== */
.list { background: var(--paper-2); border: 1px solid var(--stone-line); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 15px 16px; border-top: 1px solid var(--stone-line); min-height: 60px; }
.row:first-child { border-top: none; }
.row .name { font-family: var(--serif); font-weight: 500; font-size: 17px; }
.row .meta { font-family: var(--mono); font-size: 12px; color: var(--stone); margin-top: 3px; }
.row.low { background: #F7EFDD; }

/* ===== Forms ===== */
label { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--brass-dark); font-weight: 500; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 13px 14px; border: 1px solid #CBBE9E; border-radius: var(--radius);
  font-family: var(--sans); font-size: 16px; /* >=16px stops iOS Safari zoom */
  background: #FBF7EE; color: var(--ink); min-height: 50px;
}
textarea { min-height: 80px; font-family: var(--sans); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px rgba(184,134,62,.22); }
.field { margin-bottom: 14px; }
.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.inline > * { flex: 1; min-width: 140px; }
.inline .grow2 { flex: 2; }

button {
  font-family: var(--sans); font-size: 16px; font-weight: 600; border: 1px solid var(--ink); border-radius: var(--radius);
  padding: 13px 20px; background: var(--ink); color: var(--paper-2); cursor: pointer; min-height: 50px; line-height: 1;
  transition: background .18s ease, color .18s ease, transform .12s ease;
}
button:hover { background: var(--brass-dark); border-color: var(--brass-dark); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; transform: none; }
button.ghost { background: var(--ink); }
button.sm { padding: 9px 14px; font-size: 14px; min-height: 42px; }
button.outline { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
button.outline:hover { background: var(--ink); color: var(--paper-2); }
button.amber { background: var(--brass); border-color: var(--brass); color: var(--ink); }
button.amber:hover { background: var(--brass-dark); border-color: var(--brass-dark); color: var(--paper-2); }
button.block { width: 100%; padding: 16px; font-size: 17px; min-height: 56px; }
button.link { background: none; border: none; color: var(--brass-dark); padding: 6px 4px; min-height: 0; font-weight: 500; }
button.link:hover { background: none; text-decoration: underline; }

.box { background: var(--paper-2); border: 1px solid var(--stone-line); border-radius: var(--radius); padding: 18px; margin-top: 16px; }
.box.amber { background: #F6EAD1; border-color: var(--brass); }
.box.green { background: #E2EBDB; border-color: var(--hunter); }
.notice { border-radius: var(--radius); padding: 12px 14px; font-size: 15px; margin-top: 12px; }
.notice.error { background: #F3DAD3; color: var(--brick); }
.notice.ok { background: #E2EBDB; color: var(--hunter); }

/* ===== Table ===== */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--stone-line); border-radius: var(--radius); background: var(--paper-2); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--stone); background: #F0E8D6; padding: 11px 14px; white-space: nowrap; }
td { padding: 12px 14px; border-top: 1px solid var(--stone-line); white-space: nowrap; }
td.num, th.num { text-align: right; }
tr.low td { background: #F7EFDD; }
.low-val { color: var(--brass-dark); font-weight: 600; }

/* ===== Login ===== */
.login { max-width: 400px; margin: 7vh auto 0; }
.login .brand-lockup { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login .brand-lockup .mark { width: 46px; height: 46px; border: 1.5px solid var(--brass); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 18px; color: var(--brass-dark); }
.login .brand-lockup .co { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--brass-dark); }
.login .brand-lockup .nm { font-family: var(--serif); font-weight: 600; font-size: 22px; }
.login h1 { font-size: 30px; margin-top: 6px; }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--brass-dark); }

/* ===== toast + net bar ===== */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + var(--safe-b));
  background: var(--ink); color: var(--paper-2); padding: 12px 18px; border-radius: 999px; font-size: 15px; z-index: 60;
  box-shadow: 0 6px 18px rgba(34,29,23,.3); max-width: 90%; text-align: center;
}
.netbar {
  position: fixed; left: 0; right: 0; bottom: 0; text-align: center;
  padding: 14px 16px calc(14px + var(--safe-b)); font-size: 15px; font-weight: 600; color: var(--paper-2); z-index: 55;
  font-family: var(--sans);
}
.netbar.offline { background: var(--stone); }
.netbar.syncing { background: var(--brass-dark); }
.netbar.error { background: var(--brick); }

.cart-bar { position: sticky; bottom: 0; padding: 14px 0 calc(14px + var(--safe-b)); background: linear-gradient(to top, var(--paper) 74%, transparent); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper input { width: 72px; text-align: center; }
.spacer { height: 10px; }
