* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: Barlow, Arial, sans-serif; }
body { min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--red); }

#app { max-width: 640px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

.bar { background: var(--ink); color: #fff; padding: 18px 20px; display: flex; align-items: center; gap: 14px; }
.bar .back { color: #fff; text-decoration: none; font-size: 28px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; flex: none; }
.bar h1 { margin: 0; font-size: 24px; font-weight: 600; }
.bar .sub { font-size: 15px; color: #B9BEC6; }
.brand { font-family: 'Barlow Condensed', Arial, sans-serif; font-weight: 700; font-size: 28px; letter-spacing: .5px; }
.brand b { color: var(--red-hi); font-weight: 700; }
.hero { background: var(--ink); color: #fff; padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.hero .row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.hero .hello { font-size: 26px; font-weight: 600; }
.hero .meta { color: #B9BEC6; font-size: 16px; }
.hero .logout { background: none; border: 0; color: #B9BEC6; font-size: 15px; text-decoration: underline; cursor: pointer; padding: 8px 0; }

.body { padding: 20px; display: flex; flex-direction: column; gap: 18px; flex: 1; }
.label { font-size: 13px; font-weight: 600; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.card { background: var(--card); border: 1px solid var(--line-soft); border-radius: 10px; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.card.live { border: 2px solid var(--red); }
.card .big { font-size: 22px; font-weight: 600; }
.note { font-size: 15px; color: var(--ink-2); }
.note.warn { background: var(--warn-soft); color: var(--warn-ink); padding: 12px 14px; border-radius: 8px; }
.note.ok { background: var(--ok-soft); color: var(--ok-ink); border: 1px solid var(--ok); padding: 12px 14px; border-radius: 10px; }
.row-sb { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.card .primary { margin-top: 4px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { min-height: 110px; border-radius: 10px; background: var(--card); border: 1px solid var(--line-soft); padding: 16px; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; text-decoration: none; color: var(--ink); text-align: left; cursor: pointer; }
.tile b { font-size: 21px; font-weight: 600; }
.tile span { font-size: 14px; color: var(--muted); }
.tile[aria-disabled="true"] { opacity: .45; pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 15px; color: var(--muted); }
.field input, .field select { height: 56px; font-size: 20px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 12px; font-size: 18px; min-height: 48px; }
.check input { width: 26px; height: 26px; }

.choice { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.choice button { min-height: 60px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 17px; font-weight: 600; cursor: pointer; padding: 6px 12px; }
.choice button[aria-pressed="true"] { border: 2px solid var(--red); background: var(--red-soft); color: var(--red-dark); }

.photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.photo { position: relative; min-height: 96px; border-radius: 8px; border: 2px dashed #9A968F; background: #fff; font-size: 16px; font-weight: 600; color: var(--ink-2); cursor: pointer; display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px; overflow: hidden; }
.photo.done { border: 1.5px solid var(--ok); background: var(--ok-soft); color: var(--ok-ink); }
.photo.busy { opacity: .6; }
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .35; }
.photo span { position: relative; }
.photo.wide { grid-column: 1 / -1; }

.primary { margin-top: auto; height: 64px; border: 0; border-radius: 8px; background: var(--red); color: #fff; font-size: 21px; font-weight: 600; cursor: pointer; width: 100%; }
.primary:disabled { background: #8E8A84; }
.secondary { height: 56px; border-radius: 8px; border: 2px solid var(--ink); background: #fff; font-size: 18px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink); }
.card.queue { border: 2px solid #D9A300; background: var(--warn-soft); }
.link { background: none; border: 0; color: var(--red-dark); text-decoration: underline; font-size: 16px; padding: 8px 0 0; cursor: pointer; display: block; }
.error { background: var(--red-soft); color: var(--red-dark); border-radius: 8px; padding: 12px 14px; font-size: 16px; }

.list { display: flex; flex-direction: column; }
.list div { display: flex; justify-content: space-between; gap: 12px; font-size: 16px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.list div:last-child { border-bottom: 0; }

.login { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 32px 24px; }
.login .brand { font-size: 44px; text-align: center; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 14px 20px; border-radius: 8px; font-size: 17px; max-width: calc(100% - 32px); }

@media (max-width: 420px) {
  .body { padding: 16px; }
  .tiles { gap: 10px; }
}

.sigpad { position: fixed; inset: 0; z-index: 20; background: rgba(30, 34, 39, .85); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sigpad-in { background: var(--card); border-radius: 12px; padding: 18px; width: 100%; max-width: 760px; display: flex; flex-direction: column; gap: 12px; }
.sigpad h2 { margin: 0; font-size: 22px; }
.sigpad canvas { width: 100%; height: min(50vh, 340px); background: #fff; border: 2px dashed #9A968F; border-radius: 8px; touch-action: none; }
.sigpad-btns { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 10px; }
.sigpad-btns .primary { margin-top: 0; height: 56px; }
