/* Mobile-first RTL style for playground inspection app */
:root {
  --c-primary: #1e6fbb;
  --c-primary-dark: #15538e;
  --c-bg: #f4f6f9;
  --c-card: #fff;
  --c-text: #1a2330;
  --c-muted: #6b7785;
  --c-border: #e3e7ee;
  --c-ok: #2e9c4d;
  --c-minor: #e8a626;
  --c-major: #d9542b;
  --c-forbidden: #c0263c;
  --shadow: 0 1px 3px rgba(16, 30, 50, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Heebo", "Arial", sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--c-muted); }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--c-primary);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1100px; margin: 0 auto; padding: 12px 16px;
  gap: 12px;
}
.brand { color: #fff; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 22px; }
.topnav { display: flex; align-items: center; gap: 14px; font-size: 14px; flex-wrap: wrap; }
.topnav a { color: rgba(255,255,255,.92); }
.topnav .user { opacity: 0.85; }

/* Page */
.page { max-width: 1100px; margin: 0 auto; padding: 16px; }
.page-head { margin-bottom: 16px; }
.page-head h1 { margin: 4px 0 8px; font-size: 22px; }
.back { display: inline-block; margin-bottom: 6px; font-size: 14px; }
.garden-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--c-muted); font-size: 14px; }
.garden-num { color: var(--c-muted); font-weight: 400; font-size: 15px; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.flash-error { background: #ffe1e1; color: #8a1414; }
.flash-success { background: #d6f3df; color: #11592a; }

/* Login */
.login-card {
  max-width: 380px; margin: 60px auto; background: var(--c-card);
  padding: 28px; border-radius: 14px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 4px; }
.form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.form input, textarea {
  font: inherit; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--c-border); background: #fff;
}
.form input:focus, textarea:focus { outline: 2px solid var(--c-primary); border-color: transparent; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; min-height: 42px;
  text-decoration: none;
}
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); text-decoration: none; }
.btn-ghost { background: #fff; color: var(--c-text); border-color: var(--c-border); }
.btn-ghost:hover { background: #f7f9fc; text-decoration: none; }

/* Filters */
.filters { display: flex; gap: 8px; margin-top: 10px; }
.filters input[type=search] {
  flex: 1; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--c-border); font: inherit;
}

/* Garden list */
.garden-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.garden-row { background: var(--c-card); border-radius: 12px; box-shadow: var(--shadow); }
.garden-row a {
  display: flex; align-items: center; padding: 14px 16px; color: inherit;
  border-radius: 12px;
  border-right: 6px solid var(--c-border);
}
.garden-row.is-done a { border-right-color: var(--c-ok); }
.garden-row.is-progress a { border-right-color: var(--c-minor); }
.garden-row.is-pending a { border-right-color: var(--c-border); }
.garden-row a:hover { text-decoration: none; background: #fafbfd; }
.garden-main { flex: 1; }
.garden-title { font-weight: 600; font-size: 16px; }
.garden-addr { color: var(--c-muted); font-size: 13px; margin-top: 2px; }

/* Badges */
.badge { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: #d8f1de; color: #146e2c; }
.badge-progress { background: #fff1d6; color: #8a5b07; }
.badge-pending { background: #eceff3; color: var(--c-muted); }

/* Equipment list */
.equipment-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.equip-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--c-card); border-radius: 12px; box-shadow: var(--shadow);
  padding: 14px; color: inherit;
  border-right: 6px solid var(--c-border);
}
.equip-card:hover { text-decoration: none; background: #fafbfd; }
.equip-card.status-ok { border-right-color: var(--c-ok); }
.equip-card.status-minor { border-right-color: var(--c-minor); }
.equip-card.status-major { border-right-color: var(--c-major); }
.equip-card.status-forbidden { border-right-color: var(--c-forbidden); }
.equip-num {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--c-primary); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.equip-main { flex: 1; }
.equip-kind { font-weight: 600; }
.equip-status { color: var(--c-muted); font-size: 13px; }
.equip-card.status-ok .equip-status { color: var(--c-ok); }
.equip-card.status-minor .equip-status { color: var(--c-minor); }
.equip-card.status-major .equip-status { color: var(--c-major); }
.equip-card.status-forbidden .equip-status { color: var(--c-forbidden); }
.equip-arrow { color: var(--c-muted); font-size: 22px; }

/* Cards & form */
.card {
  background: var(--c-card); border-radius: 12px;
  box-shadow: var(--shadow); padding: 14px 16px; margin-top: 12px;
}
.card > summary { font-weight: 700; cursor: pointer; padding: 4px 0; }
.section-title {
  font-size: 14px; color: var(--c-muted); text-transform: none;
  margin: 14px 0 6px;
  padding-bottom: 4px; border-bottom: 1px dashed var(--c-border);
}
.block { display: block; }
.block textarea { width: 100%; margin-top: 6px; }

.inspection-finish { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.inspection-finish textarea { width: 100%; }

/* Status buttons (overall) */
.status-buttons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 14px; border: none; }
.status-buttons legend { font-weight: 700; grid-column: 1 / -1; padding: 0 0 6px; }
.btn-radio {
  display: flex; align-items: center; justify-content: center;
  padding: 12px; border-radius: 10px; border: 2px solid var(--c-border);
  background: #fff; cursor: pointer; font-weight: 600; user-select: none;
}
.btn-radio input { display: none; }
.btn-radio.s-ok { color: var(--c-ok); }
.btn-radio.s-minor { color: var(--c-minor); }
.btn-radio.s-major { color: var(--c-major); }
.btn-radio.s-forbidden { color: var(--c-forbidden); }
.btn-radio.selected { border-color: currentColor; background: color-mix(in srgb, currentColor 8%, white); }

/* Tristate (per-check item) */
.check-grid { display: flex; flex-direction: column; gap: 4px; }
.check-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 6px 0; border-bottom: 1px solid #f1f3f7;
}
.check-row:last-child { border-bottom: none; }
.check-label { flex: 1; font-size: 14px; }
.tristate { display: flex; gap: 4px; flex-shrink: 0; }
.tristate button {
  font: inherit; padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--c-border); background: #fff; cursor: pointer; font-size: 12px;
}
.tristate .t-ok.selected { background: var(--c-ok); color: #fff; border-color: var(--c-ok); }
.tristate .t-defect.selected { background: var(--c-major); color: #fff; border-color: var(--c-major); }
.tristate .t-na.selected { background: var(--c-muted); color: #fff; border-color: var(--c-muted); }

/* Photos */
#photos { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.photo-thumb {
  position: relative; width: 92px; height: 92px;
  border-radius: 8px; overflow: hidden; background: #eee;
}
.photo-thumb.small { width: 64px; height: 64px; }

/* Per-item photos area (shown when item marked as defect) */
.item-photos {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 0 10px;
  margin-bottom: 6px;
  border-bottom: 1px dashed #f1f3f7;
}
.item-photos.hidden { display: none; }
.btn-add-photo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px;
  border: 2px dashed var(--c-major);
  border-radius: 8px;
  background: #fff5ef;
  color: var(--c-major);
  font-size: 22px; font-weight: 700;
  cursor: pointer;
  user-select: none;
}
.btn-add-photo:hover { background: #ffe9de; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-del {
  position: absolute; top: 4px; left: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.65); color: #fff; border: none;
  cursor: pointer; line-height: 18px; font-size: 14px;
}
.photo-add { cursor: pointer; }

/* Form actions */
.form-actions {
  position: sticky; bottom: 0; background: var(--c-bg);
  padding: 10px 0; margin-top: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

/* Dashboard */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 720px) { .stats-grid { grid-template-columns: repeat(5, 1fr); } }
.stat { background: var(--c-card); border-radius: 12px; padding: 14px; box-shadow: var(--shadow); text-align: center; }
.stat-num { font-size: 28px; font-weight: 700; color: var(--c-primary); }
.stat-defects .stat-num { color: var(--c-major); }
.stat-done .stat-num { color: var(--c-ok); }
.stat-progress .stat-num { color: var(--c-minor); }
.stat-label { color: var(--c-muted); font-size: 13px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--c-border); }
.data-table th { background: #f7f9fc; font-weight: 600; }
.row-forbidden td { background: #fdeef0; }
.row-major td { background: #fdf2ec; }
.row-minor td { background: #fff8e8; }

/* Map view */
.map-canvas { height: 70vh; min-height: 480px; border-radius: 12px; box-shadow: var(--shadow); }
.map-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--c-muted); margin-top: 6px; }
.map-legend i.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-left: 4px; vertical-align: middle; border: 2px solid #fff; box-shadow: 0 0 0 1px #ccc; }
.dot-ok { background: var(--c-ok); }
.dot-progress { background: var(--c-minor); }
.dot-pending { background: #9aa3ad; }
.dot-defect { background: var(--c-forbidden); }

/* Page actions */
.page-actions { display: flex; gap: 8px; margin-top: 8px; }
.month-nav { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.month-nav a { padding: 6px 12px; border-radius: 8px; background: var(--c-card); box-shadow: var(--shadow); }

/* History */
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; background: var(--c-card); border-radius: 10px; box-shadow: var(--shadow);
}
.history-row .h-month { font-weight: 600; }
.history-row .h-defects { color: var(--c-major); }

/* Defect status pills */
.defect-status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.defect-status.open { background: #fdeef0; color: #8a1525; }
.defect-status.assigned { background: #fff1d6; color: #8a5b07; }
.defect-status.fixed { background: #d8f1de; color: #146e2c; }

.defects-table select.defect-status-select { padding: 4px 6px; border-radius: 6px; border: 1px solid var(--c-border); font: inherit; font-size: 12px; }
.defects-table .fix-notes { width: 100%; padding: 6px 8px; margin-top: 4px; border-radius: 6px; border: 1px solid var(--c-border); font: inherit; font-size: 12px; }

/* Admin / inline buttons */
.link-btn { background: none; border: none; padding: 0; font: inherit; color: var(--c-primary); cursor: pointer; text-decoration: underline; }
.link-btn:hover { color: var(--c-primary-dark); }
.checkbox-line { display: flex; align-items: center; gap: 8px; flex-direction: row !important; }
.checkbox-line input { width: 18px; height: 18px; }

/* Alert banner (dangerous defects) */
.alert-banner { background: #fdeef0; color: #8a1525; border-right: 5px solid var(--c-forbidden); padding: 14px 18px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; }
.alert-banner .small { font-weight: 400; font-size: 13px; display: block; margin-top: 4px; }

/* Garden layout image */
.layout-card summary { font-weight: 700; cursor: pointer; padding: 4px 0; }
.layout-card .small { font-weight: 400; font-size: 12px; }
.layout-image { display: block; max-width: 100%; max-height: 60vh; margin: 8px auto 0; border-radius: 8px; box-shadow: var(--shadow); object-fit: contain; background: #fff; }
.layout-field { background: #fafbfd; border: 1px dashed var(--c-border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.layout-field > span:first-child { font-weight: 600; }
.layout-preview img { display: block; max-width: 100%; max-height: 240px; margin-bottom: 8px; border-radius: 6px; }

/* Mobile: hide inline diagram, show button */
.layout-desktop-only { display: none; }
.layout-btn-mobile { display: inline-flex; }

/* Desktop: show inline diagram, hide button */
@media (min-width: 720px) {
  .layout-desktop-only { display: block; }
  .layout-btn-mobile { display: none; }
}

/* Photo gallery */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.gallery-item { background: var(--c-card); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.gallery-item img { width: 100%; height: 140px; object-fit: cover; display: block; }
.gallery-item .meta { padding: 6px 8px; font-size: 12px; color: var(--c-muted); }
.gallery-item .meta strong { display: block; color: var(--c-text); }

/* Analytics charts */
.charts-row { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
@media (min-width: 720px) {
  .charts-row { grid-template-columns: 1fr 1fr; }
}
.charts-row .card h2, .card h2 { margin: 0 0 10px; font-size: 16px; color: var(--c-text); }
.card canvas { max-width: 100%; }

/* Desktop tweaks */
@media (min-width: 720px) {
  .status-buttons { grid-template-columns: repeat(4, 1fr); }
  .page-head h1 { font-size: 26px; }
}
