:root {
  --brand: #6b2d8b;
  --brand-dark: #521f6d;
  --brand-soft: #f2eaf7;
  --brand-border: #d9c6e6;
  --bg: #f7f6fb;
  --surface: #ffffff;
  --text: #1f1a29;
  --muted: #5c546b;
  --line: #e4dfec;
  --danger: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font: 16px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

header, main {
  max-width: 600px;
  margin: auto;
  padding: 16px 18px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.brand-logo {
  height: 36px;
  width: auto;
  display: block;
}

.brand-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--brand);
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

h1 {
  font-size: clamp(24px, 6.5vw, 34px);
  letter-spacing: -0.03em;
  margin: 8px 0 14px;
  line-height: 1.12;
}

h2 {
  font-size: 17px;
  margin: 20px 0 10px;
  color: var(--muted);
}

.card, .case, .entry {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(31, 26, 41, 0.03);
}

.login {
  margin-top: 24px;
  padding: 26px 22px;
}

.login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.login-brand img {
  max-width: 210px;
  height: auto;
}

.login h1 {
  text-align: center;
  margin-bottom: 4px;
}

.login-sub {
  text-align: center;
  margin: 0 0 18px;
  font-size: 14px;
}

button, input, textarea { font: inherit; }

button {
  cursor: pointer;
  border: 1px solid var(--brand-border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--brand-dark);
  padding: 10px 14px;
  min-height: 44px;
  font-weight: 650;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

button:hover:not(:disabled) {
  background: var(--brand-soft);
}

button:disabled { opacity: 0.55; cursor: not-allowed; }

.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  width: 100%;
  min-height: 52px;
  font-size: 17px;
}

.primary:hover:not(:disabled) {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-small {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.grid button {
  text-align: left;
  min-height: 56px;
  background: var(--brand-soft);
  border-color: var(--brand-border);
}

.grid button.recording {
  background: #fdecec;
  border-color: #f3b1b1;
  color: var(--danger);
  animation: pulse-rec 1.2s ease-in-out infinite;
}

@keyframes pulse-rec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(180, 35, 24, 0.25); }
  50% { box-shadow: 0 0 0 6px rgba(180, 35, 24, 0); }
}

.live-transcript {
  background: #fff8e6;
  border: 1px solid #f2d58a;
  color: #6b4e00;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 14px;
}

/* Lista de Ocorrências com miniatura compacta */
.filter-bar {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.filter-input {
  margin: 0 !important;
}

.filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tab-btn {
  min-height: 34px;
  padding: 5px 12px;
  font-size: 13px;
  border-radius: 999px;
}

.tab-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.case {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px;
  color: var(--text);
}

.case-thumb {
  position: relative;
  width: 54px;
  height: 54px;
  min-width: 54px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.case-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.case-thumb-icon {
  font-size: 22px;
}

.case-thumb-play {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.case-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 3px;
}

.case-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.case-title {
  font-size: 15px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.case-sku {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-open {
  background: #fff3cd;
  color: #8a5a00;
}

.badge-done {
  background: #e6f6ec;
  color: #166534;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail-head h1 { margin: 4px 0 10px; }

/* Seletor de Produto (SKU - Nome) */
.sku-picker {
  margin-bottom: 12px;
}

.sku-search-wrap {
  position: relative;
}

.sku-input {
  margin: 6px 0 0 !important;
}

.sku-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--brand-border);
  border-radius: 12px;
  box-shadow: 0 10px 26px rgba(31, 26, 41, 0.14);
  z-index: 30;
  padding: 4px;
}

.sku-option {
  display: flex;
  align-items: baseline;
  gap: 4px;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: transparent;
}

.sku-option:hover {
  background: var(--brand-soft);
}

.sku-code {
  font-weight: 750;
  color: var(--brand);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.sku-option-custom {
  color: var(--brand);
  font-weight: 650;
  border-top: 1px dashed var(--line);
}

.sku-hint {
  padding: 8px 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.sku-selected {
  margin-top: 6px;
}

.sku-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
}

.sku-chip-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-dark);
}

.sku-change-btn {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 12.5px;
}

.product-card {
  padding: 12px 14px;
}

.product-card .sku-picker { margin-bottom: 10px; }

.req {
  color: var(--danger);
  font-weight: 800;
}

.serial-label {
  margin-bottom: 0;
}

.serial-input {
  margin: 6px 0 10px !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.product-save-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.feedback-inline {
  margin: 0;
  font-size: 13px;
  color: var(--brand);
  min-height: 18px;
}

.feedback-inline.is-error {
  color: var(--danger);
  font-weight: 600;
}

/* Miniaturas bem pequenas (foto e vídeo) */
.thumb-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.thumb-tile {
  position: relative;
  width: 72px;
  height: 72px;
}

.thumb-btn {
  width: 72px;
  height: 72px;
  min-height: 72px;
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--brand-border);
  background: var(--brand-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-fallback {
  font-size: 24px;
}

.thumb-play {
  position: absolute;
  inset: auto 5px 5px auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid #fff;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb-remove:hover:not(:disabled) {
  background: #911c13;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 12, 22, 0.85);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.lightbox-box {
  position: relative;
  max-width: min(94vw, 760px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.lightbox-close {
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  min-height: 36px;
  padding: 6px 14px;
  font-size: 14px;
}

.lightbox-media {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 12px;
  background: #000;
  display: block;
}

/* Áudio & notas */
.audio-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.audio-item {
  background: #faf9fd;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.audio-draft {
  padding: 12px;
}

.audio-transcript {
  margin: 8px 0 4px;
  font-size: 13.5px;
  color: var(--muted);
}

.entry-meta {
  font-size: 13px;
  margin-bottom: 6px;
}

.resolved-tag {
  color: #166534;
}

.entry-note {
  margin: 6px 0 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

input, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #cfc6dc;
  border-radius: 10px;
  background: #fff;
  margin: 5px 0 14px;
  color: var(--text);
}

textarea { min-height: 110px; resize: vertical; }

label {
  display: block;
  font-weight: 650;
  font-size: 14px;
}

audio { width: 100%; display: block; }

.back { margin-bottom: 10px; }

.actions {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.feedback {
  color: var(--danger);
  font-size: 14px;
  min-height: 20px;
  margin: 6px 0 10px;
}

[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid #9333ea;
  outline-offset: 2px;
}
