:root {
  --green: #00524C; --green-dark: #003B37; --sage: #D4E3BE; --sage-light: #EEF3E4;
  --paper: #F6F4EC; --ink: #1B1B1B; --muted: #5A5F5A; --line: #E3E1D8; --line-dark: #C9CFC6;
  --amber: #8A5A00; --amber-bg: #FFFBEA; --amber-line: #B8A24A; --grey-cell: #9A9A9A;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: Inter, system-ui, sans-serif; font-size: 15px; }
#app { min-height: 100vh; padding-bottom: 92px; }
a { color: var(--green); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; }
h1, h2, h3 { margin: 0; }

.topbar { background: var(--green); color: #fff; padding: calc(env(safe-area-inset-top) + 16px) 20px 16px; }
.topbar .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.topbar .brand { font-size: 12px; font-weight: 700; letter-spacing: .12em; }
.topbar h1 { font-size: 22px; font-weight: 700; line-height: 1.2; margin-top: 10px; }
.topbar .sub { font-size: 13px; color: var(--sage); margin-top: 4px; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 999px; padding: 8px 12px; font-size: 13px; font-weight: 600; min-height: 40px; }
.pill select { background: transparent; border: none; color: #fff; font-weight: 600; font-size: 13px; }
.pill select option { color: var(--ink); }
.back { display: inline-flex; align-items: center; color: #fff; font-size: 13px; gap: 6px; min-height: 44px; }

.content { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.section-label { font-size: 12px; font-weight: 600; letter-spacing: .08em; color: var(--muted); padding: 8px 4px 0; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.card.primary { border: 1.5px solid var(--green); }
.card.warn { background: var(--amber-bg); border: 1px solid #E6D48A; border-left: 4px solid var(--amber-line); }
.card .title { font-size: 15px; font-weight: 600; }
.card .meta { font-size: 13px; color: var(--muted); }
.card.link { flex-direction: row; align-items: center; gap: 12px; color: var(--ink); }
.card.link .body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.tag { font-size: 12px; font-weight: 600; color: var(--green); background: var(--sage); border-radius: 999px; padding: 4px 10px; }
.tag.amber { color: var(--amber); background: #FFF3C4; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.note { font-size: 12px; color: var(--muted); }
.note.amber { color: var(--amber); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 18px; border-radius: 12px; border: none; background: var(--green); color: #fff; font-size: 15px; font-weight: 700; }
.btn.secondary { background: #fff; color: var(--green); border: 1.5px solid var(--green); }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.text { background: none; color: var(--green); padding: 0 6px; min-height: 44px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }

.table { display: flex; flex-direction: column; }
.thead, .trow { display: grid; gap: 8px; align-items: center; padding: 8px 16px; }
.thead { font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--muted); padding-bottom: 4px; }
.trow { background: #fff; border-top: 1px solid var(--line); min-height: 60px; }
.trow:last-child { border-bottom: 1px solid var(--line); }
.trow .name { font-size: 15px; font-weight: 600; min-width: 0; }
.trow .sub { font-size: 12px; color: var(--muted); }
.trow .sub.amber { color: var(--amber); }
.num { width: 100%; height: 44px; border: 1.5px solid var(--green); border-radius: 10px; background: #fff; font-size: 17px; font-weight: 600; text-align: center; color: var(--ink); }
.num.empty { border-color: var(--amber-line); background: var(--amber-bg); }
.num.disabled { border-color: var(--line-dark); background: #F0EFE8; color: var(--muted); }
.calc { height: 44px; display: flex; align-items: center; justify-content: center; background: var(--sage-light); border-radius: 10px; font-size: 17px; font-weight: 700; color: var(--green); }
.calc.zero { background: #F0EFE8; color: var(--muted); }
.calc.pending { background: #F0EFE8; color: #8A8E89; font-size: 15px; font-weight: 600; }
.cols-count { grid-template-columns: minmax(0,1fr) 88px 72px; }
.cols-hub { grid-template-columns: minmax(0,1fr) 52px 72px 60px; }
.cols-par { grid-template-columns: minmax(0,1fr) 70px 70px; }
.center { text-align: center; }
.small-input { width: 100%; height: 40px; border: 1px solid var(--line-dark); border-radius: 8px; padding: 0 8px; background: #fff; }
.row-actions { display: flex; gap: 8px; }
.footer { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px); display: flex; flex-direction: column; gap: 8px; z-index: 5; }
.footer .between { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.footer .between b { color: var(--ink); }

#nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; background: #fff; border-top: 1px solid var(--line); padding: 8px 8px calc(env(safe-area-inset-bottom) + 10px); z-index: 4; }
#nav a { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 56px; min-height: 44px; font-size: 11px; font-weight: 500; color: var(--muted); }
#nav a.active { color: var(--green); font-weight: 600; }
#nav svg { width: 22px; height: 22px; }

.auth { max-width: 420px; margin: 0 auto; padding: 40px 20px; display: flex; flex-direction: column; gap: 12px; }
.auth input { height: 48px; border: 1px solid var(--line-dark); border-radius: 10px; padding: 0 12px; }
.auth .logo { font-size: 13px; font-weight: 700; letter-spacing: .14em; color: var(--green); }
.error { color: #9B1C1C; font-size: 13px; }
.ok { color: var(--green); font-size: 13px; }

[hidden] { display: none !important; }
.expiring { display: flex; gap: 8px; align-items: center; padding: 6px 16px 10px; background: #fff; border-top: 1px dashed var(--line); font-size: 13px; }
.expiring input { height: 40px; border: 1px solid var(--line-dark); border-radius: 8px; padding: 0 8px; }
.expiring input[type=number] { width: 72px; text-align: center; }
.expiring input[type=date] { flex: 1; }

/* Print run sheet */
.print { background: #fff; padding: 20px; }
.print table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.print th, .print td { border: 1px solid var(--line-dark); padding: 4px 6px; text-align: center; }
.print th { font-weight: 700; }
.print td.item { text-align: left; font-weight: 600; }
.print td.grey { background: var(--grey-cell); }
.print td.make { background: #E4EFD3; font-weight: 700; font-size: 13px; }
.print td.send { background: #E3EEFA; font-weight: 600; }
.print td.who { background: #FFF59A; font-style: italic; }
.print td.notes { text-align: left; }
.print .grp td { text-align: left; font-size: 10px; font-weight: 700; letter-spacing: .1em; color: var(--muted); border: none; padding-top: 10px; }
.print .head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--green); padding-bottom: 8px; margin-bottom: 10px; }
.print .head h1 { font-size: 22px; }
.print .datebox { display: grid; grid-template-columns: 90px 110px; border: 2px solid var(--ink); font-size: 11px; }
.print .datebox div { padding: 4px 8px; border-bottom: 1px solid var(--ink); }
.print .datebox div:nth-child(odd) { background: #FFF59A; font-weight: 700; border-right: 1px solid var(--ink); }
.print .datebox div:nth-last-child(-n+2) { border-bottom: none; }
.print .signoff { display: flex; justify-content: flex-end; gap: 24px; margin-top: 16px; font-size: 10px; color: var(--muted); }
.print .signoff div { width: 140px; border-bottom: 1px solid var(--muted); padding-bottom: 18px; }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; }
  #nav, .no-print, .topbar { display: none !important; }
  #app { padding: 0; }
  .print { padding: 0; }
}
@media (min-width: 900px) {
  .content { max-width: 1100px; margin: 0 auto; }
  .cols-hub { grid-template-columns: minmax(0,1fr) 80px 90px 80px 140px minmax(0,1fr); }
}
