/* =============================================================
   Münter Tool Register - styles
   Palette lives in the variables below. To match the brand deck
   exactly, swap these hex values and nothing else needs to change.
   ============================================================= */

:root {
  --shadow:  #1c2420;   /* darkest ink */
  --forest:  #22332a;   /* primary surface, headers, tag plate */
  --moss:    #4f6a54;   /* primary action */
  --moss-dk: #405746;
  --lichen:  #a9baa4;   /* soft accent */
  --granite: #6d726c;   /* muted text */
  --ash:     #f3f2ee;   /* page background */
  --card:    #ffffff;
  --line:    #e0dfd9;
  --ok:      #3e6b47;
  --warn:    #9a6b1f;
  --bad:     #8c3a34;
  --radius:  10px;
  --mono: "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ash);
  color: var(--shadow);
  font-family: "Avenir Next", Avenir, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 680px; margin: 0 auto; padding-bottom: 56px; }

/* ---------- Header ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--forest);
  color: #e9ede6;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar .wordmark {
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}
.topbar .wordmark span { color: var(--lichen); font-weight: 400; }
.topbar button {
  background: none;
  border: 1px solid rgba(233,237,230,0.35);
  color: #e9ede6;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
}

/* ---------- Tag plate (signature element) ---------- */

.tag-plate {
  background: var(--forest);
  color: #eef1ec;
  margin: 16px;
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 10px rgba(28,36,32,0.18);
}
.tag-plate .code {
  font-family: var(--mono);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.tag-plate .sub {
  font-size: 0.78rem;
  color: var(--lichen);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* ---------- Generic layout ---------- */

.wrap { padding: 0 16px; }
.center-wrap {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 16px 16px;
}

h1 { font-size: 1.35rem; margin: 18px 16px 8px; font-weight: 600; }
h2 { font-size: 1.05rem; margin: 0 0 10px; font-weight: 600; }
p.muted, .muted { color: var(--granite); }
.small { font-size: 0.85rem; }

/* ---------- Forms ---------- */

label.field { display: block; margin-bottom: 14px; }
label.field > .lbl {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--granite);
  margin-bottom: 5px;
}
label.field .req { color: var(--bad); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  font-size: 16px;               /* stops iOS zoom-on-focus */
  font-family: inherit;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--shadow);
  appearance: none;
  -webkit-appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236d726c' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 1px;
}

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; gap: 0; } }

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

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  text-align: center;
}
.btn-primary { background: var(--moss); color: #fff; }
.btn-primary:active { background: var(--moss-dk); }
.btn-primary:disabled { background: var(--lichen); cursor: default; }
.btn-secondary {
  background: #fff;
  color: var(--forest);
  border: 1px solid var(--line);
}
.btn + .btn { margin-top: 10px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- Photo pickers ---------- */

.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.photo-slot {
  border: 1.5px dashed var(--lichen);
  border-radius: var(--radius);
  background: #fbfbf9;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  text-align: center;
  padding: 8px;
}
.photo-slot img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-slot .ps-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--granite);
  position: relative;
  z-index: 1;
}
.photo-slot.has-img .ps-label {
  background: rgba(28,36,32,0.72);
  color: #fff;
  padding: 3px 8px;
  border-radius: 6px;
}
.photo-slot .ps-icon { font-size: 1.5rem; position: relative; z-index: 1; }
.photo-slot.has-img .ps-icon { display: none; }

/* ---------- Tool list ---------- */

.controls { padding: 12px 16px 4px; display: flex; flex-direction: column; gap: 10px; }
.controls .filters { display: flex; gap: 10px; }
.controls .filters select { flex: 1; }

.tool-row {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 16px 10px;
  cursor: pointer;
}
.tool-row .thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: var(--ash);
  flex: none;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: var(--lichen);
  overflow: hidden;
}
.tool-row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.tool-row .meta { min-width: 0; flex: 1; }
.tool-row .meta .code { font-family: var(--mono); font-weight: 700; font-size: 0.95rem; }
.tool-row .meta .name {
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tool-row .meta .where { font-size: 0.8rem; color: var(--granite); }

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 99px;
  white-space: nowrap;
}
.badge.active      { background: #e4ecdf; color: var(--ok); }
.badge.in_repair   { background: #f3e8d2; color: var(--warn); }
.badge.lost        { background: #f2ddda; color: var(--bad); }
.badge.retired     { background: #e6e5e1; color: var(--granite); }
.badge.good        { background: #e4ecdf; color: var(--ok); }
.badge.fair        { background: #f3e8d2; color: var(--warn); }
.badge.needs_service { background: #f2ddda; color: var(--bad); }

/* ---------- Detail view ---------- */

.detail-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 16px 16px; }
.detail-photos a {
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--card);
}
.detail-photos img { width: 100%; height: 150px; object-fit: cover; display: block; }
.detail-photos .cap {
  font-size: 0.75rem;
  color: var(--granite);
  padding: 6px 8px;
  text-align: center;
}

.kv { display: grid; grid-template-columns: 42% 58%; gap: 8px 10px; font-size: 0.95rem; }
.kv dt { color: var(--granite); font-size: 0.85rem; padding-top: 1px; }
.kv dd { margin: 0; word-break: break-word; }
.kv dd.mono { font-family: var(--mono); font-size: 0.9rem; }

/* ---------- Success screen ---------- */

.success-check {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: var(--moss);
  color: #fff;
  font-size: 2.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

/* ---------- Toasts and spinner ---------- */

#toast-zone {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: min(92vw, 480px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--shadow);
  color: #fff;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.92rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  animation: toast-in 0.18s ease-out;
}
.toast.err { background: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

.spinner {
  width: 34px;
  height: 34px;
  border: 3.5px solid var(--line);
  border-top-color: var(--moss);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.6s; }
  .toast { animation: none; }
}
