.tree-history { box-sizing: border-box; margin-block: 16px; padding: 20px; border: 1px solid #334155; border-radius: 16px; background: #111b2c; color: #e2e8f0; font-family: 'Inter', system-ui, sans-serif; font-size: .875rem; line-height: 1.5; }
.tree-history h3 { margin: 0 0 6px; color: #e2e8f0; font-size: 1rem; font-weight: 700; line-height: 1.4; }
.tree-history > p { max-width: 50rem; margin: 0 0 12px; }
.tree-history p, .tree-history small { color: #94a3b8; line-height: 1.5; }
.tree-history button { min-height: 40px; margin: 0; border: 1px solid #475569; border-radius: 10px; padding: 9px 12px; background: #1e293b; color: #e2e8f0; font-family: inherit; font-size: .8rem; font-weight: 600; line-height: 1.25; cursor: pointer; transition: border-color .15s ease, background .15s ease, color .15s ease; }
.tree-history button:hover:not(:disabled) { border-color: #64748b; background: #27364a; color: #f8fafc; }
.tree-history button:disabled { cursor: default; opacity: .65; }
.tree-history .tree-history__add { margin-bottom: 12px; border-color: #4e9874; background: #1a513a; color: #e3fff0; }
.tree-history .tree-history__add:hover:not(:disabled) { border-color: #6ac393; background: #236345; }
.tree-history button:focus-visible, .tree-history input:focus-visible { outline: 2px solid #60a5fa; outline-offset: 3px; }
.tree-history__visit { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px 12px; align-items: center; padding: 14px 0; border-top: 1px solid rgba(148, 163, 184, .2); }
.tree-history__visit-details { min-width: 0; }
.tree-history__visit-details strong { display: block; color: #e2e8f0; font-size: .875rem; font-weight: 700; overflow-wrap: anywhere; }
.tree-history__visit-meta { display: flex; flex-wrap: wrap; gap: 4px 9px; margin-top: 3px; color: #94a3b8; font-size: .75rem; }
.tree-history__visit-meta small { font-size: inherit; }
.tree-history__visit-meta span { color: #cbd5e1; }
.tree-history__correct { white-space: nowrap; }
.tree-history label, .tree-history__original label { display: inline-flex; align-items: center; gap: 8px; margin: 8px 12px 8px 0; }
.tree-history__visit-toggle { min-height: 40px; margin: 0 !important; white-space: nowrap; color: #cbd5e1; font-size: .8rem; font-weight: 600; }
.tree-history input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: #60a5fa; }
.tree-history input[type=date], .tree-history__original input[type=date] { background: #0b1120; color: #e5edf7; color-scheme: dark; border: 1px solid #334155; padding: 9px 10px; border-radius: 10px; font: inherit; }
.tree-history__controls[hidden] { display: none; }
.tree-history__error { color: #fbbf24 !important; }
.tree-history__original { padding: 12px 0; border-bottom: 1px solid #334155; }
.tree-history__original summary { cursor: pointer; color: #dce8f5; }
.tree-history__text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 22rem; overflow: auto; }
.tree-history__graph { width: 100%; max-height: 240px; color: #83d5b0; }
.tree-history__readings { width: 100%; border-collapse: collapse; }
.tree-history__readings th, .tree-history__readings td { text-align: left; padding: 8px; border-bottom: 1px solid #334155; }
.tree-history__capture { display: flex; flex-wrap: wrap; gap: 12px; margin-block: 12px; }
.tree-history__capture label { display: grid; gap: 6px; }
body:not(.ara-edit-mode) #editMeasurementHistory:not(.tree-history--field) { display: none; }
body.ara-edit-mode #editMeasurementHistory { display: block !important; }

@media (max-width: 640px) {
  .tree-history { padding: 16px; }
  .tree-history__visit { grid-template-columns: minmax(0, 1fr) auto; }
  .tree-history__visit-details { grid-column: 1 / -1; }
}
.tree-history pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .8rem; }

/* Public history follows the surrounding Advanced Data glass cards. */
.tree-history-public { padding: 20px; border-radius: 16px; min-width: 0; }
.tree-history-public h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 16px; color: #9ca3af; font-size: 12px; font-weight: 700; line-height: 16px; letter-spacing: .05em; text-transform: uppercase; }
.tree-history-public h3 .material-symbols-rounded { font-size: 16px; }
.tree-history-public p { margin: 0 0 12px; color: #9ca3af; font-size: 12px; line-height: 1.6; }
.tree-history-public button { padding: 8px 12px; border: 1px solid rgb(255 255 255 / .05); border-radius: 12px; background: rgb(255 255 255 / .05); color: #9ca3af; font: inherit; font-size: 12px; cursor: pointer; transition: background .15s, color .15s; }
.tree-history-public button:hover, .tree-history-public button[aria-pressed=true] { background: rgb(255 255 255 / .1); color: #fff; }
.tree-history-public button[aria-pressed=true] { border-color: rgb(255 255 255 / .2); }
.tree-history-public button:focus-visible, .tree-history-public summary:focus-visible { outline: 2px solid #93c5fd; outline-offset: 3px; }
.tree-history-public button:disabled { opacity: .6; cursor: wait; }
.tree-history-public__controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.tree-history-public__chart:has(svg) { margin-bottom: 16px; padding: 8px; background: rgb(255 255 255 / .05); border: 1px solid rgb(255 255 255 / .05); border-radius: 12px; }
.tree-history-public__visits details { margin-top: 12px; padding: 12px; border: 1px solid rgb(255 255 255 / .05); border-radius: 12px; background: rgb(255 255 255 / .05); }
.tree-history-public summary { color: #fff; font-size: 12px; font-weight: 700; line-height: 1.7; cursor: pointer; overflow-wrap: anywhere; }
.tree-history-public details p { margin-top: 12px; }
.tree-history-public dl { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 16px; margin-top: 16px; }
.tree-history-public dt { color: #6b7280; font-size: 10px; letter-spacing: .05em; text-transform: uppercase; overflow-wrap: anywhere; }
.tree-history-public dd { margin: 0; color: #fff; font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
