:root {
  --color-primary: #2f6f4f;
  --color-primary-dark: #234f38;
  --color-bg: #f5f7f3;
  --color-card: #ffffff;
  --color-text: #1f2a22;
  --color-muted: #5b6b60;
  --color-danger: #b3452f;
  --color-ok: #2f6f4f;
  --radius: 10px;
  --spacing: 1rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

.container {
  max-width: 780px;
  margin: 0 auto;
  padding: calc(var(--spacing) * 1.5) var(--spacing);
}

.card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: calc(var(--spacing) * 1.25);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  margin-bottom: var(--spacing);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: var(--spacing);
}

.field label {
  font-weight: 600;
  font-size: 0.9rem;
}

.field input,
.field textarea,
.field select {
  padding: 0.6rem;
  border: 1px solid #cdd6cf;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

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

.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.muted { color: var(--color-muted); font-size: 0.9rem; }
.status-ok { color: var(--color-ok); font-weight: 600; }
.status-bad { color: var(--color-danger); font-weight: 600; }

.plant-card {
  border: 1px solid #e1e7e2;
  border-radius: var(--radius);
  padding: var(--spacing);
  margin-bottom: var(--spacing);
}

.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.photo-grid img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
}

.lang-switch {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.lang-switch button {
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--color-primary);
  background: transparent;
  color: var(--color-primary);
  font-size: 0.8rem;
  cursor: pointer;
}

.lang-switch button.active {
  background: var(--color-primary);
  color: white;
}

.app-logo {
  display: flex;
  justify-content: flex-start;
  margin-bottom: var(--spacing);
}

.logo-circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.logo-circle img {
  max-width: 78%;
  max-height: 78%;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* ---------- app shell ---------- */
.container.narrow { max-width: 460px; }
.center { text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app-header {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  padding: 0.6rem var(--spacing); background: var(--color-card);
  border-bottom: 1px solid #e1e7e2; position: sticky; top: 0; z-index: 20;
}
.app-header-logo { width: 40px; height: 40px; border-radius: 50%; }
.app-header-title { flex: 1; display: flex; flex-direction: column; min-width: 140px; line-height: 1.2; }
.app-header .lang-switch { margin: 0; }

.tabs {
  display: flex; gap: 0.25rem; overflow-x: auto; padding: 0 var(--spacing);
  background: var(--color-card); border-bottom: 1px solid #e1e7e2;
  position: sticky; top: 57px; z-index: 19;
}
.tabs button {
  border: none; background: none; padding: 0.8rem 1rem; font-size: 0.95rem; cursor: pointer;
  color: var(--color-muted); border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs button.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }

.btn-small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn-danger { background: transparent; color: var(--color-danger); border: 1px solid var(--color-danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible, .tabs button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #9cc9b1; outline-offset: 2px;
}
.row-actions { display: flex; gap: 0.4rem; align-items: center; }
.row-actions.wrap { flex-wrap: wrap; }

.inline-form { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }
.field.grow { flex: 1; min-width: 160px; }
.field select, .field input[type="checkbox"] { font-size: 1rem; }
.field select { padding: 0.6rem; border: 1px solid #cdd6cf; border-radius: 6px; background: #fff; }
.field textarea { resize: vertical; }
.check { display: inline-flex; align-items: center; gap: 0.35rem; margin-right: 1rem; }
.checks { display: flex; flex-wrap: wrap; gap: 0.3rem 0.5rem; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th { text-align: left; font-size: 0.8rem; color: var(--color-muted); font-weight: 600; padding: 0.4rem 0.5rem; border-bottom: 2px solid #e1e7e2; }
.table td { padding: 0.5rem; border-bottom: 1px solid #edf1ee; vertical-align: middle; }

.badge { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.78rem; background: #edf1ee; color: var(--color-muted); margin-right: 0.3rem; }
.badge-ok { background: #dcefe3; color: var(--color-primary-dark); }
.badge-warn { background: #fff1d6; color: #7a5200; }

.photo-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
.photo { position: relative; margin: 0; }
.photo img, .photo-btn img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; display: block; }
.photo-btn { border: none; padding: 0; background: none; cursor: zoom-in; }
.photo-large { max-width: 100%; max-height: 70vh; border-radius: 8px; }
.photo-remove {
  position: absolute; top: -6px; right: -6px; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: var(--color-danger); color: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer;
}

.modal { border: none; border-radius: var(--radius); padding: 1.25rem; max-width: min(640px, 94vw); width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(20, 30, 24, 0.5); }
.modal-body { margin: 0.5rem 0 1rem; max-height: 65vh; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; }

#toasts { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 0.4rem; width: min(92vw, 420px); }
.toast { background: #1f2a22; color: #fff; padding: 0.7rem 1rem; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.toast-error { background: var(--color-danger); }

.secret, .code-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.08em; }
.secret { font-size: 1.05rem; background: #f0f4f1; padding: 0.15rem 0.4rem; border-radius: 4px; }
.code-input { font-size: 1.4rem; text-align: center; text-transform: uppercase; }

/* ---------- student app ---------- */
body.student .container { padding-bottom: 6rem; max-width: 640px; }
.card-button { display: block; width: 100%; text-align: left; border: none; font: inherit; color: inherit; cursor: pointer; text-decoration: none; }
.card-button:hover { box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.card-button p { margin: 0.25rem 0; }
.back { display: inline-block; margin-bottom: 0.5rem; }
.plant .row-actions { margin: 0.5rem 0; }
.location { margin: 0.5rem 0 1rem; }
.sticky-actions {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 0.5rem; justify-content: center;
  padding: 0.75rem var(--spacing) calc(0.75rem + env(safe-area-inset-bottom)); background: var(--color-card);
  border-top: 1px solid #e1e7e2; z-index: 15;
}
.result { background: #e6f2ea; }
.feedback { padding: 0.6rem 0.8rem; border-radius: 8px; margin: 0.5rem 0; background: #edf1ee; }
.feedback p { margin: 0.2rem 0; }
.feedback-correct { background: #dcefe3; }
.feedback-partial { background: #fff1d6; }
.feedback-incorrect { background: #f8dfd9; }

/* ---------- printing ---------- */
#print-sheet { display: none; }
.code-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.6rem; }
.code-card { border: 1px dashed #888; border-radius: 8px; padding: 0.7rem; }
.code-card code { display: block; font-size: 1.3rem; letter-spacing: 0.1em; margin-top: 0.2rem; }
@media print {
  body.print-codes > *:not(#print-sheet) { display: none !important; }
  body.print-codes #print-sheet { display: block; }
  .app-header, .tabs, .btn, dialog, #toasts { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}
