:root {
  color-scheme: light;
  --ink: #16201f;
  --muted: #64706e;
  --line: #dce5df;
  --panel: #ffffff;
  --bg: #f5f7f2;
  --green: #1e7b54;
  --blue: #255f85;
  --red: #a84535;
  --amber: #a56b18;
}

* { box-sizing: border-box; }

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

.topbar {
  min-height: 88px;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #102422;
  color: white;
}

h1, h2, p { margin: 0; letter-spacing: 0; }
h1 { font-size: 28px; font-weight: 750; }
h2 { font-size: 16px; }
.topbar p { color: #bed0c9; margin-top: 4px; }

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px;
}

button, select, input, textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover { border-color: #9aa9a2; }
.primary { background: var(--green); border-color: var(--green); color: white; }
.danger { color: var(--red); border-color: #e0b4ad; }
.icon { width: 36px; padding: 0; font-size: 24px; line-height: 1; }
.top-actions { display: flex; gap: 10px; }

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  font-weight: 750;
  color: var(--muted);
}

.tab.active {
  color: var(--ink);
  border-bottom-color: var(--green);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.filters {
  display: grid;
  grid-template-columns: 140px 160px minmax(180px, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

select, input, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 10px;
  background: white;
  color: var(--ink);
}

.checks {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 10px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.metric span { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric strong { display: block; margin-top: 8px; font-size: 22px; }

.table-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-head span { color: var(--muted); font-size: 13px; }

.table-section { margin-bottom: 18px; padding: 16px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; background: white; min-width: 920px; }
th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
  font-size: 13px;
}
th {
  position: sticky;
  top: 0;
  background: #edf3ee;
  color: #354542;
  font-size: 12px;
  text-transform: uppercase;
}
td:first-child, th:first-child, td:nth-child(8), th:nth-child(8) {
  text-align: left;
}
tr:hover td { background: #f8faf7; }

.editable-cell {
  cursor: pointer;
}

.editable-cell:hover {
  background: #edf6f0;
}

.comment-cell {
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.strong-value {
  font-weight: 750;
}

.actions-cell {
  width: 56px;
  text-align: center;
}

.trash-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  color: var(--red);
}

.trash-button svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.new-record-row td {
  text-align: center;
  background: #f8faf7;
  padding: 14px;
}

.new-record-row:hover td {
  background: #f0f6f1;
}

.chip {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #e8f2ec;
  color: var(--green);
  font-weight: 700;
  font-size: 12px;
}
.muted { color: var(--muted); }
.negative { color: var(--red); }
.positive { color: var(--green); }

.empty-state {
  min-height: 240px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 8px;
}

.empty-state p {
  color: var(--muted);
}

.empty-row {
  text-align: center;
  color: var(--muted);
  background: #f8faf7;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}
dialog::backdrop { background: rgba(10, 22, 20, .44); }
form { padding: 18px; }
.modal-head, .modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-head { margin-bottom: 16px; }
.modal-actions { margin-top: 16px; display: grid; grid-template-columns: auto 1fr auto auto; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.full { margin-top: 12px; }

@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: 14px; padding: 18px; }
  main { padding: 14px; }
  .filters, .metrics { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .checks { align-items: stretch; }
  .checks label { flex: 1 1 130px; }
  .tabs { overflow-x: auto; }
}
