:root {
  --bg-main: #ffffff;
  --bg-subtle: #fafafa;
  --bg-hover: #f4f4f6;

  --border-soft: #e5e5ea;
  --border-muted: #ededf0;

  --text-main: #1c1c1e;
  --text-muted: #6e6e73;

  --accent: #6d5e97;
  --accent-soft: rgba(109, 94, 151, 0.12);
  --accent-hover: rgba(109, 94, 151, 0.18);

  --error: #c0392b;
  --error-bg: #fdf2f2;
  --error-border: #f5c6c6;

  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-subtle);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Utilitários ── */
.screen { min-height: 100dvh; }
.hidden { display: none !important; }

/* ── Login ── */
.login-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 360px;
  margin: 0 auto;
  padding: 32px 24px;
  padding-top: max(72px, 14dvh);
}

.app-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-main);
}

.app-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: -8px;
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-main);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-title-small {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text-main);
}

/* ── Container ── */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Drop Zone ── */
.drop-zone {
  border: 1.5px dashed var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  background: var(--bg-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.drop-zone:hover {
  border-color: var(--accent);
  background: var(--bg-subtle);
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-icon {
  width: 40px;
  height: 40px;
  color: var(--text-muted);
}

.drop-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-main);
}

.drop-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Divider ── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}

/* ── Fields ── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

input[type="password"],
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: inherit;
  color: var(--text-main);
  background: var(--bg-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  resize: vertical;
  outline: none;
}

input[type="password"]:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ── Botões ── */
.btn-primary {
  padding: 12px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  min-height: 44px;
}

.btn-primary:hover {
  background: #5c4f80;
  box-shadow: var(--shadow-md);
}

.btn-primary:active { background: #4e4470; }

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  padding: 10px 16px;
  background: var(--bg-main);
  color: var(--accent);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
  min-height: 44px;
}

.btn-secondary:hover { background: var(--bg-hover); }

.btn-ghost {
  padding: 8px 12px;
  background: none;
  color: var(--accent);
  border: none;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background 0.15s ease;
  min-height: 44px;
}

.btn-ghost:hover { background: var(--accent-soft); }

.btn-full { width: 100%; }

/* ── Files list ── */
.files-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-main);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  font-size: 14px;
}

.file-item-icon {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.file-item-name {
  flex: 1;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item-status {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.file-item-remove {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-muted);
  border-radius: 6px;
  transition: background 0.12s ease, color 0.12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 28px;
}

.file-item-remove:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

/* ── Resultado ── */
.resultado {
  background: var(--bg-main);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 24px;
  font-size: 14px;
  line-height: 1.7;
  box-shadow: var(--shadow-sm);
}

.resultado h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 20px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-muted);
}

.resultado h2:first-child { margin-top: 0; }

.resultado h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 12px 0 4px;
}

.resultado p { margin: 4px 0; color: var(--text-main); }

.resultado ul {
  padding-left: 18px;
  margin: 4px 0;
}

.resultado li { color: var(--text-main); }

.resultado strong { color: var(--text-main); font-weight: 600; }

/* Lab alterado */
.lab-alert {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-weight: 500;
  font-size: 12px;
}

/* ── Erro ── */
.error {
  font-size: 13px;
  color: var(--error);
  text-align: center;
}

/* ── Modal de perfil ── */
.perfil-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-main);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  z-index: 60;
  box-shadow: 0 16px 48px rgba(0,0,0,0.12);
  width: min(320px, calc(100vw - 40px));
  text-align: center;
}

.perfil-modal-titulo {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 24px;
}

.perfil-opcoes {
  display: flex;
  gap: 12px;
}

.perfil-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 12px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.perfil-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--shadow-sm);
}

.perfil-avatar {
  width: 44px;
  height: 44px;
  background: var(--accent-soft);
  border: 1.5px solid rgba(109, 94, 151, 0.22);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.perfil-nome {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

/* ── Painel badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.badge-pendente {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffe08a;
}

.badge-aceito {
  background: #d1f5dc;
  color: #1a6b3a;
  border: 1px solid #a3e4b8;
}

.badge-recusado {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
}

/* ── Painel item ── */
.painel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-muted);
  background: var(--bg-subtle);
  gap: 8px;
}

.painel-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.status-select {
  font-size: 13px;
  font-family: inherit;
  color: var(--text-main);
  background: var(--bg-main);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
  min-height: 30px;
}

.status-select:focus {
  border-color: var(--accent);
}

/* ── Resposta para a equipe ── */
.resposta-card {
  margin-top: 24px;
  background: var(--accent-soft);
  border: 1px solid rgba(109, 94, 151, 0.22);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}

.resposta-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.resposta-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--accent);
}

.resposta-texto {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-main);
  margin: 0;
}

.btn-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  flex-shrink: 0;
}

.btn-copy:hover {
  background: rgba(109, 94, 151, 0.15);
}

.btn-copy.copied {
  color: #34c759;
}

/* ── Header actions ── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Botão icon ── */
.btn-icon {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
}

/* ── Botão sm ── */
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  min-height: 32px;
}

/* ── Botão danger ── */
.btn-danger {
  color: var(--error);
}

.btn-danger:hover {
  background: var(--error-bg);
  color: var(--error);
}

/* ── Split view ── */
.split-view {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 53px);
}

.split-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-main);
  flex-shrink: 0;
}

.split-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-hover);
  padding: 3px;
  border-radius: var(--radius-pill);
  margin-left: auto;
}

.split-tab {
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  background: none;
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.12s ease, color 0.12s ease;
  min-height: 30px;
}

.split-tab.active {
  background: var(--bg-main);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.split-panels {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

.split-panel {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Desktop: side-by-side */
@media (min-width: 768px) {
  .split-panels {
    gap: 0;
  }

  .split-panel {
    border-right: 1px solid var(--border-soft);
  }

  .split-panel:last-child {
    border-right: none;
  }

  .split-panel.hidden {
    display: block !important;
  }

  .split-tabs {
    display: none;
  }
}

/* ── Ficha viewer ── */
.ficha-viewer {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ficha-iframe {
  width: 100%;
  height: calc(100dvh - 160px);
  border: none;
  border-radius: var(--radius-md);
}

.ficha-img {
  width: 100%;
  border-radius: var(--radius-md);
  display: block;
}

.viewer-empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px 0;
}

/* ── Checklist items (pendências) ── */
.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  margin: 3px 0;
  line-height: 1.4;
}

.checklist-item::before {
  content: '!';
  font-size: 11px;
  font-weight: 700;
  background: var(--error);
  color: #fff;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.checklist-item.checked {
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-color: var(--border-muted);
}

.checklist-item.checked::before {
  content: '';
  background: #34c759;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-size: 10px;
  background-repeat: no-repeat;
  background-position: center;
}

/* ── Overlay ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 40;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* ── Drawer histórico ── */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(360px, 100vw);
  height: 100dvh;
  background: var(--bg-main);
  border-left: 1px solid var(--border-soft);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.drawer-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

/* ── Histórico lista ── */
.historico-lista {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.historico-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-muted);
  background: var(--bg-subtle);
  gap: 8px;
}

.historico-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.historico-nome {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.historico-hora {
  font-size: 12px;
  color: var(--text-muted);
}

.historico-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.historico-vazio {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px 16px;
}

/* ── Responsivo ── */
@media (max-width: 480px) {
  .container { padding: 16px 16px 40px; }
  .login-card { padding: 24px 20px; padding-top: max(56px, 12dvh); }
  .app-header { padding: 12px 16px; }
  .drop-zone { padding: 32px 16px; }
  .resultado { padding: 16px; }
  .split-panel { padding: 12px; }
  .ficha-iframe { height: calc(100dvh - 140px); }
}
