@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap");

:root {
  --bg: #08120e;
  --bg-soft: #0d1b15;
  --surface: rgba(12, 25, 20, 0.84);
  --surface-strong: rgba(16, 33, 26, 0.96);
  --surface-bright: rgba(255, 255, 255, 0.08);
  --surface-border: rgba(255, 255, 255, 0.08);
  --text: #f4fff9;
  --muted: #b9d7c8;
  --accent: #0c8a53;
  --accent-strong: #12b56d;
  --success: #1aaf61;
  --warning: #c9a227;
  --danger: #d74f56;
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 14px 32px rgba(0, 0, 0, 0.22);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-height: 25vh;
  --camera-height: 41vh;
  --result-height: 120px;
  --bottom-bar-height: 88px;
  --sheet-max-width: 720px;
  --transition-fast: 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-smooth: 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(18, 181, 109, 0.22), transparent 30%),
    radial-gradient(circle at bottom right, rgba(44, 114, 255, 0.15), transparent 28%),
    linear-gradient(180deg, #07100c 0%, #08120e 45%, #050b08 100%);
  color: var(--text);
  font-family: "Outfit", system-ui, sans-serif;
}

body.sheet-open .bottom-bar {
  transform: translate(-50%, calc(100% + 16px));
}

body.sheet-open .sheet-backdrop {
  opacity: 1;
  pointer-events: auto;
}

body.sheet-open .sheet.is-open {
  transform: translateX(-50%) translateY(0);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  padding: calc(var(--safe-top) + 12px) 14px calc(var(--safe-bottom) + 94px);
  overflow: hidden;
}

.ambient {
  position: absolute;
  border-radius: 999px;
  filter: blur(10px);
  opacity: 0.8;
  pointer-events: none;
}

.ambient-top {
  top: 2%;
  right: -10%;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(18, 181, 109, 0.42), transparent 70%);
}

.ambient-bottom {
  left: -10%;
  bottom: 15%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(33, 197, 137, 0.22), transparent 68%);
}

.network-banner {
  position: fixed;
  top: calc(var(--safe-top) + 10px);
  left: 50%;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  min-width: 220px;
  max-width: calc(100% - 28px);
  border: 1px solid rgba(255, 205, 90, 0.18);
  border-radius: 999px;
  background: rgba(75, 50, 7, 0.92);
  color: #ffe8b3;
  box-shadow: var(--shadow-md);
  transform: translateX(-50%);
}

.network-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f3bf3a;
  box-shadow: 0 0 16px rgba(255, 202, 86, 0.55);
}

.app {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 25vh) minmax(0, 1fr) var(--result-height);
  gap: 14px;
}

.top-card,
.camera-card,
.result-card,
.sheet,
.bottom-bar,
.manual-card,
.metric-card,
.dashboard-progress {
  backdrop-filter: blur(16px);
}

.top-card {
  position: relative;
  padding: 18px 18px 16px;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    rgba(9, 20, 16, 0.72);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.top-card::after {
  content: "";
  position: absolute;
  inset: auto -20% -45% auto;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(18, 181, 109, 0.2), transparent 66%);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #89c9ab;
}

.top-card h1,
.sheet h2,
.metric-section__header h3,
.manual-card h3 {
  margin: 0;
}

.top-card h1 {
  font-size: clamp(1.1rem, 2.8vw, 1.42rem);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.hero-stat,
.hero-clock {
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.hero-stat__label,
.hero-clock__label,
.status-caption,
.metric-label,
.progress-summary span,
.metric-card span,
.manual-card p,
.manual-status,
.field__label,
.result-card__meta,
.hero-stat__meta,
.hero-clock__meta {
  color: var(--muted);
}

.hero-stat__value,
.metric-value {
  display: block;
  margin-top: 6px;
  font-size: 1.2rem;
}

.hero-clock__value {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.25rem, 5vw, 1.6rem);
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.08em;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.94rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.status-pill[data-status="active"] {
  background: rgba(19, 173, 103, 0.18);
  color: #d8ffee;
}

.status-pill[data-status="warning"] {
  background: rgba(216, 177, 47, 0.16);
  color: #fff3c7;
}

.status-pill[data-status="error"] {
  background: rgba(215, 79, 86, 0.16);
  color: #ffdfe1;
}

.status-pill[data-status="loading"] {
  background: rgba(87, 127, 255, 0.16);
  color: #e4ecff;
}

.status-pill__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 16px currentColor;
}

.status-caption {
  font-size: 0.82rem;
  text-align: right;
}

.camera-card {
  position: relative;
  min-height: 0;
}

.camera-stage {
  position: relative;
  height: 100%;
  min-height: 0;
  border-radius: 34px;
  background:
    radial-gradient(circle at top, rgba(19, 173, 103, 0.15), transparent 30%),
    #000;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

#cameraVideo,
.fallback-reader {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.fallback-reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 34px !important;
}

.fallback-reader > div {
  border: 0 !important;
}

.fallback-reader section {
  display: none !important;
}

.camera-empty,
.camera-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  text-align: center;
}

.camera-empty {
  padding: 24px;
  background:
    radial-gradient(circle at center, rgba(18, 181, 109, 0.15), rgba(0, 0, 0, 0.3)),
    rgba(0, 0, 0, 0.42);
}

.camera-empty__art {
  width: 128px;
  max-width: 42%;
  margin-bottom: 14px;
}

.camera-empty__title {
  font-size: 1.1rem;
}

.camera-empty__text {
  display: block;
  max-width: 260px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.camera-empty__button {
  margin-top: 16px;
  min-height: 50px;
  padding: 0 20px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  font-weight: 700;
  box-shadow: var(--shadow-md);
}

.camera-empty__button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.camera-frame {
  position: absolute;
  inset: 13%;
  z-index: 2;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.frame-corner {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 4px solid rgba(94, 255, 171, 0.9);
  filter: drop-shadow(0 0 10px rgba(94, 255, 171, 0.35));
}

.top-left {
  top: -2px;
  left: -2px;
  border-right: 0;
  border-bottom: 0;
  border-radius: 20px 0 0 0;
}

.top-right {
  top: -2px;
  right: -2px;
  border-left: 0;
  border-bottom: 0;
  border-radius: 0 20px 0 0;
}

.bottom-left {
  bottom: -2px;
  left: -2px;
  border-top: 0;
  border-right: 0;
  border-radius: 0 0 0 20px;
}

.bottom-right {
  right: -2px;
  bottom: -2px;
  border-top: 0;
  border-left: 0;
  border-radius: 0 0 20px 0;
}

.frame-line {
  position: absolute;
  top: 18%;
  left: 10%;
  right: 10%;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(0, 255, 153, 0),
    rgba(122, 255, 194, 0.9),
    rgba(0, 255, 153, 0)
  );
  animation: scan-line 2.6s linear infinite;
}

.camera-overlay {
  align-items: start;
  justify-items: center;
  padding-top: 16px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.25), transparent 28%);
  pointer-events: none;
}

.camera-overlay__badge {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(13, 25, 20, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f2fff9;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

.result-card {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  min-height: var(--result-height);
  border-radius: 28px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-md);
  transition:
    transform var(--transition-smooth),
    background var(--transition-smooth),
    border-color var(--transition-smooth);
}

.result-card--idle {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.05);
}

.result-card--success {
  background: linear-gradient(135deg, rgba(25, 165, 95, 0.94), rgba(14, 104, 58, 0.94));
  border-color: rgba(208, 255, 231, 0.18);
}

.result-card--warning {
  background: linear-gradient(135deg, rgba(206, 156, 30, 0.95), rgba(133, 99, 10, 0.95));
  border-color: rgba(255, 240, 192, 0.18);
}

.result-card--error {
  background: linear-gradient(135deg, rgba(201, 73, 80, 0.95), rgba(120, 27, 39, 0.95));
  border-color: rgba(255, 219, 223, 0.18);
}

.result-card--processing {
  background: linear-gradient(135deg, rgba(47, 98, 201, 0.95), rgba(34, 56, 122, 0.95));
  border-color: rgba(219, 229, 255, 0.14);
}

.result-card.is-pop {
  animation: pop-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.result-card.is-shake {
  animation: shake-x 380ms ease;
}

.result-card__icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.result-card__headline {
  margin: 0 0 4px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-card__name {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.result-card__meta {
  margin-top: 6px;
  font-size: 0.88rem;
  line-height: 1.35;
}

.bottom-bar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 14px);
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: min(calc(100% - 28px), 540px);
  padding: 10px;
  border-radius: 28px;
  background: rgba(11, 23, 18, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
  transition: transform var(--transition-smooth);
}

.bottom-action {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 58px;
  padding: 8px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  transition:
    transform var(--transition-fast),
    background var(--transition-fast);
}

.bottom-action:active,
.icon-button:active,
.manual-submit:active,
.field__action:active {
  transform: scale(0.98);
}

.bottom-action--primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #f6fffb;
}

.bottom-action__icon {
  font-size: 1.15rem;
  line-height: 1;
}

.bottom-action__label {
  font-size: 0.92rem;
  font-weight: 700;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(2, 8, 5, 0.58);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity var(--transition-smooth);
  pointer-events: none;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 80;
  width: min(100%, var(--sheet-max-width));
  height: min(80dvh, 760px);
  padding: 10px 16px calc(var(--safe-bottom) + 14px);
  border-radius: 30px 30px 0 0;
  background:
    linear-gradient(180deg, rgba(22, 39, 31, 0.98), rgba(10, 18, 14, 0.98)),
    rgba(12, 25, 20, 0.98);
  box-shadow: 0 -20px 40px rgba(0, 0, 0, 0.3);
  transform: translateX(-50%) translateY(102%);
  transition: transform var(--transition-smooth);
}

.sheet__handle {
  width: 56px;
  height: 5px;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1.5rem;
}

.sheet__body {
  height: calc(100% - 72px);
  margin-top: 16px;
  overflow: auto;
  padding-right: 2px;
}

.sheet__body::-webkit-scrollbar {
  width: 6px;
}

.sheet__body::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.dashboard-progress,
.manual-card {
  padding: 16px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.progress-header,
.progress-summary,
.metric-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.progress-tag {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(19, 173, 103, 0.14);
  color: #d9ffec;
  font-size: 0.88rem;
  font-weight: 700;
}

.progress-track {
  width: 100%;
  height: 14px;
  margin-top: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #14a861 0%, #49d98d 100%);
  transition: width var(--transition-smooth);
}

.progress-summary {
  margin-top: 14px;
}

.progress-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 1.08rem;
}

.metric-section {
  margin-top: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

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

.metric-card {
  padding: 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 1.45rem;
}

.recent-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.recent-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.recent-item__avatar,
.manual-card__avatar {
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(18, 181, 109, 0.9), rgba(8, 138, 83, 0.9));
  color: white;
  font-weight: 800;
}

.recent-item__avatar {
  width: 44px;
  height: 44px;
}

.recent-item__title {
  margin: 0;
  font-weight: 700;
}

.recent-item__meta,
.recent-item__time {
  color: var(--muted);
  font-size: 0.88rem;
}

.search-form {
  margin-bottom: 14px;
}

.field__label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.field__input-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.field__input {
  min-width: 0;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  outline: none;
}

.field__input:focus {
  border-color: rgba(100, 255, 174, 0.4);
  box-shadow: 0 0 0 4px rgba(18, 181, 109, 0.12);
}

.field__action,
.manual-submit {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 18px;
  font-weight: 700;
}

.field__action {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.manual-status {
  min-height: 24px;
  margin-bottom: 14px;
  font-size: 0.92rem;
  line-height: 1.4;
}

.manual-card {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 14px;
  align-items: center;
}

.manual-card__avatar {
  width: 68px;
  height: 68px;
  font-size: 1.35rem;
}

.manual-card h3 {
  font-size: 1.06rem;
}

.manual-card p {
  margin: 4px 0 0;
  font-size: 0.92rem;
}

.manual-submit {
  width: 100%;
  margin-top: 16px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
}

.manual-submit:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

@keyframes scan-line {
  0% {
    transform: translateY(0);
    opacity: 0.6;
  }

  50% {
    transform: translateY(170px);
    opacity: 1;
  }

  100% {
    transform: translateY(0);
    opacity: 0.6;
  }
}

@keyframes pop-in {
  0% {
    transform: scale(0.96);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes shake-x {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-4px);
  }

  50% {
    transform: translateX(4px);
  }

  75% {
    transform: translateX(-3px);
  }
}

@media (max-width: 380px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .status-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .status-caption {
    text-align: left;
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  .app-shell {
    padding-bottom: calc(var(--safe-bottom) + 84px);
  }

  .app {
    grid-template-columns: 1.1fr 1.2fr;
    grid-template-rows: 1fr var(--result-height);
  }

  .top-card {
    grid-column: 1;
    grid-row: 1;
  }

  .camera-card {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .result-card {
    grid-column: 1;
    grid-row: 2;
  }
}
