:root {
  color-scheme: light;
  --bg: #eff3ee;
  --surface: rgba(255, 253, 247, .92);
  --surface-solid: #fffdf8;
  --ink: #071b24;
  --ink-2: #34484d;
  --muted: #737d78;
  --line: rgba(28, 45, 45, .14);
  --line-strong: rgba(28, 45, 45, .22);
  --teal: #0d7c75;
  --teal-dark: #075a55;
  --amber: #f3b53f;
  --green: #15803d;
  --red: #b42318;
  --navy: #071b24;
  --shadow: 0 8px 22px rgba(10, 29, 34, .07);
  --shadow-soft: 0 4px 14px rgba(10, 29, 34, .05);
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, .75), transparent 34%),
    linear-gradient(145deg, #f4f0e7 0%, var(--bg) 62%, #f5e8c7 100%);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(7, 27, 36, .03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(7, 27, 36, .025) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .55), transparent 72%);
  content: "";
}

button,
input,
select {
  font: inherit;
}

a { color: inherit; }

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, .78), transparent 34%),
    linear-gradient(145deg, #f4f0e7 0%, #eff3ee 62%, #f5e8c7 100%);
  transition: opacity .32s ease, visibility .32s ease;
}

.page-loader.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.loader-card {
  width: min(320px, calc(100% - 48px));
  display: grid;
  justify-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 247, .92);
  box-shadow: var(--shadow);
  padding: 28px;
  text-align: center;
}

.loader-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #f7c75f, var(--amber));
  color: var(--navy);
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(243, 181, 63, .24);
  animation: loaderPulse 1.2s ease-in-out infinite;
}

.loader-card strong {
  font-size: 17px;
}

.loader-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.loader-bar {
  width: 100%;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(13, 124, 117, .12);
  margin-top: 8px;
}

.loader-bar span {
  width: 42%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--amber));
  animation: loaderSlide 1s ease-in-out infinite;
}

@keyframes loaderPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

@keyframes loaderSlide {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(250%);
  }
}

.app-header {
  position: relative;
  z-index: 20;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 max(20px, calc((100vw - 1260px) / 2));
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(7, 27, 36, .97);
  color: #fff;
  box-shadow: 0 14px 32px rgba(7, 27, 36, .14);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(145deg, #f7c75f, var(--amber));
  color: var(--navy);
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(243, 181, 63, .24);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
  letter-spacing: 0;
}

.brand small {
  color: rgba(255, 255, 255, .62);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .17em;
  text-transform: uppercase;
}

.header-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  color: rgba(255, 255, 255, .72);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.support-btn,
.support-email,
.header-meta strong {
  min-height: 31px;
  display: inline-flex;
  align-items: center;
  border-radius: 9px;
  padding: 0 11px;
}

.support-btn,
.support-email {
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .045);
  color: rgba(255, 255, 255, .72);
  box-shadow: none;
  text-decoration: none;
}

.support-btn {
  cursor: pointer;
  font-size: 12px;
}

.support-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.support-email {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 50;
  border-color: rgba(255, 255, 255, .16);
  background: rgba(7, 27, 36, .98);
  box-shadow: 0 16px 34px rgba(7, 27, 36, .24);
  color: #fff;
  white-space: nowrap;
}

.support-email::before {
  position: absolute;
  top: -5px;
  right: 18px;
  width: 10px;
  height: 10px;
  background: rgba(7, 27, 36, .98);
  content: "";
  transform: rotate(45deg);
}

.support-email[hidden] {
  display: none;
}

.header-meta strong {
  border: 1px solid rgba(52, 211, 153, .28);
  background: rgba(13, 124, 117, .28);
  color: #7ef3c1;
  font-weight: 900;
}

.page {
  position: relative;
  z-index: 1;
  width: min(1260px, calc(100% - 32px));
  height: calc(100vh - 104px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 292px);
  gap: 16px;
  align-items: start;
  margin: 10px auto 0;
  overflow: hidden;
}

.main-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 10px;
  overflow: hidden;
  padding: 0 1px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 248px;
  gap: 12px;
  align-items: stretch;
}

.hero-copy,
.hero-image,
.item-panel,
.calc-grid,
.result-panel,
.message,
.logs-page {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero-copy {
  position: relative;
  overflow: hidden;
  padding: 14px 16px;
}

.hero-copy::before {
  position: absolute;
  inset: 0;
  border-top: 3px solid var(--teal);
  background: linear-gradient(100deg, rgba(13, 124, 117, .07), transparent 42%, rgba(243, 181, 63, .1));
  content: "";
  pointer-events: none;
}

.hero-copy > * {
  position: relative;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal-dark);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 720px;
  margin-bottom: 6px;
  font-size: clamp(21px, 1.8vw, 26px);
  font-weight: 700;
  line-height: 1.15;
}

.lede {
  max-width: 680px;
  margin: 0 0 12px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.35;
}

.scan-form {
  display: grid;
  gap: 8px;
}

label {
  display: grid;
  gap: 7px;
  color: #6c5f50;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.scan-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 118px;
  gap: 10px;
}

input,
select,
button {
  min-height: 42px;
  border-radius: 10px;
  font-size: 13px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .92);
  color: var(--ink);
  padding: 0 13px;
  outline: none;
}

#scanCode {
  min-height: 46px;
  border-width: 2px;
  border-color: rgba(13, 124, 117, .28);
  box-shadow: inset 0 0 0 3px rgba(13, 124, 117, .08);
  font-size: clamp(16px, 1.3vw, 19px);
  font-weight: 700;
  letter-spacing: .02em;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(13, 124, 117, .16);
}

#scanCode:focus {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 3px rgba(13, 124, 117, .1), 0 0 0 4px rgba(13, 124, 117, .15);
  transform: translateY(-1px);
}

button {
  border: 1px solid transparent;
  background: linear-gradient(145deg, var(--teal), var(--teal-dark));
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 0 16px;
  box-shadow: 0 6px 14px rgba(13, 124, 117, .14);
  transition: filter .18s ease, transform .18s ease, box-shadow .18s ease;
}

button:hover {
  filter: saturate(1.08) brightness(1.02);
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(13, 124, 117, .22);
}

button:disabled {
  cursor: wait;
  opacity: .65;
}

.ghost {
  width: max-content;
  min-height: 36px;
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, .66);
  color: var(--ink);
  box-shadow: none;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.helper-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.helper-text::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 5px rgba(13, 124, 117, .12);
  content: "";
}

.hero-image {
  min-width: 0;
  margin: 0;
  overflow: hidden;
}

.hero-image figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 7px;
}

.hero-image figcaption span {
  color: #6c5f50;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
}

.hero-image figcaption strong {
  color: var(--teal-dark);
  font-size: 11px;
  white-space: nowrap;
}

.hero-image img {
  width: calc(100% - 28px);
  height: 136px;
  display: block;
  margin: 0 14px 14px;
  border-radius: 12px;
  object-fit: cover;
}

.calculator-column {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(42px, auto);
  gap: 7px;
}

.tab-page { display: block; }

.item-panel,
.calc-grid,
.result-panel {
  padding: 10px 12px;
}

.item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.item-head h2 {
  max-height: 44px;
  overflow: hidden;
  font-size: 18px;
  line-height: 1.18;
}

.pill {
  border: 1px solid rgba(13, 124, 117, .2);
  border-radius: 999px;
  background: #e6f8f5;
  color: var(--teal-dark);
  padding: 7px 11px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.facts,
.result-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.facts div,
.result-panel div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, .64);
  padding: 9px 10px;
}

.facts span,
.result-panel span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.facts strong,
.result-panel strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 100px 112px;
  gap: 8px;
  align-items: end;
}

.result-panel {
  grid-template-columns: repeat(3, minmax(0, 1fr)) 142px;
}

.result-panel button {
  min-height: 100%;
  background: linear-gradient(145deg, var(--navy), #123b49);
}

.total-card {
  border-color: rgba(13, 124, 117, .24) !important;
  background: #edfdf8 !important;
}

.total-card strong {
  color: var(--green);
  font-size: 19px;
}

.message {
  min-height: 42px;
  display: flex;
  align-items: center;
  border-color: rgba(21, 128, 61, .2);
  background: rgba(240, 253, 244, .9);
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  padding: 10px 14px;
}

.message.error {
  border-color: rgba(180, 35, 24, .24);
  background: #fff1ee;
  color: var(--red);
}

.message.good {
  border-color: rgba(21, 128, 61, .22);
  background: #f0fdf4;
  color: var(--green);
}

.hidden { display: none; }

.logs-page {
  width: 100%;
  height: auto;
  max-height: min(392px, calc(100vh - 126px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-self: start;
  overflow: hidden;
  padding: 14px;
}

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

.logs-toolbar h2 {
  font-size: 16px;
}

.logs-toolbar .ghost {
  min-height: 34px;
  padding: 0 11px;
}

.log-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
}

.log-list:empty {
  align-content: center;
  justify-content: center;
}

.log-list:empty::before {
  display: block;
  max-width: 220px;
  border: 1px dashed var(--line-strong);
  border-radius: 13px;
  color: var(--muted);
  content: "Nenhuma execucao registrada ainda. Bipe um codigo para iniciar.";
  font-size: 12px;
  line-height: 1.45;
  padding: 26px 18px;
  text-align: center;
}

.log-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface-solid);
  padding: 9px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.log-card.good,
.log-card.status-200,
.log-card.ok { border-left-color: var(--green); }

.log-card.error,
.log-card.status-400,
.log-card.status-404,
.log-card.status-429,
.log-card.running { border-left-color: var(--red); }

.log-card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.log-card span,
.log-card em {
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
}

.log-card strong {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-card pre {
  display: none;
}

.log-card ol {
  display: grid;
  gap: 3px;
  max-height: 50px;
  overflow: hidden;
  margin: 7px 0 0;
  padding-left: 16px;
}

.log-card li {
  color: #334155;
  font-size: 10px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.log-card li.error {
  color: var(--red);
  font-weight: 900;
}

.app-footer {
  position: relative;
  z-index: 1;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.app-footer strong {
  color: var(--ink);
  font-weight: 700;
}

.app-footer a {
  color: var(--teal-dark);
  font-weight: 700;
  text-decoration: none;
}

@keyframes enterUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-copy,
.hero-image,
.item-panel,
.calc-grid,
.result-panel,
.message,
.logs-page {
  animation: enterUp .3s ease both;
}

@media (max-width: 1120px) {
  body { overflow: auto; }

  .page {
    height: auto;
    min-height: calc(100vh - 92px);
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .main-column {
    overflow: visible;
  }

  .logs-page {
    height: auto;
    min-height: 220px;
  }
}

@media (max-width: 860px) {
  .app-header,
  .header-meta,
  .app-footer {
    height: auto;
    align-items: stretch;
    flex-direction: column;
  }

  .app-header,
  .app-footer {
    padding: 14px 18px;
  }

  .header-meta {
    width: 100%;
    white-space: normal;
  }

  .support-btn,
  .support-email,
  .header-meta strong {
    justify-content: center;
  }

  .support-menu {
    width: 100%;
    justify-content: center;
  }

  .support-email {
    position: static;
    margin-top: 8px;
    white-space: normal;
  }

  .page {
    width: min(100% - 24px, 1260px);
    margin-top: 12px;
  }

  .hero,
  .scan-row,
  .facts,
  .calc-grid,
  .result-panel {
    grid-template-columns: 1fr;
  }

  .hero-copy,
  .item-panel,
  .calc-grid,
  .result-panel,
  .logs-page {
    padding: 16px;
  }

  #scanCode {
    min-height: 58px;
    font-size: 22px;
  }

  .hero-image img {
    height: 210px;
  }
}
