:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #697586;
  --line: #d9e2ec;
  --surface: #ffffff;
  --page: #f3f6f8;
  --green: #1f7a5a;
  --blue: #2f6fed;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 17px;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0 18px;
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 30px;
  font-weight: 700;
}

h2 {
  font-size: 18px;
}

#status, #lastSeen, .metric span, .device-picker {
  color: var(--muted);
}

.device-picker, .filters label {
  display: grid;
  gap: 6px;
  font-size: 15px;
}

.dashboard-actions {
  display: flex;
  align-items: end;
  gap: 12px;
}

.public-home-link {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}

.public-home-link:hover {
  border-color: var(--green);
}

select, input[type="datetime-local"] {
  min-width: 220px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover {
  border-color: var(--blue);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.metric strong {
  font-size: 31px;
}

.panel {
  margin-top: 14px;
  padding: 16px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.range-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
}

.range-control span, .filters label {
  color: var(--muted);
}

.range-button {
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.range-button:hover {
  border-color: var(--blue);
}

.range-button.active {
  border-color: var(--blue);
  color: #ffffff;
  background: var(--blue);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.table-wrap {
  overflow-x: auto;
}

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

th, td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 15px;
}

.chart-wrap {
  position: relative;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  width: 215px;
  padding: 10px 12px;
  border: 1px solid #aeb7bf;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(31, 41, 51, 0.16);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.98);
  font-size: 14px;
  pointer-events: none;
}

.chart-tooltip strong,
.chart-tooltip span {
  display: block;
}

.chart-tooltip strong {
  margin-bottom: 4px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(100%, 480px);
}

.login-brand {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.login-panel {
  padding: 30px;
  border-top: 4px solid #d00000;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(31, 41, 51, 0.12);
}

.login-panel h1 {
  margin-bottom: 8px;
}

.login-panel p {
  margin-bottom: 20px;
  color: var(--muted);
  line-height: 1.55;
}

.login-eyebrow {
  margin-bottom: 6px;
  color: #d00000;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.login-panel form {
  display: grid;
  gap: 14px;
}

.login-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 15px;
}

.login-panel input {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.login-submit,
.login-cancel {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.login-submit {
  border: 1px solid #2f6fed;
  color: #ffffff;
  background: #2f6fed;
}

.login-cancel {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  text-decoration: none;
}

.login-error {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-left: 3px solid #d00000;
  color: #8f0000;
  background: #faeaea;
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .range-control {
    flex-wrap: wrap;
  }

  select, input[type="datetime-local"] {
    width: 100%;
  }
}
