/* One-screen app layout: tabs at the bottom; the Scan tab fits the screen without scrolling. */
html,body{height:100%}
body{overflow:hidden}
.app{height:100vh;height:100dvh;display:flex;flex-direction:column;max-width:850px;margin:0 auto}
.topbar{display:flex;align-items:center;gap:8px;padding:8px 12px;padding-top:max(8px,env(safe-area-inset-top));max-width:none;margin:0}
.topbar h1{font-size:1.1rem;margin:0;margin-right:auto}
.topbar h1 span{font-size:.7rem;color:var(--accent);border:1px solid var(--accent);border-radius:5px;padding:2px 4px;vertical-align:middle}
.topbar .small{padding:6px 10px;font-size:.8rem;flex:none}
.topbar .small:disabled{display:none}
main.tabs{flex:1 1 auto;min-height:0;max-width:none;margin:0;padding:0;position:relative}
.tab{display:none;height:100%;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:10px 12px 16px}
.tab.active{display:block}
.tab h2{font-size:1.1rem;margin:4px 0 10px}

/* Scan tab: camera grows to fill whatever height is left */
.tab.scan.active{display:flex;flex-direction:column;gap:6px;overflow:hidden;padding:6px 10px 8px}
.tab.scan .viewfinder{flex:1 1 auto;min-height:170px;aspect-ratio:auto!important;border-radius:10px}
.tab.scan .viewfinder video{position:absolute;inset:0;height:100%;width:100%;object-fit:cover}
.start-overlay{position:absolute;z-index:4;left:50%;top:50%;transform:translate(-50%,-50%);min-width:180px;min-height:52px;font-size:1rem;box-shadow:0 4px 18px #000a}
.start-overlay:disabled{display:none}
.viewfinder-capture:disabled{opacity:0;pointer-events:none}
.tab.scan .viewfinder .guide-label{bottom:72px;font-size:.8rem}
.notice.clamp{min-height:0;padding:6px 9px;font-size:.85rem;line-height:1.3;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;cursor:pointer}
.notice.clamp.open{-webkit-line-clamp:unset;display:block;max-height:30vh;overflow:auto}
.checks-strip{all:unset;display:block;color:var(--muted);font-size:.78rem;line-height:1.3;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.checks-strip:empty{display:none}
.checks-strip::after{content:'  ›'}
.quick{display:grid;grid-template-columns:1fr 1fr;gap:5px 8px}
.quick .wide{grid-column:1/-1}
.quick label{display:flex;flex-direction:column;gap:2px;font-size:.72rem;color:var(--muted)}
.quick input:not([type=checkbox]){padding:7px 9px;font-size:.95rem;border-radius:6px}
.quick label.tick{flex-direction:row;align-items:center;gap:7px;font-size:.9rem;color:var(--ink);align-self:end;padding-bottom:7px}
.quick label.tick input{width:20px;height:20px}
.actions{display:grid;grid-template-columns:1fr 1.3fr 1fr;gap:8px}
.actions button{padding:12px 8px;min-height:46px}
.actions button[hidden]{display:none}

/* Bottom tab bar */
.tabbar{display:grid;grid-template-columns:repeat(4,1fr);gap:4px;padding:6px 8px;padding-bottom:max(6px,env(safe-area-inset-bottom));background:#0c1f30;border-top:1px solid var(--line)}
.tabbar button{background:none;color:var(--muted);border:0;border-radius:8px;padding:9px 4px;font-weight:650;font-size:.85rem}
.tabbar button.active{background:#1b3a52;color:var(--accent)}
.checks.stack{flex-direction:column;gap:12px}
.tab .panel{margin:12px 0}

/* Short screens (small phones, landscape, keyboard open): tighten further */
@media (max-height:640px){
  .tab.scan .viewfinder{min-height:120px}
  .quick label{font-size:0}
  .quick label input{font-size:.9rem}
  .quick label.tick{font-size:.85rem}
  .notice.clamp{-webkit-line-clamp:1;max-height:calc(1.3em + 12px)}
  .notice.clamp.open{max-height:30vh}
  .topbar{padding-top:4px;padding-bottom:4px}
}
/* Wide screens: camera beside the fields */
@media (min-width:760px) and (min-height:520px){
  .tab.scan.active{display:grid;grid-template-columns:1.25fr 1fr;grid-template-rows:auto auto 1fr auto;column-gap:14px}
  .tab.scan .viewfinder{grid-column:1;grid-row:1/5}
  .tab.scan>:not(.viewfinder){grid-column:2}
}
