:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #d8dee4;
  --ok: #2e7d32;
  --warn: #e2001a;
  --accent: #e2001a; /* FEUERCON red */
  --navy: #0e1e36;   /* FEUERCON dark navy */
  --sky: #1890d7;    /* FEUERCON light blue */
  --ink: #1b2733;
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute must always win over layout `display` rules
   (e.g. `.login-screen { display: flex }`), otherwise the login screen
   can never be hidden after a successful login. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Poppins", "Lato", system-ui, Arial, sans-serif;
  background: var(--bg);
  color: #222;
  font-size: 16px;
}

#app {
  width: 100%;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 4rem);
}

header {
  background: #fff;
  color: var(--ink);
  padding: 1.25rem clamp(1rem, 3vw, 4rem);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  border-bottom: 4px solid var(--accent);
}

.header-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-right: auto;
}

.header-subtitle {
  margin: 0;
  font-size: 1rem;
  color: #5b6673;
}

h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.1;
  color: var(--navy);
}

.main-nav {
  display: flex;
  gap: 0.5rem;
}

.main-nav a {
  color: var(--navy);
  text-decoration: none;
  padding: 0.35rem 0.9rem;
  border-radius: 4px;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 600;
}

.main-nav a:hover {
  background: #eef1f5;
}

.main-nav a.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 1.25rem clamp(1rem, 3vw, 4rem);
  margin-top: 2rem;
  background: var(--navy);
  border-top: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.9rem;
}

.footer-sep {
  color: rgba(255, 255, 255, 0.4);
}

.inventory-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1rem;
  margin-top: 0.5rem;
}

.inventory-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.95rem;
  gap: 0.3rem;
}

.inventory-form .hint,
.inventory-form button[type="submit"] {
  grid-column: 1 / -1;
}

.inventory-form button[type="submit"] {
  justify-self: start;
}

.hint {
  font-size: 0.9rem;
  color: #555;
}

.field-hint {
  font-size: 0.8rem;
  color: #777;
}

.de-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.4rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: #f59e0b;
  border-radius: 999px;
  vertical-align: middle;
}

.inv-checkbox {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.inv-checkbox input,
.inv-edit-checkbox input {
  width: auto;
  margin: 0;
}

.inv-edit-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 1rem;
  font-weight: 700;
  color: #555;
}

.page[hidden] {
  display: none;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(360px, 28%) minmax(0, 1fr);
  gap: clamp(1.25rem, 2vw, 2.5rem);
  align-items: start;
  padding: clamp(1.25rem, 2vw, 2rem) 0;
}

/* Very high-resolution screens: give the sidebar more room and add a
   3rd column to the report form so fields aren't stretched too wide. */
@media (min-width: 2200px) {
  .split-layout {
    grid-template-columns: minmax(420px, 22%) minmax(0, 1fr);
  }
  #fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.split-side {
  position: sticky;
  top: 1.5rem;
  min-width: 0;
}

.split-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.saved-group h3 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.saved-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1.1rem;
  background: #fff;
  font-size: 1rem;
}

.saved-row-main {
  display: grid;
  grid-template-columns: 110px 120px 10rem 1.2fr 1.5fr 1fr auto;
  align-items: center;
  gap: 1.25rem;
  flex: 1;
  min-width: 0;
}

.fuell-row-main {
  grid-template-columns: 1.2fr 1fr 14rem 1fr 1fr;
}

.inv-row-main {
  grid-template-columns: 85px 140px minmax(0, 1fr) 100px 140px 140px 110px 140px 120px 48px minmax(0, 1fr);
  gap: 0.75rem;
}

.search-main {
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
}

/* Multi-select checkboxes (ZIP download) + header spacer for alignment. */
.zip-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.report-check {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  flex: none;
  cursor: pointer;
  accent-color: var(--accent);
}

.header-check-spacer {
  width: 1.1rem;
  flex: none;
}

/* Header labels for the Reports page saved lists. Mirrors a saved row
   (flex: grid + hidden spacer button) so the labels line up with the columns. */
.report-list-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.25rem 1.1rem 0.6rem;
}

.report-list-header-grid {
  display: grid;
  grid-template-columns: 110px 120px 10rem 1.2fr 1.5fr 1fr auto;
  align-items: center;
  gap: 1.25rem;
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: #5b6673;
}

.report-list-header-grid span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fuell-cols {
  grid-template-columns: 1.2fr 1fr 14rem 1fr 1fr;
}

.inventory-cols {
  grid-template-columns: 85px 140px minmax(0, 1fr) 100px 140px 140px 110px 140px 120px 48px minmax(0, 1fr);
  gap: 0.75rem;
}

.report-list-header-grid .inv-sortable {
  cursor: pointer;
  user-select: none;
}

.report-list-header-grid .inv-sortable:hover {
  color: var(--accent);
}

.report-list-header-grid .inv-sortable.sorted-asc::after {
  content: " ▲";
}

.report-list-header-grid .inv-sortable.sorted-desc::after {
  content: " ▼";
}

.inventory-table-scroll {
  overflow-x: auto;
}

.search-cols {
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
}

.users-cols,
.users-main {
  grid-template-columns: 11rem minmax(240px, 320px) 110px;
}

.user-name-line {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}

.user-name-line .user-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-username {
  color: #777;
  font-weight: 400;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-locked-badge {
  align-self: flex-start;
  background: #fdecef;
  color: var(--warn);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.compressor-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.compressor-date {
  font-weight: 600;
}

.compressor-date.invalid {
  color: var(--warn);
}

.dot.gray {
  background: #b0bec5;
}

.users-edit-row {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
  border-radius: 6px;
  padding: 1.1rem 1.4rem;
  background: var(--panel);
}

.users-edit-head {
  min-width: 0;
}

.users-edit-label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #555;
}

.users-edit-label input {
  width: 100%;
  max-width: 20rem;
  font-size: 1.15rem;
  padding: 0.7rem 0.85rem;
}

.users-edit-row .row-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.users-edit-row .row-actions button {
  margin: 0;
}

.users-save {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.users-cancel {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.users-edit-status {
  margin: 0;
  padding-left: 0.15rem;
}

/* Admin user management (create user + role/password/delete). */
.admin-user-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin: 0 0 1.25rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}

.admin-user-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #555;
}

.admin-user-form input,
.admin-user-form select {
  width: 100%;
  max-width: 100%;
  font-size: 1.05rem;
  padding: 0.75rem 0.85rem;
}

.admin-user-form button {
  margin: 0;
  align-self: flex-start;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.admin-user-form .status {
  margin: 0;
}

/* Role documentation panel. */
.roles-doc-panel h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
}

.roles-doc-panel .hint {
  margin: 0 0 0.9rem;
}

.roles-doc {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.roles-doc-item {
  margin: 0;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.roles-doc-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.roles-doc-item dt {
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 0.25rem;
}

.roles-doc-item dd {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #555;
}

.admin-users-cols,
.admin-users-main {
  grid-template-columns: 1.2fr 0.9fr 1.5fr;
}

.admin-role-cell {
  display: flex;
  align-items: center;
  min-width: 0;
}

.admin-role-select {
  width: 100%;
  max-width: 100%;
  font-size: 0.95rem;
  padding: 0.5rem 0.6rem;
}

.admin-compressor-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.admin-compressor-input {
  width: 100%;
  max-width: 11rem;
  font-size: 0.95rem;
  padding: 0.5rem 0.6rem;
}

.changelog-action {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.changelog-action.created {
  background: #e6f4ea;
  color: var(--ok);
}

.changelog-action.updated {
  background: #e8f3fb;
  color: #1890d7;
}

.changelog-action.deleted {
  background: #fdecef;
  color: var(--warn);
}

.changelog-table-wrap {
  overflow-x: auto;
  margin-top: 0.25rem;
}

.changelog-table {
  min-width: 42rem;
  margin-top: 0.5rem;
}

.changelog-table th {
  font-size: 0.75rem;
  font-weight: 700;
  color: #5b6673;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.changelog-table td {
  font-size: 0.95rem;
  white-space: nowrap;
  vertical-align: middle;
}

.changelog-table .changelog-date {
  color: #666;
}

.changelog-table .changelog-actor {
  font-weight: 600;
}

.changelog-table .changelog-num {
  font-weight: 600;
}

.changelog-table td.empty {
  color: #777;
  font-style: italic;
}

/* The Change Log page has no left sidebar, so its content should span the
   full width instead of being squeezed into the narrow sidebar column. */
#page-changelog .split-layout {
  grid-template-columns: minmax(0, 1fr);
}

/* The Interspiro page has no sidebar – use the full page width. */
#page-interspiro .split-layout {
  grid-template-columns: minmax(0, 1fr);
}

/* The Search page also has no sidebar. */
#page-search .split-layout {
  grid-template-columns: minmax(0, 1fr);
}

/* The Profile page is a single centered column. */
#page-profile .split-layout {
  grid-template-columns: minmax(0, 1fr);
  justify-content: center;
}

.profile-panel {
  max-width: 32rem;
  margin: 0 auto;
}

.profile-form {
  margin-top: 0.25rem;
}

.profile-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.profile-subhead {
  margin: 1.5rem 0 0;
  font-size: 1rem;
  color: var(--navy);
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.compressor-display {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.compressor-display input {
  flex: 1;
}

.compressor-display .dot {
  flex-shrink: 0;
}

/* Viewers have no create/edit sidebar, so their lists span the full width. */
body.is-viewer .split-layout {
  grid-template-columns: minmax(0, 1fr);
}

.header-spacer {
  visibility: hidden;
  pointer-events: none;
}

/* Action buttons that sit beside the grid in a saved row (Edit/Delete). */
.row-actions {
  display: flex;
  gap: 0.5rem;
}

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

button.link.danger-link:hover {
  background: #fdecef;
}

.saved-row-cat {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-row-num {
  font-weight: 700;
  font-size: 1.15rem;
}

.saved-row-num.compressor-num {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-row-abbr {
  font-weight: 700;
  color: #444;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-row-field {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expiry {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot.green {
  background: var(--ok);
}

.dot.yellow {
  background: #f9a825;
}

.dot.red {
  background: var(--warn);
}

.saved-row-name {
  font-weight: 600;
}

.saved-row-de {
  justify-self: center;
}

.saved-row-de .de-badge {
  margin-left: 0;
}

.saved-row-reason,
.saved-row-created {
  color: #666;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-detail {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 0.75rem 1rem 1rem;
  background: #fafbfc;
}

.inventory-add {
  position: sticky;
  top: 1.5rem;
}

.inv-new-btn {
  width: 100%;
  margin: 0;
}

/* Title row inside a saved-group panel: heading + filters + refresh. */
.saved-group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.saved-group-head h3 {
  margin: 0;
}

/* Keep the Füllprotokoll list controls (filters + ZIP + refresh) on a single
   line, vertically centered, instead of wrapping onto multiple rows. */
#page-fuell .saved-group-head {
  flex-wrap: nowrap;
  align-items: center;
}

#page-fuell .saved-group-head .inv-filters {
  flex: none;
}

/* Uniform height so the filter pills, ZIP button and refresh button line up. */
#page-fuell .saved-group-head .inv-filter,
#page-fuell .saved-group-head button.link,
#page-fuell .saved-group-head button.ghost {
  height: 2.1rem;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 0.9rem;
  box-sizing: border-box;
}

/* Per-category column headers (mirror the per-category row grid). */
.inventory-group-cols {
  display: grid;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: #5b6673;
}

.inventory-group-cols span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inventory-group-cols .inv-sortable {
  cursor: pointer;
  user-select: none;
}

.inventory-group-cols .inv-sortable:hover {
  color: var(--accent);
}

.inventory-group-cols .inv-sortable.sorted-asc::after {
  content: " ▲";
}

.inventory-group-cols .inv-sortable.sorted-desc::after {
  content: " ▼";
}

[data-theme="dark"] .inventory-group-cols {
  color: #8b97a5;
}

.interspiro-gallery {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
}

.interspiro-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.interspiro-thumb {
  height: 200px;
  overflow: hidden;
  background: #eef1f5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.interspiro-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.interspiro-no-thumb {
  font-size: 2rem;
  font-weight: 700;
  color: #5b6673;
}

.interspiro-info {
  padding: 0.6rem 0.75rem;
  flex: 1;
}

.interspiro-name {
  margin: 0;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.interspiro-size {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: #777;
}

.interspiro-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
}

.interspiro-dl {
  flex: 1;
  text-align: center;
  padding: 0.35rem 0.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  margin: 0;
}

.interspiro-del {
  background: transparent;
  color: var(--warn);
  border: 1px solid var(--warn);
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
  margin: 0;
}

[data-theme="dark"] .interspiro-no-thumb {
  color: #8b97a5;
}

[data-theme="dark"] .interspiro-thumb {
  background: #151a21;
}

.inv-filters {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
}

/* Date search row on the Search page. */
.search-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.search-date-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}

.search-date-label input {
  width: auto;
  min-width: 12rem;
}

.search-bar .ghost {
  margin: 0;
}

.inv-filter {
  border: 1px solid var(--border);
  background: #fff;
  color: #444;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
}

.inv-filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

button.ghost {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--navy);
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
}

.inv-row {
  position: relative;
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1.8fr) auto;
  align-items: center;
  gap: 1rem 0.5rem;
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
  border-radius: 6px;
  padding: 0.2rem 0.2rem;
  background: #fff;
  font-size: 1rem;
}

.inv-row.cat-mask { border-left-color: #e2001a; }
.inv-row.cat-regulator { border-left-color: #0e1e36; }
.inv-row.cat-equipment { border-left-color: #1890d7; }

.inv-badge {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--accent);
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  justify-self: start;
}

.inv-row.cat-mask .inv-badge { background: #e2001a; }
.inv-row.cat-regulator .inv-badge { background: #0e1e36; }
.inv-row.cat-equipment .inv-badge { background: #1890d7; }

.inv-edit-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

.inv-edit-fields-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 0.6rem 0.8rem;
  min-width: max-content;
}

.inv-edit-row .inv-badge {
  flex: 0 0 auto;
  align-self: center;
}

.inv-edit-row .inv-edit-checkbox {
  flex: 0 0 auto;
  align-self: center;
}

.inv-edit-row input[type="text"] {
  height: 2.1rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.95rem;
}

.inv-edit-row .inv-edit-number {
  width: 5rem;
  flex: 0 0 auto;
}

.inv-edit-row .inv-edit-name {
  flex: 0 0 12rem;
}

.inv-edit-row .inv-edit-notes {
  flex: 0 0 14rem;
}

.inv-edit-field {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
}

.inv-edit-field input[type="text"] {
  width: 9rem;
}

.inv-edit-field select {
  width: 9rem;
  height: 2.1rem;
  padding: 0.4rem 0.6rem;
  padding-right: 1.6rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.95rem;
  background-color: #fff;
  color: #222;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23777'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 0.6rem;
}

.inv-edit-row .inv-edit-status {
  margin: 0;
}

.empty {
  color: #777;
  font-style: italic;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.25rem;
}

.pager-label {
  font-size: 0.9rem;
  color: #555;
}

main {
  display: block;
  padding: 0;
}

/* Tablet / small laptops: stack the sidebar above the list. */
@media (max-width: 1100px) {
  .split-layout {
    grid-template-columns: 1fr;
  }
  .split-side {
    position: static;
  }
}

/* Phones: collapse the fixed grid rows into stacked, labeled blocks. */
@media (max-width: 640px) {
  #fields {
    grid-template-columns: 1fr;
  }
  .inline-edit-fields {
    grid-template-columns: 1fr;
  }
  .inventory-form {
    grid-template-columns: 1fr;
  }
  .saved-row-main,
  .fuell-row-main,
  .inv-row-main,
  .search-main,
  .report-list-header-grid,
  .fuell-cols,
  .inventory-cols,
  .search-cols,
  .users-cols,
  .users-main {
    grid-template-columns: 1fr 1fr;
  }
  .saved-row-created {
    margin-left: 0;
  }
  .inv-filters {
    margin-left: 0;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem 1.75rem;
}

label {
  display: block;
  margin: 0.75rem 0 0.25rem;
  font-weight: 600;
}

input,
select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  background: #fff;
  color: #222;
}

input[readonly] {
  background: #f0f2f5;
  color: #555;
  cursor: default;
}

/* Hide the native number-input spinners (the +/- inside the field). The
   custom ▲/▼ stepper buttons stay available next to the field. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Up/down (▲/▼) stepper for numeric fields */
.stepper {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.stepper input {
  flex: 1;
  min-width: 0;
  width: auto;
}

.step-btn {
  margin: 0;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--navy);
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.step-btn:hover {
  background: #eef1f5;
}

/* Ja/Nein radio buttons for select fields. */
.yesno-group {
  display: flex;
  gap: 1.25rem;
  padding: 0.35rem 0;
}

.yesno-option {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-weight: 500;
  cursor: pointer;
}

.yesno-option input[type="radio"] {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.yesno-option span {
  line-height: 1;
}

/* Bottle number picker: inventory dropdown + manual entry (mutually exclusive). */
.bottle-number-control {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.bottle-or {
  font-size: 0.8rem;
  font-weight: 600;
  color: #5b6673;
  text-align: center;
}

[data-theme="dark"] .bottle-or {
  color: #8b97a5;
}

#fields select[data-inventory-select="true"] {
  width: auto;
  max-width: 100%;
  font-size: 0.92rem;
  padding: 0.2rem 0.6rem;
  line-height: 1.3;
}

button {
  margin-top: 1rem;
  padding: 0.65rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
}

button:hover {
  opacity: 0.9;
}

#fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 1rem;
  margin-top: 0.5rem;
}

.field-row {
  margin: 0;
}

#fields .limit-hint {
  grid-column: 1 / -1;
}

.field-row.out-of-limits input {
  border-color: var(--warn);
  background: #fff0f0;
}

.field-row.missing input {
  border-color: #b0bec5;
}

.limit-hint {
  font-size: 0.8rem;
  color: #666;
  margin: 0.15rem 0 0;
}

.status {
  font-weight: 700;
}

.status.ok {
  color: var(--ok);
}

.status.out-of-limits,
.status.missing {
  color: var(--warn);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

th,
td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.result-badge {
  font-weight: 700;
}

.result-badge.ok {
  color: var(--ok);
}

.result-badge.fail {
  color: var(--warn);
}

button.link {
  margin: 0;
  padding: 0.3rem 0.6rem;
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--border);
}

button.link:hover {
  background: #eef1f5;
  opacity: 1;
}

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

button:disabled {
  background: #b0bec5;
  cursor: not-allowed;
  opacity: 0.6;
}

button:disabled:hover {
  opacity: 0.6;
}

.detail {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

#detailMeta {
  color: #555;
  font-size: 0.9rem;
}

.logo {
  display: block;
  margin: 0 auto 1rem;
}

.header-logo {
  margin: 0;
  height: 44px;
  width: auto;
}

.new-report-panel {
  min-width: 0;
}

/* ---------------------------------------------------------------------------
   Dichtprüfung timer (60 s) in the new report form
   --------------------------------------------------------------------------- */
.report-timer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
  border-radius: 6px;
  background: #f8fafc;
}

.timer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.timer-label {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--navy);
}

.timer-state {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5b6673;
}

.report-timer[data-state="running"] .timer-state {
  color: var(--accent);
}

.report-timer[data-state="finished"] .timer-state {
  color: var(--ok);
}

.timer-display {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

#timerValue {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.report-timer[data-state="finished"] #timerValue {
  color: var(--ok);
}

.timer-unit {
  font-size: 1.1rem;
  font-weight: 600;
  color: #777;
}

.timer-bar {
  height: 8px;
  border-radius: 999px;
  background: #e6eaf0;
  overflow: hidden;
}

.timer-bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 1s linear, background 0.3s;
}

.timer-bar-fill.timer-low {
  background: var(--warn);
}

.timer-actions {
  display: flex;
  gap: 0.5rem;
}

.timer-actions button {
  margin: 0;
}

.detail-row td {
  padding: 0;
  border-bottom: 1px solid var(--border);
}

.detail-inline {
  padding: 1rem;
  background: #f8fafc;
  border-top: 2px solid var(--accent);
}

.detail-meta {
  color: #555;
  font-size: 0.9rem;
  margin: 0 0 0.75rem;
}

.detail-inline table {
  margin-bottom: 0.75rem;
}

.detail-actions {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
}

.detail-actions button {
  margin-top: 0;
}

.detail-actions button.link {
  padding-top: 0.59rem;
  padding-bottom: 0.59rem;
}

.inline-edit-slot {
  margin: 0 0 0.75rem;
}

.inline-edit-form {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  background: #fff;
}

.inline-edit-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 1rem;
}

.inline-edit-fields .status {
  display: none;
}

.inline-edit-fields select[data-inventory-select="true"] {
  width: auto;
  max-width: 100%;
  font-size: 0.92rem;
  padding: 0.2rem 0.6rem;
  line-height: 1.3;
}

.inline-edit-form .detail-actions {
  margin-top: 0.75rem;
}

[data-theme="dark"] .inline-edit-form {
  background: var(--panel);
}

header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-logo {
  margin: 0;
  height: 44px;
  width: auto;
}

/* ---------------------------------------------------------------------------
   Login screen
   --------------------------------------------------------------------------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem clamp(1rem, 3vw, 4rem);
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-logo {
  width: 100%;
  max-width: 280px;
  height: auto;
  margin-bottom: 0.5rem;
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.login-card form {
  text-align: left;
  margin-top: 0.5rem;
}

.login-card button[type="submit"] {
  width: 100%;
  margin-top: 1.25rem;
}

#loginStatus {
  margin: 0.75rem 0 0;
  text-align: center;
  white-space: pre-wrap;
}

#loginStatus:empty {
  display: none;
}

/* First-login forced password change modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(14, 30, 54, 0.55);
  z-index: 1000;
}

.modal-card {
  width: 100%;
  max-width: 24rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.75rem 1.75rem 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.modal-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
  color: var(--navy);
}

.modal-card form {
  margin-top: 0.5rem;
}

.modal-card label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.modal-card button[type="submit"] {
  width: 100%;
  margin-top: 1.25rem;
}

.modal-card .status {
  margin: 0.75rem 0 0;
  text-align: center;
}

/* Logged-in user + logout in the header */
.header-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.current-user {
  color: var(--navy);
  font-size: 0.95rem;
  font-weight: 600;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0.35rem 1.35rem 0.35rem 0.9rem;
  cursor: pointer;
  margin: 0;
  position: relative;
}

.current-user::after {
  content: "";
  position: absolute;
  right: 0.6rem;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--navy);
  transform: translateY(-50%);
}

.current-user:hover {
  background: #eef1f5;
  opacity: 1;
}

.user-menu-wrap {
  position: relative;
}

.user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 12rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 0.3rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.user-menu-item {
  margin: 0;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  background: transparent;
  color: var(--navy);
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  font-weight: 600;
}

.user-menu-item:hover {
  background: #eef1f5;
  opacity: 1;
}

#logoutBtn {
  color: var(--accent);
}

#logoutBtn:hover {
  background: #fdecef;
}

.logout-btn {
  margin: 0;
  padding: 0.35rem 0.9rem;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

.logout-btn:hover {
  background: #fdecef;
}

.theme-btn {
  margin: 0;
  padding: 0.35rem 0.9rem;
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

.theme-btn:hover {
  background: #eef1f5;
}

/* ===========================================================================
   Dark mode
   =========================================================================== */
[data-theme="dark"] {
  --bg: #0f1319;
  --panel: #171d25;
  --border: #2a323c;
  --ok: #5dbf66;
  --warn: #ff5c6c;
  --accent: #ff4d5e;
  --navy: #d5e0eb;
  --sky: #4fc3f7;
  --ink: #e7edf3;
}

[data-theme="dark"] body {
  color: #dbe2ea;
}

[data-theme="dark"] header {
  background: #141a22;
}

[data-theme="dark"] .header-subtitle {
  color: #8b97a5;
}

[data-theme="dark"] .main-nav a:hover {
  background: #232b35;
}

[data-theme="dark"] .app-footer {
  background: #0b0f14;
}

[data-theme="dark"] .hint,
[data-theme="dark"] .limit-hint,
[data-theme="dark"] .detail-meta,
[data-theme="dark"] #detailMeta,
[data-theme="dark"] .pager-label {
  color: #9aa7b5;
}

[data-theme="dark"] .saved-row,
[data-theme="dark"] .inv-row {
  background: var(--panel);
}

[data-theme="dark"] .saved-detail,
[data-theme="dark"] .detail-inline {
  background: #141a22;
}

[data-theme="dark"] .saved-row-abbr {
  color: #c8d2dd;
}

[data-theme="dark"] .saved-row-reason,
[data-theme="dark"] .saved-row-created {
  color: #9aa7b5;
}

[data-theme="dark"] .report-list-header-grid {
  color: #8b97a5;
}

[data-theme="dark"] .report-timer {
  background: #141a22;
}

[data-theme="dark"] .timer-bar {
  background: #2a323c;
}

[data-theme="dark"] .timer-state,
[data-theme="dark"] .timer-unit {
  color: #8b97a5;
}

[data-theme="dark"] .user-username {
  color: #9aa7b5;
}

[data-theme="dark"] .user-locked-badge {
  background: #2a1519;
  color: #ff8a95;
}

[data-theme="dark"] .users-edit-label {
  color: #9aa7b5;
}

[data-theme="dark"] .users-cancel:hover {
  background: #232b35;
}

[data-theme="dark"] .admin-user-form label,
[data-theme="dark"] .roles-doc-item dd {
  color: #9aa7b5;
}

[data-theme="dark"] .dot.gray {
  background: #46505c;
}

[data-theme="dark"] .inv-filter {
  background: var(--panel);
  color: #c8d2dd;
}

[data-theme="dark"] button.ghost {
  background: var(--panel);
}

[data-theme="dark"] .inv-row.cat-regulator {
  border-left-color: #4fc3f7;
}

[data-theme="dark"] .inv-row.cat-regulator .inv-badge {
  background: #4fc3f7;
  color: #0b0f14;
}

[data-theme="dark"] .inv-edit-row input[type="text"] {
  background: var(--panel);
  color: #dbe2ea;
}

[data-theme="dark"] .inv-edit-field {
  color: #9aa7b5;
}

[data-theme="dark"] .inv-edit-field select {
  background-color: var(--panel);
  color: #dbe2ea;
}

[data-theme="dark"] .empty {
  color: #8b97a5;
}

[data-theme="dark"] input,
[data-theme="dark"] select {
  background-color: #10151c;
  color: #dbe2ea;
}

[data-theme="dark"] input[readonly] {
  background: #202830;
  color: #9aa7b5;
}

[data-theme="dark"] .step-btn {
  background: var(--panel);
  color: #dbe2ea;
}

[data-theme="dark"] .step-btn:hover {
  background: #232b35;
}

[data-theme="dark"] .field-row.out-of-limits input {
  background: #2a1519;
}

[data-theme="dark"] .field-row.missing input {
  border-color: #46505c;
}

[data-theme="dark"] button.link:hover,
[data-theme="dark"] .theme-btn:hover {
  background: #232b35;
}

[data-theme="dark"] .current-user:hover,
[data-theme="dark"] .user-menu-item:hover {
  background: #232b35;
}

[data-theme="dark"] #logoutBtn:hover {
  background: #2a1519;
}

[data-theme="dark"] .current-user::after {
  border-top-color: var(--navy);
}

[data-theme="dark"] button.link.danger-link:hover,
[data-theme="dark"] .logout-btn:hover {
  background: #2a1519;
}

[data-theme="dark"] button:disabled {
  background: #2a323c;
}

[data-theme="dark"] .changelog-action.created {
  background: #16301c;
  color: #7dd887;
}

[data-theme="dark"] .changelog-action.updated {
  background: #12303f;
  color: #4fc3f7;
}

[data-theme="dark"] .changelog-action.deleted {
  background: #2a1519;
  color: #ff8a95;
}

[data-theme="dark"] .changelog-table th,
[data-theme="dark"] .changelog-table .changelog-date,
[data-theme="dark"] .changelog-table td.empty {
  color: #8b97a5;
}

/* The logo is a white-background image; give it a white chip in dark mode. */
[data-theme="dark"] .header-logo,
[data-theme="dark"] .login-logo {
  background: #fff;
  border-radius: 6px;
  padding: 4px 10px;
}
