:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #1a2332;
  --muted: #5c6b7a;
  --line: #e2e8ef;
  --accent: #0d9488;
  --accent-deep: #0f766e;
  --accent-soft: #ccfbf1;
  --accent-glow: rgba(13, 148, 136, 0.14);
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #059669;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(26, 35, 50, 0.06);
  --tap: 52px;
  --header-h: 72px;
  --font: "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei",
    system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: calc(24px + var(--safe-bottom));
  /* iPad / touch: avoid accidental text selection on chrome */
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

.app-shell.single-page {
  display: block;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-shell.single-page .main {
  max-width: 720px;
  margin: 0 auto;
}

/* Four-tab navigation */
.tab-bar {
  position: sticky;
  top: var(--header-h, 72px);
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 14px;
  background: rgba(244, 246, 248, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.tab-btn {
  min-height: 48px;
  padding: 6px 4px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.15;
  color: var(--muted);
  background: var(--surface);
  border: 1.5px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab-btn .tab-count {
  flex-shrink: 0;
}

.tab-btn.active {
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.tab-count {
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 6px;
  border-radius: 999px;
  background: #e2e8ef;
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tab-btn.active .tab-count {
  background: var(--accent);
  color: #fff;
}

.tab-panel {
  animation: fadeIn 0.16s ease;
}

.tab-panel[hidden] {
  display: none !important;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.panel-head h2 {
  margin: 0;
}

.btn-sm {
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.88rem;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wizard-panel {
  animation: fadeIn 0.16s ease;
  /* Keep step content below sticky header + tab bar when scrolling into view */
  scroll-margin-top: calc(var(--header-h, 72px) + 64px + var(--safe-top));
}

#manualCard {
  scroll-margin-top: calc(var(--header-h, 72px) + 64px + var(--safe-top));
}

.wizard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  /* Keep nav buttons reachable while keyboard is open */
  position: sticky;
  bottom: calc(8px + var(--safe-bottom));
  z-index: 2;
  padding: 10px 0 2px;
  background: linear-gradient(
    to top,
    var(--surface) 70%,
    rgba(255, 255, 255, 0)
  );
}

.wizard-actions .btn {
  min-height: var(--tap);
}

.wizard-actions .btn-primary {
  flex: 1 1 auto;
}

.confirm-summary {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #f8fafb;
  font-size: 0.95rem;
}

.confirm-summary .row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
}

.confirm-summary .k {
  color: var(--muted);
  font-weight: 600;
}

.lookup-preview {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.45;
  border: 1.5px solid var(--line);
  background: #f8fafb;
}

.lookup-preview.ok {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.lookup-preview.err {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.lookup-preview strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.85;
}

.reason-field {
  margin-top: 14px;
}

.reason-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 520px) {
  .reason-options {
    grid-template-columns: repeat(3, 1fr);
  }
}

.reason-chip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 68px;
  width: 100%;
  padding: 16px 14px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: #f8fafb;
  font-weight: 700;
  font-size: 1.12rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s,
    box-shadow 0.15s,
    transform 0.12s;
}

.reason-chip-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.reason-chip-emoji {
  font-size: 1.15em;
  line-height: 1;
}

.reason-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* 覆診/病 — rose / medical */
.reason-chip.reason-medical {
  border-color: #fca5a5;
  background: linear-gradient(180deg, #fff5f5 0%, #fee2e2 100%);
  color: #b91c1c;
}
.reason-chip.reason-medical:has(input:checked) {
  border-color: #dc2626;
  background: linear-gradient(180deg, #fecaca 0%, #fca5a5 100%);
  color: #7f1d1d;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.35);
}

/* 家事 — sky / personal */
.reason-chip.reason-family {
  border-color: #7dd3fc;
  background: linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 100%);
  color: #0369a1;
}
.reason-chip.reason-family:has(input:checked) {
  border-color: #0284c7;
  background: linear-gradient(180deg, #bae6fd 0%, #7dd3fc 100%);
  color: #0c4a6e;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.35);
}

/* 其他 — amber */
.reason-chip.reason-other {
  border-color: #fcd34d;
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  color: #b45309;
}
.reason-chip.reason-other:has(input:checked) {
  border-color: #d97706;
  background: linear-gradient(180deg, #fde68a 0%, #fcd34d 100%);
  color: #78350f;
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.35);
}

.reason-chip:active {
  transform: scale(0.98);
}

.reason-chip:has(input:focus-visible) {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.reason-other {
  margin-top: 10px;
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.reason-other:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 4px;
}

.tag-selfgo {
  background: #fef3c7;
  color: #b45309;
}

.tag-feed {
  background: #e0f2fe;
  color: #0369a1;
}

.tag-manual {
  background: #f3e8ff;
  color: #7e22ce;
}

/* Split: 系統 / 手動 sections */
.record-sections {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.record-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 6px;
}

.record-section-head h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--ink);
}

.record-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 0.78rem;
  font-weight: 700;
}

.section-hint {
  margin: 0 0 10px;
  font-size: 0.8rem;
}

.records-hint {
  margin-top: -6px;
}

.empty-section {
  padding: 20px 14px;
  font-size: 0.9rem;
}

.detail-extra-actions {
  margin-top: 12px;
}

.modal-actions {
  margin-top: 16px;
  justify-content: flex-end;
}

.modal-actions .btn-danger {
  margin-right: auto;
}

.modal-compact {
  max-width: 400px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + var(--safe-top)) 20px 14px;
  min-height: var(--header-h);
  background: linear-gradient(135deg, #0f766e 0%, #0d9488 55%, #14b8a6 100%);
  color: #fff;
  box-shadow: 0 4px 18px rgba(13, 148, 136, 0.28);
}

/* Keep tab bar stuck under header height approx */
.app-shell.single-page {
  --header-h: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  min-width: 48px;
  height: 48px;
  padding: 0 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1;
  letter-spacing: -0.04em;
  border: 1px solid rgba(255, 255, 255, 0.25);
  white-space: nowrap;
  user-select: none;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand p {
  margin: 2px 0 0;
  font-size: 0.78rem;
  opacity: 0.9;
}

.btn-header-icon {
  flex-shrink: 0;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.btn-header-icon:active {
  background: rgba(255, 255, 255, 0.28);
}

.print-method-field {
  margin: 12px 0 0;
  padding: 0;
  border: none;
}

.print-method-field legend {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 8px;
  padding: 0;
}

.radio-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}

.radio-row:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.radio-row input {
  margin-top: 4px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.radio-row span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.radio-row strong {
  font-size: 0.95rem;
}

.radio-row small {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.settings-hint {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.settings-hint.warn {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}

.settings-hint.ok {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.settings-meta {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.settings-actions {
  flex-wrap: wrap;
  gap: 8px;
}

.settings-actions .btn-secondary {
  margin-right: auto;
}

.main {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  text-align: center;
}

.stat-card .n {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent-deep);
  line-height: 1.1;
}

.stat-card .l {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2::before {
  content: "";
  width: 4px;
  height: 1.1em;
  border-radius: 4px;
  background: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.field label .req {
  color: var(--danger);
  margin-left: 2px;
}

.field input,
.field select,
.field textarea {
  min-height: var(--tap);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fafbfc;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s, background 0.15s, opacity 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px rgba(13, 148, 136, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-deep);
}

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.btn-ghost {
  background: #eef2f6;
  color: var(--ink);
}

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
}

.btn-block {
  width: 100%;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.toolbar input,
.toolbar select {
  min-height: 44px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  background: var(--surface);
  flex: 1 1 140px;
}

.record-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.record-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  min-height: 72px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.record-item:active {
  background: #f8fafb;
}

.record-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.record-item .name {
  font-weight: 700;
  font-size: 1.05rem;
}

.record-item .meta {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-pending {
  background: #fff7ed;
  color: var(--warn);
}

.badge-verified {
  background: #ecfdf5;
  color: var(--ok);
}

.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--line);
}

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(26, 35, 50, 0.05);
}

.nav button {
  min-height: 56px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.nav button .ico {
  font-size: 1.15rem;
  line-height: 1;
}

.nav button.active {
  color: var(--accent-deep);
  background: var(--accent-soft);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%) translateY(12px);
  z-index: 50;
  max-width: min(92vw, 420px);
  padding: 14px 18px;
  border-radius: 12px;
  background: #1a2332;
  color: #fff;
  font-size: 0.95rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: #991b1b;
}

.toast.ok {
  background: var(--accent-deep);
}

/* Full-screen print progress overlay (above modals; paint before print on iPad) */
.print-loading {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: calc(24px + var(--safe-top));
  padding-bottom: calc(24px + var(--safe-bottom));
  background: rgba(15, 23, 32, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  pointer-events: all;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.print-loading.is-on,
.print-loading:not([hidden]) {
  display: flex !important;
}

.print-loading[hidden] {
  display: none !important;
}

.print-loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: min(78vw, 240px);
  padding: 28px 32px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
  text-align: center;
}

.print-loading-card p {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.print-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3.5px solid var(--line);
  border-top-color: var(--accent);
  animation: printSpin 0.75s linear infinite;
}

@keyframes printSpin {
  to {
    transform: rotate(360deg);
  }
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 32, 0.45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  /* Closed modal must never intercept clicks */
  pointer-events: none;
  visibility: hidden;
}

.modal-backdrop.open {
  display: flex;
  pointer-events: auto;
  visibility: visible;
}

.modal {
  width: min(100%, 520px);
  max-height: min(86vh, 720px);
  overflow: auto;
  background: var(--surface);
  border-radius: 18px 18px 14px 14px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(16px);
    opacity: 0.6;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.modal h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.detail-grid {
  display: grid;
  gap: 8px;
  margin: 12px 0 16px;
  font-size: 0.95rem;
}

.detail-grid .row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
}

.detail-grid .k {
  color: var(--muted);
  font-weight: 600;
}

.hint {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 12px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  min-height: var(--tap);
  align-items: center;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 8px 12px;
  border-radius: 12px;
  background: #f8fafb;
  border: 1.5px solid var(--line);
  cursor: pointer;
}

.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.choice input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.choice-locked {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
  cursor: default;
  opacity: 1;
}

.choice-locked input {
  display: none;
}

.choice-hint {
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--muted);
}

.preview-slip {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.78rem;
  white-space: pre-wrap;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  line-height: 1.45;
}

@media (min-width: 768px) {
  .main {
    padding: 22px 28px;
  }

  .modal-backdrop {
    align-items: center;
  }

  .modal {
    border-radius: 18px;
    width: min(100%, 560px);
  }

  .stats {
    gap: 14px;
  }

  .stat-card .n {
    font-size: 1.85rem;
  }

  .reason-chip {
    min-height: 76px;
    font-size: 1.18rem;
    padding: 18px 16px;
  }

  .toolbar input,
  .toolbar select,
  .toolbar .btn {
    min-height: 48px;
  }
}

@media (min-width: 900px) {
  .app-shell.single-page .main {
    max-width: 800px;
  }

  .tab-bar {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
  }

  .tab-btn {
    min-height: 52px;
    font-size: 1.08rem;
  }

  .record-item {
    min-height: 76px;
    padding: 18px 20px;
  }

  .record-item .name {
    font-size: 1.12rem;
  }

  .record-item .meta {
    font-size: 0.9rem;
  }

  .btn {
    min-height: 52px;
    padding: 0 22px;
    font-size: 1rem;
  }

  .field input,
  .field select,
  .field textarea {
    font-size: 1.05rem;
  }

  /* Prevent iOS zoom on focus: ≥16px */
  input,
  select,
  textarea {
    font-size: 16px;
  }
}

/* Coarse pointer (finger): larger hit targets */
@media (pointer: coarse) {
  :root {
    --tap: 56px;
  }

  .reason-chip {
    min-height: 74px;
    font-size: 1.16rem;
    padding: 18px 14px;
  }

  .record-item {
    min-height: 80px;
  }
}

/* Offline / connectivity banner */
.connectivity-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  font-size: var(--text-sm, 0.9rem);
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
  border-bottom: 1px solid #fcd34d;
  z-index: 20;
}

.connectivity-banner.is-offline {
  background: #fee2e2;
  color: #991b1b;
  border-bottom-color: #fecaca;
}

.connectivity-banner.is-syncing {
  background: #e0f2fe;
  color: #075985;
  border-bottom-color: #7dd3fc;
}

.connectivity-banner.is-pending {
  background: #fef3c7;
  color: #92400e;
}

.connectivity-banner[hidden] {
  display: none !important;
}

.manual-entry-panel {
  margin-top: 12px;
  padding: 14px;
  border-radius: 12px;
  border: 1.5px dashed var(--accent, #0d9488);
  background: #f8fafc;
}

.manual-entry-panel .field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.lookup-preview .btn-manual-entry {
  margin-top: 10px;
}

.badge-pending-upload {
  background: #fef3c7;
  color: #92400e;
}

/* Legacy bottom-nav hidden (single-page app) */
.nav {
  display: none !important;
}

@media (max-width: 560px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .btn {
    width: 100%;
  }

  .modal-actions .btn-danger {
    margin-right: 0;
  }
}
