:root {
  --green: #2d8a4e;
  --green-dark: #1f6b3c;
  --green-soft: #e8f6ec;
  --ink: #16301e;
  --muted: #5b7262;
  --line: #d7e4db;
  --bg: #f4f7f5;
  --white: #ffffff;
  --danger: #c0392b;
  --warn: #c47b12;
  --shadow: 0 10px 28px rgba(22, 48, 30, 0.12);
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "PT Sans", system-ui, sans-serif;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
}

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 18px 16px 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  background: #fff;
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow);
}

.brand h1 {
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
}

.brand p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 6px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 14px;
  font-size: 16px;
  background: #fbfdfc;
  color: var(--ink);
}

input:focus {
  outline: 2px solid rgba(45, 138, 78, 0.35);
  border-color: var(--green);
}

.btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 15px 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(180deg, var(--green), var(--green-dark));
  color: #fff;
  margin-top: 18px;
}

.btn-ghost {
  background: var(--green-soft);
  color: var(--green-dark);
  margin-top: 10px;
}

.btn-danger {
  background: #fdecea;
  color: var(--danger);
  margin-top: 10px;
}

.btn:disabled {
  opacity: 0.55;
}

.error {
  color: var(--danger);
  font-size: 14px;
  margin-top: 10px;
  min-height: 20px;
}

.ok {
  color: var(--green-dark);
  font-size: 14px;
  margin-top: 10px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.topbar img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  padding: 4px;
}

.user-chip {
  font-size: 13px;
  color: var(--muted);
  text-align: right;
}

.hero {
  background: linear-gradient(160deg, var(--green), #14532d);
  color: #fff;
  border-radius: 22px;
  padding: 22px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.hero h2 { font-size: 22px; margin-bottom: 6px; }
.hero p { opacity: 0.9; font-size: 14px; }

.actions { display: grid; gap: 10px; }

.menu-btn {
  background: #fff;
  border: 0;
  border-radius: 16px;
  padding: 18px;
  text-align: left;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.menu-btn strong { display: block; font-size: 16px; margin-bottom: 4px; }
.menu-btn span { color: var(--muted); font-size: 13px; }

.scanner {
  overflow: hidden;
  border-radius: 16px;
  background: #111;
  min-height: 240px;
}

#reader {
  width: 100%;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin: 10px 0 14px;
}

.stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--green-soft);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 12px 0;
}

.stat b { font-size: 22px; color: var(--green-dark); }

.code-list {
  list-style: none;
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 38vh;
  overflow: auto;
}

.code-list li {
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  word-break: break-all;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 20;
  max-width: 90%;
}

.row {
  display: flex;
  gap: 8px;
}

.row .btn { flex: 1; }

.manual {
  margin-top: 8px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 10px;
}

.badge {
  display: inline-block;
  background: var(--green-soft);
  color: var(--green-dark);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.registry-item {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 0;
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  cursor: pointer;
}

.registry-item .title {
  font-size: 13px;
  word-break: break-all;
  font-weight: 700;
}
