/* Shared components for every drown screen. Reads only theme variables, so it works in dark and light. */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 400 18px/1.4 var(--font-ui); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
h1, h2, h3, p { margin: 0; }
.display { font-family: var(--font-display); font-weight: 400; letter-spacing: -.01em; }
.eyebrow { font: 500 13px/1 var(--font-ui); letter-spacing: .14em; text-transform: uppercase; color: var(--text-soft); }
.soft { color: var(--text-soft); }
.num { font-variant-numeric: tabular-nums; font-weight: 500; }
.small { font-size: 15px; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: var(--s3); }
.col { display: flex; flex-direction: column; gap: var(--s3); }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.hide { display: none !important; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.wordmark { font-family: var(--font-display); font-size: 28px; line-height: 1; letter-spacing: -.02em; text-transform: lowercase; }

.btn { min-height: var(--touch); padding: 0 var(--s5); border-radius: var(--r-btn); background: var(--surface-2); color: var(--text); font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); border: 1px solid var(--line); transition: transform .12s ease-out, background .15s ease-out, opacity .15s; white-space: nowrap; }
.btn:active { transform: scale(.98); }
a.btn, a.chip, a.tag { text-decoration: none; }
a.btn:not(.primary), a.chip:not(.on) { color: var(--text); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: transparent; }
.btn.small { min-height: 44px; padding: 0 var(--s4); font-size: 15px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.icon-btn { width: var(--touch); height: var(--touch); border-radius: var(--r-btn); display: inline-grid; place-items: center; border: 1px solid var(--line); background: var(--surface); flex: none; }
.icon-btn.small { width: 44px; height: 44px; }

.chip { min-height: 44px; padding: 0 var(--s4); border-radius: var(--r-chip); border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; gap: var(--s2); font-size: 16px; font-weight: 500; white-space: nowrap; transition: background .15s ease-out, color .15s ease-out; }
.chip.on { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.chip.big { min-height: var(--touch); padding: 0 var(--s5); font-size: 18px; }
.chip[disabled] { opacity: .35; text-decoration: line-through; pointer-events: none; }
.tag { display: inline-flex; align-items: center; height: 24px; padding: 0 var(--s2); border-radius: 6px; font: 600 12px/1 var(--font-ui); letter-spacing: .08em; text-transform: uppercase; background: var(--surface-2); color: var(--text-soft); white-space: nowrap; }
.tag.ok { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }
.tag.warn { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.tag.danger { background: color-mix(in srgb, var(--danger) 22%, transparent); color: var(--danger); }
.tag.info { background: color-mix(in srgb, var(--info) 24%, transparent); color: var(--info); }
.tag.brand { background: var(--caramel); color: var(--roast); }

.input, .select, .textarea { width: 100%; min-height: var(--touch); padding: 0 var(--s4); border-radius: var(--r-btn); border: 1px solid var(--line); background: var(--surface); outline: none; }
.textarea { padding: var(--s3) var(--s4); min-height: 96px; resize: vertical; line-height: 1.4; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--caramel); box-shadow: 0 0 0 3px color-mix(in srgb, var(--caramel) 30%, transparent); }
.input::placeholder { color: var(--text-soft); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 15px; color: var(--text-soft); }
.field > small { font-size: 14px; color: var(--text-soft); }
.switch { position: relative; width: 56px; height: 32px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); flex: none; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--text-soft); transition: transform .15s ease-out, background .15s; }
.switch.on { background: var(--caramel); border-color: transparent; }
.switch.on::after { transform: translateX(24px); background: var(--roast); }

.count { display: inline-block; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px; background: var(--caramel); color: var(--roast); font: 600 14px/24px var(--font-ui); text-align: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s4); }

/* Sheets (dialogs) */
.sheet-back { position: fixed; inset: 0; background: rgba(12,6,4,.62); display: grid; place-items: center; z-index: 50; padding: var(--s4); animation: fade .15s ease-out; }
.sheet { width: min(100%, var(--w, 640px)); max-height: calc(100dvh - 32px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sheet); display: flex; flex-direction: column; animation: rise .2s ease-out; }
.sheet > header { padding: var(--s5) var(--s5) var(--s3); display: flex; align-items: flex-start; gap: var(--s3); }
.sheet > header h2 { font: 400 28px/1.15 var(--font-display); }
.sheet > .body { padding: var(--s2) var(--s5) var(--s5); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s4); }
.sheet > footer { padding: var(--s4) var(--s5); border-top: 1px solid var(--line); display: flex; gap: var(--s3); justify-content: flex-end; }
@keyframes fade { from { opacity: 0 } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) } }

.toasts { position: fixed; left: 50%; bottom: var(--s5); transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--s2); z-index: 80; pointer-events: none; width: max-content; max-width: 92vw; }
.toast { background: var(--crema); color: var(--roast); padding: var(--s3) var(--s5); border-radius: var(--r-btn); font-weight: 500; animation: rise .2s ease-out; display: flex; gap: var(--s3); align-items: center; pointer-events: auto; }
.toast.bad { background: var(--danger); color: #fff; }
.toast button { font-weight: 600; text-decoration: underline; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.off { background: var(--warn); }
.banner { background: var(--warn); color: var(--roast); padding: var(--s2) var(--s4); font-weight: 600; text-align: center; font-size: 15px; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.keypad button { height: 64px; border-radius: var(--r-btn); background: var(--surface-2); border: 1px solid var(--line); font: 500 24px var(--font-ui); }
.keypad button:active { background: var(--caramel); color: var(--roast); }
.pin-dots { display: flex; gap: var(--s3); justify-content: center; height: 24px; align-items: center; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--text-soft); }
.pin-dots i.on { background: var(--caramel); border-color: var(--caramel); }

table.table { width: 100%; border-collapse: collapse; font-size: 16px; }
.table th { text-align: left; font: 500 13px/1 var(--font-ui); letter-spacing: .12em; text-transform: uppercase; color: var(--text-soft); padding: var(--s3); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: var(--s3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table td.r, .table th.r { text-align: right; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-2); }

.center-screen { min-height: 100dvh; display: grid; place-items: center; padding: var(--s5); }
.auth-card { width: min(100%, 460px); display: flex; flex-direction: column; gap: var(--s4); }
.auth-card .wordmark { font-size: 56px; }

@media print {
  body > *:not(.print-root) { display: none !important; }
  .print-root { display: block !important; position: static !important; }
}
