:root {
  --bg: #f2efe9;
  --bg-panel: #fcfaf5;
  --ink: #172526;
  --muted: #546567;
  --line: #d8d1c4;
  --brand: #0f766e;
  --brand-2: #14532d;
  --danger: #b42318;
  --ok: #177245;
  --warn: #9c5700;
  --critical: #8f1f13;
  --shadow: 0 18px 50px rgba(23, 37, 38, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, #efe5d2 0%, transparent 32%),
    radial-gradient(circle at 88% 14%, #d3ebe4 0%, transparent 30%),
    var(--bg);
}

.bg-shape {
  position: fixed;
  z-index: -1;
  opacity: 0.4;
  filter: blur(0.5px);
}

.bg-shape-a {
  width: 260px;
  height: 260px;
  border-radius: 58% 42% 65% 35% / 38% 53% 47% 62%;
  background: #efc98a;
  top: 68vh;
  left: -90px;
}

.bg-shape-b {
  width: 290px;
  height: 290px;
  border-radius: 38% 62% 44% 56% / 67% 42% 58% 33%;
  background: #bde1d5;
  top: -120px;
  right: -120px;
}

.app-shell {
  width: min(1120px, 92vw);
  margin: 0 auto;
  padding: 42px 0 60px;
  display: grid;
  gap: 16px;
}

.access-shell {
  width: min(1120px, 92vw);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 34px 0;
}

.access-card {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(165deg, #fffdf8, #f6f1e4);
  box-shadow: var(--shadow);
  padding: 24px;
}

.hero {
  padding: 8px 2px;
}

.app-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.tag {
  margin: 0 0 8px;
  font-family: "Source Code Pro", monospace;
  font-size: 0.78rem;
  letter-spacing: 1.5px;
  color: var(--brand-2);
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.3rem);
  line-height: 1.04;
}

.subtitle {
  margin-top: 12px;
  max-width: 62ch;
  color: var(--muted);
}

.feedback {
  position: fixed;
  right: 14px;
  top: 14px;
  z-index: 20;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  padding: 11px 13px;
  box-shadow: var(--shadow);
  max-width: min(560px, calc(100vw - 28px));
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 170ms ease, transform 170ms ease;
}

.feedback.show {
  opacity: 1;
  transform: translateY(0);
}

.feedback[data-tone="error"] {
  border-color: color-mix(in srgb, var(--danger), white 62%);
  background: color-mix(in srgb, var(--danger), white 92%);
}

.feedback[data-tone="success"] {
  border-color: color-mix(in srgb, var(--ok), white 60%);
  background: color-mix(in srgb, var(--ok), white 92%);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(165deg, var(--bg-panel), #f7f3e9);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel h2 {
  margin: 0 0 14px;
}

.session-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fffefb;
  padding: 10px 12px;
  min-width: 260px;
}

.session-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.session-email {
  margin: 2px 0 10px;
  font-weight: 700;
  font-size: 0.96rem;
  word-break: break-all;
}

.form-grid,
.filters {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.auth-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.auth-status {
  margin: 10px 0 0;
  font-size: 0.92rem;
  color: var(--muted);
}

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

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid #ccc5b7;
  border-radius: 12px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fffdf9;
}

input:focus,
select:focus {
  outline: 2px solid color-mix(in srgb, var(--brand), white 40%);
  border-color: var(--brand);
}

.actions-row {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(0.98);
}

.btn.primary {
  color: #fff;
  background: var(--brand);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.btn.danger {
  color: #fff;
  background: var(--danger);
}

.btn.tiny {
  padding: 7px 10px;
  font-size: 0.86rem;
}

.stats-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fffcf6;
  padding: 12px;
}

.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.stat-value {
  margin: 4px 0 0;
  font-size: 1.7rem;
  line-height: 1;
}

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

#contador-itens {
  color: var(--muted);
  font-size: 0.95rem;
}

.cards {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.item-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffefb;
  padding: 12px;
  display: grid;
  gap: 12px;
  animation: reveal 420ms ease both;
}

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

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.item-nome {
  margin: 0 0 2px;
  font-size: 1.1rem;
}

.item-meta,
.item-validade {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.badge {
  align-self: start;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  border: 1px solid transparent;
}

.badge.ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok), white 65%);
  background: color-mix(in srgb, var(--ok), white 92%);
}

.badge.warn {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn), white 62%);
  background: color-mix(in srgb, var(--warn), white 90%);
}

.badge.critical {
  color: var(--critical);
  border-color: color-mix(in srgb, var(--critical), white 58%);
  background: color-mix(in srgb, var(--critical), white 88%);
}

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

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 20px;
  color: var(--muted);
  text-align: center;
  background: #fffdf9;
}

@media (max-width: 980px) {
  .app-hero {
    flex-direction: column;
    align-items: start;
  }

  .session-box {
    width: 100%;
  }

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

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

@media (max-width: 640px) {
  .access-shell,
  .app-shell {
    width: min(1120px, 94vw);
    padding-top: 30px;
  }

  .access-card {
    border-radius: 18px;
    padding: 18px;
  }

  .form-grid,
  .filters,
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
