:root {
  --bg: #f5f6f8;
  --card: #fff;
  --text: #1c2430;
  --muted: #667085;
  --border: #d9dde3;
  --accent: #1f5fbf;
  --danger: #b42318;
  --ok: #1a7f4b;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, sans-serif; background: var(--bg); color: var(--text); }
header { background: #162033; color: #fff; padding: 0 24px; display: flex; align-items: center; gap: 24px; height: 52px; }
header .brand { display: flex; align-items: center; }
header .brand img { display: block; }
header a { color: #cfd8e6; text-decoration: none; }
header a:hover { color: #fff; }
header .spacer { flex: 1; }
header form { margin: 0; }
main { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
a { color: var(--accent); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 18px; margin-bottom: 20px; overflow-x: auto; }
.narrow { max-width: 380px; margin: 80px auto; }
.form-card { max-width: 420px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], select { width: 100%; background: #fff; color: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 160px; }
.field { margin-bottom: 12px; }
button { padding: 8px 14px; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 6px; font: inherit; cursor: pointer; }
button.secondary { background: #fff; color: var(--text); border-color: var(--border); }
button.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: 0; color: #cfd8e6; padding: 0; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #e7eaef; color: var(--muted); }
.badge.ok { background: #dcf3e6; color: var(--ok); }
.badge.bad { background: #fde4e1; color: var(--danger); }
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; background: #fde4e1; color: var(--danger); }
.alert.ok { background: #dcf3e6; color: var(--ok); }
.token { border: 2px solid var(--ok); }
.token code { display: block; padding: 12px; background: #f0f2f5; border-radius: 6px; font-size: 15px; word-break: break-all; white-space: normal; user-select: all; }
.muted { color: var(--muted); }
code { font-family: ui-monospace, Consolas, monospace; }

/* analysis */
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.stats { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; min-width: 130px; }
.stat .value { font-size: 22px; font-weight: 600; }
.stat .name { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.note { color: var(--muted); font-size: 13px; white-space: normal; max-width: 80ch; }
.badge.warn { background: #fdf0d0; color: #8a5a00; }
.inline { display: inline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
h1 .badge { vertical-align: middle; font-weight: 400; }
tr.out td { background: #fdf3f2; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #e7eaef; stroke-width: 1; }
.chart .axis { stroke: #898781; stroke-width: 1; }
.chart .tick, .chart .label, .chart .ref-label { font-size: 11px; fill: #52514e; }
.chart .label { font-size: 12px; }
.chart .bar { fill: #2a78d6; }
.chart .line { fill: none; stroke: #2a78d6; stroke-width: 2; stroke-linejoin: round; }
.chart .line.thin { stroke-width: 1; stroke: #86b6ef; }
.chart .mark { fill: #2a78d6; stroke: #fff; stroke-width: 2; }
.chart .mark-out { fill: #d03b3b; stroke: #fff; stroke-width: 2; }
.chart .ref-mean { stroke: #52514e; stroke-width: 1; }
.chart .ref-control { stroke: #898781; stroke-width: 1; stroke-dasharray: 2 4; }
.chart .ref-spec { stroke: #d03b3b; stroke-width: 1.5; stroke-dasharray: 7 4; }
.chart a:hover .mark, .chart a:hover .mark-out, .chart .bar:hover { opacity: .7; }
.chart .mark-defect { fill: #52514e; stroke: #fff; stroke-width: 2; }
.chart .mark-small { fill: #2a78d6; fill-opacity: .55; }
.chart .group-mean { stroke: #0b0b0b; stroke-width: 2.5; stroke-linecap: round; }
.chart .ref-trend { stroke: #0b0b0b; stroke-width: 1.5; }
.chart .cell { stroke: none; }
.chart a:hover .mark-defect, .chart a:hover .cell { opacity: .7; }

/* navigation inside a section, filters, small forms */
.subnav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.subnav a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); text-decoration: none; color: var(--text); }
.subnav a:hover, .subnav a.current { border-color: var(--accent); color: var(--accent); }
.filters > div { min-width: 150px; }
.inline-form { display: flex; gap: 6px; align-items: center; margin: 0; }
.inline-form select, .inline-form input { width: auto; min-width: 110px; }
td form { margin: 0; }
.button-link { padding: 8px 4px; }
label.check { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; margin: 0; }
table.wrap td { white-space: normal; }
.pager { margin: 12px 0 0; }
header .badge { background: #2b3a55; color: #cfd8e6; }
.clip { display: inline-block; max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* sub points of a navigation entry; opens on hover and on keyboard focus (no JavaScript) */
header .menu { position: relative; height: 100%; display: flex; align-items: center; }
header .submenu { display: none; position: absolute; top: 100%; left: -16px; min-width: 170px; padding: 6px 0; background: #162033; border-radius: 0 0 8px 8px; box-shadow: 0 6px 14px rgba(0, 0, 0, .25); z-index: 10; }
header .menu:hover .submenu, header .menu:focus-within .submenu { display: block; }
header .submenu a { display: block; padding: 8px 16px; white-space: nowrap; }
header .submenu a:hover, header .submenu a:focus { background: #22304a; }

details > summary { cursor: pointer; font-weight: 600; font-size: 17px; }
details[open] > summary { margin-bottom: 14px; }
textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: 14px/1.5 ui-monospace, Consolas, monospace; resize: vertical; }

/* a link that sits next to buttons and should look like one */
a.button { display: inline-block; padding: 8px 14px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); text-decoration: none; line-height: inherit; }
a.button:hover { border-color: var(--accent); color: var(--accent); }
.actions { align-items: center; }
.actions form { margin: 0; }

/* links that leave the admin panel open in a new tab and say so */
a.external::after { content: " \2197"; font-size: .85em; }
header .menu > a.external::after { content: " \2197  \25BE"; font-size: inherit; }

/* a dropdown with a "+" that opens a small panel for adding an entry */
.with-add { display: flex; gap: 6px; align-items: stretch; }
.with-add select { flex: 1; min-width: 0; }
details.add { position: relative; }
details.add > summary { list-style: none; display: flex; align-items: center; justify-content: center; height: 100%; min-width: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: 20px; font-weight: 400; line-height: 1; margin: 0; }
details.add > summary::-webkit-details-marker { display: none; }
details.add > summary:hover, details.add[open] > summary { border-color: var(--accent); color: var(--accent); }
details.add .popover { position: absolute; top: calc(100% + 6px); right: 0; z-index: 5; width: 260px; padding: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px rgba(0, 0, 0, .15); }
details.add .popover input { margin-bottom: 8px; }
/* a card whose "+" panel may reach beyond its border */
.card.popovers { overflow: visible; }

/* pop-up window (HTML popover: opens and closes without JavaScript, Esc closes it too) */
.popup { width: min(920px, 94vw); max-height: 90vh; overflow: auto; padding: 20px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); box-shadow: 0 16px 48px rgba(0, 0, 0, .3); }
.popup::backdrop { background: rgba(22, 32, 51, .45); }
.popup-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.popup-head h2 { margin: 0; }
button.close { padding: 2px 11px; font-size: 20px; line-height: 1.3; }

/* small icon button in the top right corner of a card */
.card-tools { display: flex; justify-content: flex-end; margin: -6px -6px 4px 0; }
button.icon { padding: 2px 8px; font-size: 18px; line-height: 1.3; color: var(--muted); }
button.icon:hover { color: var(--accent); border-color: var(--accent); }
/* inline-block children do not inherit the underline of their link */
a .clip { text-decoration: underline; }

.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.login-brand h1 { margin: 0; line-height: 1.25; }
