:root {
  --app-bg: #f6f7f2;
  --ink: #17201d;
  --muted: #66716d;
  --line: #dfe5df;
  --primary: #0f766e;
  --primary-dark: #0a5f58;
  --surface: #ffffff;
  --amber: #b7791f;
  --blue: #2563eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
  max-width: 520px;
  min-height: 100vh;
  margin: 0 auto;
  background: linear-gradient(180deg, #f9faf6 0%, var(--app-bg) 36%);
  position: relative;
  box-shadow: 0 0 0 1px rgba(23, 32, 29, 0.04);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 14px 18px;
  background: rgba(246, 247, 242, 0.92);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(223, 229, 223, 0.8);
}

.brand,
.icon-link,
.bottom-nav a {
  color: inherit;
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark,
.metric-icon,
.activity-row > span {
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  color: #fff;
  background: var(--primary);
}

.icon-link {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.app-main {
  padding: 18px 16px 98px;
}

.login-screen {
  min-height: calc(100vh - 140px);
  display: grid;
  align-items: center;
}

.login-panel,
.content-block,
.scan-card,
.result-panel,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-panel,
.content-block,
.scan-card,
.result-panel {
  padding: 20px;
}

.section-kicker {
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
  font-weight: 800;
}

h2 {
  font-size: 22px;
  font-weight: 800;
}

.muted,
small {
  color: var(--muted);
}

.hero-band {
  display: grid;
  gap: 18px;
  padding: 22px;
  color: #fff;
  background: linear-gradient(135deg, #0f766e 0%, #134e4a 100%);
  border-radius: 8px;
}

.hero-band p {
  margin: 12px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 16px;
}

.hero-band .section-kicker {
  color: #b7fff4;
}

.action-pill,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  font-weight: 700;
}

.btn-primary {
  --bs-btn-bg: var(--primary);
  --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary-dark);
  --bs-btn-hover-border-color: var(--primary-dark);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.metric-card {
  min-height: 124px;
  padding: 14px 10px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.metric-card strong {
  font-size: 24px;
  line-height: 1;
}

.metric-card span:last-child {
  min-height: 34px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
}

.metric-icon {
  width: 36px;
  height: 36px;
  color: #fff;
}

.metric-icon.teal {
  background: var(--primary);
}

.metric-icon.amber {
  background: var(--amber);
}

.metric-icon.blue {
  background: var(--blue);
}

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

.section-heading a {
  color: var(--primary-dark);
  font-weight: 700;
  text-decoration: none;
}

.activity-list,
.settings-list,
.stack-form,
.scan-layout {
  display: grid;
  gap: 14px;
}

.activity-row,
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.activity-row {
  justify-content: flex-start;
}

.activity-row > span {
  flex: 0 0 42px;
  height: 42px;
  color: var(--primary-dark);
  background: #dff7f2;
}

.activity-row strong,
.setting-row strong {
  display: block;
}

.setting-row {
  min-height: 72px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.scan-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  background: #111c1a;
  border-radius: 8px;
}

.scan-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-reticle {
  position: absolute;
  inset: 18%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28);
}

.camera-button {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

.scan-status {
  min-height: 44px;
  margin: 0 0 18px;
  padding: 11px 12px;
  color: var(--muted);
  background: #f1f5f2;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
}

.scan-status.success {
  color: #0f5132;
  background: #dff7ea;
  border-color: #b7ebcf;
}

.scan-status.warning {
  color: #7c4a03;
  background: #fff3cd;
  border-color: #f5d98b;
}

.scan-actions {
  margin: 0 0 18px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  width: min(520px, 100%);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-height: 76px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.bottom-nav a {
  display: grid;
  place-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.bottom-nav i {
  font-size: 21px;
}

.bottom-nav a.active {
  color: var(--primary-dark);
}

@media (min-width: 760px) {
  .app-shell {
    margin-top: 24px;
    margin-bottom: 24px;
    min-height: calc(100vh - 48px);
    border-radius: 16px;
    overflow: hidden;
  }

  .bottom-nav {
    border-radius: 16px 16px 0 0;
  }
}
