:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --danger: #b91c1c;
  --warning: #a16207;
  --radius: 8px;
  --sidebar-width: 240px;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

.container.narrow {
  max-width: 480px;
  margin: 0 auto;
}

.card {
  max-width: 720px;
  width: 100%;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
  padding: 32px;
}

.card.wide {
  max-width: 1200px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #3b82f6;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0 0 16px;
  font-size: 2rem;
}

h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.2rem;
}

p {
  margin: 0;
  line-height: 1.6;
}

form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  align-items: end;
  gap: 12px;
  margin: 20px 0;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 600;
}

input,
select,
textarea {
  box-sizing: border-box;
  max-width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
}

textarea {
  resize: vertical;
}

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: #2563eb;
  color: white;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
}

button.secondary, .button.secondary {
  background: #e5e7eb;
  color: #111827;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  color: #1f2937;
  text-decoration: none;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 12px;
  background: #f9fafb;
}

/* A row of buttons and links that never overlap (header actions, user menu). */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.toolbar form {
  flex-direction: row;
}

.page-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.page-navigation a {
  color: #1f2937;
  text-decoration: none;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 12px;
  background: #f9fafb;
}

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.issue-error {
  color: #b91c1c;
  font-weight: 700;
}

.issue-warning {
  color: #a16207;
  font-weight: 700;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.honeypot {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

a.stat-box {
  color: inherit;
  text-decoration: none;
}

a.stat-box:hover {
  border-color: #93c5fd;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.stat-box {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-box span {
  font-size: 0.8rem;
  color: #6b7280;
}

.stat-box strong {
  font-size: 1.1rem;
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin: 24px 0;
}

.nav-card {
  display: block;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
  text-decoration: none;
  color: #1d4ed8;
  font-weight: 700;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.panel {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 18px;
  background: #f9fafb;
}

.list {
  padding-left: 18px;
  margin: 0;
  line-height: 1.8;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 18px;
}

.table th,
.table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.94rem;
  vertical-align: top;
}

.table th {
  background: #f3f4f6;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 22px 0;
}

h3 {
  margin: 16px 0 8px;
  font-size: 1rem;
}

small {
  color: #6b7280;
  font-weight: 400;
}

.table td form {
  gap: 8px;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  padding: 16px;
  font-size: 0.85rem;
  color: #6b7280;
}

.site-footer a {
  color: #4b5563;
}

.matrix td,
.matrix th {
  text-align: center;
  white-space: nowrap;
}

.matrix td:first-child,
.matrix th:first-child {
  text-align: left;
}

.cell-valid { background: #dcfce7; }
.cell-expiring { background: #fef3c7; }
.cell-expired, .cell-missing.required { background: #fee2e2; }

fieldset {
  border: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

label.checkbox-label {
  flex-direction: row;
  align-items: flex-start;
  font-weight: 400;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap;
}

.tabs a {
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  color: #1f2937;
  text-decoration: none;
}

.tabs a.active {
  background: #1f2937;
  color: white;
  border-color: #1f2937;
}

.inline-upload {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.inline-upload input[type="text"] {
  flex: 1 1 160px;
}

.inline-form {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

button.link-button {
  background: none;
  color: #b91c1c;
  padding: 0;
  font-size: 0.9rem;
  font-weight: 400;
  text-decoration: underline;
}

.muted {
  color: #6b7280;
}

.group-row td {
  background: #eef2f7;
  font-weight: 700;
}

/* Status and deadline colours: the only colour coding in the interface. */
.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-active,
.status-completed,
.status-closed,
.status-in_use {
  background: #dcfce7;
  color: #166534;
}

/* Not started yet: neutral. In work: yellow. Done/valid: green. Late: red. */
.status-open,
.status-in_progress,
.status-in_repair,
.status-warning {
  background: #fef3c7;
  color: #92400e;
}

.status-draft,
.status-planned,
.status-withdrawn,
.status-retired,
.status-blocked {
  background: #e5e7eb;
  color: #374151;
}

.status-overdue {
  background: #fee2e2;
  color: #991b1b;
}

.deadline-expired {
  color: #b91c1c;
  font-weight: 700;
}

.deadline-soon {
  color: #a16207;
  font-weight: 700;
}

.stat-box.stat-error strong {
  color: #b91c1c;
}

.stat-box.stat-warning strong {
  color: #a16207;
}

@media (max-width: 900px) {
  .container {
    padding: 12px;
  }

  .card {
    padding: 18px;
  }

  h1 {
    font-size: 1.5rem;
  }

  /* minmax(0, …): a column must not grow to the widest option of a select. */
  .stats,
  .filters,
  .two-column {
    grid-template-columns: minmax(0, 1fr);
  }

  label {
    min-width: 0;
  }

  .nav-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    flex-wrap: wrap;
  }

  /* Wide registers scroll sideways instead of breaking the page. */
  .table {
    display: block;
    overflow-x: auto;
  }
}

.cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  z-index: 10;
}

.cookie-banner[hidden] {
  display: none;
}

.legal h2 {
  margin-top: 24px;
}

/* ---------- Application shell: left menu, header, full-width content ---------- */
body.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  box-sizing: border-box;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: block;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
  text-decoration: none;
  padding: 4px 10px 12px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}

.nav-group-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 4px 10px;
}

.nav-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
}

.nav-link:hover {
  background: var(--bg);
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.nav-count {
  background: var(--danger);
  color: white;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 1px 7px;
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.appbar-org {
  color: var(--muted);
  font-size: 0.9rem;
}

.menu-toggle {
  display: none;
}

.content {
  flex: 1 1 auto;
  padding: 24px;
  background: var(--surface);
  margin: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 0;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.page-head h1 {
  margin-bottom: 0;
  font-size: 1.6rem;
}

.eyebrow:empty {
  display: none;
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.2);
  }

  body.menu-open .sidebar {
    transform: none;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .content {
    margin: 8px;
    padding: 16px;
  }

  .page-head {
    flex-wrap: wrap;
  }
}

/* Buttons keep their natural width instead of stretching across a form. */
form > button,
fieldset > button {
  align-self: flex-start;
}

/* Secondary actions inside tables and inline forms stay quiet; one blue button per screen. */
.table button,
.table .button,
.inline-form button,
.button.small,
button.small {
  padding: 5px 10px;
  font-size: 0.88rem;
}

.table select,
.table input,
.inline-form select,
.inline-form input {
  padding: 5px 8px;
  font-size: 0.9rem;
}

.row-action,
.nowrap {
  white-space: nowrap;
}

.row-action {
  text-align: right;
}

.count-badge {
  display: inline-block;
  min-width: 1.4em;
  padding: 1px 8px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-size: 0.8rem;
  text-align: center;
  vertical-align: middle;
}

.count-badge.calm {
  background: var(--border-strong);
  color: var(--text);
}

/* ---------- Today page ---------- */
.first-steps {
  border: 1px solid #bfdbfe;
  background: var(--primary-soft);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 20px;
}

.first-steps ol {
  margin: 8px 0 0;
  padding-left: 22px;
  line-height: 1.9;
}

.first-steps li.done,
.first-steps li.done a {
  color: var(--muted);
  text-decoration: line-through;
}

.stats.compact {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.stats.compact .stat-box {
  padding: 10px 12px;
}

/* ---------- Forms: collapsed optional fields, checkbox lists, inline errors ---------- */
details > summary {
  cursor: pointer;
  font-weight: 600;
  margin: 8px 0;
}

.details-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 0 4px 14px;
  border-left: 3px solid var(--border);
}

.checklist {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  max-height: 220px;
  overflow-y: auto;
  padding: 6px 10px;
  font-weight: 400;
  background: var(--surface);
}

.checklist label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  padding: 3px 0;
}

.checklist-filter {
  width: 100%;
  font-weight: 400;
}

.form-error {
  margin-bottom: 0;
}
/* Sections of a page breathe: a heading after a table or form starts a new block. */
.content h2 {
  margin-top: 28px;
}

.content .page-head + h2 {
  margin-top: 8px;
}

.field-hint {
  display: block;
  margin-top: 4px;
  max-width: 260px;
}
.filters > button {
  justify-self: start;
}

@media (max-width: 700px) {
  /* Narrow screens: action buttons wrap their label instead of being cut off. */
  .row-action {
    white-space: normal;
  }

  .row-action .button {
    white-space: normal;
    text-align: center;
  }
}
.two-column > section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.two-column > section > h3 {
  margin: 0;
}