:root {
  --bg: #0f1115;
  --card: #171a21;
  --border: #2a2e37;
  --text: #e6e8eb;
  --muted: #9aa1ac;
  --blue: #3575e2;
  --green: #2fae5e;
  --amber: #d99a2b;
  --red: #d9484b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.topnav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.topnav a { color: var(--text); text-decoration: none; }
.topnav a:hover { color: var(--blue); }
.topnav .brand { font-weight: 600; margin-right: auto; }

main { padding: 24px; max-width: 960px; margin: 0 auto; }

/* Tables scroll horizontally rather than ever breaking the page width - the mobile
   card transform below is the real fix, this is just a safety net (e.g. a very long
   device id). */
.table-scroll { width: 100%; overflow-x: auto; }

table { width: 100%; border-collapse: collapse; margin-top: 16px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.devices-table th { color: var(--muted); font-weight: 500; font-size: 13px; text-transform: uppercase; }
.detail-table th { color: var(--muted); font-weight: 500; width: 200px; vertical-align: top; }

.badge { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-online { background: rgba(47, 174, 94, 0.15); color: var(--green); }
.badge-stale { background: rgba(217, 154, 43, 0.15); color: var(--amber); }
.badge-never { background: rgba(217, 72, 75, 0.15); color: var(--red); }

form { margin-top: 12px; display: flex; flex-direction: column; gap: 12px; max-width: 420px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
label.checkbox { flex-direction: row; align-items: center; gap: 8px; }

input[type=text], input[type=number], input[type=url], input[type=file] {
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 16px; /* 16px+ stops iOS Safari auto-zooming into the field on focus */
  width: 100%;
}

button {
  padding: 12px 16px;
  border-radius: 6px;
  border: none;
  background: var(--blue);
  color: white;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  width: 100%;
}
button:hover { opacity: 0.9; }

.error { color: var(--red); }
.hint { color: var(--muted); font-size: 13px; }
a { color: var(--blue); }

@media (max-width: 640px) {
  .topnav { padding: 12px 16px; gap: 8px 16px; }
  main { padding: 16px; }
  form { max-width: 100%; }
  button { width: 100%; }

  .devices-table thead { display: none; }
  .devices-table, .devices-table tbody, .devices-table tr, .devices-table td {
    display: block;
    width: 100%;
  }
  .devices-table tr {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 12px;
  }
  .devices-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }
  .devices-table td:last-child { border-bottom: none; }
  .devices-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 500;
  }

  .detail-table tr { display: flex; flex-direction: column; padding: 8px 0; }
  .detail-table th, .detail-table td { display: block; width: auto; border-bottom: none; padding: 2px 0; }
  .detail-table tr:not(:last-child) { border-bottom: 1px solid var(--border); }
}
