:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1d2733;
  --muted: #5f6b7a;
  --border: #d3d9e0;
  --primary: #1f5fbf;
  --primary-text: #ffffff;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --notice-bg: #e8f1fd;
  --warning-bg: #fff4d6;
  --radius: 6px;
  --touch: 44px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--primary); }

/* Left sidebar; the groups are <details>, which needs no script (CSP). */
.layout { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  flex: 0 0 15rem;
  width: 15rem;
  height: 100vh;
  overflow-y: auto;
  padding: 8px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.brand { padding: 4px 12px; font-weight: 700; font-size: 1.25rem; text-decoration: none; }

.menu { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.menu a {
  display: flex;
  align-items: center;
  min-height: var(--touch);
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--text);
  text-align: left;
  text-decoration: none;
}
.menu a:hover { background: var(--bg); }
.menu a[aria-current="page"] { background: var(--notice-bg); color: var(--primary); font-weight: 600; }

.menu-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--touch);
  padding: 0 12px;
  border-radius: var(--radius);
  cursor: pointer;
  list-style: none;
}
.menu-group > summary::-webkit-details-marker { display: none; }
.menu-group > summary::after { content: "\25B8"; margin-left: 6px; color: var(--muted); }
.menu-group[open] > summary::after { content: "\25BE"; }
.menu-group > summary:hover { background: var(--bg); }
.menu-group > a { padding-left: 24px; }

/* A screen not yet validated by the lead in the running application. */
.unvalidated { color: var(--danger); font-weight: 700; margin-right: 4px; }

.account { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 8px 12px 0; border-top: 1px solid var(--border); }
.account form { margin: 0; }

.content { flex: 1; min-width: 0; max-width: 1100px; margin: 0 auto; padding: 16px; }

@media (max-width: 800px) {
  .layout { flex-direction: column; align-items: stretch; }
  .sidebar { position: static; flex-basis: auto; width: auto; height: auto; overflow-y: visible; border-right: 0; border-bottom: 1px solid var(--border); }
}

.public-main { padding: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.narrow { max-width: 420px; margin: 32px auto; }

label { display: block; margin: 12px 0 4px; font-weight: 600; }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  display: block;
  width: 100%;
  min-height: var(--touch);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

button {
  min-height: var(--touch);
  padding: 0 20px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--primary-text);
  font: inherit;
  cursor: pointer;
}

button.link {
  padding: 0 8px;
  border-color: transparent;
  background: none;
  color: var(--primary);
  text-decoration: underline;
}

form button[type="submit"]:not(.link) { margin-top: 16px; }

.error {
  margin: 12px 0;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--danger-bg);
  color: var(--danger);
}

.notice {
  margin: 12px 0;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--notice-bg);
}

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; }
th { font-weight: 600; background: var(--bg); }

.muted { color: var(--muted); }

/* Panel administracyjny */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 16px 0;
}
.page-head h1 { margin: 0; }

.stack > * + * { margin-top: 16px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.actions form { margin: 0; }
.actions button[type="submit"]:not(.link) { margin-top: 0; }

button.danger { border-color: var(--danger); background: var(--danger); }

.badge {
  display: inline-block;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-size: 0.875rem;
  font-weight: 400;
}
.badge.warn { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }

.checks { margin: 12px 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.checks legend { font-weight: 600; }
.check,
.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--touch);
  margin: 0;
  font-weight: 400;
}
.check input,
.checks input { width: 20px; height: 20px; }

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 16px;
  align-items: end;
}

.matrix th.area { background: var(--notice-bg); }
.matrix td.cell { text-align: center; }
.matrix button.toggle[type="submit"] { min-width: var(--touch); margin: 0; padding: 0 8px; }
.matrix button.toggle.off { border-color: var(--border); background: var(--surface); color: var(--muted); }
.mark { font-weight: 700; }
.htmx-error:empty { display: none; }
.error-inline { display: block; color: var(--danger); font-size: 0.875rem; }

.diff tr.changed td { background: var(--notice-bg); }
pre.value { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 0.875rem; }

.pager { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; }

.matrix select { min-height: var(--touch); }
.matrix td.cell form { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; margin: 0; }
.matrix td.cell button[type="submit"].link { margin-top: 0; }

/* Procesy */
.graph { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.graph-level { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.node {
  min-width: 140px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}
.node a { text-decoration: none; }
.st-ready, .st-in_progress { border-color: var(--primary); background: var(--notice-bg); font-weight: 600; }
.st-pending { color: var(--muted); }
.st-suspended { border-color: var(--danger); border-style: dashed; }
.st-completed { border-color: var(--border); }
.st-skipped, .st-cancelled, .st-completed, .st-manually_acknowledged { color: var(--muted); background: var(--bg); }
.history .return { border-left: 4px solid var(--danger); padding-left: 8px; }
.pre-line { white-space: pre-line; word-break: break-word; }
.thumb { max-width: 120px; max-height: 120px; }

/* Laboratory calculators: label on the left, input on the right, the error under the input */
.calc-form { max-width: 640px; margin: 16px 0; }
.calc-field {
  display: grid;
  grid-template-columns: 16rem 10rem;
  align-items: center;
  gap: 0 12px;
  margin-bottom: 12px;
}
.calc-field label { margin: 0; }
.calc-field .error-inline { grid-column: 2; }
@media (max-width: 800px) {
  .calc-field { grid-template-columns: 1fr; }
  .calc-field label { margin-bottom: 4px; }
  .calc-field .error-inline { grid-column: 1; }
}
.calc-result .warning {
  margin: 12px 0;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--warning-bg);
}
.density-chart { width: 100%; max-width: 640px; height: auto; }
.density-chart .axis { stroke: var(--text); }
.density-chart .grid { stroke: var(--border); }
.density-chart .tick { fill: var(--muted); font-size: 12px; }
.density-chart .curve { fill: none; stroke: var(--primary); stroke-width: 2; }
.density-chart .point { fill: var(--primary); }

/* Tablet calculators: measurement table, summary, mass uniformity and its chart */
.calc-table-form { max-width: none; }
.measure-table input { width: 6.5rem; min-height: var(--touch); }
.measure-table td.cell-disabled { background: var(--bg); }
.measure-table input:disabled { background: var(--border); border-color: var(--border); cursor: not-allowed; }
.verdict-pass { color: var(--text); font-weight: 700; }
.verdict-fail { color: var(--danger); font-weight: 700; }
tr.beyond-limit { background: var(--warning-bg); }
tr.beyond-double { background: var(--danger-bg); font-weight: 600; }
.mass-chart { width: 100%; max-width: 640px; height: auto; }
.mass-chart .axis { stroke: var(--text); }
.mass-chart .grid { stroke: var(--border); }
.mass-chart .tick { fill: var(--muted); font-size: 12px; }
.mass-chart .band { fill: var(--warning-bg); }
.mass-chart .limit { stroke: var(--danger); stroke-dasharray: 4 3; }
.mass-chart .mean { stroke: var(--primary); }
.mass-chart .point { fill: var(--primary); }
.mass-chart .point.beyond { fill: var(--danger); }
.mass-chart .point.beyond-double { stroke: var(--text); stroke-width: 2; }

.text-block-body { white-space: pre-line; }

/* Recipes: a hidden default button (Enter), the version screen with the tree of the package */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.recipe-layout { display: grid; grid-template-columns: 16rem minmax(0, 1fr); gap: 16px; align-items: start; }
.recipe-tree-list { list-style: none; margin: 0; padding: 0; }
.recipe-tree-list li { padding: 4px 0; }
.recipe-tree-list .depth-0 { padding-left: 0; }
.recipe-tree-list .depth-1 { padding-left: 16px; }
.recipe-tree-list .depth-2 { padding-left: 32px; }
.recipe-tree-list .depth-3 { padding-left: 48px; }
.recipe-tree-list .depth-4 { padding-left: 64px; }
.recipe-tree-list .depth-5 { padding-left: 80px; }
.recipe-tree-list a[aria-current="page"] { font-weight: 700; }
.recipe-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 12px; padding: 0; list-style: none; }
.recipe-tabs a { display: block; padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-decoration: none; }
.recipe-tabs a[aria-current="page"] { border-color: var(--primary); background: var(--notice-bg); font-weight: 600; }
.recipe-main .card { margin-bottom: 16px; }
.findings ul { margin: 4px 0 12px; padding-left: 20px; }
.finding-blocking { color: var(--danger); font-weight: 600; }
.finding-warning { font-weight: 600; }
.recipe-edit summary { cursor: pointer; color: var(--primary); }
.repins { background: var(--warning-bg); margin-bottom: 16px; }
.search-form { margin-bottom: 12px; }
@media (max-width: 800px) {
  .recipe-layout { grid-template-columns: 1fr; }
}
