:root {
  --yellow: #ffcc00;
  --yellow-dark: #e6b800;
  --yellow-soft: #fff4c2;
  --red: #d40511;
  --red-dark: #a8040d;
  --ink: #1a1a1a;
  --ink-2: #4a4a4a;
  --ink-3: #767676;
  --line: #dcdcdc;
  --bg: #f4f4f4;
  --card: #ffffff;
  --ok: #2e7d32;
  --warn: #b26a00;
  --radius: 4px;
  --font: "Delivery", "Frutiger", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}

/* ---------- header ---------- */
header.top {
  background: var(--yellow);
  border-bottom: 4px solid var(--red);
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}
header.top .logo { height: 34px; display: block; }
header.top .title {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: .04em;
  text-transform: uppercase;
  border-left: 2px solid var(--ink);
  padding-left: 18px;
  line-height: 1.1;
}
header.top .title small {
  display: block;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--ink-2);
}
header.top .spacer { flex: 1; }
header.top .who { font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 12px; }
.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  background: #eee;
  color: var(--ink-2);
  white-space: nowrap;
}
.pill.red { background: var(--red); color: #fff; }
.pill.yellow { background: var(--yellow); color: var(--ink); }
.pill.green { background: #e3f1e4; color: var(--ok); }
.pill.dark { background: var(--ink); color: #fff; }
.pill.warn { background: #fff0d6; color: var(--warn); }

/* ---------- layout ---------- */
.shell { display: flex; min-height: calc(100% - 68px); }
nav.side {
  width: 220px;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 16px 0;
  flex: none;
}
nav.side a {
  display: block;
  padding: 11px 24px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  border-left: 5px solid transparent;
  cursor: pointer;
}
nav.side a:hover { background: var(--yellow-soft); }
nav.side a.active { background: var(--yellow-soft); border-left-color: var(--red); }
nav.side .sec {
  padding: 18px 24px 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  color: var(--ink-3);
  text-transform: uppercase;
}
main { flex: 1; padding: 24px 32px 120px; min-width: 0; max-width: 1400px; }

h1 {
  font-size: 26px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .02em;
  margin: 0 0 4px;
}
h1::after { content: ""; display: block; width: 56px; height: 5px; background: var(--red); margin-top: 8px; }
h2 { font-size: 16px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; margin: 0 0 10px; }
h3 { font-size: 14px; font-weight: 800; margin: 14px 0 6px; }
p.lead { color: var(--ink-2); margin: 10px 0 20px; max-width: 900px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--yellow);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.card.danger { border-top-color: var(--red); }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 800px) {
  .shell { flex-direction: column; }
  nav.side { width: auto; display: flex; overflow-x: auto; padding: 0; }
  nav.side .sec { display: none; }
  nav.side a { border-left: 0; border-bottom: 4px solid transparent; white-space: nowrap; padding: 12px 16px; }
  nav.side a.active { border-bottom-color: var(--red); }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }
  main { padding: 16px 14px 120px; }
}

/* ---------- forms ---------- */
label.f { display: block; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
label.f .tags { margin-left: 6px; text-transform: none; letter-spacing: 0; }
label.f .hint { display: block; font-weight: 400; font-size: 12px; text-transform: none; letter-spacing: 0; color: var(--ink-3); margin-top: 2px; }
input[type=text], input[type=number], input[type=time], input[type=password], select, textarea {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid #b5b5b5;
  border-radius: var(--radius);
  font: inherit;
  background: #fff;
  color: var(--ink);
}
input.mono, textarea.mono, td.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--yellow); outline-offset: 0; border-color: var(--ink); }
input:disabled, select:disabled, textarea:disabled { background: #efefef; color: var(--ink-3); }
input.bad, select.bad, textarea.bad { border-color: var(--red); background: #fff1f2; }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--red); vertical-align: middle; margin: 0 6px 0 0; }
.check { display: inline-flex; align-items: center; margin-right: 16px; font-weight: 600; white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
code, .code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; background: #f0f0f0; padding: 1px 5px; border-radius: 3px; }
pre.json {
  background: #1d1d1d; color: #f5f5f5; padding: 14px; border-radius: var(--radius);
  overflow: auto; max-height: 460px; font-size: 12.5px; line-height: 1.45; margin: 0;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
}

button {
  font: inherit;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 12.5px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  cursor: pointer;
}
button:hover { background: var(--yellow-dark); }
button.primary { background: var(--red); border-color: var(--red); color: #fff; }
button.primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
button.ghost { background: #fff; }
button.ghost:hover { background: var(--yellow-soft); }
button.sm { padding: 4px 10px; font-size: 11.5px; }
button.icon { padding: 3px 9px; font-size: 15px; line-height: 1; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- tables ---------- */
table.t { width: 100%; border-collapse: collapse; }
table.t th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-2); padding: 8px 8px; border-bottom: 3px solid var(--yellow); white-space: nowrap;
}
table.t td { padding: 5px 8px; border-bottom: 1px solid #ececec; vertical-align: middle; }
table.t td input, table.t td select { margin-top: 0; padding: 6px 8px; }
table.t tr:hover td { background: #fffdf2; }
table.t.plain td { padding: 7px 8px; }
.tablewrap { overflow-x: auto; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 3px solid var(--yellow); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a {
  padding: 10px 18px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; font-size: 12.5px;
  cursor: pointer; color: var(--ink); background: #e9e9e9; border-radius: var(--radius) var(--radius) 0 0;
}
.tabs a.active { background: var(--yellow); }
.tabs a .n { margin-left: 6px; }

/* ---------- misc ---------- */
.banner { padding: 10px 14px; border-left: 5px solid var(--yellow); background: var(--yellow-soft); margin: 0 0 16px; border-radius: 0 var(--radius) var(--radius) 0; }
.banner.red { border-left-color: var(--red); background: #fdecee; }
.banner.green { border-left-color: var(--ok); background: #e9f4ea; }
.issues { margin: 0 0 16px; padding: 0; list-style: none; }
.issues li { padding: 6px 12px; margin-bottom: 4px; border-left: 5px solid var(--red); background: #fdecee; font-size: 13px; }
.issues li.warning { border-left-color: var(--warn); background: #fff6e5; }
.issues li b { font-family: ui-monospace, Menlo, monospace; font-weight: 600; }

.savebar {
  position: fixed; left: 220px; right: 0; bottom: 0; z-index: 15;
  background: var(--ink); color: #fff; padding: 12px 32px; display: flex; gap: 12px; align-items: center;
  border-top: 4px solid var(--yellow);
}
.savebar .msg { flex: 1; font-weight: 700; }
.savebar button.ghost { background: transparent; color: #fff; border-color: #fff; }
.savebar button.ghost:hover { background: #333; }
@media (max-width: 800px) { .savebar { left: 0; padding: 12px 14px; } }

.devcard { display: flex; flex-direction: column; gap: 6px; }
.devcard .imei { font-family: ui-monospace, Menlo, monospace; font-size: 17px; font-weight: 800; }
.devcard dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 6px 0; font-size: 13px; }
.devcard dt { color: var(--ink-3); }
.devcard dd { margin: 0; font-weight: 600; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #bbb; margin-right: 6px; }
.dot.on { background: #2e9d3a; box-shadow: 0 0 0 3px #d7efd9; }
.dot.stale { background: var(--yellow-dark); }

.rulecard { border: 1px solid var(--line); border-left: 5px solid var(--red); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; background: #fff; }
.rulecard header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.rulecard header b { flex: 1; font-size: 14px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow: auto; }
.modal { background: #fff; border-top: 6px solid var(--yellow); border-radius: var(--radius); width: min(980px, 100%); padding: 20px 24px; }
.modal .row.head { justify-content: space-between; margin-bottom: 10px; }

.login { max-width: 420px; margin: 12vh auto; }

details.entry { border-bottom: 1px solid #ececec; }
details.entry summary { cursor: pointer; padding: 6px 4px; list-style: none; display: flex; gap: 10px; align-items: center; }
details.entry summary::-webkit-details-marker { display: none; }
details.entry summary:hover { background: #fffdf2; }
details.entry[open] summary { background: var(--yellow-soft); }
details.entry .body { padding: 8px 4px 14px; display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
@media (max-width: 1000px) { details.entry .body { grid-template-columns: 1fr; } }

.stripes { height: 6px; background: repeating-linear-gradient(135deg, var(--red) 0 10px, var(--yellow) 10px 20px); }
footer.page { color: var(--ink-3); font-size: 12px; margin-top: 30px; }

table.t.wide td input[type=text], table.t.wide td input[type=number] { min-width: 110px; }
table.t.wide td input[type=number] { min-width: 64px; }
table.t.wide td:nth-child(6) input { min-width: 190px; }
table.t.wide td select { min-width: 70px; }

details.entry { min-width: 0; }
details.entry .body > div { min-width: 0; }
details.entry summary { flex-wrap: wrap; }
details.entry summary .path { overflow-wrap: anywhere; word-break: break-all; }
