:root {
  --bg: #f5f6f2;
  --panel: #fff;
  --ink: #202823;
  --muted: #65706a;
  --line: #dfe4dc;
  --green: #245f47;
  --green-2: #e7f1ec;
  --gold: #9b6815;
  --red: #9a352e;
  --blue: #285f8f;
  --shadow: 0 16px 38px rgba(20, 28, 24, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 300px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #17231d;
  color: #f7faf7;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 112px;
  height: auto;
  border-radius: 4px;
  background: #fff;
  padding: 5px;
}
.brand h1, .brand p, .toolbar h2, .toolbar p, .section-title h2 { margin: 0; }
.brand h1 { font-size: 20px; }
.brand p, .toolbar p { color: #b8c4bd; font-size: 12px; margin-top: 3px; }
.side-nav { display: grid; gap: 9px; }
.nav-button {
  border: 1px solid rgba(255,255,255,.13); background: rgba(255,255,255,.055); color: #f7faf7;
  border-radius: 8px; padding: 11px; text-align: left; font-weight: 850;
}
.nav-button.active { background: #f7faf7; color: #17231d; border-color: #f7faf7; }
.sidebar-panel {
  margin-top: auto; border: 1px solid rgba(255,255,255,.14); border-radius: 8px; padding: 14px;
  background: rgba(255,255,255,.055);
}
.panel-label { color: #b8c4bd; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; }
.metric-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; }
.workspace { min-width: 0; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.toolbar, .panel, .stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.toolbar { display: flex; justify-content: space-between; gap: 14px; padding: 14px 16px; align-items: center; }
.toolbar p { color: var(--muted); }
.toolbar-actions, .card-actions, .form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.user-badge { color: var(--muted); font-size: 12px; font-weight: 850; }
.primary-button, .secondary-button, .icon-button {
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
.primary-button { background: var(--green); color: #fff; border-color: var(--green); padding: 10px 14px; font-weight: 900; }
.secondary-button { padding: 8px 10px; font-weight: 900; }
.secondary-button.small { padding: 6px 8px; font-size: 12px; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; font-size: 18px; }
.primary-link {
  display: inline-flex; align-items: center; justify-content: center; min-height: 34px; border-radius: 8px;
  background: var(--green); color: #fff; text-decoration: none; padding: 7px 10px; font-weight: 900;
}
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
input, select { min-height: 38px; padding: 0 10px; }
textarea { padding: 10px; min-height: 86px; resize: vertical; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 16px; }
.stat span { display: block; color: var(--muted); font-size: 12px; font-weight: 850; text-transform: uppercase; }
.stat strong { display: block; margin-top: 8px; font-size: 28px; }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.section-title { min-height: 56px; padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title h2 { font-size: 18px; }
.panel-body { padding: 14px; }
.record-list { display: grid; gap: 10px; padding: 12px; }
.record-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fff; }
.record-card h3 { margin: 8px 0 5px; font-size: 17px; }
.record-card p { margin: 5px 0; color: var(--muted); line-height: 1.35; }
.card-topline { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.card-actions { margin-top: 10px; }
.tag { border-radius: 999px; background: #eef0ec; color: var(--muted); padding: 5px 9px; font-size: 12px; font-weight: 900; }
.tag.green { background: var(--green-2); color: var(--green); }
.tag.gold { background: #fff2cc; color: var(--gold); }
.tag.red { background: #f9dddd; color: var(--red); }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.field { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 850; }
.field.wide { grid-column: 1 / -1; }
.check-field { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 850; padding-top: 22px; }
.check-field input { width: auto; }
.form-actions { justify-content: flex-end; padding: 0 14px 14px; }
.card-form { display: grid; gap: 12px; }
.form-error {
  margin: 0;
  border: 1px solid #e2b8b4;
  border-radius: 8px;
  background: #fff0ef;
  color: var(--red);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.35;
}
.edit-note { margin: 0; border: 1px solid #c8dbd1; border-radius: 8px; background: var(--green-2); color: var(--green); padding: 10px 12px; font-size: 13px; font-weight: 800; line-height: 1.35; }
.sub-records { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sub-records > span { border-radius: 8px; background: #f4f6f3; color: var(--muted); padding: 6px 8px; font-size: 12px; font-weight: 800; }
.equipment-pill { display: inline-flex; align-items: center; gap: 8px; }
.equipment-pill > span { display: grid; gap: 2px; min-width: 0; }
.equipment-pill strong { color: var(--ink); }
.equipment-pill small { color: var(--muted); font-weight: 750; }
.table-wrap { overflow: auto; }
.checklist-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.checklist-table th, .checklist-table td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
.checklist-table th { background: #f4f7f4; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.checklist-table td:first-child { font-weight: 850; width: 260px; }
.checklist-table td:nth-child(2) { width: 180px; }
.checklist-table td:nth-child(4) { min-width: 270px; }
.photo-uploader { display: grid; gap: 7px; }
.photo-preview-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 32px; align-items: center; }
.photo-empty { color: var(--muted); font-size: 12px; font-weight: 750; }
.photo-chip {
  display: inline-grid;
  grid-template-columns: 42px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 6px;
  max-width: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbf8;
  padding: 4px;
}
.photo-chip img { width: 42px; height: 42px; object-fit: cover; border-radius: 6px; background: #eef0ec; }
.photo-chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: 12px; font-weight: 750; }
.photo-chip button {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-weight: 900;
}
.photo-upload-button {
  position: relative;
  display: inline-flex;
  width: fit-content;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--green);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 900;
}
.photo-upload-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-uploader + input[name="itemPhotoRefs"] { margin-top: 7px; }
.empty-state { min-height: 160px; display: grid; place-content: center; text-align: center; padding: 24px; color: var(--muted); }
.toast { position: fixed; right: 18px; bottom: 18px; background: #18241f; color: #fff; border-radius: 8px; padding: 11px 13px; box-shadow: var(--shadow); z-index: 99; }
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}
.login-card {
  width: min(100%, 380px);
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
.login-logo { width: 128px; border-radius: 4px; }
.login-card h1 { margin: 0; font-size: 24px; }
.login-error { min-height: 20px; margin: 0; color: var(--red); font-size: 13px; font-weight: 850; }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .stat-grid, .two-column, .form-grid { grid-template-columns: 1fr; }
  .check-field { padding-top: 0; }
}
