@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;600;700&family=Barlow+Condensed:wght@600;700&display=swap');

:root {
  --green: #327D3C;
  --green-dark: #26602E;
  --green-light: #EAF3EB;
  --ink: #20241f;
  --ink-soft: #5B6169;
  --border: #DCE3DD;
  --bg: #F5F7F5;
  --card: #ffffff;
  --danger: #C0392B;
  --danger-light: #FBEAE8;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Barlow', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

h1, h2, h3 {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  letter-spacing: 0.2px;
}

a { color: var(--green-dark); }

.muted { color: var(--ink-soft); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }

.btn-outline { background: #fff; color: var(--ink); border-color: var(--border); }
.btn-outline:hover { border-color: var(--green); color: var(--green-dark); }

.btn-outline.active { background: var(--green-light); border-color: var(--green); color: var(--green-dark); }

.btn-danger { background: var(--danger-light); color: var(--danger); }
.btn-danger:hover { background: #f5d5d1; }

.btn-ghost { background: transparent; color: var(--ink-soft); border-color: transparent; padding: 6px 8px; }
.btn-ghost:hover { color: var(--ink); background: #F0F1EF; }

.btn-full { width: 100%; padding: 11px 14px; font-size: 14.5px; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Login ---------- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--green) 0%, var(--green-dark) 100%);
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

.login-card h1 { font-size: 26px; margin: 4px 0 8px; }
.login-card .muted { font-size: 13.5px; margin-bottom: 20px; }

.login-card form { display: flex; flex-direction: column; gap: 14px; }

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.login-card input {
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
}

.login-card input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(50,125,60,0.15); }

.login-card button { margin-top: 6px; }

.alert { padding: 10px 12px; border-radius: 8px; font-size: 13.5px; margin-bottom: 6px; }
.alert-error { background: var(--danger-light); color: var(--danger); }
.alert-success { background: var(--green-light); color: var(--green-dark); }

/* ---------- Brand / Topbar ---------- */

.brand { display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}
.brand span {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--green-dark);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

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

.save-indicator {
  font-size: 12.5px;
  color: var(--green-dark);
  min-width: 90px;
  opacity: 0;
  transition: opacity 0.2s;
}
.save-indicator.visible { opacity: 1; }
.save-indicator.error { color: var(--danger); }

/* ---------- Page / Sections ---------- */

.page { max-width: 880px; margin: 0 auto; padding: 28px 20px 80px; }
.page h1 { font-size: 30px; margin: 4px 0 6px; color: #13201A; }
.page > .muted { font-size: 14px; margin: 0 0 26px; }

.section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 2px solid var(--green);
  padding-bottom: 8px;
  margin-bottom: 16px;
}

.section-header h2 { font-size: 18px; color: var(--green-dark); margin: 0; }
.section-hint { font-size: 12.5px; color: var(--ink-soft); margin: -10px 0 16px; }

.field-row {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--border);
}
.field-row:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }

.field-label { font-size: 13.5px; font-weight: 600; }
.field-hint { font-size: 12px; color: var(--ink-soft); margin: 2px 0 8px; }

.field-controls { display: flex; align-items: center; gap: 2px; }

.field-save-tick {
  font-size: 11.5px;
  color: var(--green-dark);
  opacity: 0;
  transition: opacity 0.25s;
  margin-left: 6px;
}
.field-save-tick.visible { opacity: 1; }

.section-title-row { display: flex; align-items: center; gap: 8px; }
.section-title-row h2 { margin: 0; }

input[type=text].field-input,
textarea.field-input,
select.field-input {
  width: 100%;
  font-family: inherit;
  font-size: 14.5px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

textarea.field-input { min-height: 88px; resize: vertical; }

.field-input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(50,125,60,0.15); }

/* ---------- Repeatable groups ---------- */

.repeat-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: #FBFCFB;
  position: relative;
}
.repeat-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ---------- Image upload ---------- */

.image-field { }
.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 13px;
  background: #FAFBFA;
  transition: border-color 0.12s, background 0.12s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--green); background: var(--green-light); color: var(--green-dark); }
.dropzone input[type=file] { display: none; }

.image-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.image-tile {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #F0F1EF;
}
.image-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-tile.uploading::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.55);
  animation: pulse 1.1s infinite ease-in-out;
}
.image-tile .remove-btn {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.image-tile .remove-btn:hover { background: var(--danger); }

.file-tile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  background: #fff;
  max-width: 200px;
}
.file-tile .file-icon { font-size: 18px; }
.file-tile .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@keyframes pulse { 0%,100% { opacity: 0.3; } 50% { opacity: 0.8; } }

/* ---------- Edit mode ---------- */

body.edit-mode .field-controls,
body.edit-mode .section-controls { visibility: visible; }
.field-controls,
.section-controls { visibility: hidden; }

.add-field-btn, .add-section-btn {
  display: none;
}
body.edit-mode .add-field-btn,
body.edit-mode .add-section-btn {
  display: inline-flex;
}

body.edit-mode .section { outline: 1px dashed rgba(50,125,60,0.35); outline-offset: 4px; }

/* ---------- Modal (field editor) ---------- */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20,24,20,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 { margin: 0 0 16px; font-size: 18px; }
.modal label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 12px 0 6px;
}
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.options-list { display: flex; flex-direction: column; gap: 6px; }
.options-list .option-row { display: flex; gap: 6px; }
.options-list input { flex: 1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; color: var(--ink); margin-top: 12px; }
.checkbox-row input { width: auto; }

/* ---------- Overview / print page ---------- */

.overview-section h2 { font-size: 17px; color: var(--green-dark); border-bottom: 2px solid var(--green); padding-bottom: 6px; margin: 26px 0 14px; }
.overview-item { margin-bottom: 12px; font-size: 14px; }
.overview-item .ov-label { font-weight: 600; margin-bottom: 3px; }
.overview-item .ov-value { color: var(--ink); white-space: pre-wrap; }
.overview-item .ov-empty { color: var(--ink-soft); font-style: italic; }
.overview-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.overview-images img { width: 110px; height: 110px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  .section, .overview-section { break-inside: avoid; }
}

@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
  .page { padding: 20px 14px 60px; }
  .section { padding: 16px; }
}
