/* ClinicOS typography standard
   Loaded last so legacy modules and injected compatibility styles inherit one
   readable cross-platform system. Print/receipt layouts remain independent. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --head: var(--font);
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

[data-theme="light"] {
  --ink-5: #34463f;
  --ink-3: #52635e;
}

[data-theme="dark"] {
  --ink-5: #bdc9c5;
  --ink-3: #93a49e;
}

html {
  font-family: var(--font);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-synthesis: none;
}

body,
button,
input,
select,
textarea {
  font-family: var(--font) !important;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  font-size: 14px;
  line-height: 1.5;
}

/* Reliable hierarchy on every application page. */
#app .page h1 {
  font-family: var(--font) !important;
  font-size: clamp(1.75rem, 2.5vw, 2.125rem) !important;
  font-weight: 760 !important;
  line-height: 1.15 !important;
  letter-spacing: -.035em !important;
}

#app .page h2 {
  font-family: var(--font) !important;
  font-size: 1.25rem !important;
  font-weight: 720 !important;
  line-height: 1.25 !important;
  letter-spacing: -.02em !important;
}

#app .page h3,
#app .card-head h2,
#app .card-head h3,
#app .empty-title {
  font-family: var(--font) !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
  line-height: 1.3 !important;
  letter-spacing: -.012em !important;
}

#app .page p,
#app .page li,
#app .page .empty-sub {
  font-size: .875rem;
  line-height: 1.55;
}

/* Operational text must remain readable at normal viewing distance. */
#app .field label,
#app .section-label,
#app .app-section-title,
#app .kpi-label,
#app .ds-label,
#app .ux-eyebrow,
#app .admin-eyebrow,
#app .cal-eyebrow,
#app .dsh-eyebrow,
#app .lc-eyebrow,
#app .bk-eyebrow,
#app .intel-eyebrow,
#app .my-sheets-eyebrow,
#app .closures-eyebrow {
  font-family: var(--font) !important;
  font-size: .6875rem !important;
  font-weight: 750 !important;
  line-height: 1.35 !important;
  letter-spacing: .07em !important;
}

#app small,
#app .kpi-sub,
#app .admin-row-sub,
#app .ux-profile p,
#app .ux-focus-copy span,
#app .admin-control-copy span,
#app .admin-list-toolbar span {
  font-size: .75rem !important;
  line-height: 1.45 !important;
}

#app .tbl {
  font-family: var(--font) !important;
  font-size: .8125rem !important;
}

#app .tbl th {
  font-family: var(--font) !important;
  font-size: .6875rem !important;
  font-weight: 750 !important;
  line-height: 1.35 !important;
  letter-spacing: .055em !important;
}

#app .tbl td {
  font-family: var(--font) !important;
  font-size: .8125rem !important;
  line-height: 1.45 !important;
  vertical-align: middle;
}

#app .badge,
#app .sb-badge {
  font-family: var(--font) !important;
  font-size: .6875rem !important;
  font-weight: 700 !important;
  line-height: 1.25 !important;
}

#app .btn {
  font-family: var(--font) !important;
  font-size: .8125rem;
  line-height: 1.25;
}

#app input,
#app select,
#app textarea {
  font-family: var(--font) !important;
  font-size: .875rem;
  line-height: 1.4;
}

#app .sidebar .sb-name,
#app .sidebar .sb-link,
#app .sidebar .sb-uname,
#app .topbar-title {
  font-family: var(--font) !important;
}

#app .sidebar .sb-link {
  font-size: .8125rem !important;
  line-height: 1.35 !important;
}

#app .sidebar .sb-sect,
#app .sidebar .sb-tagline,
#app .sidebar .sb-urole {
  font-size: .6875rem !important;
  line-height: 1.4 !important;
}

/* Prevent clipped labels while keeping data-heavy tables horizontally usable. */
#app .page :is(p, li, label, .empty-sub, .card-head h2, .card-head h3) {
  overflow-wrap: anywhere;
}

#app .page .money,
#app .page .mono,
#app .page .hist-mono,
#app .page .audit-time,
#app .page .pt-uid-value,
#app .page .patient-qr-ref,
#app .page .ds-system-time-value,
#app .page code,
#app .page pre {
  font-family: var(--mono) !important;
  font-variant-numeric: tabular-nums;
}

/* Financial columns align without making surrounding prose look technical. */
#app .page :is(.money, [data-money], .kpi-value, .ds-total-item .value) {
  font-variant-numeric: tabular-nums;
}

/* Do not alter thermal receipts, printable tallies, QR cards, or PDF staging. */
.receipt-body,
.receipt-body *,
.receipt-ultra,
.receipt-ultra *,
.clinician-tally-print,
.clinician-tally-print *,
.qr-print-card,
.qr-print-card * {
  font-family: inherit;
}

@media (max-width: 768px) {
  body { font-size: 14px; }
  #app input,
  #app select,
  #app textarea { font-size: 16px !important; }
  #app .tbl td { font-size: .8125rem !important; }
}

@media print {
  html, body { -webkit-font-smoothing: auto; text-rendering: geometricPrecision; }
}

/* History workspace visibility and density correction. */
#page-ds-history .dsh-page-intro p {
  font-size: .9375rem !important;
  color: var(--ink-5) !important;
}

#page-ds-history .dsh-open-btn {
  min-height: 44px !important;
  padding: 0 18px !important;
  font-size: .875rem !important;
}

#page-ds-history .hist-filters {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 16px !important;
}

#page-ds-history .hist-filters select {
  flex: 1 1 180px !important;
  width: auto !important;
  min-width: 180px !important;
}

#page-ds-history .hist-filters input[type="date"] {
  flex: 1 1 165px !important;
  width: auto !important;
  min-width: 165px !important;
}

#page-ds-history .hist-filters select,
#page-ds-history .hist-filters input {
  height: 44px !important;
  padding: 0 14px !important;
  font-size: .875rem !important;
  font-weight: 600 !important;
  text-overflow: clip !important;
}

#page-ds-history .hist-filters .btn {
  flex: 0 0 auto !important;
  height: 44px !important;
  padding: 0 16px !important;
  font-size: .8125rem !important;
}

#page-ds-history #dsh-count {
  flex: 0 0 auto !important;
  margin-left: auto !important;
  padding: 8px 12px !important;
  font-size: .75rem !important;
}

#page-ds-history .dsh-sheet-row :is(.dsh-date,.dsh-office,.dsh-clin,.dsh-patients,.dsh-collected,.dsh-balance) {
  font-size: .8125rem !important;
  line-height: 1.45 !important;
}

#page-ds-history .dsh-status .badge,
#page-ds-history .dsh-actions .btn {
  font-size: .75rem !important;
}

#page-ds-history .dsh-actions .btn {
  min-height: 34px !important;
  height: 34px !important;
  padding: 0 10px !important;
}

@media (max-width: 1050px) {
  #page-ds-history > .card {
    padding: 8px !important;
  }

  #page-ds-history #dsh-content {
    gap: 8px !important;
  }

  #page-ds-history .dsh-sheet-row {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    grid-auto-rows: auto !important;
    align-content: start !important;
    align-items: start !important;
    column-gap: 14px !important;
    row-gap: 10px !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 13px 14px !important;
  }

  #page-ds-history .dsh-sheet-row > div {
    min-height: 38px !important;
    gap: 4px !important;
  }

  #page-ds-history .dsh-sheet-row [data-label]::before {
    font-size: .6875rem !important;
    line-height: 1.3 !important;
    letter-spacing: .06em !important;
  }

  #page-ds-history .dsh-actions {
    grid-column: auto !important;
    min-height: 38px !important;
    padding-top: 0 !important;
    border-top: 0 !important;
    justify-content: flex-end !important;
  }
}

@media (max-width: 680px) {
  #page-ds-history .dsh-page-intro {
    align-items: stretch !important;
    flex-direction: column !important;
  }

  #page-ds-history .dsh-open-btn {
    align-self: flex-start;
  }

  #page-ds-history .hist-filters select,
  #page-ds-history .hist-filters input[type="date"],
  #page-ds-history .hist-filters .btn {
    flex: 1 1 100% !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  #page-ds-history #dsh-count {
    margin-left: 0 !important;
  }

  #page-ds-history .dsh-sheet-row {
    grid-template-columns: 1fr 1fr !important;
  }

  #page-ds-history .dsh-actions {
    grid-column: 1 / -1 !important;
    border-top: 1px solid var(--silver) !important;
    padding-top: 10px !important;
  }
}
