/* Doc Ready — senior-friendly, offline visit prep product */

:root {
  --accent: #1b4f72;
  --accent-hover: #143d59;
  --accent-soft: #e8f1f8;
  --accent-mid: #2e86c1;
  --warn: #9a4d0a;
  --warn-bg: #fff4e8;
  --danger: #9b1c1c;
  --danger-bg: #fdecec;
  --ok: #1b6b3a;
  --ok-bg: #e8f6ee;
  --text: #1a1f24;
  --text-secondary: #3d4a54;
  --muted: #5c6b75;
  --border: #c5d0d6;
  --bg: #f3f6f9;
  --surface: #ffffff;
  --shadow: 0 1px 3px rgba(26, 31, 36, 0.08), 0 4px 12px rgba(26, 31, 36, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --space: 1rem;
  --touch: 48px;
  --max: 720px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

:focus-visible {
  outline: 3px solid var(--accent-mid);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1rem;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Header */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 700;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0.1rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Tabs */
.tab-nav {
  display: flex;
  gap: 0.25rem;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.5rem 0.75rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  width: 100%;
}

.tab {
  flex: 0 0 auto;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0.5rem 0.9rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

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

/* Main */
main {
  flex: 1;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}

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

.panel-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  color: var(--text);
}

.panel-lead {
  margin: 0 0 1.25rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.panel-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.panel-header-row .panel-title {
  margin-bottom: 0.25rem;
}

.panel-header-row .panel-lead {
  margin-bottom: 0;
}

/* Profile banner */
.profile-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.profile-banner-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.profile-banner-name {
  margin: 0.15rem 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
}

.profile-banner-meta {
  margin: 0 0 0.75rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 560px) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat-card.stat-accent {
  border-color: var(--accent-mid);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface) 70%);
}

.stat-card.stat-warn {
  border-color: #e8c48a;
  background: var(--warn-bg);
}

.stat-card.stat-ok {
  border-color: #9fd4b0;
  background: var(--ok-bg);
}

.stat-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-value {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-value-sm {
  font-size: 1.05rem;
  line-height: 1.3;
}

.stat-link {
  margin-top: auto;
  align-self: flex-start;
  min-height: 44px;
  padding: 0.35rem 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.15rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.card-head h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text);
}

.card-hint {
  margin: 0 0 0.85rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.muted-sm {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  line-height: 1.2;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

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

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent-mid);
}

.btn-text {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
  min-width: auto;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-text:hover:not(:disabled) {
  color: var(--accent-hover);
}

.btn-back {
  margin-bottom: 0.35rem;
  min-height: 44px;
  padding-left: 0;
}

.btn-sm {
  min-height: 44px;
  padding: 0.45rem 0.85rem;
  font-size: 0.9rem;
}

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

.btn-danger:hover:not(:disabled) {
  background: #7f1616;
  border-color: #7f1616;
}

.btn-danger-outline {
  background: var(--surface);
  color: var(--danger);
  border-color: #e8b4b4;
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch);
  height: var(--touch);
  min-width: var(--touch);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.btn-icon:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-row.wrap {
  flex-wrap: wrap;
}

/* Filters */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field-grow {
  flex: 1 1 160px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 480px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

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

input[type="text"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 0.55rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: var(--surface);
}

textarea {
  min-height: 5rem;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-mid);
  outline: none;
  box-shadow: 0 0 0 3px rgba(46, 134, 193, 0.25);
}

.check-label {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-weight: 500;
  cursor: pointer;
  min-height: var(--touch);
  padding: 0.5rem 0;
}

.check-label input[type="checkbox"] {
  width: 1.35rem;
  height: 1.35rem;
  min-height: 1.35rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

/* Item list */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.item-card.is-sample {
  border-left: 4px solid #c9a227;
}

.item-card.is-done {
  opacity: 0.85;
  background: #fafbfc;
}

.item-card.is-overdue {
  border-left: 4px solid var(--warn);
  background: var(--warn-bg);
}

.item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.item-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.item-meta {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.item-body {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.item-actions .btn {
  min-height: 44px;
  padding: 0.4rem 0.75rem;
  font-size: 0.88rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.6rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.pill-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.pill-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.pill-muted {
  background: #eef1f3;
  color: var(--muted);
}

.pill-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.pill-sample {
  background: #fff6d6;
  color: #7a5b00;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.status-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.empty-state {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.empty-state p {
  margin: 0 0 0.75rem;
}

.empty-state .btn {
  margin-top: 0.25rem;
}

/* Detail tabs */
.detail-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}

.detail-tab {
  flex: 1 1 auto;
  min-height: var(--touch);
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}

.detail-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.detail-tab:hover:not(.is-active) {
  background: var(--accent-soft);
  border-color: var(--accent-mid);
  color: var(--accent);
}

/* Checklist */
.checklist {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  min-height: var(--touch);
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.check-item:hover {
  background: var(--accent-soft);
}

.check-item input {
  width: 1.35rem;
  height: 1.35rem;
  min-height: 1.35rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.check-item.is-checked span {
  text-decoration: line-through;
  color: var(--muted);
}

/* Question row with toggle */
.q-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.q-row input[type="checkbox"] {
  width: 1.35rem;
  height: 1.35rem;
  min-height: 1.35rem;
  margin-top: 0.35rem;
  flex-shrink: 0;
  accent-color: var(--ok);
}

.q-row.is-asked .item-title {
  text-decoration: line-through;
  color: var(--muted);
}

/* Audio */
.audio-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.audio-playback audio {
  width: 100%;
  margin-top: 0.5rem;
}

.mt-sm {
  margin-top: 0.5rem;
}

.mb-sm {
  margin-bottom: 0.65rem;
}

/* Share preview */
.share-preview {
  margin: 0 0 0.85rem;
  padding: 1rem;
  background: #f8fafb;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 22rem;
  overflow: auto;
  color: var(--text);
}

/* Bars (insights) */
.bar-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr 2.5rem;
  gap: 0.5rem;
  align-items: center;
}

.bar-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 0.75rem;
  background: #e8eef2;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  min-width: 0;
}

.bar-count {
  font-weight: 700;
  font-size: 0.9rem;
  text-align: right;
  color: var(--text);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  max-width: min(90vw, 28rem);
  padding: 0.85rem 1.15rem;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.toast[hidden] {
  display: none !important;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal[hidden] {
  display: none !important;
}

@media (min-width: 560px) {
  .modal {
    align-items: center;
    padding: 1.5rem;
  }
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 31, 36, 0.45);
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 34rem;
  max-height: min(92vh, 40rem);
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
  z-index: 1;
}

@media (min-width: 560px) {
  .modal-sheet {
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  }
}

.modal-sheet-sm {
  max-width: 26rem;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.75rem 0.5rem 1.1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-body {
  padding: 1rem 1.1rem 1.25rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

body.modal-open {
  overflow: hidden;
}

/* Export */
.export-area {
  margin-top: 0.85rem;
}

.export-area textarea {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding: 1.25rem 1rem 1.75rem;
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.app-footer p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Print */
@media print {
  .app-header,
  .tab-nav,
  .app-footer,
  .filter-bar,
  .btn,
  .btn-row,
  .detail-tabs,
  .skip-link,
  .toast,
  .modal {
    display: none !important;
  }

  body {
    background: #fff;
  }

  main {
    max-width: none;
    padding: 0;
  }

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

  .share-preview {
    max-height: none;
    border: none;
    padding: 0;
    font-size: 12pt;
  }
}

/* Check select list */
.check-select-list .item-card {
  cursor: pointer;
}

.check-select-list .item-card:hover {
  border-color: var(--accent-mid);
  background: var(--accent-soft);
}
