:root {
  color-scheme: light;
  font: 16px/1.5 system-ui, sans-serif;
  color: #172424;
  background: #edf2f1;
  --accent: #185e51;
}
* { box-sizing: border-box; }
body { margin: 0; }
.dashboard { width: min(1120px, 100% - 2rem); margin: 2rem auto; }
header, .filters, nav { display: flex; align-items: end; gap: 1rem; flex-wrap: wrap; }
header { justify-content: space-between; }
header { align-items: center; margin-bottom: 1.25rem; }
h1, h2, p { margin: 0 0 .65rem; }
h1 { font-size: clamp(1.7rem, 3.8vw, 2.45rem); }
.device-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem 1rem; }
.device-heading h1 { font-size: clamp(1.45rem, 3vw, 2rem); margin: 0; }
.refresh-button { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: .35rem; color: var(--accent); text-decoration: none; font-size: 1.65rem; line-height: 1; }
.refresh-button:hover { background: #dceae6; }
.device-heading p { margin: 0; }
.history-import { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .7rem; }
.history-import button { padding: .3rem .6rem; }
.history-import button:disabled { opacity: .65; cursor: default; }
.sync-content { margin-top: .75rem; }
.sync-content h3 { margin: 1rem 0 .4rem; font-size: 1rem; }
.sync-table th, .sync-table td { vertical-align: top; border: 1px solid #aebfbc; }
.sync-full-header { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.sync-table .history-import { display: flex; font-weight: normal; }
.sync-table .history-import button { padding: .3rem .6rem; }
.sync-import-status { margin-top: .3rem; font-weight: normal; }
.settings-logout { margin-top: 1rem; }
h2 { font-size: 1.24rem; }
.panel { background: white; border: 1px solid #d6e0de; border-radius: .75rem; padding: 1.25rem; margin-bottom: 1rem; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login .panel { width: min(100%, 27rem); }
.login form { display: grid; gap: .7rem; }
.filters label { display: grid; gap: .25rem; }
.section-controls, .header-actions, .date-form { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
.section-controls { justify-content: space-between; margin-bottom: .75rem; }
.section-controls h2 { margin: 0; }
.date-field { position: relative; display: inline-flex; }
.date-field > input { padding-right: 2.4rem; width: 9.1rem; }
.date-picker { position: absolute; right: .15rem; top: 50%; transform: translateY(-50%); }
.date-picker button { border: 0; padding: .3rem .5rem; }
.date-picker input { position: absolute; inset: 0; width: 100%; opacity: 0; pointer-events: none; }
.day-arrow { border: 1px solid #aebfbc; border-radius: .35rem; padding: .5rem .7rem; text-decoration: none; color: var(--accent); }
.day-arrow[aria-disabled] { color: #788986; }
#events, #overview { position: relative; }
.event-summary { cursor: pointer; }
.event-summary h2 { display: inline; margin: 0; }
.panel[open] .event-summary { max-width: 53%; min-height: 2.6rem; padding: .4rem 0; }
.event-controls { position: absolute; top: 1.25rem; right: 1.25rem; max-width: 44%; }
.event-controls select { max-width: 100%; }
.journal-controls { max-width: 65%; }
#events[open] .event-summary { max-width: 35%; }
.technical-toggle { white-space: nowrap; }
.technical-toggle input { margin-right: .25rem; }
input, select, button { font: inherit; border: 1px solid #aebfbc; border-radius: .35rem; padding: .5rem .7rem; }
button { background: var(--accent); color: white; cursor: pointer; border-color: var(--accent); }
button.secondary { color: var(--accent); background: white; }
a { color: var(--accent); text-underline-offset: .15em; }
:focus-visible { outline: 2px solid #0e493d; outline-offset: 3px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: .7rem; }
.stats div { background: #eef5f3; padding: .45rem .65rem; border-radius: .35rem; }
dd { margin: 0; font-size: 1.25rem; font-weight: 650; }
.stats dd.state-unlocked { color: #148373; }
.stats dd.state-locked { color: #d29e4d; }
.stats dd.state-sleep { color: #899aab; }
.stats dd.state-off { color: #35474e; }
.muted, .ticks { color: #506561; font-size: .88rem; }
.timeline, .bar { display: flex; background: #f0f3f2; border-radius: .2rem; }
.timeline { height: 1.6rem; }
.bar { min-width: 7rem; height: .7rem; }
.ticks { position: relative; height: 1.5em; font-size: clamp(.62rem, 2.5vw, .82rem); font-variant-numeric: tabular-nums; }
.ticks span { position: absolute; transform: translateX(-50%); }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem .9rem; padding: 0; }
.legend i { width: .75rem; height: .75rem; display: inline-block; margin-right: .25rem; }
.unlocked { background: #148373; }
.locked { background: #d29e4d; }
.awake_unknown { background: #b179aa; }
.sleep { background: #899aab; }
.off { background: #35474e; }
.unknown { background: repeating-linear-gradient(45deg,#d9e1df,#d9e1df 3px,#f3f5f4 3px,#f3f5f4 6px); }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; margin-top: .5rem; }
th, td { text-align: left; padding: .5rem; border-bottom: 1px solid #e1e9e7; white-space: nowrap; }
th.duration, td.duration { text-align: right; font-variant-numeric: tabular-nums; }
nav { margin-top: .7rem; }
@media (max-width: 540px) {
  .dashboard { width: calc(100% - 1rem); margin: .5rem auto; }
  .panel { padding: .8rem; }
  .event-controls { top: .8rem; right: .8rem; }
  #events[open] .event-summary { max-width: none; }
  .journal-controls { position: static; max-width: none; margin-bottom: .5rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; margin: .55rem 0; }
}
