/* HAMWARE — FN-2400 industrial controller UI
   Light industrial theme, ca. 2005-2015 embedded device management look. */

:root {
  --bg: #e7eaee;
  --panel: #f6f7f9;
  --panel-alt: #eef1f4;
  --ink: #1b2733;
  --ink-soft: #5a6b7b;
  --line: #c3ccd6;
  --line-strong: #9aa8b6;
  --blue: #1c5a97;
  --blue-dark: #15456f;
  --blue-soft: #e4eef7;
  --green: #2f8f4e;
  --amber: #c98a12;
  --red: #c1352b;
  --head: #253749;
  --mono: "DejaVu Sans Mono", "Consolas", "Courier New", monospace;
  --sans: "Segoe UI", Tahoma, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.mono { font-family: var(--mono); }

/* ---- top bar ---- */
.topbar {
  background: linear-gradient(180deg, #2c4055, #233546);
  color: #eaf1f7;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 8px 16px;
  border-bottom: 3px solid var(--blue);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  font-family: var(--mono);
  font-size: 18px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 3px;
  border: 1px solid #0d3253;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 15px; letter-spacing: 0.5px; }
.brand-text span { font-size: 11px; color: #9fb4c6; }

.device-strip {
  display: flex;
  gap: 18px;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12px;
}
.device-strip > div { display: flex; flex-direction: column; }
.device-strip label { color: #8aa2b6; font-size: 10px; letter-spacing: 0.5px; }
.device-strip span { color: #e7eef5; font-weight: 600; }
.device-strip .conn { flex-direction: row; align-items: center; gap: 6px; margin-left: auto; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #8aa2b6; display: inline-block; }
.dot.ok { background: #46c46e; box-shadow: 0 0 6px #46c46e88; }
.dot.bad { background: var(--red); }

/* ---- nav ---- */
.mainnav {
  background: var(--panel);
  border-bottom: 1px solid var(--line-strong);
  display: flex;
  gap: 0;
  padding: 0 10px;
  flex-wrap: wrap;
}
.mainnav a {
  padding: 9px 16px;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 13px;
  border-bottom: 3px solid transparent;
}
.mainnav a:hover { background: var(--panel-alt); text-decoration: none; }
.mainnav a.active { color: var(--blue-dark); border-bottom-color: var(--blue); background: #fff; }

/* ---- content ---- */
.content { flex: 1; padding: 16px; max-width: 1280px; width: 100%; margin: 0 auto; }

.sitefoot {
  background: #dde3e9;
  border-top: 1px solid var(--line-strong);
  color: var(--ink-soft);
  font-size: 11px;
  padding: 8px 16px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: space-between;
}

/* ---- panels ---- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  margin-bottom: 16px;
}
.panel > h2, .panel > .panel-head {
  margin: 0;
  background: var(--head);
  color: #eaf1f7;
  font-size: 12px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 7px 12px;
  border-radius: 2px 2px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel .panel-body { padding: 12px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: 2fr 1fr; }
.grid.main { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 900px) {
  .grid.cols-2, .grid.cols-3, .grid.main { grid-template-columns: 1fr; }
}

/* ---- tables ---- */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
table.data th, table.data td {
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
}
table.data th {
  background: var(--panel-alt);
  color: var(--ink-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
table.data td.val { font-family: var(--mono); font-weight: 600; text-align: right; }
table.data tr:hover td { background: #fff; }

/* key/value readout grid */
.readout { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.readout .cell { background: var(--panel); padding: 8px 10px; }
.readout .cell label { display: block; font-size: 10.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.5px; }
.readout .cell .v { font-family: var(--mono); font-size: 17px; font-weight: 700; color: var(--ink); }
.readout .cell .v.big { font-size: 22px; }

/* status indicators */
.ind { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; }
.ind .led { width: 11px; height: 11px; border-radius: 2px; background: #b9c4ce; border: 1px solid #93a1ad; }
.ind.on .led { background: var(--green); border-color: #1d6b38; box-shadow: 0 0 5px #2f8f4e88; }
.ind.on.cool .led { background: var(--blue); border-color: #0d3253; box-shadow: 0 0 5px #1c5a9788; }
.ind.on.heat .led { background: var(--red); border-color: #7d1c15; box-shadow: 0 0 5px #c1352b88; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 2px; font-size: 11px; font-weight: 700; letter-spacing: 0.4px; }
.badge.ok { background: #dff0e4; color: var(--green); border: 1px solid #a9d6b8; }
.badge.warn { background: #faf0d7; color: var(--amber); border: 1px solid #e5cf98; }
.badge.bad { background: #f7dcda; color: var(--red); border: 1px solid #e0a9a4; }
.badge.info { background: var(--blue-soft); color: var(--blue-dark); border: 1px solid #b4d2ea; }

/* forms / controls */
label.field { display: block; margin-bottom: 10px; font-size: 12px; color: var(--ink-soft); }
label.field span { display: block; margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
input[type=text], input[type=password], input[type=number], select, textarea {
  font-family: var(--mono);
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }

button, .btn {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border: 1px solid var(--blue-dark);
  background: linear-gradient(180deg, #2a72b5, #1c5a97);
  color: #fff;
  border-radius: 2px;
  cursor: pointer;
}
button:hover, .btn:hover { background: linear-gradient(180deg, #2f7cc4, #19507f); text-decoration: none; }
button.secondary, .btn.secondary { background: linear-gradient(180deg, #f3f5f7, #e2e7ec); color: var(--ink); border-color: var(--line-strong); }
button.secondary:hover { background: #fff; }
button.danger { background: linear-gradient(180deg, #cf4b40, #b02a20); border-color: #7d1c15; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.note { font-size: 12px; color: var(--ink-soft); }
.hint { background: var(--blue-soft); border-left: 3px solid var(--blue); padding: 8px 10px; font-size: 12px; color: var(--blue-dark); border-radius: 0 2px 2px 0; }
.alert { background: #f7dcda; border-left: 3px solid var(--red); padding: 8px 10px; font-size: 12px; color: #7d1c15; border-radius: 0 2px 2px 0; }
.success { background: #dff0e4; border-left: 3px solid var(--green); padding: 8px 10px; font-size: 12px; color: #1d6b38; border-radius: 0 2px 2px 0; }

.event-log { font-family: var(--mono); font-size: 12px; max-height: 240px; overflow-y: auto; }
.event-log .row { display: grid; grid-template-columns: 70px 54px 1fr; gap: 8px; padding: 2px 4px; border-bottom: 1px solid var(--line); }
.event-log .row .sev { font-weight: 700; }
.event-log .sev.INFO { color: var(--ink-soft); }
.event-log .sev.ALARM { color: var(--red); }
.event-log .sev.WARN { color: var(--amber); }

.chart-wrap { position: relative; width: 100%; }
canvas { display: block; width: 100%; }

h1.page-title { font-size: 20px; margin: 4px 0 14px; color: var(--head); }
h1.page-title small { font-weight: 400; color: var(--ink-soft); font-size: 13px; }

code.inline { background: #e2e7ec; padding: 1px 5px; border-radius: 2px; font-family: var(--mono); font-size: 12px; }

/* documentation */
.doc { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 3px; padding: 18px 22px; }
.doc h2 { font-size: 16px; color: var(--head); border-bottom: 2px solid var(--line); padding-bottom: 4px; margin: 22px 0 10px; }
.doc h2:first-child { margin-top: 2px; }
.doc h3 { font-size: 14px; color: var(--blue-dark); margin: 16px 0 6px; }
.doc p { margin: 8px 0; }
.doc ul { margin: 8px 0; padding-left: 22px; }
.doc li { margin: 3px 0; }
.doc table.data { margin: 10px 0; }
.doc-code {
  background: #11202b; color: #d6f0ff; font-family: var(--mono); font-size: 12px;
  padding: 12px 14px; border-radius: 3px; overflow-x: auto; line-height: 1.4;
  border: 1px solid #0a141b;
}
.docmeta { margin-bottom: 12px; }
.doc-nav { list-style: none; margin: 0; padding: 0; }
.doc-nav li { margin: 2px 0; }
.doc-nav a { display: block; padding: 5px 8px; border-radius: 2px; font-size: 12.5px; }
.doc-nav a:hover { background: var(--panel-alt); text-decoration: none; }
.doc-nav a.active { background: var(--blue-soft); color: var(--blue-dark); font-weight: 600; }

/* qualification modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000; background: rgba(15,24,34,0.6);
  display: flex; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-left, 0px));
}
/* the author display:flex above would otherwise beat the UA [hidden] rule,
   leaving the modal permanently visible — this restores hide-on-hidden */
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 4px;
  max-width: 520px; width: 100%; box-shadow: 0 12px 40px rgba(0,0,0,0.35); }
.modal-head { background: var(--green); color: #fff; padding: 10px 14px; font-weight: 700;
  letter-spacing: 0.5px; border-radius: 3px 3px 0 0; }
.modal-body { padding: 14px; }
.modal-body p { margin: 8px 0; }
.flag-box { background: #11202b; color: #7dffa6; font-size: 16px; font-weight: 700;
  padding: 12px 14px; border-radius: 3px; border: 1px solid #0a141b; text-align: center;
  user-select: all; word-break: break-all; }
