/* Clinic Compliance Calendar — app styles (on top of /assets/labs.css) */
.app-page .page-title { margin-bottom: 18px; }
.app-block { margin-top: 20px; }
.h-sm { font-size: 22px; margin: 0 0 14px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.grid-fields { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-fields .span2 { grid-column: 1 / -1; }
.field-msg { min-height: 1.4em; margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.field-msg.err, .field-msg.warn { color: var(--danger); font-weight: 600; }
.field-msg.ok { color: var(--ok); font-weight: 600; }
.req { font-size: 13px; color: var(--muted); font-weight: 500; }
.danger { color: var(--danger) !important; border-color: color-mix(in srgb, var(--danger) 45%, var(--line)) !important; background: var(--bg) !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
label.inline { display: block; max-width: 360px; margin: 4px 0 8px; }
.disclaimer { margin-top: 28px; }
html { scroll-padding-top: 84px; }

/* Tabs */
.tabs { display: flex; gap: 6px; margin-top: 22px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { font: inherit; font-weight: 650; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); padding: 12px 16px; cursor: pointer; white-space: nowrap; min-height: 48px; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); }

/* Tiles */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-top: 20px; }
.tile { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.tile-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.tile strong { font-size: 34px; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 13px; color: var(--muted); }
.tile-bad.has strong { color: var(--danger); }
.tile-soon.has strong { color: var(--warn); }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.filters label { flex: 1 1 150px; font-size: 14px; }
.filters .grow { flex: 2 1 220px; }

/* Task list */
.task-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.task { border: 1px solid var(--line); border-left: 5px solid var(--ok); border-radius: var(--radius-sm); padding: 14px 16px; background: var(--bg); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; align-items: start; }
.task.st-overdue { border-left-color: var(--danger); }
.task.st-soon { border-left-color: var(--warn); }
.task h3 { font-size: 17px; margin: 0 0 4px; line-height: 1.3; overflow-wrap: anywhere; }
.task .meta { font-size: 14px; color: var(--muted); margin: 0; overflow-wrap: anywhere; }
.task .note { font-size: 14px; margin: 6px 0 0; overflow-wrap: anywhere; white-space: pre-line; }
.task .src { font-size: 13px; margin: 6px 0 0; overflow-wrap: anywhere; }
.task .due { text-align: right; font-size: 14px; }
.task .due strong { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.task .actions-row { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.task .actions-row .btn { min-height: 38px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: 2px; border: 1px solid currentColor; }
.badge.overdue { color: var(--danger); }
.badge.soon { color: var(--warn); }
.badge.ok { color: var(--ok); }
.pill.cat { font-size: 12px; margin-right: 6px; }
@media (max-width: 560px) {
  .task { grid-template-columns: minmax(0, 1fr); }
  .task .due { text-align: left; }
}

/* Library */
.lib { display: grid; gap: 16px; margin-top: 12px; }
.lib fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px 12px; margin: 0; }
.lib legend { font-weight: 700; padding: 0 6px; }
.lib-item { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 4px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-weight: 500; }
.lib-item:last-child { border-bottom: 0; }
.lib-item input { width: 20px; height: 20px; margin: 2px 0 0; }
.lib-item .t { font-weight: 650; }
.lib-item .d { grid-column: 2; font-size: 13px; color: var(--muted); }
.lib-item .d a { font-weight: 600; }
.lib-item.added .t::after { content: " · added"; color: var(--ok); font-weight: 600; font-size: 13px; }

/* Frequency */
fieldset.freq { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 90px 1fr; gap: 8px; align-items: end; min-width: 0; }
fieldset.freq legend { font-weight: 600; font-size: 15px; padding: 0; margin-bottom: 6px; }

/* Calendar */
.months { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); margin-top: 14px; }
.month { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; background: var(--bg); }
.month h3 { font-size: 16px; margin: 0 0 8px; display: flex; justify-content: space-between; gap: 8px; }
.month h3 span { color: var(--muted); font-weight: 600; font-size: 13px; }
.month ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.month li { font-size: 14px; display: grid; grid-template-columns: 3.2em minmax(0, 1fr); gap: 8px; overflow-wrap: anywhere; }
.month li .day { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 650; }
.month.overdue-box { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.month.overdue-box h3 { color: var(--danger); }
.month .none { color: var(--muted); font-size: 14px; }

/* Log */
.table-wrap { overflow-x: auto; }
table.log { border-collapse: collapse; width: 100%; font-size: 14px; }
table.log th, table.log td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
table.log thead th { font-size: 13px; color: var(--muted); font-weight: 650; white-space: nowrap; }
.res-late { color: var(--danger); font-weight: 650; }
.res-ok { color: var(--ok); font-weight: 650; }

/* Dialog */
dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; width: min(480px, calc(100vw - 32px)); background: var(--bg); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(11, 15, 20, 0.55); }
dialog label { display: block; margin-bottom: 12px; }

/* Print */
@media print {
  .top, .foot, .tabs, .filters, .btn, .btn-row, #phi-notice, .skip, #panel-cal, #panel-add, #panel-log, #panel-data, #empty-state { display: none !important; }
  #panel-tasks { display: block !important; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .task { break-inside: avoid; }
  body { background: #fff; color: #000; }
}

/* HITL fixes */
[hidden] { display: none !important; }
.print-only { display: none; }
.nowrap { white-space: nowrap; }
.lib-opts { margin-bottom: 4px; }
.lib-row { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 8px 16px; align-items: start; border-bottom: 1px solid var(--line); }
.lib-row:last-child { border-bottom: 0; }
.lib-row .lib-item { border-bottom: 0; }
.lib-date-wrap { padding: 8px 0; }
.lib-date { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.lib-date-wrap input { width: 100%; }
@media (max-width: 640px) {
  .lib-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .lib-date-wrap { padding: 0 0 10px 32px; }
}
@media (max-width: 640px) {
  table.log thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.log, table.log tbody, table.log tr, table.log td { display: block; width: 100%; }
  table.log tr { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 10px; }
  table.log td { border: 0; padding: 3px 0; display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 8px; }
  table.log td::before { content: attr(data-label); font-weight: 650; color: var(--muted); font-size: 13px; }
  table.log td:empty { display: none; }
}
@media print {
  .print-only { display: block !important; margin: 0 0 12px; }
  .print-only strong { display: block; font-size: 20px; }
  .eyebrow, .page-title, #save-error, #load-note { display: none !important; }
  body[data-print="log"] #panel-tasks { display: none !important; }
  body[data-print="log"] #panel-log { display: block !important; }
  .task .actions-row { display: none !important; }
  table.log { font-size: 11px; }
  table.log td:nth-child(5) { white-space: nowrap; }
}

/* Audit fixes */
.month.overdue-box { grid-column: 1 / -1; }
.month li { grid-template-columns: 4.2em minmax(0, 1fr); }
.month li .day { white-space: nowrap; }
@media (max-width: 560px) {
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { padding: 12px; }
  .tile strong { font-size: 28px; }
  .tabs { flex-wrap: wrap; overflow-x: visible; }
  .tab { padding: 10px 12px; min-height: 44px; }
}
