/* FSC-branded light theme — palette taken from fsc.org
   dark green #285c4d, bright green #78be20, orange #ff6d2c */
:root {
  --fsc-green: #285c4d;      /* primary / header */
  --fsc-green-dark: #1e463b;
  --fsc-lime: #78be20;       /* bright accent */
  --fsc-lime-dark: #5f9a15;
  --fsc-orange: #ff6d2c;

  --bg: #ffffff;
  --bg-soft: #f4f8ee;        /* light green tint */
  --panel: #ffffff;
  --border: #dcdfd8;
  --text: #333333;
  --muted: #6b7280;

  --ok: #78be20;
  --off: #ff6d2c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-soft);
  color: var(--text);
  font-family: "Open Sans", Arial, Helvetica, sans-serif;
  font-size: 14px;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header — FSC dark green bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--fsc-green);
  color: #fff;
  border-bottom: 3px solid var(--fsc-lime);
}
.topbar h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 700;
  letter-spacing: .01em;
}
.subtitle { margin: 3px 0 0; color: #d7e8d0; font-size: 12px; }
.status { display: flex; align-items: center; gap: 8px; color: #e6efe4; font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-on { background: var(--fsc-lime); box-shadow: 0 0 0 3px rgba(120,190,32,.25); }
.dot-off { background: var(--fsc-orange); }

/* Filter bar */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: flex-end;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.metric { min-width: 92px; padding: 2px 14px 2px 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; }
.metric-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.metric strong { color: var(--fsc-green); font-size: 20px; line-height: 1; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.field.grow { flex: 1 1 260px; }
.field label {
  font-size: 11px;
  color: var(--fsc-green);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 700;
}
.field input, .field select {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.field input::placeholder { color: #a3aa9c; }
.field input:focus, .field select:focus {
  border-color: var(--fsc-lime);
  box-shadow: 0 0 0 3px rgba(120,190,32,.2);
}
.field select[multiple] { min-height: 34px; max-height: 96px; }
.field select[multiple] option:checked {
  background: var(--fsc-lime) linear-gradient(0deg, var(--fsc-lime), var(--fsc-lime));
  color: #fff;
}

.btn {
  background: var(--fsc-green);
  color: #fff;
  border: 1px solid var(--fsc-green);
  border-radius: 6px;
  padding: 9px 16px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: background .12s;
}
.btn:hover { background: var(--fsc-green-dark); border-color: var(--fsc-green-dark); }
.btn-light { background: var(--fsc-lime); border-color: var(--fsc-lime); color: var(--fsc-green-dark); }
.btn-light:hover { background: #a4d65e; border-color: #a4d65e; }
.btn:disabled { cursor: wait; opacity: .65; }
.select-grid { display: contents; }
.select-grid .field { min-width: 128px; flex: 1 1 128px; }

/* Keep Perspective's shadow DOM controls in the same pale-green accent family. */
perspective-viewer {
  --active--color: var(--fsc-lime);
  --inactive--color: var(--fsc-green);
  --icon--color: var(--fsc-green);
  --plugin--background: var(--bg-soft);
}
perspective-viewer ::part(button),
perspective-viewer ::part(select),
perspective-viewer ::part(input) { accent-color: var(--fsc-lime); }

.main { flex: 1 1 auto; min-height: 0; background: var(--bg); }
perspective-viewer { width: 100%; height: 100%; }
.error { margin: 24px; padding: 16px; border: 1px solid var(--fsc-orange); color: #8b3215; background: #fff4ef; }
.hidden { display: none; }

/* Detail slide-in */
.detail {
  position: fixed;
  top: 0; right: 0;
  width: min(520px, 92vw);
  height: 100vh;
  background: #fff;
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(40,92,77,.12);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transition: transform .18s ease;
}
.detail.hidden { transform: translateX(105%); }
.detail-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: var(--fsc-green);
  color: #fff;
}
.detail-head strong { font-size: 15px; font-weight: 700; }
.detail-body { padding: 14px 18px; overflow-y: auto; }
.btn-close { background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; opacity: .85; }
.btn-close:hover { opacity: 1; }

.overlay {
  position: fixed; inset: 0; background: rgba(30,70,59,.35); z-index: 40;
}
.overlay.hidden { display: none; }
.detail.hidden ~ .overlay { display: none; }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 12px; }
.kv dt { color: var(--fsc-green); font-size: 12px; font-weight: 600; }
.kv dd { margin: 0; word-break: break-word; }
.kv dd.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  background: var(--bg-soft);
  border: 1px solid var(--fsc-lime);
  color: var(--fsc-green-dark);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
}

/* desktop-only: block mobile layout */
.mobile-block { display: none; }
@media (max-width: 860px) {
  .mobile-block {
    display: flex; position: fixed; inset: 0; z-index: 9999;
    flex-direction: column; align-items: center; justify-content: center;
    gap: 14px; text-align: center; padding: 32px;
    background: var(--fsc-green); color: #fff; font-size: 20px; font-weight: 700;
  }
  .mobile-block > div:first-child { font-size: 46px; }
  .mobile-block .mb-sub { font-size: 13px; font-weight: 400; opacity: .9; max-width: 340px; line-height: 1.5; }
}
