:root {
  --ink: #1c1612;
  --muted: #6f645b;
  --paper: #f4efe6;
  --card: #fffdf9;
  --line: #e5dcd0;
  --accent: #9a3412;
  --accent-soft: #f8ebe3;
  --header: #241c16;
  --good: #17693f;
  --good-soft: #e5f4eb;
  --warn: #8a5a08;
  --warn-soft: #fbf3dc;
  --bad: #9f1239;
  --bad-soft: #fde8ee;
  --info: #1e4e78;
  --info-soft: #e7f0f8;
  --shadow: 0 1px 2px rgba(48, 28, 8, 0.06), 0 8px 24px rgba(48, 28, 8, 0.04);
  --radius: 14px;
  --tap: 46px;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  line-height: 1.4;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

.top {
  background: var(--header);
  color: #f6efe6;
  padding: 12px 16px calc(12px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand:hover { text-decoration: none; }
.mark {
  width: 32px; height: 36px; border: 2px solid #e7c7a4; border-radius: 3px 3px 2px 2px;
  position: relative; flex: none;
}
.mark:before, .mark:after {
  content: ""; position: absolute; background: #e7c7a4;
}
.mark:before { width: 8px; height: 2px; top: 14px; left: 6px; box-shadow: 0 6px 0 #e7c7a4; }
.mark:after { width: 7px; height: 7px; border-radius: 50%; border: 2px solid #e7c7a4; background: transparent; right: 4px; top: 12px; }
.brand b { display: block; letter-spacing: 0.14em; font-size: 14px; }
.brand span { display: block; font-size: 11px; letter-spacing: 0.04em; color: #d9cbbd; font-weight: 500; }
.who { font-size: 13px; color: #eadfD2; }

.wrap { max-width: 860px; margin: 0 auto; padding: 16px 14px 108px; }
h1 { font-size: 26px; line-height: 1.15; margin: 0 0 6px; letter-spacing: -0.02em; }
h2 { font-size: 18px; margin: 0 0 10px; }
.lede, .muted { color: var(--muted); }
.lede { margin: 0 0 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin: 0 0 12px;
}
.card h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; gap: 8px; align-items: center; }

label { display: block; font-size: 13px; font-weight: 650; margin: 10px 0 4px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid #d9cfc3;
  border-radius: 10px;
  padding: 12px 12px;
  min-height: var(--tap);
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid #e7c7a4;
  border-color: var(--accent);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 560px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.btn, button, .btn-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 0 14px; border-radius: 12px;
  border: 1px solid transparent; font: inherit; font-weight: 650;
  cursor: pointer; text-decoration: none; gap: 6px;
}
.btn-primary, button.primary { background: var(--accent); color: white; }
.btn-primary:hover, button.primary:hover { filter: brightness(1.05); text-decoration: none; }
.btn-ghost { background: transparent; border-color: #d9cfc3; color: var(--ink); }
.btn-danger { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn-block { width: 100%; }
.inline { display: inline; }
.tiny { min-height: 36px; padding: 0 10px; font-size: 13px; border-radius: 9px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 8px 0 12px; }
.chip {
  flex: none; border-radius: 999px; padding: 8px 12px; background: #fff; border: 1px solid var(--line);
  color: var(--ink); font-size: 13px; text-decoration: none; min-height: 36px;
}
.chip.on { background: var(--header); color: white; border-color: var(--header); }
.chip:hover { text-decoration: none; }

.badge {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 3px 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.01em;
  background: #efe8df; color: var(--ink);
}
.st-needs-status { background: #ece7e1; color: #4b433c; }
.st-quote-expired { background: #ece7e1; color: #6b625a; }
.st-delayed { background: var(--warn-soft); color: var(--warn); }
.st-on-order { background: var(--info-soft); color: var(--info); }
.st-received { background: #e7f6f4; color: #0f6e68; }
.st-scheduled { background: #ece9fb; color: #4338ca; }
.st-complete { background: var(--good-soft); color: var(--good); }
.st-invoiced { background: #fff1e6; color: #9a3412; }
.st-paid { background: #d9f5e5; color: #115c36; }
.flag { background: var(--bad-soft); color: var(--bad); }

.job {
  display: block; color: inherit; text-decoration: none; padding: 12px 0;
  border-top: 1px solid var(--line);
}
.job:hover { text-decoration: none; }
.job:first-of-type { border-top: 0; }
.job strong { display: block; font-size: 16px; }
.code { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; font-weight: 750; }
.meta { color: var(--muted); font-size: 13px; margin-top: 2px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.stat b { display: block; font-size: 20px; }
.stat span { color: var(--muted); font-size: 12px; }

.money { font-variant-numeric: tabular-nums; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; }
.totals div:nth-child(odd) { color: var(--muted); }
.totals div:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }
.totals .grand { color: var(--ink); font-size: 18px; font-weight: 750; }
.good { color: var(--good); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.shot { position: relative; display: block; }
.shot img { width: 100%; height: 104px; object-fit: cover; border-radius: 10px; background: #efe8df; }
.shot em {
  position: absolute; left: 6px; bottom: 6px; font-style: normal; font-size: 10px;
  background: rgba(28, 22, 18, 0.78); color: white; border-radius: 999px; padding: 2px 6px;
}
.full { width: 100%; border-radius: 12px; background: #1c1612; }

.banner {
  background: var(--warn-soft); color: #6a4506; border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px;
}
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.ok { background: var(--good-soft); color: var(--good); }
.note { font-size: 13px; color: var(--muted); }

.check { display: flex; align-items: center; gap: 8px; min-height: var(--tap); }
.check input { width: 20px; height: 20px; min-height: 0; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fffdf9; border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  text-align: center; color: var(--muted); font-size: 12px; font-weight: 700;
  text-decoration: none; padding: 6px 0 4px; border-radius: 10px;
}
.tabbar a.on, .tabbar a:hover { color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.tabbar svg { display: block; margin: 0 auto 2px; }

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; background:
  radial-gradient(1200px 500px at 50% -10%, #3a2a20, transparent 60%), var(--paper); }
.login-card { width: min(420px, 100%); }
.login-card h1 { color: var(--header); }
.hint { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; }

.menu a.item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 4px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; min-height: 52px;
}
.menu a.item:hover { text-decoration: none; color: var(--accent); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 8px; font-size: 15px; }
.kv span { color: var(--muted); }

table.sheet { width: 100%; border-collapse: collapse; font-size: 14px; }
table.sheet th, table.sheet td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.sheet th { font-size: 12px; color: var(--muted); font-weight: 700; }
.scroll { overflow-x: auto; }

details.edit { margin-top: 8px; }
details.edit summary { cursor: pointer; color: var(--accent); font-weight: 650; }

.empty { padding: 18px 8px; color: var(--muted); }

@media print {
  .top, .tabbar, .noprint, .internal, form, .btn, button { display: none !important; }
  body { background: white; }
  .wrap { max-width: none; padding: 0; }
  .card { box-shadow: none; }
}
