:root {
  --bg: #eef3ef;
  --panel: #ffffff;
  --text: #17221d;
  --muted: #66756d;
  --line: #d6dfd9;
  --accent: #0d7f68;
  --accent-strong: #075f50;
  --accent-soft: #dff2ec;
  --ink: #25322c;
  --danger: #a33b2d;
  --gold: #a66a12;
  --shadow: 0 14px 34px rgba(23, 34, 29, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(13, 127, 104, 0.12), transparent 260px),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1;
}

h2 {
  font-size: 24px;
  line-height: 1.1;
}

h3 {
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  align-content: end;
  gap: 28px;
  padding: 28px 18px max(28px, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.04), rgba(13, 127, 104, 0.22)),
    radial-gradient(circle at 30% 12%, rgba(255, 255, 255, 0.95), transparent 34%),
    #e8f1ec;
}

.brand-block {
  display: grid;
  gap: 12px;
  max-width: 560px;
}

.lead {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}

.login-actions {
  display: grid;
  gap: 10px;
  width: min(100%, 520px);
}

.password-form {
  display: grid;
  gap: 10px;
}

.login-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px 14px 12px;
  background: rgba(238, 243, 239, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  font-size: 24px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

main {
  display: grid;
  gap: 14px;
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 14px 12px 40px;
}

.home-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.home-panel {
  display: grid;
  gap: 18px;
}

.hero-copy {
  display: grid;
  gap: 7px;
}

.home-actions {
  display: grid;
  gap: 12px;
}

.action-tile {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
  color: var(--text);
  text-align: left;
  box-shadow: 0 6px 14px rgba(23, 34, 29, 0.06);
}

.action-tile.scan {
  border-color: rgba(13, 127, 104, 0.32);
  background: var(--accent-soft);
}

.action-tile strong {
  display: block;
  font-size: 19px;
  line-height: 1.1;
}

.action-tile small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.tile-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 26px;
  font-weight: 900;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

form,
.grid {
  display: grid;
  gap: 12px;
}

.grid.two {
  grid-template-columns: 1fr;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #c6d1cb;
  border-radius: 6px;
  padding: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

button {
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

a {
  color: inherit;
  text-decoration: none;
}

input:focus,
textarea:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(13, 127, 104, 0.22);
  outline-offset: 1px;
}

.primary,
.secondary,
.google-button {
  min-height: 48px;
  padding: 13px 16px;
}

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

.capture-action,
.analyze-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.capture-action {
  background: #0d7f68;
}

.analyze-action {
  background: #c56a18;
}

.button-symbol {
  font-size: 18px;
  line-height: 1;
}

.secondary {
  color: var(--ink);
  background: #e6ece8;
}

.danger {
  min-height: 40px;
  padding: 10px 12px;
  color: white;
  background: var(--danger);
}

.full {
  width: 100%;
}

.google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: #ffffff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.google-dot {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: conic-gradient(#4285f4 0 25%, #34a853 0 50%, #fbbc05 0 75%, #ea4335 0);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  background: #e5ece8;
  color: var(--text);
  font-size: 21px;
}

.scan-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.scan-controls.primary-controls {
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
}

.camera-box {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111a16;
  aspect-ratio: 3 / 4;
  width: 80%;
  margin: 0 auto;
}

.camera-box video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 22px;
  background: linear-gradient(180deg, #20332b, #111a16);
  color: white;
  text-align: center;
}

.camera-placeholder strong {
  font-size: 18px;
}

.camera-placeholder span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  line-height: 1.4;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.fallback-controls {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 8px;
}

.text-button {
  min-height: 34px;
  padding: 5px 2px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.preview-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.analysis-panel {
  min-height: calc(100vh - 120px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  padding: 28px 18px;
  text-align: center;
}

.analysis-panel p {
  color: var(--muted);
}

.spinner {
  width: 54px;
  height: 54px;
  border: 5px solid rgba(13, 127, 104, 0.18);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.preview-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #eef2f0;
}

.preview-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  padding: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.preview-footer button {
  width: 20px;
  height: 20px;
  background: #ece4df;
  color: var(--danger);
  font-size: 14px;
  padding: 0;
}

.warning {
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.45;
}

.warning.compact {
  margin-top: 0;
}

.summary {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

.results-list {
  display: grid;
  gap: 10px;
}

.result-card {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--text);
  text-align: left;
}

.result-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.result-title {
  font-size: 16px;
  font-weight: 850;
  line-height: 1.25;
}

.original {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.score {
  min-width: 54px;
  border-radius: 999px;
  padding: 6px 9px;
  background: #e5f3ef;
  color: var(--accent-strong);
  font-weight: 900;
  text-align: center;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  border-radius: 999px;
  padding: 4px 8px;
  background: #eef2f0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tag.warn {
  background: #fff5df;
  color: var(--gold);
}

dialog {
  width: min(680px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.38);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

#detailBody {
  display: grid;
  gap: 14px;
  padding: 16px;
}

#detailBody ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 4;
  border-radius: 8px;
  padding: 12px 14px;
  background: #17221d;
  color: white;
  box-shadow: var(--shadow);
}

.admin-panel {
  display: grid;
  gap: 14px;
}

.admin-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-summary span,
.status-pill {
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef2f0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.status-pill.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-pill.admin {
  background: #edf0ff;
  color: #33428f;
}

.status-pill.banned {
  background: #f9e7e2;
  color: var(--danger);
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  background: #fff;
}

.admin-table th,
.admin-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.admin-table td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.credit-input {
  width: 96px;
  padding: 9px 10px;
}

.admin-actions {
  display: flex;
  gap: 7px;
}

.admin-actions .secondary,
.admin-actions .danger {
  min-height: 40px;
  padding: 9px 11px;
}

@media (min-width: 760px) {
  .login-screen {
    align-content: center;
    justify-items: center;
  }

  .topbar {
    padding-inline: 28px;
  }

  main {
    padding: 22px 18px 56px;
  }

  .home-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scan-controls {
    grid-template-columns: 1fr auto;
  }

  .camera-box {
    aspect-ratio: 16 / 10;
    width: 70%;
  }

  .preview-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .grid.two {
    grid-template-columns: 1fr 1fr;
  }
}
