:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #20242a;
  --muted: #667085;
  --line: #d7dce2;
  --primary: #1f7a5c;
  --primary-dark: #155d46;
  --danger: #a43d3d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a {
  color: var(--primary);
  text-decoration: none;
}

.topbar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 28px;
}

.brand {
  color: var(--text);
  font-weight: 700;
}

.topbar nav {
  align-items: center;
  display: flex;
  gap: 18px;
}

.page {
  margin: 0 auto;
  max-width: 1600px;
  width: 95%;
  padding: 32px 20px;
}

.page-wide {
  max-width: 98%;
  width: 100%;
  padding-left: 20px;
  padding-right: 20px;
}

.page-header {
  margin-bottom: 24px;
}

.page-header.split {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
p {
  margin-top: 0;
}

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

.auth-panel,
.form-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

.auth-panel,
.form-panel {
  margin: 60px auto;
  max-width: 460px;
}

form {
  display: grid;
  gap: 16px;
}

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

.compact-form {
  display: grid;
  gap: 12px;
}

.wide-field {
  grid-column: 1 / -1;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 14px;
  gap: 7px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 122, 92, 0.12);
}

textarea {
  resize: vertical;
}

.check {
  align-items: center;
  display: flex;
  gap: 10px;
}

.check input {
  width: auto;
}

.button,
button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  justify-content: center;
  padding: 10px 14px;
  transition: all 0.2s ease;
}

.button:hover,
button:hover {
  border-color: #a2aab8;
  background: #fcfdfe;
}

.button.primary,
button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.button.primary:hover,
button.primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.messages {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.message {
  border-radius: 6px;
  padding: 10px 12px;
}

.message.success {
  background: #e7f5ef;
}

.message.danger {
  background: #fdecec;
  color: var(--danger);
}

.message.warning {
  background: #fff5d6;
}

.module-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.module-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: block;
  min-height: 150px;
  padding: 20px;
}

.module-card:hover {
  border-color: var(--primary);
}

.dashboard-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.list-stack {
  display: grid;
  gap: 12px;
}

.list-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 10px 0;
}

.list-row.align-start {
  align-items: flex-start;
}

.list-row:last-child {
  border-bottom: 0;
}

.status-row.overdue {
  background: #fff5f5;
  border: 1px solid #f0c7c7;
  border-radius: 8px;
  padding: 12px;
}

.checklist-field-list {
  display: grid;
  gap: 16px;
}

.checklist-field-card {
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  padding: 16px;
}

.checklist-field-card strong {
  color: var(--text);
}

.checklist-field-card span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 3px;
}

.subtle-panel {
  background: #f8faf9;
  box-shadow: none;
  padding: 18px;
}

.history-filter-form {
  align-items: end;
}

.history-filter-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.field-edit-form {
  flex: 1;
}

.history-record {
  display: grid;
  gap: 8px;
  width: 100%;
}

.history-record-header {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
}

.status-badge.danger {
  background: #fdecec;
  color: var(--danger);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.table-wrap-tall {
  min-height: 520px;
}

table {
  background: var(--panel);
  border-collapse: collapse;
  min-width: 720px;
  width: 100%;
}

.resizable-table {
  table-layout: fixed;
  width: 100%;
}

.resizable-table th {
  position: relative;
  user-select: none;
  border-right: 1px solid var(--line);
  background: #f8fafc;
  font-weight: 600;
}

.resizable-table td {
  overflow: visible;
  border-right: 1px solid var(--line);
}

.resizable-table th:last-child,
.resizable-table td:last-child {
  border-right: none;
}

.resizable-table input {
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 14px;
}

.resizable-table input:focus {
  border-color: var(--primary);
  background: var(--panel);
}

.resizable-table input[readonly] {
  background: rgba(241, 245, 249, 0.5);
  color: #475569;
  cursor: not-allowed;
  font-weight: 500;
}

.resizable-table tr:hover td {
  background-color: #fafbfc;
}

.col-resizer {
  bottom: 0;
  cursor: col-resize;
  position: absolute;
  right: -3px;
  top: 0;
  width: 6px;
  z-index: 5;
}

.col-resizer::after {
  background: #cbd5e1;
  bottom: 0;
  content: "";
  position: absolute;
  right: 2px;
  top: 0;
  width: 2px;
  transition: background-color 0.15s;
}

.col-resizer:hover::after,
.resizing-columns .col-resizer::after {
  background: var(--primary);
  width: 3px;
}

.resizing-columns {
  cursor: col-resize;
  user-select: none;
}

.bottling-page .panel {
  padding: 32px;
}

.bottling-input-table,
.bottling-history-table {
  min-width: 100%;
}

.bottling-page th,
.bottling-page td {
  padding: 14px 12px;
  vertical-align: middle;
  font-size: 14px;
}

.bottling-page button {
  white-space: nowrap;
}

.section-title-row {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.bottling-entry-list {
  display: grid;
  gap: 18px;
}

.bottling-entry {
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}

.bottling-entry-header {
  align-items: end;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.bottling-entry-header label {
  max-width: 220px;
}

.bottling-entry-columns {
  display: grid;
  align-items: stretch;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.bottling-subcard {
  background: var(--panel);
  border: 1px solid #e3e7ec;
  border-radius: 8px;
  padding: 14px;
}

.bottling-subcard h3 {
  font-size: 16px;
  margin: 0 0 14px;
}

.bottling-subcard-sfuso {
  border-color: #bdd8cf;
}

.field-grid,
.sfuso-control-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sfuso-control-grid {
  background: #eef7f3;
  border: 1px solid #c9e3da;
  border-radius: 8px;
  margin-top: 12px;
  padding: 12px;
}

.diff-ok {
  background: #edf8f1;
  color: #146c43;
}

.diff-warn {
  background: #fff7df;
  color: #906500;
}

.diff-alert {
  background: #fdecec;
  color: var(--danger);
}

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

th {
  color: var(--muted);
  font-size: 13px;
}

td span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 4px;
}

.actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.actions form {
  display: inline;
}

.toolbar-line,
.actions-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.actions-row {
  margin-bottom: 0;
  margin-top: 20px;
}

.spacing-top {
  margin-top: 32px;
}

.autocomplete-wrapper {
  position: relative;
}

.autocomplete-results {
  background: var(--panel);
  border: 1px solid var(--primary);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  display: none;
  left: 0;
  max-height: 240px;
  overflow-y: auto;
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 20;
}

.autocomplete-item {
  cursor: pointer;
  padding: 10px;
}

.autocomplete-item:hover {
  background: #eef7f3;
}

.progress-panel {
  background: #f3f7f6;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 18px;
  padding: 14px;
}

.progress-header {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.progress-header span {
  color: var(--muted);
  font-size: 14px;
}

.progress-bar {
  background: #d9e4e0;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  animation: loading-slide 1.2s ease-in-out infinite;
  background: var(--primary);
  border-radius: 999px;
  height: 100%;
  position: absolute;
  width: 38%;
}

@keyframes loading-slide {
  0% {
    left: -40%;
  }

  100% {
    left: 102%;
  }
}

@media (max-width: 1024px) {
  .toolbar-line {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-line>* {
    width: 100%;
  }

  .toolbar-line a.button {
    text-align: center;
  }
}

@media (max-width: 700px) {

  .topbar,
  .page-header.split {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    padding: 18px 20px;
  }

  .panel {
    padding: 20px;
  }

  .bottling-page .panel {
    padding: 20px;
  }

  .section-title-row,
  .bottling-entry-header {
    align-items: stretch;
    flex-direction: column;
  }

  .bottling-entry-columns {
    grid-template-columns: 1fr;
  }

  .bottling-entry-header label {
    max-width: none;
  }

  .field-grid,
  .sfuso-control-grid {
    grid-template-columns: 1fr;
  }

  .bottling-entry {
    padding: 14px;
  }

  .bottling-subcard {
    padding: 14px;
  }
}
