/*
 * LITS Fleet dashboard styles (#24): one small hand-written stylesheet shared by every page, so
 * the look changes in one place. No framework, no CDN: it works offline and before login.
 */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e4e7ec;
  --text: #101828;
  --muted: #667085;
  --accent: #1d4ed8;
  --accent-soft: #eff4ff;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h2, h3 { margin: 0 0 12px; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }

/* ---- navigation ------------------------------------------------------------------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 52px;
}
.nav-brand { font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.nav-brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav-links a {
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--muted);
  white-space: nowrap;
}
.nav-links a:hover { color: var(--text); background: var(--bg); text-decoration: none; }
.nav-links a.active { color: var(--accent); background: var(--accent-soft); font-weight: 500; }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; text-align: center; }
/* Health strip under the nav row: part of the shell, quiet enough to ignore until it goes red. */
.nav-status {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 3px 24px 5px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
}
.nav-status a { color: var(--muted); }
.nav-status strong { color: var(--text); font-weight: 500; }
.nav-user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.nav-user form { margin: 0; }

/* ---- layout ----------------------------------------------------------------------------- */
.container {
  max-width: 1200px;
  margin: 24px auto;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.page-narrow { max-width: 520px; }

.muted, .empty { color: var(--muted); font-size: 13px; }
.empty { padding: 20px 10px !important; text-align: center; }

/* ---- tables ----------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  background: transparent;
}
tbody tr:hover { background: var(--bg); }
tbody tr:last-child td { border-bottom: 0; }
td code, p code, li code { font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 4px; word-break: break-all; }

/* ---- forms and buttons ------------------------------------------------------------------ */
input, select, textarea, button { font: inherit; }
input, select, textarea {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { width: 100%; }

button {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button:hover { background: var(--bg); }
button[type="submit"]:not(.link) { border-color: var(--text); background: var(--text); color: #fff; }
button[type="submit"]:not(.link):hover { background: #1f2937; }
/* Secondary buttons: the nav and actions inside table rows stay quiet. */
.nav-user button[type="submit"], td button[type="submit"] { padding: 4px 10px; border-color: var(--border); background: var(--surface); color: var(--text); }
.nav-user button[type="submit"]:hover, td button[type="submit"]:hover { background: var(--bg); }

form.inline { display: inline; }
form.add, form.create { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
form.add label, form.create label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
form.create.grid { display: grid; grid-template-columns: repeat(3, 1fr); }
form.create .wide { grid-column: span 3; }

/* ---- status and notices ----------------------------------------------------------------- */
.error, .warn { color: var(--danger); }
p.error, div.error { background: var(--danger-soft); padding: 10px 12px; border-radius: 8px; }
p.notice { color: var(--accent); background: var(--accent-soft); padding: 10px 12px; border-radius: 8px; }
.low { color: var(--danger); font-weight: 600; }
.lost, .tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.lost { background: var(--danger); color: #fff; }
.tag { background: var(--accent-soft); color: var(--accent); }
.danger { border-color: var(--danger); }
.danger button[type="submit"] { background: var(--danger); border-color: var(--danger); color: #fff; }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }

ol { margin: 0; padding-left: 20px; line-height: 1.7; }
#map { border-radius: 8px; }

/* ---- modal forms (native <dialog>) ------------------------------------------------------ */
dialog { width: min(440px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--border); border-radius: 12px; }
dialog::backdrop { background: rgba(17, 24, 39, 0.4); }
form.stack label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
form.stack input { display: block; width: 100%; margin-top: 4px; }

/* ---- sign-in ---------------------------------------------------------------------------- */
.auth { max-width: 360px; margin: 12vh auto 0; }
.auth h2 { text-align: center; }
.auth label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.auth input { display: block; width: 100%; margin-top: 4px; }
.auth button { width: 100%; padding: 9px; }
.version { margin-top: 16px; text-align: center; font-size: 12px; color: var(--muted); }

@media (max-width: 720px) {
  .nav-inner { gap: 12px; padding: 0 12px; }
  .nav-user span { display: none; }
  .container { margin: 12px; padding: 16px; }
  form.create.grid { grid-template-columns: 1fr; }
  form.create .wide { grid-column: auto; }
}

/* ---- device list row actions (#46) ------------------------------------------------------ */
td.actions { white-space: nowrap; }
td.actions .muted { white-space: normal; font-size: 12px; }
button.danger { border-color: var(--danger); color: var(--danger); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- table row navigation ---------------------------------------------------------------- */
/* #101: a row's only control is the link to its device page. Styled like the secondary buttons the
   action controls used to be, so the table still reads as a table of things you can open. */
td a.manage {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
td a.manage:hover { background: var(--bg); }
