/* The technician interface's only style sheet. No frameworks, no web fonts. */

:root {
  color-scheme: light dark;
  --fg: #1b1f24;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --muted: #5b6470;
  --line: #d8dde3;
  --accent: #0b5cad;
  --accent-fg: #ffffff;
  --ok-bg: #e7f5ec;
  --ok-fg: #14532d;
  --warn: #8a4b00;
  --err-bg: #fdecec;
  --err-fg: #8f1018;
  --danger: #b4232c;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e6e9ed;
    --bg: #111417;
    --panel: #1a1e23;
    --muted: #9aa4af;
    --line: #2f363e;
    --accent: #6aa9ef;
    --accent-fg: #0b1420;
    --ok-bg: #12301f;
    --ok-fg: #b7ebc9;
    --warn: #e2a560;
    --err-bg: #3a1417;
    --err-fg: #ffb3b7;
    --danger: #ff7b83;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
}

a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.skip { position: absolute; left: -9999px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
details summary { cursor: pointer; color: var(--accent); }
details.inventory { margin: 8px 0; }
.skip:focus { left: 16px; top: 8px; background: var(--panel); padding: 8px; z-index: 1; }

/* Top bar */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--fg); text-decoration: none; }
.top nav { display: flex; flex-wrap: wrap; gap: 4px 16px; flex: 1 1 auto; }
.top nav a, .me a { text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.top nav a[aria-current="page"], .me a[aria-current="page"] { border-bottom-color: var(--accent); color: var(--fg); }
.me { display: flex; align-items: center; gap: 12px; }
.me form { margin: 0; }
.search { margin: 0; }
.search input[type="search"] { width: 12rem; max-width: 100%; padding: 4px 8px; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }

h1 { font-size: 1.6rem; margin: 8px 0 12px; overflow-wrap: anywhere; }
h2 { font-size: 1.2rem; margin: 24px 0 8px; }
.card h2:first-child { margin-top: 0; }

.crumbs { margin: 0; font-size: 0.9rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 0.9rem; }
.warn { color: var(--warn); }
.nowrap { white-space: nowrap; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.9em; }
code.wrap { overflow-wrap: anywhere; }

.notice, .problem {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin: 8px 0 16px;
}
.notice { background: var(--ok-bg); color: var(--ok-fg); }
.problem { background: var(--err-bg); color: var(--err-fg); font-weight: 600; }
.status { min-height: 1.5em; color: var(--muted); }
.status.error { color: var(--err-fg); font-weight: 600; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
}
.narrow { max-width: 34rem; margin-left: auto; margin-right: auto; }
.forms { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }

.tag {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  vertical-align: middle;
}

/* Totals on the home page */
.tiles {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
}
.tiles li {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--muted);
}
.tiles a { text-decoration: none; color: inherit; display: block; }
.tiles .count { display: block; font-size: 2rem; font-weight: 700; color: var(--fg); line-height: 1.2; }

/* Tables scroll sideways on a narrow screen rather than squeezing. */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 16px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 30rem) {
  dl.facts { grid-template-columns: 1fr; }
  dl.facts dd { margin-bottom: 8px; }
}

ul.plain { padding-left: 1.2rem; }

/* Forms */
label { display: block; font-weight: 600; margin: 12px 0 4px; }
label.choice { font-weight: normal; margin: 6px 0; }
input[type="text"], input[type="email"], input[type="number"], input[type="date"], input[type="month"], input[type="search"], select, textarea {
  width: 100%;
  max-width: 32rem;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
}
input[type="number"] { max-width: 10rem; }
textarea { max-width: none; resize: vertical; }
textarea#script { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.9rem; }
input[type="file"] { font: inherit; }
pre.script, pre.output, .message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 8px 0;
  max-height: 32rem;
  overflow-y: auto;
}
pre.script, pre.output { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.85rem; }
.message-body { max-height: none; }
.inline-form { display: inline; margin: 0; }
.inline-form input[type="text"] { width: auto; max-width: 14rem; padding: 4px 8px; }
.inline-form button { padding: 4px 10px; }
td form { margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 16px 0 0; padding: 8px 12px 12px; }
legend { font-weight: 600; padding: 0 4px; }
.ticks { max-height: 16rem; overflow-y: auto; padding-left: 1.5rem; }
form.inline { margin: 0 0 16px; }

button {
  font: inherit;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button.danger { border-color: var(--danger); color: var(--danger); }
button:disabled { opacity: 0.55; cursor: default; }
button.linkish { border: 0; background: none; padding: 4px 0; color: var(--accent); text-decoration: underline; }

.status-active { color: var(--ok-fg); }
.status-pending_approval { color: var(--warn); }
.status-retired { color: var(--muted); }

/* The policy editor */
.indent { margin-left: 1.5rem; padding-left: 12px; border-left: 2px solid var(--line); }
.duration { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.duration select { width: auto; }
ul.problem { padding-left: 2rem; font-weight: normal; }

/* Notifications */
.card.unread { border-left: 4px solid var(--accent); }
.warn-text { color: var(--warn); }
