/* The Smartlock admin panel: a neutral look (slate and teal) in the system's own fonts. Every image
   is served from this site (css/img): the Content-Security-Policy allows nothing else. Light and
   dark follow the system. */

:root {
  --bg: #f5f7fa;
  --fg: #344054;
  --heading: #101828;
  --muted: #667085;
  --card: #ffffff;
  --line: #e4e7ec;
  --head-bg: #f2f4f7;
  --row-hover: #f9fafb;
  --accent: #0e7490;
  --accent-fg: #ffffff;
  --accent-soft: #a5e3ee;
  --link: #0e7490;
  --focus: #0e7490;
  --ok-bg: #e3f4ea;
  --ok-fg: #1d6b3d;
  --warn-bg: #fbf1d9;
  --warn-fg: #7a5200;
  --bad-bg: #fbe6e5;
  --bad-fg: #a0262b;
  --idle-bg: #eef0f3;
  --idle-fg: #55606a;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 2px 8px rgba(16, 24, 40, 0.05);
  --logo: url("img/smartlock-mark.svg");
  --heading-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --text-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono-font: ui-monospace, SFMono-Regular, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --fg: #d0d5dd;
    --heading: #f2f4f7;
    --muted: #98a2b3;
    --card: #111a2b;
    --line: #1f2a3d;
    --head-bg: #162033;
    --row-hover: #152035;
    --accent: #67d3e6;
    --accent-fg: #062a33;
    --accent-soft: #2a7f8f;
    --link: #8bdcec;
    --focus: #67d3e6;
    --ok-bg: #173323;
    --ok-fg: #8fd7a6;
    --warn-bg: #3a2e10;
    --warn-fg: #f0c661;
    --bad-bg: #3b1a1c;
    --bad-fg: #f19a9e;
    --idle-bg: #1d283a;
    --idle-fg: #b3bec8;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 var(--text-font);
  -webkit-text-size-adjust: 100%;
}

body.center { display: grid; min-height: 100vh; place-items: center; padding: 16px; }

main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 40px; }

a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--heading); }

h1, h2, h3, legend { font-family: var(--heading-font); color: var(--heading); letter-spacing: 0.01em; }
h1 { font-size: 1.65rem; font-weight: 700; margin: 0.3em 0 0.5em; line-height: 1.2; }
h1 small { color: var(--muted); font-weight: 500; font-size: 1rem; margin-left: 0.5em; }
h2 { font-size: 1.2rem; font-weight: 700; margin: 1.4em 0 0.6em; }
h3 { font-size: 1rem; font-weight: 700; margin: 1em 0 0.4em; }

code { font-family: var(--mono-font); font-size: 0.9em; }

.muted, .hint { color: var(--muted); }
dd.late { color: var(--bad-fg); }
.hint { display: block; font-size: 0.875em; font-weight: normal; line-height: 1.4; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* the logo: the mark and the product's name */
.logo {
  display: inline-flex; align-items: center; gap: 9px; flex: none; text-decoration: none;
  font-family: var(--heading-font); font-weight: 700; font-size: 1.1rem; color: var(--heading);
  letter-spacing: 0.01em;
}
.logo::before {
  content: ""; width: 28px; height: 28px; flex: none; background: var(--logo) no-repeat center / contain;
}
a.logo:hover { color: var(--heading); }

/* top bar */
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 28px;
  padding: 10px 24px; background: var(--card); border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
/* The menu keeps to one row while it fits; when it and .me don't fit side by side, .me moves to a
   row of its own (right-aligned) rather than squeezing the menu onto several rows. */
.top nav { display: flex; flex-wrap: wrap; gap: 4px 22px; flex: 1 1 auto; }
.top nav a, .top .me a, .top .me button.link {
  font-family: var(--heading-font); font-weight: 600; font-size: 0.82rem; letter-spacing: 0.08em;
  text-transform: uppercase; text-decoration: none; color: var(--muted);
  padding: 6px 0; border-bottom: 2px solid transparent;
}
.top nav a:hover, .top .me a:hover, .top .me button.link:hover { color: var(--heading); }
.top a.on { color: var(--heading); border-bottom-color: var(--accent-soft); }
.top .me { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; margin-left: auto; }
.top .who { font-weight: 600; color: var(--heading); }
.top .tenant {
  display: inline-flex; align-items: center; gap: 8px; padding: 3px 12px; border-radius: 999px;
  background: var(--head-bg); border: 1px solid var(--line); font-size: 0.9rem;
}
.top .tenant strong { color: var(--heading); }
.top .tenant.none { color: var(--muted); }
.top .tenant a { font-size: 0.8rem; }
.top .who::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%;
  background: var(--accent-soft); vertical-align: 1px;
}

.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.bar h1 { margin-bottom: 0.3em; }
.intro { max-width: 70ch; }

/* cards and layout */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px;
  box-shadow: var(--shadow);
}
main.card { margin-top: 24px; max-width: 760px; }
.narrow { max-width: 460px; width: 100%; }
main.card.narrow { max-width: 460px; }
section.card.narrow { margin-top: 28px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin-top: 16px; }
.cols .card h2, .card > h2:first-child { margin-top: 0.1em; }

/* the sign-in page */
.login { padding: 32px 28px 28px; }
.login .logo { display: flex; justify-content: center; font-size: 1.6rem; gap: 12px; }
.login .logo::before { width: 40px; height: 40px; }
.login .tagline {
  margin: 10px 0 22px; text-align: center; font-family: var(--heading-font); font-weight: 600;
  font-size: 0.8rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted);
}
.login h1 { font-size: 1.25rem; text-align: center; }
.login button.primary { margin-top: 4px; padding: 10px 16px; }

/* forms and buttons */
form.inline { display: inline; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; color: var(--heading); }
.filters {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; margin: 0 0 16px;
  padding: 12px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 0.85em; color: var(--muted); }

input, select, textarea {
  font: inherit; font-weight: normal; color: var(--fg); background: var(--card);
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; min-height: 38px; max-width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.25); }
input[readonly] { color: var(--muted); background: var(--bg); }
input[type="checkbox"] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
textarea { font-family: var(--mono-font); font-size: 0.9em; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px;
  font-family: var(--heading-font); font-size: 0.9rem; font-weight: 700; letter-spacing: 0.02em;
  cursor: pointer; text-decoration: none; line-height: 1.2;
  color: var(--heading); background: var(--card); border: 1px solid var(--accent); border-radius: 6px; padding: 7px 16px;
}
button:hover, .button:hover { background: var(--head-bg); color: var(--heading); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button.primary:hover, .button.primary:hover { filter: brightness(1.15); background: var(--accent); color: var(--accent-fg); }
button.danger { color: var(--bad-fg); border-color: var(--bad-fg); }
button.danger:hover { background: var(--bad-bg); color: var(--bad-fg); }
button.link {
  background: none; border: none; padding: 0; min-height: 0; color: var(--muted);
  font-family: inherit; font-weight: normal; letter-spacing: normal;
}
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0; }
td.actions { margin: 0; gap: 6px; }
td.actions button, td.actions .button, td form.inline button { min-height: 32px; padding: 4px 10px; font-size: 0.82rem; }
.htmx-request button, button.htmx-request { opacity: 0.6; cursor: progress; }

/* notices */
.notice { padding: 10px 14px; border-radius: 8px; margin: 10px 0; border-left: 4px solid transparent; }
ul.notice { padding-left: 32px; }
.notice.ok { background: var(--ok-bg); color: var(--ok-fg); border-left-color: var(--ok-fg); }
.notice.warn { background: var(--warn-bg); color: var(--warn-fg); border-left-color: var(--warn-fg); }
.notice.error { background: var(--bad-bg); color: var(--bad-fg); border-left-color: var(--bad-fg); }
.notice.secret { background: var(--warn-bg); color: var(--warn-fg); border-left-color: var(--warn-fg); }
.notice.secret code { font-size: 1.15em; letter-spacing: 0.05em; user-select: all; }

/* tables */
table.grid {
  width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow);
}
table.grid th, table.grid td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid th {
  background: var(--head-bg); font-family: var(--heading-font); font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap;
}
table.grid tbody tr:hover td { background: var(--row-hover); }
table.grid.small { font-size: 0.92em; }
table.grid td a { font-weight: 600; }
td.nowrap { white-space: nowrap; }
td.details { font-family: var(--mono-font); font-size: 0.82em; word-break: break-all; color: var(--muted); }
tr.security td:first-child { box-shadow: inset 3px 0 var(--warn-fg); }
tr.operation td:first-child { box-shadow: inset 3px 0 var(--accent-soft); }

@media (max-width: 760px) {
  table.grid { display: block; overflow-x: auto; }
}

/* key/value lists */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
.pre { white-space: pre-wrap; }
ul.plain { padding-left: 18px; margin: 4px 0; }

/* status pills */
.pill {
  display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 0.8em; font-weight: 600;
  white-space: nowrap; background: var(--idle-bg); color: var(--idle-fg);
}
.pill.online, .pill.match { background: var(--ok-bg); color: var(--ok-fg); }
.pill.connecting, .pill.wait { background: var(--warn-bg); color: var(--warn-fg); }
.pill.mismatch { background: var(--bad-bg); color: var(--bad-fg); }
.pill .raw { font-weight: normal; opacity: 0.75; font-family: var(--mono-font); font-size: 0.9em; margin-left: 4px; }

.pager { display: flex; gap: 16px; align-items: center; margin: 16px 0; }

/* guest access */
.stack label.check, label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: normal; flex-wrap: wrap; }
label.check .hint { flex-basis: 100%; }
fieldset.scopes {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0;
  display: flex; flex-direction: column; gap: 8px;
}
fieldset.scopes legend { font-weight: 700; padding: 0 4px; }
/* Checkbox, scope name, description: a long description wraps in its own column. */
fieldset.scopes label.check { display: grid; grid-template-columns: auto 4.5em 1fr; align-items: baseline; }
.notice.handover p { margin: 4px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.notice.handover code { word-break: break-all; }
fieldset.group {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0;
  display: flex; flex-direction: column; gap: 14px;
}
fieldset.group legend { font-weight: 700; padding: 0 4px; }
fieldset.group .notice, fieldset.group .hint { margin: 0; }

/* guest check-in */
.checkin { margin: 18px 0; }
.checkin form.stack { max-width: 560px; margin: 10px 0; }
.checkin .review { margin: 12px 0; }
.checkin details.settings { margin: 16px 0; }
.checkin details.settings summary { cursor: pointer; font-weight: 600; color: var(--heading); }
.checkin blockquote { margin: 4px 0 0; padding: 2px 10px; border-left: 3px solid var(--line); white-space: pre-wrap; }
.travellers { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.travellers .traveller { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.travellers h4 { margin: 0 0 8px; color: var(--heading); }
.checkin .police-report { margin: 14px 0; padding: 10px 14px; border: 1px solid var(--line);
  border-left: 4px solid var(--accent-soft); border-radius: 8px; }
.checkin .police-report h3 { margin-top: 0; }
.checkin .police-when { font-weight: 600; color: var(--heading); }
.police-note { color: var(--heading); }

/* phones */
@media (max-width: 640px) {
  .top { padding: 10px 16px; gap: 6px 16px; }
  .top nav { order: 3; flex-basis: 100%; gap: 2px 16px; }
  .top .me { margin-left: auto; }
  main { padding: 14px 12px 32px; }
  h1 { font-size: 1.4rem; }
  .card { padding: 14px 14px; }
  .cols { grid-template-columns: 1fr; }
  dl.kv { grid-template-columns: 1fr; gap: 0; }
  dl.kv dd { margin-bottom: 8px; }
}
