:root {
  --brand: #54697A;
  --brand-dark: #072943;
  --bg: #EAE7DE;
  --card: #F7F4EE;
  --text: #072943;
  --muted: #54697A;
  --border: rgba(84, 105, 122, 0.24);
  --danger: #c0392b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 28px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand);
  font-weight: 700;
  margin: 0 0 6px;
}

h1, h2 { margin: 0 0 8px; }
.subtitle { margin: 0; color: var(--muted); }

.mode-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(7, 41, 67, 0.1);
  color: var(--brand-dark);
  font-weight: 700;
}

button {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  min-height: 20px;
  font: inherit;
}

button.primary { background: var(--brand-dark); color: #EAE7DE; }
button.primary:hover { background: var(--brand); }
button.secondary { background: var(--brand); color: #EAE7DE; }
button.secondary:hover { opacity: 0.86; }
button.compact { min-height: 32px; padding: 6px 10px; font-size: 13px; border-radius: 10px; }

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--brand);
  color: #EAE7DE;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(15, 76, 129, 0.06);
}

.asset-menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, 260px);
  gap: 14px;
}

.asset-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 4px 16px rgba(15, 76, 129, 0.06);
}

.asset-card-arrow {
  font-size: 1.6rem;
  color: var(--brand);
  align-self: center;
}

.sign-in-prompt {
  margin-bottom: 16px;
}

.status-message,
.scan-status {
  min-height: 22px;
  margin: 12px 0 0;
  font-weight: 600;
  color: var(--brand-dark);
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.is-error { color: var(--danger); }
.inline-note { margin: 0; }

.scan-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.scan-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.meter-controls,
.meter-settings-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meter-control-row,
.manual-entry,
.meter-summary-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.meter-control-row label {
  font-weight: 600;
  color: var(--muted);
}

.meter-control-row select,
.manual-entry input {
  flex: 1;
  min-width: 180px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  font: inherit;
  color: var(--text);
}

.meter-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meter-list-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

.meter-list-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.meter-id-block {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.meter-plot {
  color: var(--text);
  font-weight: 500;
}

.meter-sync-label {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.meter-inline-edit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.meter-edit-input {
  width: 140px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.upload-label { cursor: pointer; display: inline-block; }
.upload-label input[type="file"] { position: absolute; opacity: 0; width: 0; height: 0; }

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--brand-dark);
  color: #EAE7DE;
  font-weight: 600;
  cursor: pointer;
}

.scanner-wrap {
  position: relative;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 1 / 1;
  max-height: 56vh;
}

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

.scan-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
}

.scan-target {
  position: relative;
  width: min(78%, 360px);
  aspect-ratio: 1 / 1;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
  border-radius: 4px;
}

.corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: #EAE7DE;
  border-style: solid;
  border-width: 0;
}

.corner.tl { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; }
.corner.tr { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; }
.corner.bl { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; }
.corner.br { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; }

.scan-line {
  position: absolute;
  left: 6px;
  right: 6px;
  height: 2px;
  background: var(--brand);
  top: 0;
  animation: scanline 2s ease-in-out infinite;
}

@keyframes scanline {
  0% { top: 6px; }
  50% { top: calc(100% - 6px); }
  100% { top: 6px; }
}

.detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 41, 67, 0.35);
  z-index: 199;
}

.meter-complete-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100vw - 22px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  z-index: 260;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
}

.meter-complete-header,
.meter-complete-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.meter-complete-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

@media (max-width: 700px) {
  .hero, .hero-actions, .scan-header-row {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .meter-list-item {
    grid-template-columns: 1fr;
  }

  .scanner-wrap {
    max-width: 300px;
    max-height: 42vh;
  }

  .scan-target {
    width: min(68vw, 240px);
  }
}
