@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/Montserrat-SemiBold.ttf?v=2") format("truetype");
}

:root {
  --color-navy: #07274E;
  --color-teal: #0D7E92;
  --color-teal-hover: #0A6577;
  --color-coral: #F2994A;
  --color-sand: #F7F5F0;
  --color-slate: #4A5568;
  --color-white: #FFFFFF;
  --color-primary: var(--color-navy);
  --color-accent: var(--color-teal);
  --color-highlight: var(--color-coral);
  --color-bg: var(--color-sand);
  --color-text: var(--color-slate);
  --font-heading: "Montserrat", system-ui, sans-serif;
  --font-body: system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

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

h1, h2, h3 {
  font-family: var(--font-heading);
  color: var(--color-primary);
  font-weight: 600;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--color-navy);
  padding: 0.7rem 1.5rem;
}

.site-header a { display: flex; }

.site-header img {
  height: 40px;
  width: auto;
  max-width: min(280px, 70vw);
  display: block;
}

.card a { color: var(--color-teal); }

.header-label {
  margin: 0;
  color: var(--color-sand);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

.page {
  flex: 1;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.25rem 1.5rem 1.5rem;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
  max-width: 100%;
}

.toolbar h1 { margin: 0; font-size: 1.5rem; }

.lede { margin: 0.2rem 0 0; }

.btn {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  background: var(--color-accent);
  color: var(--color-white);
  border: 0;
  border-radius: 6px;
  padding: 0.55rem 1.05rem;
  cursor: pointer;
}

.btn:hover { background: var(--color-teal-hover); }

a.btn {
  display: inline-block;
  text-decoration: none;
}

.btn-quiet {
  background: transparent;
  color: var(--color-navy);
  border: 1px solid #e4dfd6;
}

.btn-quiet:hover { background: var(--color-white); }

.toolbar-actions {
  display: flex;
  gap: 0.5rem;
  flex: none;
}

.toolbar-actions form .btn { margin-top: 0; }

label {
  display: block;
  margin: 0.9rem 0 0.3rem;
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--color-navy);
}

input[type="text"],
input[type="password"] {
  width: 100%;
  max-width: 24rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid #e4dfd6;
  border-radius: 6px;
  font: inherit;
  color: var(--color-navy);
  background: var(--color-white);
}

form .btn { margin-top: 1rem; }

.form-error { color: #9a3412; }

.data-window {
  flex: 1;
  min-height: 12rem;
  min-width: 0;
  max-width: 100%;
  overflow: auto;
  background: var(--color-white);
  border: 1px solid #e4dfd6;
  border-radius: 10px;
  padding: 0;
}

.data-window h2 {
  font-size: 1.05rem;
  margin: 1.1rem 0 0.6rem;
}

table { width: 100%; border-collapse: collapse; }

th, td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid #ece8e1;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: var(--color-white);
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--color-navy);
  box-shadow: inset 0 -1px 0 #ece8e1;
}

tr.alert td:first-child { box-shadow: inset 3px 0 0 var(--color-coral); }

.card {
  background: var(--color-white);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  max-width: 40rem;
}

.empty { margin: 1.25rem; }

.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;
}

.viewer {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border: 0;
  padding: 0;
  margin: 0;
}

.viewer > input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.tabbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  flex-wrap: wrap;
}

.tabs { display: flex; gap: 0.25rem; }

.tab {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-navy);
  border-bottom: 3px solid transparent;
  padding: 0.4rem 0.75rem 0.35rem;
  cursor: pointer;
}

.tab:hover { color: var(--color-teal); }

#view-overview:checked ~ .tabbar label[for="view-overview"],
#view-table:checked ~ .tabbar label[for="view-table"],
#view-all:checked ~ .tabbar label[for="view-all"] {
  color: var(--color-teal);
  border-bottom-color: var(--color-teal);
}

#view-overview:focus-visible ~ .tabbar label[for="view-overview"],
#view-table:focus-visible ~ .tabbar label[for="view-table"],
#view-all:focus-visible ~ .tabbar label[for="view-all"] {
  outline: 2px solid var(--color-teal);
  outline-offset: 3px;
  border-radius: 4px;
}

#view-overview:checked ~ #panel-table,
#view-overview:checked ~ #panel-all,
#view-table:checked ~ #panel-overview,
#view-table:checked ~ #panel-all,
#view-all:checked ~ #panel-overview,
#view-all:checked ~ #panel-table { display: none; }

.history-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.85rem 0.85rem 0;
}

.kept {
  margin: 0.75rem 0.85rem 0.2rem;
  font-size: 0.85rem;
}

.live-note {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
}

.view-panel {
  flex: 1;
  min-height: 12rem;
  min-width: 0;
  max-width: 100%;
  overflow: auto;
}

#device-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.device {
  background: var(--color-white);
  border: 1px solid #e4dfd6;
  border-radius: 10px;
  padding: 1rem 1.1rem 0.75rem;
  min-width: 0;
  max-width: 100%;
}

.device-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
}

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

.device h3,
.stat-label {
  margin: 0.15rem 0 0;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-navy);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2.5rem;
  margin: 0.85rem 0 0.7rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.freshness {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.55rem;
  line-height: 1.2;
  color: var(--color-navy);
}

.dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--color-navy);
  flex: none;
}

.freshness.fresh .dot { background: var(--color-teal); }
.freshness.stale .dot { background: var(--color-coral); }

.count {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.55rem;
  line-height: 1.2;
  color: var(--color-navy);
}

.stat-sub { font-size: 0.85rem; }

.chart-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.2rem;
}

.chart-controls h3 { margin: 0; }

.chart-controls label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-navy);
}

.span {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--color-navy);
  background: var(--color-white);
  border: 1px solid #e4dfd6;
  border-radius: 6px;
  padding: 0.28rem 0.4rem;
}

.chart-note {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
}

.chart-frame {
  position: relative;
  margin-top: 0.35rem;
  min-width: 0;
  max-width: 100%;
}

.chart {
  min-width: 0;
  max-width: 100%;
  cursor: crosshair;
}

.chart svg {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
}

.chart-tip {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  min-width: 11.5rem;
  background: var(--color-navy);
  color: var(--color-sand);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  line-height: 1.35;
}

.chart-tip strong {
  display: block;
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--color-white);
}
